Skip to content

Attempting to update Chart.js chart in React using react-chartjs-2, doc is unclear #411

@jscheinhorn

Description

@jscheinhorn

Hello,
I'm just getting started with chart-reactjs-2. I am dynamically loading data onto the chart and need it to update with each render.

I read the following:

 chartReference = {};
 
componentDidMount() {
  console.log(this.chartReference); // returns a Chart.js instance reference
}
 
render() {
  return (<Doughnut ref={(reference) => this.chartReference = reference } data={data} />)

and would like to do something like:

let lineChart = this.chartReference.chartInstance
lineChart.update();

but I don't know what to include within chartReference. Any guidance is greatly appreciated!

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions