ElementStacks
HTML
<script src="http://highcharts.com/js/highcharts.src.js"></script>
<script src="http://highcharts.com/js/excanvas.compiled.js"></script>
<div id="container" style="height: 400px"></div>
<button id="button">Change type</button>
JavaScript
$('#button').click(function() {
var series = chart.series[0],
newType = series.type == 'line' ? 'column' : 'line';
changeType(series, newType);
})
function changeType(series, newType) {
var dataArray = [],
points = series.data;
series.chart.addSeries({
type: newType,
name: series.name,
color: series.color,
data: series.options.data
}, false);
series.remove();
}
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
defaultSeriesType: 'line'
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
yAxis: {
},
legend: {
layout: 'vertical',
backgroundColor: '#FFFFFF',
style: {
left: '100px',
top: '70px',
bottom: 'auto'
}
},
tooltip: {
formatter: function() {
return '<b>'+ this.series.name +'</b><br/>'+
this.x +': '+ this.y;
}
},
plotOptions: {
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}]
});