Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

5. Exporting Charts > Time for action — create separate buttons to export the c...

Time for action — create separate buttons to export the chart as image and PDF

  1. Create a copy of ExportUsingJavaScriptAPI.html and save it as ExportUsingJavaScriptAPI2.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')" />
    

  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint