<script src="http://static.fusioncharts.com/code/latest/fusioncharts.js"></script>
<!-- A simple Scroll Area 2D chart -->
<div id="chart-container">FusionCharts will render here</div>
JavaScript
FusionCharts.ready(function () {
var getTabularData = function () {
var i,
data2011 = [],
data2012 = [],
categories = [];
var jsonData = JSON.parse('[{"Name":"2012","Apple":"7895","orange":"89752"}, {"Name":"2013","Apple":"8975","orange":"9875"},{"Name":"2014","Apple":"9285","orange":"9987"}]');
for (var i in jsonData) {
var tmparray = jsonData[i];
categories.push({
label: tmparray.Name
});
data2011.push({
value: tmparray.Apple
});
data2012.push({
value: tmparray.orange
});
}
return {
categories: categories,
dataset: [{
seriesname: "Apple",
data: data2011
}, {
seriesname: "Orange",
data: data2012
}]
};
};
var data = getTabularData();
var revenueChart = new FusionCharts({
type: 'mscolumn2d',
renderAt: 'chart-container',
width: '500',
height: '300',
dataFormat: 'json',
id: 'revenue-chart',
dataSource: {
"chart": {
"caption": "Harry's SuperMart",
"subCaption": "Monthly revenue for previous two years",
"xAxisName": "Month",
"yAxisName": "Amount",
"numberPrefix": "$",
"theme": "fint",
"rotateValues": "1",
"exportEnabled": "1"
},
"categories": [{
"category": data.categories
}],
"dataset": data.dataset
}
});
revenueChart.render();
});
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.