Home Forums Feature Requests & Feedback Export charts as PNG on server

Export charts as PNG on server

Viewing 7 posts - 1 through 7 (of 7 total)
  • #28856


    I’m currently trying out Canvasjs on Centos O/S. For our solution we are looking at generating a number charts, saving them as png and and then building a report in HTML, then creating a PDF report from the HTML file (URL).

    My question is:
    How can I export the rendered charts as PNG on the server, without intervention e.g. headless in the background from a PHP script?

    Thanks in advance




    In order to render chart on the server side you would require a headless browser like PhantomJS. Here is an article which might help.
    Please take a look at this sample PhantomJS project, that captures the chart image from web page and saves it to a particular location. Please refer to instructions.txt file for clear understanding.

    Indranil Deo
    Team CanvasJS



    Hello Indranil,

    Thanks for the sample project, this is exactly what I need !
    Great support here, I think I will buy one licence of this great product :)



    I got one more question :)

    Now the Export-Chart method is available, should we use it instead of native page.render() ?




    In the sample shared above PhantomJS is required for rendering the chart on server and exporting the same as an image. page.render() helps in rendering the web page(containing the chart) to an image buffer and then saves it as an image with the specified filename.

    Indranil Singh Deo
    Team CanvasJS



    Yep, and it’s working flawlessly, thanks for the template and the phamtomjs demo :)

    I was just wondering if with the new exportChart method, we could speed up the fact to generate the PNG.
    But maybe not, especially if the graph render have to be complete into the browser before exportChart convert the canvas to PNG, am I right ?



    CanvasJS exportChart method is used to export the chart in the client-side. In order to save the image on server, you need to use PhantomJS’s page.render method which renders the page and save it as an image on server.

    Manoj Mohan
    Team CanvasJS

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.