Drag Column Chart - Getting data with getData method
Created using FusionCharts Suite XT - www.fusioncharts.com
by FusionCharts
HTML
<script src="https://cdn.fusioncharts.com/fusioncharts/latest/fusioncharts.js"></script>
<script src="https://cdn.fusioncharts.com/fusioncharts/latest/themes/fusioncharts.theme.fusion.js"></script>
<!-- Drag-able chart - Getting data through `getData` method. After rendering the chart we retrieve the data with `getData` and display the data in a tabular format.
method:
# getData
-->
<div>
<div id="chart-container">FusionCharts will render here</div>
<div id="tableCont">
<table id="data-table">
</table>
</div>
</div>
CSS
body {
font-family: "Arial", "Verdana", "sans";
font-size: 80%;
}
body>div {
/*only one in this sample */
width: 600px;
}
table {
margin: 5px auto;
border-collapse: collapse;
border: 1px solid;
border-bottom: 2px solid #6baa01;
}
th {
background-color: #008ee4;
color: #ffffff;
}
th,
td {
border: 1px solid #6baa01;
padding: 10px 5px;
min-width: 70px;
text-align: center;
}
#tableCont {
width: 100%;
}
#tableCont table {
width: 96%;
}
JavaScript
FusionCharts.ready(function() {
var inventoryChart = new FusionCharts({
type: 'dragcolumn2d',
renderAt: 'chart-container',
width: '500',
height: '350',
dataFormat: 'json',
dataSource: {
"chart": {
"caption": "Inventory status - Bakersfield Central",
"subCaption": "Top 5 Food items",
"xAxisName": "Food Item",
"yAxisName": "No. of Units",
"theme": "fusion"
},
"categories": [{
"category": [{
"label": "Poultry"
},
{
"label": "Rice"
},
{
"label": "Peanut Butter"
},
{
"label": "Salmon"
},
{
"label": "Cereal"
}
]
}],
"dataset": [{
"seriesname": "Available Stock",
"allowDrag": "0",
"data": [{
"id": "P_AS",
"value": "6000"
},
{
"id": "R_AS",
"value": "9500"
},
{
"id": "PB_AS",
"value": "11900"
},
{
"id": "S_AS",
"value": "8000"
},
{
"id": "C_AS",
"value": "9700"
}
]
},
{
"seriesname": "Estimated Demand",
"dashed": "1",
"data": [{
"id": "P_ED",
"value": "19000"
},
{
"id": "R_ED",
"value": "16500"
},
{
"id": "PB_ED",
"value": "14300"
},
{
"id": "S_ED",
"value": "10000"
},
{
"id": "C_ED",
"value": "9800"
}
]
}
]
},
events: {
'rendered': function(evt, arg) {
var chartIns = evt && evt.sender,
...