I have a column graph that I would like to update when user selects an option from a drop down menu. I am able to render the column graph correctly but I am not able to update the graph using setData(). I am a little stumped because I am not receiving any errors. Any help or insight you can give me would be much appreciated! here is a link to my JSFiddle
http://jsfiddle.net/mshirk/6QYzD/2/
and the Javascript code rendering the graph
$(document).ready(function () {
var chartBench = new Highcharts.Chart({
chart: {
renderTo: 'containerYo',
type: 'column'
},
title: {
text: ''
},
credits: {
enabled: false
},
legend: {},
plotOptions: {
series: {
shadow: false,
borderWidth: 0
}
},
xAxis: {
lineColor: '#999',
lineWidth: 1,
tickColor: '#666',
tickLength: 3,
categories: ['2011', '2012', '2013', '2014'],
title: {
text: 'Years'
}
},
yAxis: {
lineColor: '#999',
lineWidth: 1,
tickColor: '#666',
tickWidth: 1,
tickLength: 3,
gridLineColor: '#ddd',
labels: {
format: '$ {value}'
},
title: {
text: ''
}
},
series: [{
"name": "Yours",
"data": [110, 100, 120, 130]
}, {
"name": "Another",
"data": [100, 90, 110, 120]
}, {
"name": "Another B",
"data": [90, 80, 100, 110]
}, {
"name": "Another C",
"data": [80, 70, 90, 100]
}]
});
});
$("#list").on('change', function () {
//alert('f')
var selVal = $("#list").val();
if (selVal == "a") {
chartBench.series[0].setData([
[{
"name": "Yours",
"data": [110, 100, 120, 130]
}, {
"name": "Another",
"data": [100, 90, 110, 120]
}, {
"name": "Another B",
"data": [90, 80, 100, 110]
}, {
"name": "Another C",
"data": [80, 70, 90, 100]
}]
]);
} else if (selVal == "b") {
chartBench.series[0].setData([
[{
"name": "Yours",
"data": [210, 200, 220, 230]
}, {
"name": "Another",
"data": [200, 190, 210, 220]
}, {
"name": "Another B",
"data": [190, 180, 200, 210]
}, {
"name": "Another C",
"data": [180, 170, 190, 200]
}]
]);
} else {
}
});