Javascript 如何在 highcharts 中获得 y 轴的最大值?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12301236/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 07:39:07  来源:igfitidea点击:

How can I get the max value of a y axis at highcharts?

javascriptjqueryhighcharts

提问by kamaci

How can I get the max value of a y axis at highcharts?

如何在 highcharts 中获得 y 轴的最大值?

i.e. http://jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts.com/tree/master/samples/highcharts/demo/line-basic/here max value is 30. If you disable New York and Tokyo it is 20and so on.

http://jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts.com/tree/master/samples/highcharts/demo/line-basic/这里的最大值是30。如果禁用纽约和东京,则为20,依此类推。

Any ideas?

有任何想法吗?

回答by Ricardo Alvaro Lohmann

Assuming that chartis your chart var.
chart.yAxis[0].max;

假设这chart是您的图表变量。
chart.yAxis[0].max;

demo

演示

Update

更新

@Anagio told that it's possible to get it the following way.
chart.yAxis[0].getExtremes

@Anagio 说可以通过以下方式获得它。
chart.yAxis[0].getExtremes

This way you can get the data values and the tick values.
The data values are the values from your series, while the tick values are the values from chart lines.

通过这种方式,您可以获得数据值和刻度值。
数据值是您系列中的值,而刻度值是图表线中的值。

Reference

参考

回答by Halvor Holsten Strand

This information is directly accessible from a Axisobject. For example:

此信息可直接从Axis对象访问。例如:

var chart = $('#container').highcharts();
var axisMax = chart.yAxis[0].max; // Max of the axis
var dataMax = chart.yAxis[0].dataMax; // Max of the data

As mentioned you can use Axis.getExtremes(API) , but the same data is also available as:

如前所述,您可以使用Axis.getExtremes( API) ,但也可以使用相同的数据:

  • Axis.min: Min of the axis
  • Axis.max: Max of the axis
  • Axis.dataMin: Min of the data
  • Axis.dataMax: Max of the data
  • Axis.min: 轴的最小值
  • Axis.max: 轴的最大值
  • Axis.dataMin: 数据的最小值
  • Axis.dataMax: 数据的最大值

And even some historic data if the extremes of the axis has changed:

如果轴的极值发生了变化,甚至还有一些历史数据:

  • Axis.oldMin: The previous min of the axis
  • Axis.oldMax: The previous max of the axis
  • Axis.oldMin: 轴的前一个最小值
  • Axis.oldMax: 轴的前一个最大值