I'm using chartjs
/react-chartjs-s
to draw some plots in React/NextJS. I want to use an image for the pointStyle
for one plot in specific. In plain JavaScript, an image can be created using const i = new Image()
and used as a pointStyle
in ChartJS.
In React I get an error ReferenceError: Image is not defined
. If I try to import Image
from next/image
and use that, then the image does not appear on initial render (like here which interestingly can use new Image()
), and if I click on a datum on the chart I get an error Error: Rendered more hooks than during the previous render.
TLDR: Does anyone know how to use an image/icon as a pointStyle
using Next.js, ChartJS, and react-chartjs-2? Thanks!
I'm using:
react
v. 18.2.0react-dom
v. 18.2.0next
v 13.0.05chart.js
v. 4.1.1react-chartjs-2
v. 5.1.0