Skip to content

Rename var at "Adding or Removing Data" #11342

Closed
@fabr2004

Description

@fabr2004

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions