Skip to content

Failed to put the legend in the bottom position #2569

Open
@baurine

Description

@baurine

Describe the issue

I want to show the legend in the bottom position for line series chart but failed, it shows in the right position

To Reproduce
Steps to reproduce the behavior:

  1. open the demo app: https://bolt.new/~/sb1-cgcnmq
  2. view the demo code:
import React from 'react';
import {
  Chart,
  Settings,
  Axis,
  LineSeries,
  ScaleType,
  Position,
} from '@elastic/charts';

interface DataPoint {
  x: string;
  y: number;
}

interface LineChartProps {
  data: DataPoint[];
  title: string;
}

export function LineChart({ data, title }: LineChartProps) {
  return (
    <Chart size={{ height: 300 }}>
      <Settings
        theme={{
          chartMargins: { left: 40, right: 40, top: 20, bottom: 40 },
        }}
        showLegend={true}
        legendPosition={Position.Bottom}
      />
      <Axis
        id="bottom"
        position={Position.Bottom}
        title="Time"
        tickFormat={(d) => d}
      />
      <Axis
        id="left"
        title="Value"
        position={Position.Left}
        tickFormat={(d) => d}
      />
      <LineSeries
        id={title}
        name={title}
        xScaleType={ScaleType.Ordinal}
        yScaleType={ScaleType.Linear}
        xAccessor="x"
        yAccessors={["y"]}
        data={data}
      />
    </Chart>
  );
}
  1. preview result:

Image

Expected behaviour

I expect to see the legend is put in the bottom instead of right.

Version (please complete the following information):

  • OS: macOS 12.5
  • Browser: chrome 131.0.6778.86
  • Elastic Charts: 68.0.3

Additional context

it seems the echChartContent--column class is not added.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdependenciesPull requests that update a dependency file

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions