0

I am using react-chartjs-2 to render charts and on clicking the active point it gets redirected to some other page.

 <Line
   id={'chartid'}
   data={data}
   options={options}
   getElementAtEvent={dataset => {
     // redirects to some other page
   }}
/>

Sample chart

1

We are doing automation testing and need to check if click is working or not.

Is there any option to add id/class to active elements inside the rendered canvas. Can anyone help?

vimuth
  • 5,064
  • 33
  • 79
  • 116

1 Answers1

0

AFAIK every element has got datasetIndex and index properties related to the drawn dataset. Emitting the click event on the canvas (a specific point) you could check that dataset index and index are what you are expecting

user2057925
  • 2,377
  • 1
  • 12
  • 12