Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

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 20 and so on.

Any ideas?

like image 561
kamaci Avatar asked Sep 06 '12 13:09

kamaci


2 Answers

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

demo

Update

@Anagio told that it's possible to get it the following way.
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

like image 177
Ricardo Alvaro Lohmann Avatar answered Oct 11 '22 14:10

Ricardo Alvaro Lohmann


This information is directly accessible from a Axis object. For example:

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.min: Min of the axis
  • Axis.max: Max of the axis
  • Axis.dataMin: Min of the data
  • Axis.dataMax: Max of the data

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
like image 34
Halvor Holsten Strand Avatar answered Oct 11 '22 14:10

Halvor Holsten Strand