Miguel Flores
Miguel Flores

Reputation: 147

Max & Min highchart line

I'm trying to graphic some values, I have this part, then I want to add some max and min line, I could do this creating another series and adding the min/max value that I want, the problem here is that my value series is an array of n elements so I want to know if I could create the min/max series for example just doing data: [2] and put the line in all the width of my chart. Something like this:

enter image description here

If there is no way to do this, just if is possible doing: data[2, 2, 2,.... n] is possible to show only the first and the last point and hide the rest of them?

Here is my working code

Upvotes: 0

Views: 2187

Answers (1)

jlbriggs
jlbriggs

Reputation: 17800

You can use plotLines for this.

Example:

yAxis: {
  softMax: max,
  min: 0,
  plotLines: [{
    value: min,
    width: 1,
    color: 'rgba(204,0,0,0.75)'
  },{
    value: max,
    width: 1,
    color: 'rgba(204,0,0,0.75)'
  }]
}

Updated pen:

Alternatively, if you really want it to be a series, you can grab the min and max x values, and provide your data as arrays of [x,y] pairs. Something like:

series: [{
  name: 'Actual Series'
  ...
},{
  name: 'Max',
  data: [[xMin,yMax],[xMax,yMax]]
},{
  name: 'Min',
  data: [[xMin,yMin],[xMax,yMin]]
}]

Upvotes: 2

Related Questions