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

How to trigger reactivity / re-render chart by hand? #13

Closed
Anubarak opened this issue Jul 15, 2021 · 5 comments
Closed

How to trigger reactivity / re-render chart by hand? #13

Anubarak opened this issue Jul 15, 2021 · 5 comments

Comments

@Anubarak
Copy link

Anubarak commented Jul 15, 2021

How is it possible to re-render the chart by hand when data changes?

I made this little sandbox where I wand to change the axis by user input.
https://codesandbox.io/s/suspicious-monad-h5ecd?file=/src/components/Chart.vue

Changing the xMax / xMin changes indeed the passed options to your chart (I render the options above the chart) but the chart itself does not change.
Is it maybe because you commented out your watcher? https://github.com/victorgarciaesgi/vue-chart-3/blob/main/src/components.ts#L65-L73

Could you please explain how I can achieve that?
Btw: thank you very much for your time and effort. I like your library :)

@victorgarciaesgi
Copy link
Owner

Hi and thanks for the report!

Normaly the chart re-render automaticaly when the data changes!
I had to change how the options works because of numerous bugs when options is reactive :(

The solution for now is to force rerender by using the chartInstance, you can get it by using event chart:render, or the prop onChartRender.

I'm working on a solution to make options reactive again :)

@victorgarciaesgi
Copy link
Owner

0.3.8 should have working reactive options! (tested on vue 2), working on a vue3 repro

@Anubarak
Copy link
Author

Wow, thank you so much for your incredible fast response.
Alright, I'll play around a little bit.

@victorgarciaesgi
Copy link
Owner

@Anubarak Updated the demo to showcase the reactive options :)

https://codesandbox.io/s/demo-vue-chart-3-ugynm?file=/src/App.vue

@Anubarak
Copy link
Author

Anubarak commented Jul 15, 2021

Awesome, I updated to your version and it works great.
Thank you

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

No branches or pull requests

2 participants