-
-
Notifications
You must be signed in to change notification settings - Fork 836
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
update() not refreshing chart #148
Comments
Hey @Blaapje well it is a bit confusing, what you are doing.
You can call |
Hey @apertureless, Thanks for your reply. I mixed up some names writing down this Issue: I've tried removing both the reactiveProp and my watcher separately, but that didn't change anything in the result. Removing the I've made a codepen where I replicated my local setup as best as possible: CodePen.io: GitHub Issue 148. I've created a hardcoded |
I just got this working and thought I'd share: https://codepen.io/anon/pen/vZwaGg I'm using the I'd like to reference some other issues #78 and #10 that were dealing with this and to my likings never included a satisfying answer with example for new Vue users. For the cause of the failed updated I think that the entire chartData object gets filled with promises all at once and as such doesn't see newly add data, ergo chartJS is unable to handle promises correctly. This is just a wild guess though |
Well, there are some drawbacks with reactive data arrays, as vue can't recognize mutations, as they don't hold a reference to the old value. Like written in the docs. And Chart.js does not provide a watcher / observer for data. There is a workaround in #44 . If you work with $set for example. However a few points you should keep in mind:
You can also check out this repo https://github.com/apertureless/npm-stats or the resources section in the docs. I've posted some tutorials on working with apis and vue-chartjs . |
Work for me: export default {
} |
I fetch my data asynchronously, fetching 100 JSON objects separately. I save these objects in chartData.datasets. In case it matters, all JSON objects are time series.
In the actual line-chart component I have declared a
$watch
that listens for change. This function works correctly and reports overtime a new dataset has been added to chartData. However, calling theupdate()
function doesn't do anything.Only when I wait until all JSON objects are loaded, and I call
destroy()
and render a new chart, the data wil appear.Here's my line component:
The view implementing this component is rather obnoxious as I've been messing with it for a few hours now, would rather not share. I think most important here is that I update the datasets with
this.chartData.datasets.append(new_dataset)
.Expected Behavior
Fetched datasets from asynchronous get calls should be plotted once they are added as a new dataset.
Actual Behavior
Fetched datasets from asynchronous get calls are successfully noticed by the watcher, but calling
this._plot.update()
does not show them in the plot.Additional information
In some settings I encountered
maximum call stack size limit exceeded
errors. I would briefly see the first plot after which the error would be thrown and the chart would crash. This has me leading to believe I might be using the wrong data structures for this.Environment
The text was updated successfully, but these errors were encountered: