Time for action — create separate buttons to export the chart as image and PDF
1. Create a copy of
ExportUsingJavaScriptAPI.html
and save it asExportUsingJavaScriptAPI2.html
2. Open this file in a text editor and replace the entire
beginExportChart
function with the following modified variant:function beginChartExport (format) { if(chartObj.hasRendered && chartObj.hasRendered()) { chartObj.exportChart({ exportFormat: format }); document.getElementById("exporterContainer").innerHTML = ""; } else { alert("Please wait for the chart to render."); } }
3. Locate the HTML button to export the chart (around line 51) and replace it with the following code, having two buttons:
<input type="button" value="Export Chart as Image" onclick="beginChartExport('PNG')" /> <input type="button" value="Export Chart as PDF" onclick="beginChartExport('PDF')" />
4. Open the file in a web browser, click on the first button labeled Export Chart as Image, and let the export process complete.
5...