You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
chart display freaks out when using collection.find().observeChanges to update chart #3
If I use the Questions.find().observeChanges method, the chart becomes jumpy when I hover over the segments. If I leave this method out, then the chart behaves normally.
Please let me know if I need to provide additional information.
I am using observerChanges because that is the only way I could figure out to update the chart reactively. If there is a better way, that doesn't also redraw the chart, that would be great.
In your code, showAgeGroups is called every time something in the collection changes. This means you're creating a new Chart on the same canvas over and over without cleaning up the old canvas. The behavior is much better if you call destroy before creating the new chart. You're also creating a new Chart twice for some reason.
Activity
kamalsprasad commentedon Aug 8, 2015
I am using observerChanges because that is the only way I could figure out to update the chart reactively. If there is a better way, that doesn't also redraw the chart, that would be great.
froatsnook commentedon Sep 8, 2015
In your code,
showAgeGroupsis called every time something in the collection changes. This means you're creating a new Chart on the same canvas over and over without cleaning up the old canvas. The behavior is much better if you calldestroybefore creating the new chart. You're also creating a new Chart twice for some reason.I hope that fixes it for you! At least the jumpiness should go away.
kamalsprasad commentedon Sep 8, 2015
Thanks for the suggestion! It fixed the jitter!
Thanks also for pointing out the problem with the chart being created twice. :)
froatsnook commentedon Sep 9, 2015
OK great. Glad I could help :).
dandv commentedon Aug 17, 2016
@ecofriend: would this be a reason to provide an actual Meteor wrapper for Chart.js, vs. just using it from npm?
kamalsprasad commentedon Aug 17, 2016
@dandv sorry, I can't answer that question with any confidence.