Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to put the legend in the bottom position #2569

Open
baurine opened this issue Nov 29, 2024 · 6 comments
Open

Failed to put the legend in the bottom position #2569

baurine opened this issue Nov 29, 2024 · 6 comments
Labels
bug Something isn't working dependencies Pull requests that update a dependency file

Comments

@baurine
Copy link

baurine commented Nov 29, 2024

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

@baurine baurine added the bug Something isn't working label Nov 29, 2024
@baurine
Copy link
Author

baurine commented Dec 3, 2024

@markov00 can you help have a look, I'm blocking by this bug (maybe not a bug, but I just don't know where is the problem), thanks!

@markov00
Copy link
Member

markov00 commented Dec 3, 2024

I'm investigating this a bit, but I'm on a couple of more priorities right now. I hope I can give you an update today

@markov00
Copy link
Member

markov00 commented Dec 4, 2024

@baurine The problem is that the library still has some issues with React StrictMode that are not solved yet. If you run you app without the <React.StrictMode> wrapper it will work as expected

@markov00
Copy link
Member

markov00 commented Dec 4, 2024

cc @nickofthyme we need to definitely work on that.
I've also tested locally with React 18 and StrictMode but I got a different results then in the demo above. In this demo mouse events are at least correctly picked up.

@markov00 markov00 added the dependencies Pull requests that update a dependency file label Dec 4, 2024
@baurine
Copy link
Author

baurine commented Dec 4, 2024

@markov00 big thanks for your help!

@baurine
Copy link
Author

baurine commented Dec 5, 2024

btw, because StrictMode only affect the development mode, so this issue doesn't exist in the production build, I have tested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dependencies Pull requests that update a dependency file
Projects
None yet
Development

No branches or pull requests

2 participants