min, max threshold in highcharts

15,911

A better way to approach this problem is to add two plot lines on the chart indicating the minimum and maximum values allowed.

Let's say you would like to apply this to the yAxis and set a minimum of 100 and a maximum of 500, you can like so:

var min = 100;
var max = 500;
yAxis: {
                min: min - 100,
                max: max + 100,
                plotLines: [{
                    id: 'limit-min',
                    color: '#FF0000',
                    dashStyle: 'ShortDash',
                    width: 2,
                    value: min,
                    zIndex: 0
                }, {
                    id: 'limit-max',
                    color: '#FF0000',
                    dashStyle: 'ShortDash',
                    width: 2,
                    value: max,
                    zIndex: 0
                }]
            }

The reason for adding and subtracting 100 to the max and min values is because we'd like the plot lines to be visible on the chart.

Hope that helps.

Share:
15,911
Author by

cypronmaya

Updated on June 08, 2022

Comments