dtc
dtc

Reputation: 1849

Highcharts Straight-line value

I already have a basic line graph for highcharts. What I wanna do is add just a straight line across (with a constant y = some value) straight through the range of the x's.

Is there a way to do that or do I have to put data points everywhere even if its the same y value everytime?

Upvotes: 1

Views: 6098

Answers (2)

wergeld
wergeld

Reputation: 14442

What you are looking for is called a plotLine. This will let you specify a yValue and it just goes straight across regardless of zoom level on xAxis. You would add it like this:

yAxis: {
  plotLines: [{
    color: 'blue',
    width: 2,
    value: 150,
    dashStyle: 'longdashdot'               
  }]
}

Upvotes: 11

datadamnation
datadamnation

Reputation: 1892

You can use HighCharts.Renderer.path() to draw a line on the chart. See http://api.highcharts.com/highcharts#Renderer.path()

Upvotes: 1

Related Questions