简体   繁体   English

高图图表轴超过设置的最小值和最大值

[英]Highcharts chart axis exceeding set min and max values

I want to limit my y-axis to the range from -43 to 43. I also want my chart to not display space/area/anything under or over those values. 我想将我的y轴限制为-43到43。我还希望我的图表不显示这些值以下或以上的空间/面积/任何内容。 Here is what my axis options look like 这是我的轴选项

yAxis: {
   tickInterval: 1,
   minorTickInterval: null,
   endOnTick: false,
   min: -41,
   max: 43,
   title: {
      text: 'Y Coordinate'
   },
   gridLineColor: 'transparent'
}

However, in the following image you can clearly see that highcharts is displaying space for values below my limit and down to -45. 但是,在下面的图像中,您可以清楚地看到highcharts显示的值的空间低于我的限制,直到-45。 I want these hard limits so my background image lines up perfectly with the coordinate grid system. 我想要这些严格的限制,以便我的背景图像与坐标网格系统完美对齐。 NHL拍摄影像

I read that setting my tickInverval to 1 and endOnTick to false would produce the desired result, however it seems that is not so. 我读到将我的tickInverval设置为1并将endOnTick设置为false会产生所需的结果,但是事实并非如此。

Any ideas? 有任何想法吗?

Tick positions determine start and end axis values. 刻度位置确定起点和终点轴的值。 You can use tickPositions in order to pass your positions or create a function which returns tick positions based on your min and max value and pass it as positioner. 您可以使用tickPositions来传递您的头寸,或者创建一个函数来根据您的最小值和最大值返回报价头寸并将其作为定位器传递。

const random = () => Math.round((Math.random() * 200) - 100)
const options = {
  yAxis: {
    min: -99,
    max: 99,
    // tickPositions: [-99, 99],
    tickPositioner () {
      const axis = this
      return axis.tickPositions.map((pos) => {
        if (pos <= axis.max && pos >= axis.min) return pos // If between range
        else if (pos > axis.max) return axis.max
        else if (pos < axis.min) return axis.min
      })
    }
  },
  series: [{
    data: [...Array(10)].map(random),
    type: 'column'
  }]
}

const chart = Highcharts.chart('container', options)

Live example: https://jsfiddle.net/918zb76r/ 实时示例: https//jsfiddle.net/918zb76r/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM