Accepted answer

You can compare the plot line value to the actual axis extremes and change min and max properties if necessary. For example:

  min: yAxis.min > limits.min ? limits.min : null,
  max: yAxis.max < limits.max ? limits.max : null,
  plotLines: [{
    value: limits.max,
    width: 2,
    color: 'orange'
  }, {
    value: limits.min,
    width: 2,
    color: 'blue'

Live demo:

Related Query

More Query from same tag