mirror of
https://github.com/chartjs/Chart.js.git
synced 2026-03-06 16:26:52 +01:00
Clarify update docs (#11345)
This commit is contained in:
committed by
GitHub
parent
ec7be48470
commit
992d9322f0
@@ -4,13 +4,13 @@ It's pretty common to want to update charts after they've been created. When the
|
||||
|
||||
## Adding or Removing Data
|
||||
|
||||
Adding and removing data is supported by changing the data array. To add data, just add data into the data array as seen in this example.
|
||||
Adding and removing data is supported by changing the data array. To add data, just add data into the data array as seen in this example, to remove it you can pop it again.
|
||||
|
||||
```javascript
|
||||
function addData(chart, label, data) {
|
||||
function addData(chart, label, newData) {
|
||||
chart.data.labels.push(label);
|
||||
chart.data.datasets.forEach((dataset) => {
|
||||
dataset.data.push(data);
|
||||
dataset.data.push(newData);
|
||||
});
|
||||
chart.update();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user