Skip to content
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

Fix reactive mixins animation re-rendering issue. #109

Merged
merged 5 commits into from
Jun 4, 2017
Merged

Fix reactive mixins animation re-rendering issue. #109

merged 5 commits into from
Jun 4, 2017

Conversation

MuseofMoose
Copy link
Contributor

A small consequence of replacing the entire dataset in the reactive mixins files is that it causes charts to completely re-render even if only the 'data' attribute of a dataset is changing. In my case, I set up a reactive doughnut chart with two data points but whenever the data values change, instead of shifting the fill coloring, it completely re-renders the entire chart.

You can see the issue in this fiddle (the problem remains even when changing chart type):
https://jsfiddle.net/sg0c82ev/11/

To solve the issue, I instead run a diff between the new and old dataset keys, remove keys that aren't present in the new data, and update the rest of the attributes individually. After making these changes my doughnut chart is animating as expected (even when adding and removing new dataset attributes).

A fiddle with my changes:
https://jsfiddle.net/sg0c82ev/12/

Perhaps this is too specific of a scenario to warrant a complexity increase (and better suited for a custom handler) but I figured it would be better to dump it here and make it available for review. Let me know what you think.

Environment

  • OS: Mac OS 10.11.6
  • NPM Version: 3.10.3

Spencer Dellis added 5 commits May 19, 2017 02:40
A small consequence of replacing the entire dataset in the mixins files is that it causes certain charts to completely re-render even if only the 'data' attribute of a dataset is changing. In my case, I set up a reactive doughnut chart with two data points but whenever the data values change, instead of shifting the fill coloring, it completely re-renders the entire chart.

You can see the issue in this fiddle (note the constant re-rendering):
https://jsfiddle.net/sg0c82ev/11/

To solve the issue, I instead run a diff between the new and old dataset keys, remove keys that aren't present in the new data,  and update the rest of the attributes individually. After making these changes my doughnut chart is animating as expected (even when adding and removing new dataset attributes).

A fiddle with my changes:
https://jsfiddle.net/sg0c82ev/12/

Perhaps this is too specific of a scenario to warrant a complexity increase like this (and better suited for a custom watcher) but I figured it would be better to dump it here and make it available for review. Let me know what you think.
A small consequence of replacing the entire dataset in the [reactive mixins files](https://github.com/apertureless/vue-chartjs/blob/develop/src/mixins/reactiveData.js) is that it causes charts to completely re-render even if only the 'data' attribute of a dataset is changing. In my case, I set up a reactive doughnut chart with two data points but whenever the data values change, instead of shifting the fill coloring, it completely re-renders the entire chart.

You can see the issue in this fiddle (the problem remains even when changing chart type):
https://jsfiddle.net/sg0c82ev/11/

To solve the issue, I instead run a diff between the new and old dataset keys, remove keys that aren't present in the new data,  and update the rest of the attributes individually. After making these changes my doughnut chart is animating as expected (even when adding and removing new dataset attributes).

A fiddle with my changes:
https://jsfiddle.net/sg0c82ev/12/

Perhaps this is too specific of a scenario to warrant a complexity increase (and better suited for a custom handler) but I figured it would be better to dump it here and make it available for review. Let me know what you think.
@codecov
Copy link

codecov bot commented May 19, 2017

Codecov Report

Merging #109 into develop will not change coverage.
The diff coverage is n/a.

@@          Coverage Diff           @@
##           develop   #109   +/-   ##
======================================
  Coverage      100%   100%           
======================================
  Files           10     10           
  Lines           86     86           
======================================
  Hits            86     86

@MuseofMoose MuseofMoose changed the title Fix reactivity mixin animation re-rendering issue. Fix reactive mixins animation re-rendering issue. May 19, 2017
@apertureless apertureless self-requested a review May 20, 2017 12:34
@apertureless
Copy link
Owner

Hey @MuseofMoose
thanks for this one!

I will need some time to test it in various scenarios.

@apertureless apertureless merged commit 43363fc into apertureless:develop Jun 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants