Time for action — retrieve data from the chart and sort them
1. Create a copy of
DynamicDataUpdate2.html
in theJavaScriptCapabilities
folder and name it asSortChartData.html
.2. Open this new file in a text editor. Insert the following HTML on a new line after the end of the paragraph element
</p>
, which contains the drop-down list (around line number 45):<p> <input type="button" onClick="sortData()" value="Sort Chart Data" /> </p>
3. Now, within the
<head>
of the page, add a new line after the end of theupdateData function
(around line number 28) and insert the following code:var descendingSort = true; function sortData () { var chart = FusionCharts("myChartId"), chartData = chart.getJSONData(); if (descendingSort) { chartData.data.sort(function (a, b) { return Number(a.value) < Number (b.value); }); } else { chartData.data.sort(function (a, b) { return Number(a.value) > Number (b.value); }); } chart.setJSONData(chartData); descendingSort = !descendingSort...