Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is possible to export programmatically a highcharts chart?

Tags:

highcharts

I would like to make some reports and mail them out, using the data that I have on the web pages that my server display.

Is there a way via code, to export the graph; so I can attach it in a mail? I see that is possible to save the graph as image, using the mouse, but I can't see how you can actually go via code and create a version of the graph as image.


2 Answers

Yes, it is possible.

As you've noted it requires the export module, which is included by also having:

<script src="http://code.highcharts.com/modules/exporting.js"></script>

The functionality you are looking for is the chart.exportChart function. It allows you to:

Submit an SVG version of the chart to a server along with some parameters for conversion.

Which can simply mean saving it through a button click, as shown in this simple JFiddle demo. The functionality of the button is then:

$('#button').click(function() {
    var chart = $('#container').highcharts();
    chart.exportChart();
});
like image 77
Halvor Holsten Strand Avatar answered Jul 17 '26 16:07

Halvor Holsten Strand


Sure you can. There is plenty information on highchartsjs site. Check this article and examples and github scripts. This is basics. Of course you could use other combination. I personally use phantomjs with asp.net.

like image 34
Andrey Borisko Avatar answered Jul 17 '26 16:07

Andrey Borisko