简体   繁体   English

Highcharts-如何将yAxis设置为系列数据中最接近或准确的值

[英]Highcharts- how to set yAxis to the closest or exact value in the series data

Here is an example of what I am trying to do. 这是我想要做的一个例子。

http://jsfiddle.net/na74Lndg/1/ http://jsfiddle.net/na74Lndg/1/

how can I avoid highcharts inserting the 12.5 yAxis line. 如何避免插入12.5 yAxis线的高位图。

If the series has any data that goes 11 then I do want to see the 12.5 line but not if there is nothing there. 如果该系列有任何数据为11,那么我确实希望看到12.5行,但如果没有任何内容则不行。

I have tried using softMax but that does not solve the issue, 我尝试过使用softMax,但这并没有解决问题,

yAxis: {
 softMax: 10
}

I sure can write code to calculate the max data series and set the max accordingly, but looking for an answer without writing to much code. 我确定可以编写代码来计算最大数据系列并相应地设置最大值,但是在不写很多代码的情况下寻找答案。

You can set the maxPadding to 0 (or some other number that accomplishes your desired result). 您可以将maxPadding设置为0 (或其他一些可以完成所需结果的数字)。

yAxis: {
  maxPadding: 0,
  ...
}

Updated fiddle: 更新小提琴:

Reference: 参考:

maxPadding: Number Since 1.2.0 Padding of the max value relative to the length of the axis. maxPadding:Number自1.2.0填充最大值相对于轴的长度。 A padding of 0.05 will make a 100px axis 5px longer. 填充0.05将使100px轴长5px。 This is useful when you don't want the highest data value to appear on the edge of the plot area. 当您不希望最高数据值出现在绘图区域的边缘时,这非常有用。 Defaults to 0.05. 默认为0.05。

You can also look at the endOnTick property, which would allow the axis to extend beyond 10, but not draw the next tick. 您还可以查看endOnTick属性,该属性允许轴延伸超过10,但不会绘制下一个刻度。

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

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