1👍
I’ve had problems of weird behavior when using document.getElementById in react components with chartjs before. I’ve solved some issues with refs, so it may be worth a shot?
So, initialize with
const canvasRef = useRef<HTMLCanvasElement|null>(null)
Add to canvas with:
<canvas className='max-h-10 max-w-10' ref={canvasRef}></canvas>
And call it with:
let canvas = canvasRef?.current
- [Chartjs]-How add the sizes of the slices in the pie chart (at the top) in Chart.js?
- [Chartjs]-How could I provide my own ticks array into chart.js?
Source:stackexchange.com