Highcharts gantt or any chart x-axis scroll position to be at the start/left side on loading chart

667 Views Asked by At

I am using highcharts gantt for one of my requirement. I am trying to figure out how scroll position can be at the start of the chart. Later it can be scrolled to the end.

For demo purpose, I created a fiddle https://jsfiddle.net/jon_a_nygaard/t0bjo6dq/

  scrollbar: {
  enabled: true
  },

I will try to explain with an image.I want this scroll to be on left

This can be a general case for any highcharts chart.

I tried setExtremes, but the way chart loaded is different with this.

Please help. Thanks

1

There are 1 best solutions below

0
Sebastian Wędzel On

According to the comments - thanks for the clarification! Try to setExtremes at xAxis in this way:

  chart: {
    events: {
      load: function() {
                const chart = this,
                            series = chart.series,
                            min = series[series.length -1].processedXData[0],
                            max = min + 60 * 60 * 24 * 175 * 1000; //half year
                
                chart.xAxis[0].setExtremes(min, max)
      }
    }
  },

Demo: https://jsfiddle.net/BlackLabel/qLrjtuwh/

API: https://api.highcharts.com/class-reference/Highcharts.Axis#setExtremes