FusionCharts - Attaching an event

Created using FusionCharts Suite XT - www.fusioncharts.com

by Shamasis Bhattacharya

HTML

<script src="http://static.fusioncharts.com/code/latest/fusioncharts.js"></script>
<script src="http://static.fusioncharts.com/code/latest/fusioncharts.charts.js"></script>
<script src="http://static.fusioncharts.com/code/latest/themes/fusioncharts.theme.fint.js"></script>
<!--
    A simple Column 2D chart showing monthly revenue of Harry's SuperMart for last year along with an event attached
    on `renderComplete` event. Check your JavaScript console to see it.
-->
<div id="chart-container">FusionCharts will render here</div>

JavaScript

FusionCharts.ready(function() {
    var revenueChart,
        myEventListener;

    revenueChart = new FusionCharts({
        type: 'column2d',
        renderAt: 'chart-container',
        width: '500',
        height: '300',
        dataFormat: 'json',
        dataSource: {
            "chart": {
                "caption": "Monthly revenue for last year",
                "subCaption": "Harry's SuperMart",
                "xAxisName": "Month",
                "yAxisName": "Revenues (In USD)",
                "numberPrefix": "$",
                "theme": "fint"
            },

            "data": [{
                "label": "Jan",
                "value": "420000"
            }, {
                "label": "Feb",
                "value": "810000"
            }, {
                "label": "Mar",
                "value": "720000"
            }, {
                "label": "Apr",
                "value": "550000"
            }, {
                "label": "May",
                "value": "910000"
            }, {
                "label": "Jun",
                "value": "510000"
            }, {
                "label": "Jul",
                "value": "680000"
            }, {
                "label": "Aug",
                "value": "620000"
            }, {
                "label": "Sep",
                "value": "610000"
            }, {
                "label": "Oct",
                "value": "490000"
            }, {
                "label": "Nov",
                "value": "900000"
            }, {
                "label": "Dec",
                "value": "730000"
            }]
        }
    });

    // We create the event listener
    myEventListener = function(eventObj, eventArgs) {
        console.log(eventObj.eventType +
            " was raised by the chart whose ID is " +
            eventObj.sender.id);
    };

    // Attach the event listener to the renderComplete event of the chart.
    revenueChart.addEventListener("renderComplete", myEventListener);

    //...