ChartjsNodeCanvas icon indicating copy to clipboard operation
ChartjsNodeCanvas copied to clipboard

Question: can we use this package to save ChartJs images to disk?

Open Mirko-Tebaldi opened this issue 2 years ago • 1 comments

Our team is looking for a way to generate ChartJs on server-side. Our need is either

  • generate a data url to pass to php script
  • generate a image file to a known position so a php script can lately embed in a pdf using mPdf.

Is there an example about how to save image to disk?

Mirko-Tebaldi avatar Dec 21 '22 07:12 Mirko-Tebaldi

The src/example.ts gives an example of saving a chartJs image to disk using .renderToBuffer(), then fs.writeFile().

You can also generate a data url via the .renderToDataURL() function

joshuanianji avatar Feb 22 '23 20:02 joshuanianji