shifu
shifu

Reputation: 670

maxPadding on highstocks

I've searched that maxPadding is not supported on highstocks (as per this post Highstock - why is min/maxPadding on xAxis ignored), is there any alternative to it for Highstocks?

Appreciate your help.

Upvotes: 0

Views: 73

Answers (1)

morganfree
morganfree

Reputation: 12472

If you do not use ordinal axis, you can expand range programmatically on xAxis.events.setExtremes.

xAxis: {
  minPadding: 0.1,
  maxPadding: 0.1,
  ordinal: false,
  events: {
    setExtremes: function(e) {
      if (e.trigger) {
        e.preventDefault()
        const navigator = this.chart.xAxis[1]
        let { min, max } = e
        const range = navigator.max - navigator.min

        if (max === navigator.max) max += 0.1 * range
        if (min === navigator.min) min -= 0.1 * range

        this.setExtremes(min, max)
      }
    }
  }
},

example: http://jsfiddle.net/qaknvyz9/

Upvotes: 1

Related Questions