0👍
In componentDidMount()
you can update state variable chartData
as
this.setState({
isLoaded: true,
items: json,
chartData: {
labels: symbolsdate,
datasets: [{...this.state.chartData.datasets, data: closingprice}]
}
});
Better is to separate dynamic part from static. Store static data like backgroundColor
outside of state & provide statically in HTML of render()
while, use state variables for dynamic data.
- Chartjs-Aligning zero on y axis to the labels on x axis of line chart in chartjs
- Chartjs-Chart.js: Strikethrough tick labels
Source:stackexchange.com