Chris Farmer
Chris Farmer

Reputation: 25396

Why do my highcharts yaxis tick positions change the min and max of my chart?

I have a highcharts scatter plot, and I want to customize the locations of the tick marks. I see that I can do this with the tickPositioner callback function for each axis. This seems to work fine, but...

  1. When I define and use tickPositioner on the y-axis, it also seems to reset the chart's max and min to the range of my ticks.
  2. When I use it on the x-axis, however, the min and max range stays correct.

Why is there this different behavior between x and y axis? How can I correctly set the tick positions in my y-axis without affecting the overall range of my axis?

Below is the relevant section of my chart config, and also there's a fiddle demonstrating this at https://jsfiddle.net/cfarmerga/a6mvgbcf/

{
  // The positioner in the x axis sets the ticks and preserves the displayed range
  xAxis: {
    tickPositioner: function () { return [2, 4, 6, 8] }
  },
  // The positioner in the y axis sets the ticks but changes the displayed range
  yAxis: [{
    tickPositioner: function () { return [2, 4, 6, 8] }
  }],
}

Y axis range has changed

Upvotes: 1

Views: 878

Answers (1)

Sebastian Hajdus
Sebastian Hajdus

Reputation: 1560

The difference between the X and Y axes is the default value for endOnTick and startOnTick.

  yAxis: [{
    gridLineWidth: 1,
    startOnTick: false,
    endOnTick: false
  }],

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

Upvotes: 1

Related Questions