-
-
Notifications
You must be signed in to change notification settings - Fork 838
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
Reactive plugin causing redraw issues on re-orientation and responsive chart #288
Comments
@apertureless believe I have figured this out - could be (probably is) user error but I thought I would check and share back. From my understanding of the documentation when trying to use the reactive mixin you need to do something like:
However, when looking at the mixin it adds a watch to the chartData prop. If oldData is not passed into the handler then it simply calls:
As we call renderChart on mount and then in the watch (without a call to destroy the chart) we render twice which causes the unexpected behaviour! To resolve this simply instantiate your chart without the initial render call in mount i.e.:
Apologies if this is obvious - I just didn't get this from the documentation. Hopefully this will help someone else! |
I found my way here because I was battling this exact thing. My chart would draw initially once the data from my API was loaded, but if the browser was resized, all of the data on the chart disappeared. Removing the call the |
Thanks for the issue. The mixin should check if an chartjs instance is available and if so, destroy it before rendering the chart. This way we don't get any race conditions and duplicated instances. |
Expected Behavior
When using the reactive plugin for data with the responsive chart option (for any chart type) I would expect the chart to display on re-orientation.
Actual Behavior
When re-orientating a device the chart data is emptied. If the responsive option is removed the chart works as expected. Equally removing the use of the reactive plugin and the chart works as expected. Below is a screenshot before rotation and after rotation.
Before:

After:

Environment
The text was updated successfully, but these errors were encountered: