Drawing a vertical line on top of chart by specifying end coordinates - Javascript highcharts

Javascript examples for highcharts:Line Chart

Description

Drawing a vertical line on top of chart by specifying end coordinates

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> 
      <script type="text/javascript" src="https://code.highcharts.com/highcharts.js"></script> 
      <script type="text/javascript">
    window.onload=function(){//w ww.  j a v  a2 s .c  o m

var lineStartXposition = 120,
  lineStartYposition = 50,
  lineEndXposition = 120,
  lineEndYposition = 70;
$(function() {
  $('#container').highcharts({
    title: {
      text: 'REMISSION'
    },
    xAxis: {
      min: 0,
      max: 35,
      tickInterval: 5,
      title: {
        text: "Time"
      },
    },
    yAxis: {
      min: 0,
      max: 100,
      tickInterval: 20,
      title: {
        text: "Survival Probability(%)"
      }
    },
    series: [{
      data: [
        [1, 100],
        [6, 83],
        [7, 80],
        [9, 75],
        [12, 70],
        [15, 60],
        [20, 50],
        [28, 45]
      ],
      step: 'left',
      name: 'Group 1'
    }, {
      data: [
        [1, 100],
        [5, 75],
        [6, 70],
        [8, 66],
        [10, 61],
        [13, 50],
        [18, 40],
        [25, 32]
      ],
      step: 'left',
      name: 'Group 2'
    }]
  }, function(chart) {
    var lineStartXposition2 = lineStartXposition + chart.plotLeft + 10,
      lineStartYposition2 = lineStartYposition + chart.plotTop + 10,
      lineEndXposition2 = lineEndXposition + chart.plotLeft + 10,
      lineEndYposition2 = lineEndYposition + chart.plotTop + 10;
    chart.renderer.path(['M', lineStartXposition2, lineStartYposition2, 'L', lineEndXposition2, lineEndYposition2])
      .attr({
        'stroke-width': 2,
        stroke: 'red'
      })
      .add();
  });
});
    }

      </script> 
   </head> 
   <body> 
      <div id="container" style="height: 400px"></div>  
   </body>
</html>

Related Tutorials