1
votes

I am developing a website and using Highcharts. I have a bar/column chart selection. The chart is first displayed in bar chart, and then using the following code switch between the two chart types:

Code for changing to bar chart:

var chart = code for find the chart object
chart.inverted = true;
chart.xAxis[0].update({}, false);
chart.yAxis[0].update({}, false);
chart.series[0].update({
    type: 'bar'
});

The following code is for changing to column chart:

var chart = code for find the chart object
chart.inverted = false;
chart.xAxis[0].update({}, true);
chart.yAxis[0].update({}, true);
chart.series[0].update({
    type: 'column'
});

When the chart is first displayed in bar chart, all the data are displayed. However, when changed to column chart, some columns are missing. Please see the below picture. If I change it to bar chart, all the data are still there.

enter image description here

What could the cause for this problem? Thanks!

1

1 Answers

1
votes

After some research, I found code here works for me.

http://jsfiddle.net/lorwynz_11/sSLnn/3/

for column chart

    options.chart.renderTo = 'container';
    options.chart.type = 'column';
    var chart1 = new Highcharts.Chart(options);

for bar chart

    options.chart.renderTo = 'container';
    options.chart.type = 'bar';
    var chart1 = new Highcharts.Chart(options);

Cheers!