Are there any plans to make a NodeJS package? - Official support forum | RGraph.net

Are there any plans to make a NodeJS package?

Post a reply

Posted by Tiago Caldeira at 10:48 on Wednesday 17th August 2022 [link]
Hello there,

I'm currently working on a project that requires generating a line graph in NodeJS, saving the graph as a PNG and sending it over to a S3 bucket.

I've seen in your FAQ a way to make server-side graphs using PhantomJS which is now deprecated and not ideal, so I was wondering if there is any plans or even a target market for packaging RGraph as a npm module or not.

Additionally, if nothing's planned for it, would using Puppeteer (https://github.com/puppeteer/puppeteer) work for my use-case?

Thanks and best regards.

Posted by Richard at 11:04 on Wednesday 17th August 2022 [link]
I don't have any plans for a NodeJS npm at the moment. I tried using it once and it struck me as a little strange to say the least.

PhantomJS may be deprecated and (probably) unsupported but it's still usable if you want screenshots.

Looking at the Puppeteer Git Page it claims it can make screenshots for you so it looks like that would be great for what you want. I don't know how easy it is for it to do that though - but I can't imagine it would be difficult.

One thing to remember here is that canvas is initially transparent (not white). Now, when taking a screenshot of a webpage, this shouldn't really be an issue but, just in case, here's some code (again, that may not be necessary) that clears the canvas to white before drawing your chart (instead of leaving it as transparent):



myLine = new RGraph.Line({
    id: 'cvs',
    data: [4,8,6,3,5,4,6],
    options: {
    }
}).on('beforedraw', function (obj)
{
    RGraph.clear(obj.canvas, 'white');
}).draw();

Post a reply

What's your name?
What do you want to say?