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

    Hi,

    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

    Ramsy

    #28864

    Ramsy,

    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

    #37275

    Rck

    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 :)

    #37276

    Rck

    I got one more question :)

    Now the Export-Chart method is available, should we use it instead of native page.render() ?
    https://canvasjs.com/docs/charts/methods/chart/export-chart/

    Thanks

    #37289

    @rck,

    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

    #37296

    Rck

    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 ?

    #37301

    @rck,

    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.