chartist-js / chartist

Simple responsive charts
https://chartist.dev
MIT License
13.34k stars 2.53k forks source link

Listener receiving swapped series when drawing multi bar charts? #1064

Open RobinRamael opened 6 years ago

RobinRamael commented 6 years ago

I'm not a JS developer and this is not my code and it's incredibly messy, so please bear with me :)

We have a react-chartist component that uses the onDraw listener to fill in some tooltip data for a multi bar chart showing age/gender demographics. The tooltips seem to have been reversed: data from series 'Man' has the label from series 'Woman' and vice versa.

When looking at the data the listener received, it looks like the two have been swapped somehow:

schermafdruk 2018-01-31 15 31 55

As you can see, data.value does not appear anywhere in data.series.data, as it is a datapoint for the 'Man' series and we've received the 'Woman' series. We get our tooltip label from data.series.name, so it appears reversed.

Am I right to assume that data.series should point to the current series being drawn? Any idea what I could be overlooking? Thanks!

Arantiryo commented 1 year ago

Hello @RobinRamael 👋

Chartist has recently been updated to version 1.0 with some new exciting changes like ESM and TypeScript support. The migration guide can be found right here.

Please let me know if the quiestion is still relevant to you so we can further look into it!