Time for action — create a button to export the chart
1. Create a copy of
CustomizeClientSideExport.html
and save it asExportUsingJavaScriptAPI.html
.2. Open this new HTML file using a text editor and locate the
<script>
within the HTML<head>
element within which we have written our previous set of code. At the end of the script block (around line 31), insert a new line and type the following lines of code:function beginChartExport () { if(chartObj.hasRendered && chartObj.hasRendered()) { chartObj.exportChart(); } else { alert("Please wait for the chart to render."); } }
3. Locate the export component container
<div>
HTML element with IDexporterContainer
(around line 47) and add the following HTML code containing the button to initiate the chart export:<p id="exportControls"> <input type="button" value="Export Chart" onclick="beginChartExport()" /> </p>
4. Now open the
ExportUsingJavaScriptAPI.html
file within a browser and click on the newly...