[Chartjs]-Chart.js Uncaught TypeError: Cannot read properties of undefined (reading 'options')

2👍

chartfour is the name of the chart configuration you’re using for creating your chart. myChart2.chartfour however does not exist.

When creating the chart, make sur to to assign it to a global constant…

const myChart2 = new Chart('myChart2', chartfour);

…then, you can directly access its options and data as follows:

myChart2.options.scales.x.time.unit = period.value;
myChart2.data.datasets[0].data = months;
...

Leave a comment