Hello, I am a newcomer to chartjs and JavaScript in general. I keep encountering the error "cannot set property of undefined" in the Chrome console.
const dataPie = {
labels: ['Good Packs', 'Bad Packs'],
datasets: [{
label: 'My First Dataset',
data: [0.1, 0.1],
backgroundColor: ['#00bf90', 'rgb(255, 75, 75)'],
hoverOffset: 0
}]
};
const configPie = {
type: 'pie',
data: dataPie,
options: {}
};
const pieChart = new Chart(
document.getElementById('chart-pie'),
configPie
);
Then, in a timed loop, I am trying to perform the following operation and encountering the error "cannot set property of undefined" (I am not setting the value in HTML, it is only set when building the pie chart at the top).
pieChart.data.datasets.data[0] = 0.5;
Since I am new to JavaScript, any help would be greatly appreciated!