0👍
You should define a prop in your parent component for setting pie chart data. I assumed its name: setPieChartData
const LatestSales = props => {
const { setPieChartData, pieChartData} = props;
const toggle = () =>{
let $pieChartData = { ...pieChartData };
$pieChartData.labels[0] = "teste"
setPieChartData($pieChartData)
}
return (
<>
<button onClick={toggle}>toggle</button>
<Doughnut
data={pieChartData}
options={pieChartOptions}
/>
</>
);
};
- Chartjs-Updating chart.js with a dataset of different size not working
- Chartjs-Dynamic chart codeigniter
Source:stackexchange.com