Updating datasets with points
See original GitHub issueExpected Behavior
In version 2.9.3, when you want to update a datasets with data as points (i.e.scatter), you could change the “point” object in its x and y properties. The following code is “randomize” implementation (updated by me to show how it works in 2.9.3) of Scatter chart in CHART.js samples.
document.getElementById('randomizeData').addEventListener('click', function() {
scatterChartData.datasets.forEach(function(dataset) {
dataset.data.forEach(function(item) {
item.x = randomScalingFactor();
item.y = randomScalingFactor();
});
});
window.myScatter.update();
});
Current Behavior
With version 3, the above code does not work and the data points are not updated and the chart does not change the data representation.
To work properly it seems you have to create every time new point objects (not good for performance), as the code of Scatter chart sample is showing:
document.getElementById('randomizeData').addEventListener('click', function() {
scatterChartData.datasets.forEach(function(dataset) {
dataset.data = dataset.data.map(function() {
return {
x: randomScalingFactor(),
y: randomScalingFactor()
};
});
});
window.myScatter.update();
});
Possible Solution
In my opinion it should work as was in version 2.9.3 because it’s more efficient.
Environment
- Chart.js version: DevBuild: https://www.chartjs.org/dist/master/chart.min.js
- Browser name and version: FF 76.0.1
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Updating a portion of a terrain dataset with new measurements
Measurements can be added to a terrain dataset through the Append and the Append Terrain Points geoprocessing tools. The Append geoprocessing tool operates...
Read more >How to create an auto-updating dataset on Kaggle
Step 1: Identify a URL for a dataset that occasionally gets updated · Step 2: Create a new dataset on Kaggle by using...
Read more >Updating files in a dataset - Amazon QuickSight
To update a file in a dataset In QuickSight, choose Datasets at left. On the Datasets page, choose the dataset that you want...
Read more >Forecasting, updating datasets, and the “news” - Statsmodels
To compute forecasts based on our updated dataset, we will create an updated ... was more than 10 percentage points below the AR(1)...
Read more >Updating and Editing Your Data in Map Business Online
That brings up a process for selecting a dataset or starting a new one. If you're adding data to an already plotted group...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The demo is modifying Input data, not elements. ArrayEquals fails to notice the change (compares the objects, and those are still the same). I’d consider this to be a bug.
(assuming dataset.data is the Input data, I did not verify)
Thanks for the correction @kurkle! I agree this seems like a bug to fix. Maybe we should remove the data checks and just support the
splice
/push
/etc. API for fast data modification?@stockiNail super glad for all your feedback. We’ve only had one alpha so far, so it’s still very early and appreciated!! 😃