Search code examples
pythondjangographreportlabhighcharts

Highcharts SVG Export from Python Server Side Code


I am using reportlab in python to render a pdf server side.

I really like the look of highcharts graphs. But I am building a pdf server side which needs to include some graphs. The server side graphing (reportlab and matplotlib) do not have nearly as much choices for formatting / design.

Is there a way I can run a client side javascript graphing solution (highcharts) from the server side?

Here is a post with that request and this is what they said: You feed this Java tool a URL, it fires up its internal WebKit browser, executes the JavaScript code and dumps the rendered page to PDF.

I am looking for resources on how this could be accomplished in python.


Solution

    1. Open a web browser on the server.

    2. Point the web browser at a pre-made page that loads highcharts and renders your chart.

    3. Grab the output of the browser.

    4. Send that to a client.

    Which of those steps seems confusing?

    Note that this will be significantly slower than just using matplotlib, because you need to start up a full web browser just to render a graph. I had a quick look at the highcharts page you linked and I think you could probably reproduce that in matplotlib.