FusionCharts - Set Chart Data with user input
Created using FusionCharts Suite XT - www.fusioncharts.com
HTML
<script src="http://static.fusioncharts.com/code/latest/fusioncharts.js"></script>
<script src="http://static.fusioncharts.com/code/latest/fusioncharts.charts.js"></script>
<!-- Column 2D chart showing Monthly revenues for last year -->
<div id="chart-container">FusionCharts will render here</div>
<div>
<h5>Set the Footfall</h5>
<select id="monthSelector">
<option value="Jan">Jan</option>
<option value="Feb">Feb</option>
<option value="Mar">Mar</option>
</select>
<input type="range" min="0" max="100" value="0" id="slider" />
</div>
CSS
h5 {
margin: 10px 0;
}
JavaScript
FusionCharts.ready(function() {
var chartConfig = {
"caption": "Total footfall in Bakersfield Central - Admin View",
"subCaption": "Year 2014",
"xAxisName": "Month",
"yAxisName": "No. of Visitors",
//Cosmetics
"lineThickness": "2",
"paletteColors": "#0075c2",
"baseFontColor": "#333333",
"baseFont": "Helvetica Neue,Arial",
"captionFontSize": "14",
"subcaptionFontSize": "14",
"subcaptionFontBold": "0",
"showBorder": "0",
"bgColor": "#ffffff",
"showShadow": "0",
"canvasBgColor": "#ffffff",
"canvasBorderAlpha": "0",
"divlineAlpha": "100",
"divlineColor": "#999999",
"divlineThickness": "1",
"divLineIsDashed": "1",
"divLineDashLen": "1",
"divLineGapLen": "1",
"showXAxisLine": "1",
"xAxisLineThickness": "1",
"xAxisLineColor": "#999999",
"showAlternateHGridColor": "0",
"yAxisMinValue": "0",
"yAxisMaxValue": "100",
"animation": "0"
},
chartData = [{
"label": "Jan",
"value": "42"
}, {
"label": "Feb",
"value": "81"
}, {
"label": "Mar",
"value": "36"
}],
revenueChart = new FusionCharts({
type: 'line',
renderAt: 'chart-container',
width: '550',
height: '350',
dataFormat: 'json',
dataSource: {
"chart": chartConfig,
"data": chartData
}
});
revenueChart.render();
document.getElementById('slider').oninput = function() {
alert ('hello');
var currentData = revenueChart.getJSONData(),
selectedMonth =...