amcharts3
amcharts3 copied to clipboard
Server side rendering
Is there any possibility to generate/pre-render/render a chart on the server side? We have to include a chart (amcharts) in PDF report. It is almost not possible to use another framework to generate same charts on server side, because our client wants to have in the report just what he see on browser. Thanks!
Hi there,
While there are no built-in server-side capabilities in amCharts, you can use one of the head-less browsers, like PhantomJS to generate snapshots of charts, or the whole web pages into images or PDF.
He're a tutorial on how you can do so with amCharts and PhantomJS: https://www.amcharts.com/kbase/automate-report-generation-using-phantomjs/
I hope it helps.
With amCharts being released in version 4.0, is there a better solution for server-side rendering than using PhantomJS?
Yes ;)
https://www.amcharts.com/docs/v4/tutorials/automating-report-generation-using-puppeteer/
I downloaded the example at the end of the tutorial, but no pdf gets exported. (no error in console). Is it meant to work out of the box?
Yes ;)
https://www.amcharts.com/docs/v4/tutorials/automating-report-generation-using-puppeteer/
I followed the above tutorial and it is not working.
OK, so it looks like Puppeteer broke something and is no longer working.
We're working on other solutions.
Please bear with us ;)
It's necessary to set Page.setDownloadBehavior to define where Chrome will save the downloaded file when using Puppeteer. Unfortunately that is no longer working.
PhantomJS is not being supported for some time so the V3 solution is also not ideal at this point.
We came up with a new solution using Selenium Webdriver. Please check this link: https://www.amcharts.com/docs/v4/tutorials/automating-report-generation-using-selenium-webdriver/