Search code examples
highchartsangular2-highcharts

HighChart stacked bar chart scrollbar issue


When using highstock with stacked bar chart and scroll bar is enabled, which has 100 categories, I don't see the data on the chart when I start scrolling. It works fine upto 50 categories

https://jsfiddle.net/shashi3337/5xn92uht/1/

function test() {
  var data = [];
  for (var i = 0; i < 100; i++) {
    var value = Math.random() * 10;
    var x = {
      id: i,
      name: 'test ' + i,
      y: value
    }
    data.push(x);
  }
  return data;
}

$('#container').highcharts({
  chart: {
    type: 'column',
  },
  plotOptions: {
    column: {
      stacking: 'normal'
    },
  },
  xAxis: {
    type: 'category',
    max: 10
  },
  scrollbar: {
    enabled: true
  },
  series: [{
      name: "A",
      data: test()
    }, {
      name: "B",
      data: test()
    },
    {
      name: "C",
      data: test()
    },
    {
      name: "D",
      data: test()
    }
  ]
});

when I scroll back to initial position I'm getting this error "Cannot read property '0' of undefined" error when stacked column chart is resized"


Solution

  • It works when you set cropThreshold parameter.

    plotOptions: {
        column: {
          stacking: 'normal',
          cropThreshold: 10000
        },
      }
    

    https://jsfiddle.net/shashi3337/cbd39oLh/1/