Chartjs-Error ReferenceError: CanvasGradient is not defined

1πŸ‘

I found the solution. The number of labels should match the number of data points.

1πŸ‘

In canvas for node implementation you need to export CanvasGradient class yourself. According to this issue: https://github.com/Automattic/node-canvas/issues/990
You can do this:

["CanvasRenderingContext2D", "CanvasPattern", "CanvasGradient"].forEach(obj => {
  console.log(obj, canvas[obj])
  global[obj] = canvas[obj]
})

Leave a comment