Javascript examples for highcharts:Chart Image
synchronized charts and export download image
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-1.4.3.min.js"></script> <script type="text/javascript"> $(function(){/*from w ww . j a v a 2 s. c o m*/ Highcharts.getSVG = function(charts) { var svgArr = [], top = 0, width = 0; $.each(charts, function(i, chart) { var svg = chart.getSVG(); svg = svg.replace('<svg', '<g transform="translate(0,' + top + ')" '); svg = svg.replace('</svg>', '</g>'); svg = svg.replace('-9000000000', '-999'); // Bug in v4.2.6 top += chart.chartHeight; width = Math.max(width, chart.chartWidth); svgArr.push(svg); }); return '<svg height="'+ top +'" width="' + width + '" version="1.1" xmlns="http://www.w3.org/2000/svg">' + svgArr.join('') + '</svg>'; }; Highcharts.exportCharts = function(charts, options) { options = Highcharts.merge(Highcharts.getOptions().exporting, options); Highcharts.post(options.url, { filename: options.filename || 'chart', type: options.type, width: options.width, svg: Highcharts.getSVG(charts) }); }; var chart1 = new Highcharts.Chart({ chart: { renderTo: 'container1' }, xAxis: { categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] }, series: [{ data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]}] }); var chart2 = new Highcharts.Chart({ chart: { renderTo: 'container2', type: 'column' }, xAxis: { categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] }, series: [{ data: [176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4, 29.9, 71.5, 106.4, 129.2, 144.0]}] }); $('#export').click(function() { Highcharts.exportCharts([chart1, chart2]); }); }); </script> </head> <body> <script src="https://code.highcharts.com/highcharts.js"></script> <script src="https://code.highcharts.com/modules/exporting.js"></script> <div id="container1" style="height: 200px"></div> <div id="container2" style="height: 200px"></div> <button id="export">Export all</button> </body> </html>