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

why onElementClick not work #2229

Closed
nileblack opened this issue Nov 5, 2023 · 4 comments
Closed

why onElementClick not work #2229

nileblack opened this issue Nov 5, 2023 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@nileblack
Copy link

Describe the issue

import {
  Chart,
  Settings,
  Axis,
  LineSeries,
  BarSeries,
  DataGenerator,
  ScaleType,
  CanvasChart,
  getAxisId,
  Position,
  timeFormatter,
  niceTimeFormatByDay,
  VerticalAlignment,
  LayoutDirection,
  Tooltip,
  TooltipHeaderFormatter,
  LIGHT_THEME
} from "@elastic/charts";
...
const onElementListeners = {
  onElementClick: ()=>console.log('onElementClick'),
  onElementOver:  ()=>console.log('onElementOver'),
  onElementOut:  ()=>console.log('onElementOut'),
  onProjectionClick:  ()=>console.log('onProjectionClick'),
};
...
return (
          <Chart title={'title'} description={'description'}>
            <Settings
              showLegend
              showLegendExtra
              {...onElementListeners}
              baseTheme={LIGHT_THEME}
              legendPosition={Position.Right}
            
            />
            <Axis id="bottom" position={Position.Bottom} title="Bottom axis" showOverlappingTicks />
            <Axis id="left2" title="Left axis" position={Position.Left} tickFormat={(d) => Number(d).toFixed(2)} />

            <BarSeries
              id="bars"
              xScaleType={ScaleType.Linear}
              yScaleType={ScaleType.Linear}
              xAccessor={'x'}
              yAccessors={['y']}
              data={[
                { x: 0, y: 2, obj: { from: 10, to: 20 }, sObj: 'from 10 to 20' },
                { x: 1, y: 7, obj: { from: 20, to: 30 }, sObj: 'from 20 to 30' },
                { x: 2, y: -3, obj: { from: 30, to: 40 }, sObj: 'from 30 to 40' },
                { x: 3, y: 6, obj: { from: 40, to: 50 }, sObj: 'from 40 to 50' },
              ]}
            />
          </Chart>
)

is example code from storebook, but is not work when i put it into my page based on reactjs.

Does anyone give some advice?

@nileblack nileblack added the bug Something isn't working label Nov 5, 2023
@nickofthyme
Copy link
Collaborator

Are you using react@^18? Likely due to #2171

@nickofthyme nickofthyme self-assigned this Nov 6, 2023
@nileblack
Copy link
Author

nileblack commented Nov 8, 2023

Are you using react@^18? Likely due to #2171

yes, [email protected], after downgrade to [email protected] it works. Thanks a lot.

@nickofthyme
Copy link
Collaborator

nickofthyme commented Nov 8, 2023

Ok great, sorry about that we are down one of our main developers and we need to dig deeper to find the issue causing this. Hopefully soon!

@nickofthyme
Copy link
Collaborator

Closing in favor of #2171

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants