remove vertical plotlines - Javascript highcharts

Javascript examples for highcharts:Line Chart

Description

remove vertical plotlines

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.7.2/jquery.min.js"></script> 
      <script type="text/javascript">
    $(window).load(function(){/*from   w  ww  .j a  v a2  s . c  o m*/
$(function() {
   $('#container').highcharts('StockChart', {
       chart: {
            id: 'chart',
            events: {
                click: function(event) {
                    var label=prompt('Label for Vertical Line');
                    if(label!=null && label != '')
                    {
                        var chart ='';
                        var chart = this.xAxis[0];
                        chart.addPlotLine({
                            value: event.xAxis[0].value,
                            color: '#'+(Math.random()*0xEEEEEE<<0).toString(16),
                            width: 2,
                            id: 'vertLine_'+label,
                            zIndex: 9999,
                            events: {
                                click: function(e) {
                                    this.axis.removePlotLine(this.id);
                                }
                            },
                            label : {
                                text : label
                            }
                        });
                    }
                }
            },
      },
       rangeSelector: {
          selected: 1
       },
       series: [{
           name: 'USD to EUR',
           data: usdeur
       }]
   });
});
    });

      </script> 
   </head> 
   <body> 
      <div id="container" style="height: 400px; min-width: 600px"></div> 
      <script src="https://code.highcharts.com/stock/highstock.js"></script> 
      <script src="https://code.highcharts.com/stock/modules/exporting.js"></script> 
      <script type="text/javascript" src="https://www.highcharts.com/samples/data/usdeur.js"></script>  
   </body>
</html>

Related Tutorials