Mark a point and draw plot lines in Multi Series line chart - Javascript highcharts

Javascript examples for highcharts:Line Chart

Description

Mark a point and draw plot lines in Multi Series line chart

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Highcharts Demo</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/highcharts.js"></script> 
      <div id="container" style="height: 400px"></div> 
      <script type="text/javascript">
Highcharts.chart('container', {
chart: {//  ww w.  j  av  a 2s  .c  o  m
        events: {
            load: function () {
                  console.log(this.chart); // This will get tou the chart reference where in you can find the coordinates of the point from where you want to draw the line
    var x1 = this.series[0].data[this.series[0].data.length - 1].plotX + this.plotLeft;
var y1 = this.series[0].data[this.series[0].data.length - 1].plotY + this.plotTop;
                var label = this.renderer.path(['M', x1,y1,'L', 550, y1])//M 75 223.5 L 593 223.5
            .attr({
                  'stroke-dasharray': '2,2',
                'stroke-width': 2,
                stroke: 'red'
            })
            .add();
            var label = this.renderer.path(['M', 550, this.plotTop + this.plotHeight,'L', 550, y1])//M 75 223.5 L 593 223.5
            .attr({
                  'stroke-dasharray': '2,2',
                'stroke-width': 2,
                stroke: 'red'
            })
            .add();
            }
        }
    },
    xAxis: {
        plotLines: [{
            color: 'red',
            width: 2,
            value: Date.UTC(2010, 0, 4)
        }],
        tickInterval: 24 * 3600 * 1000, // one day
        type: 'datetime'
    },
    series: [{
        data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4],
        pointStart: Date.UTC(2010, 0, 1),
        pointInterval: 24 * 3600 * 1000
    }, {
        data: [39.9, 91.5, 196.4, 159.2, 164.0, 180.0, 188.6, 187.5, 246.4],
        pointStart: Date.UTC(2010, 0, 1),
        pointInterval: 24 * 3600 * 1000
    }]
});

      </script>  
   </body>
</html>

Related Tutorials