FusionCharts API-Methods: setData

Created using FusionCharts Suite XT - www.fusioncharts.com

by FusionCharts

HTML

<script src="https://static.fusioncharts.com/code/latest/fusioncharts.js"></script>
<script src="https://static.fusioncharts.com/code/latest/fusioncharts.charts.js"></script>
<script src="https://static.fusioncharts.com/code/latest/themes/fusioncharts.theme.fint.js"></script>
<!-- This sample shows the usage of the setData() method -->
<div id="indicatorDiv">Method Name: <strong>setData()</strong>   
   <p>Feeds real-time data to real-time charts and gauges.</p>
   <p>Click <strong>Set Data</strong> to set data for the real-time column chart.</p>
</div>

    
<div class="">
	<button id="set_data" class="">Set Data</button>
	<div id="chart-container">FusionCharts will render here</div>
</div>

CSS

body {
    padding: 5px;
    margin: 0 auto;
}

strong{
  font-weight: bold;
}

.text-center {
  text-align: center;
}

p {
  margin: 10px auto;
}

.mb-20 {
  margin-bottom: 20px;
}
#indicatorDiv {
    width: 500px;
    font-family:'Arial', 'Helvetica';
    font-size: 13px;
}
#set_data {
    font-size: 13px;
    margin: 15px 0;
    padding: 10px 20px;
}

JavaScript

FusionCharts.ready(function () {
    var transactionChart = new FusionCharts({
        id: "mychart",
        type: 'realtimecolumn',
        renderAt: 'chart-container',
        width: '450',
        height: '250',
        dataFormat: 'json',
        dataSource: {
            "chart": {
                "caption": "Online Transactions (every 10 seconds)",
                    "subCaption": "harryssupermart.com",
                    "showrealtimevalue": "1",
                    "yaxismaxvalue": "10",
                    "numdisplaysets": "10",
                    "labeldisplay": "rotate",
                    "slantLabels": "1",
                    "showLegend": "0",
                    "showValues": "0",
                    "numbersuffix": " Transactions",
                    "showlabels": "1",
                    "showRealTimeValue": "0",
                    "theme": "fint",
                    "captionFontSize": "13",
                    "subCaptionFontSize": "12"
            },
                "categories": [{
                "category": [{
                    "label": "Start"
                }]
            }],
                "dataset": [{
                "seriesname": "",
                    "alpha": "100",
                    "data": [{
                    "value": "3"
                }]
            }]
        },
            "events": {
            "initialized": function (evt, arg) {
                //Format minutes, seconds by adding 0 prefix accordingly
                function formatTime(time) {
                    if (time < 10) {
                        time = "0" + time;
                    }
                    return time;
                }
                //Update Data method
                function updateData() {

                    //Get reference to the chart using its ID
                    var chartRef = FusionCharts("mychart"),
                        //We need to create a querystring format incremental update, containing
                   ...