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
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

3. JavaScript Capabilities > Time for action — retrieve CSV data from the chart...

Time for action — retrieve CSV data from the chart and update a textarea

  1. Create a copy of SortChartData.html in the JavaScriptCapabilities folder and name it as RetrieveChartData.html.
  2. Open this new file in a text editor and insert a new button that will appear just beside the button to sort data. The code for the button will be the following:
    <input type="button" onclick=" fetchData()" value="Get Chart Data" />
    
  3. After the end of the paragraph element (around line 86) containing the previous button, insert a new line and add the following HTML code:
    <p>
    <textarea id="CSVData" style="display:none;" rows="8" cols="40" readonly="readonly" onblur="hideCSVData()"></textarea>
    </p>
    
  4. Now within the<head> of the page, add a new line after the end of the sortData function (around line number 48) and insert the following code:
    function fetchData () {
    var chart = FusionCharts("myChartId"), csvData = chart.getCSVData(), csvDataArea = document.getElementById("CSVData");
    csvDataArea.innerHTML = csvData;
    csvDataArea.style.display = "block";
    csvDataArea.focus();
    }
    function hideCSVData () {
    document.getElementById("CSVData").style.display = "none";
    }
    

  

You are currently reading a PREVIEW of this book.

                                                                                        

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

  

Start a Free Trial