-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
With multiple charts on page, tooltips for each chart all show data from last updated chart #3275
Comments
I'm not an expert, but I would try defining separate config and data blocks for each chart. I'm guessing charts.js assumes that each config/data block is separate for each chart, so it's storing metadata specific to each chart in that area, but it's actually a shared area, because of what you've done here. |
@bradherman sharing the data object is not possible before v2.1.0. I think sharing configs will work. Can you put together a jsfiddle that reproduces this issue? |
@etimberg https://jsfiddle.net/83pzooLq/ Getting the issue there... Pardon me if it's a little messy, I don't ever write js these days... This has just been a fun little project for me |
Also as mentioned, if you run the update call all in a row, the charts will show the same data too... See this fiddle: https://jsfiddle.net/9ca0m7z3/ |
So I'm pretty sure what the problem is. What happens is that the data object is the shared between all charts but the data in the data object is changed before each chart is created. When the tooltip displays, it goes back to the data object to query the data and hence looks at the last data All the charts should have a unique data object if they are to have different data. |
@etimberg Ahhh, that makes sense... Would also explain why the charts would show the same information when updated after loading all the data in. Thanks a ton! |
np, glad I could help |
I have created a page with a lot of charts on it in a grid. When I load all the data into the page and update the charts, everything works fine, however the charts all show the same tooltip data from the last updated chart. The label is correct (matches the x-value at the point), but the y-value is the same across all charts.
Here is my code:
With this code, the charts all look correct and have the right x and y axises and line data, but the tooltips show the correct x axis data for each chart (Mon, Tues, Weds... for daily charts; 1 week, 2 week, 3 week... for weekly charts; etc), but the value shown for every one is the value at the same index for the final chart (expensesMonthly)...
I've also noticed some other weird behavior on update... If I move the chart updates to a block after loading the data, all of the charts will have the exact same data... like this:
^ all 3 charts will be the exact same unless I update inline.
Any ideas?
The text was updated successfully, but these errors were encountered: