HChart Change local data
Create 2 local data series and add to chart on click.
by Bryan McIntosh
HTML
<SELECT id="list">
<OPTION VALUE="A">Data Set A</OPTION>
<OPTION VALUE="B">Data Set B</OPTION>
</SELECT>
<button id="change">Refresh Table</button>
<button id="btnClear">Clear Table</button>
<div id="container" style="height: 400px"></div>
<script src="http://code.highcharts.com/stock/highstock.js"></script>
<script src="http://code.highcharts.com/stock/modules/exporting.js"></script>
JavaScript
var options = {
chart: {
renderTo: 'container',
defaultSeriesType: 'spline'
},
series: []
};
$("#change").click(function () {
if ($("#list").val() == "A") {
options.series = [{
name: 'A',
data: [1, 2, 3, 2, 1]
}];
}
else {
options.series = [{
name: 'B1',
data: [3, 2, 1, 2, 3]
},{
name: 'B2',
data: [5, 1, 2, 4, 2]
}];
}
var chart = new Highcharts.Chart(options);
//chart = new Highcharts.Chart(options);
});
$("#btnClear").click(function () {
options.series = [0];
//options.series = [];
var chart = new Highcharts.Chart(options);
});