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

Rename var at "Adding or Removing Data" #11342

Closed
1 of 3 tasks
fabr2004 opened this issue Jun 11, 2023 · 0 comments · Fixed by #11345
Closed
1 of 3 tasks

Rename var at "Adding or Removing Data" #11342

fabr2004 opened this issue Jun 11, 2023 · 0 comments · Fixed by #11345

Comments

@fabr2004
Copy link

fabr2004 commented Jun 11, 2023

Documentation Is:

  • Missing or needed?
  • Confusing
  • Not sure?

Please Explain in Detail...

At this URL (/docs/latest/developers/updates.html) we have confusing instructions: data is everywhere.

My request is: update content at Adding or Removing Data section.
My suggestion is below.

When you want to change the graphic displayed (adding points), you need to provide newData in order to update the data array within each graphic. If you want to remove points from graphic, you just pop them from graphic. See samples below.

function addData(chart, label, **newData**) {
    chart.data.labels.push(label);
    chart.data.datasets.forEach((dataset) => {
        dataset.data.push(**newData**);
    });
    chart.update();
}
function removeData(chart) {
    chart.data.labels.pop();
    chart.data.datasets.forEach((dataset) => {
        dataset.data.pop();
    });
    chart.update();
}

Your Proposal for Changes

Update content at Adding or Removing Data documentation section, in order to be more clear and precise. The way data is shown is confusing, since there are two different places with the same var name.

Example

https://www.chartjs.org/docs/latest/developers/updates.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant