Setting Chart Attributes specifically for a renderer

by Shamasis Bhattacharya

HTML

<script src="http://static.fusioncharts.com/code/red/19835/FusionCharts.js"></script>
<div id="chartcontainer">Chart loads here!!</div>

JavaScript

FusionCharts.addEventListener("BeforeDataUpdate", function (ev, args) {
    if (ev.sender.options.renderer === 'javascript') {
        args.data = args.data
            .replace(/\<(chart|graph)(.*?)(\scaption\=\".*?\")(.*?\>)/ig,
                     "<$1$2$4")
            .replace(/\<(chart|graph)\s/ig, "<$1 caption=\"Replaced Caption\" ");
        console.log(args.data);
    }
});

var myChart = new FusionCharts({    
        type: "Column2D",
        renderAt: "chartcontainer",
        width: "500", height: "350",
        
        dataFormat: FusionChartsDataFormats.JSON,
        dataSource: {
            caption: "Productivity for various office occurences",
            baseFontSize: "14",
            useRoundEdges: "1",
            numberSuffix: "%",
            numDivLines: "5",
            showValues: "0",
            yAxisName: "Productivity",
            xAxisName: "Occurence in office",
            data: [
                {value: 100, label: 'Boss sits next to you'},
                {value: 110, label: 'Deadline 6 hours away'},
                {value: 25, label: 'Friday, 4:55 PM'},
                {value: 5, label: 'Free Pizza'}
            ]
        }
    }).render();