Setting Flag on Click Event for Candlestick Chart - Javascript highcharts

Javascript examples for highcharts:Chart Event

Description

Setting Flag on Click Event for Candlestick Chart

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  a  2s .c o  m
$(function() {
   $.getJSON('https://www.highcharts.com/samples/data/jsonp.php?filename=aapl-ohlc.json&callback=?', function(data) {
      // create the chart
      $('#container').highcharts('StockChart', {
            plotOptions: {
                series: {
                    cursor: 'pointer',
                    point: {
                        events: {
                            click: function () {
  console.log('Date: ' + Highcharts.dateFormat('%Y-%m-%d',this.x) +  'value: ' + this.y + ', close: ' + this.close + ' open: ' + this.open + ' high: ' + this.high + ' low: ' + this.low);
                            }
                        }
                    }
                }
            },
         tooltip:{
               formatter:function(){
                   return "open: " + this.points[0].point.open + ' close: ' + this.points[0].point.close + ' high: ' + this.points[0].point.high + ' low:' + this.points[0].point.low;
                }
            },
         rangeSelector : {
            selected : 1
         },
         title : {
            text : 'AAPL Stock Price'
         },
         series : [{
            type : 'candlestick',
            name : 'AAPL Stock Price',
            data : data,
            dataGrouping : {
               units : [
                  ['week', // unit name
                  [1] // allowed multiples
               ], [
                  'month',
                  [1, 2, 3, 4, 6]]
               ]
            }
         }]
      });
   });
});
    });

      </script> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/stock/highstock.js"></script> 
      <script src="https://code.highcharts.com/stock/modules/exporting.js"></script> 
      <div id="container" style="height: 500px; min-width: 500px"></div>  
   </body>
</html>

Related Tutorials