FusionCharts - Update Chart Data Runtime - dataUpdated API Call
Created using FusionCharts Suite XT - www.fusioncharts.com
HTML
<script src="http://static.fusioncharts.com/code/latest/fusioncharts.charts.js"></script>
<script src="http://static.fusioncharts.com/code/latest/fusioncharts.js"></script>
<div id="chart-container">FusionCharts will render here</div>
<button id="update-chart">Update Chart Data</button>
JavaScript
FusionCharts.ready(function () {
var chartConfiguration = {
"caption": "Sales of Liquor",
"subCaption": "Last week",
"xAxisName": "Day",
"yAxisName": "Sales (In USD)",
"numberPrefix": "$",
"paletteColors": "#0075c2",
"bgColor": "#ffffff",
"showBorder": "0",
"showCanvasBorder": "0",
"plotBorderAlpha": "10",
"usePlotGradientColor": "0",
"plotFillAlpha": "50",
"showXAxisLine": "1",
"axisLineAlpha": "25",
"divLineAlpha": "10",
"showValues": "1",
"showAlternateHGridColor": "0",
"captionFontSize": "14",
"subcaptionFontSize": "14",
"subcaptionFontBold": "0",
"toolTipColor": "#ffffff",
"toolTipBorderThickness": "0",
"toolTipBgColor": "#000000",
"toolTipBgAlpha": "80",
"toolTipBorderRadius": "2",
"toolTipPadding": "5",
"animation": "0"
};
var updateBtn = document.getElementById('update-chart');
// Event Listener for the update-chart button. Updating the chart with another random set of data. In real life use cases, this could be a different set of data like data for current week..etc
updateBtn.addEventListener('click', function (e) {
this.disabled = true;
salesChart.setJSONData({
chart: chartConfiguration,
data: [{
"label": "Mon",
"value": "3521"
}, {
"label": "Tue",
"value": "2364"
}, {
"label": "Wed",
"value": "3412"
}, {
"label": "Thu",
"value": "4823"
}, {
"label": "Fri",
"value": "3487"
}, {
"label": "Sat",
"value": "5402"
...