G2 icon indicating copy to clipboard operation
G2 copied to clipboard

Draw chart into buffer/virtual canvas

Open Destabilizator opened this issue 5 years ago • 1 comments

  • [x] I have searched the issues of this repository and believe that this is not a duplicate.

What problem does this feature solve?

I have Node.js server and want to utilize AntV G2 charting library to create chart, save it to image (cannot use base64 encoding via .toDataURL, because Google stopped displaying such images) and send it via Nodemailer. Problem is that in all the examples, AntV G2 requires a container, which I don't have when I'm server side. I've tried to utilize jsdom to create virtual container, but it doesn't work neither - throws ReferenceError: getComputedStyle is not defined. Any tips how to draw the chart on server and save it as image would be welcome.

What does the proposed API look like?

For example container in jsdom should be allowed and work, at the moment it throws ReferenceError: getComputedStyle is not defined.

Destabilizator avatar Mar 09 '21 08:03 Destabilizator

Maybe you can:

  1. install puppeteer or other headless browser
  2. render chart into headless browser
  3. get the base64, then save to image file, or use screenshot API

hustcc avatar Mar 25 '21 08:03 hustcc