crosshair with labels on axes for line chart - Javascript highcharts

Javascript examples for highcharts:Crosshair Chart

Description

crosshair with labels on axes for line chart

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Highcharts Stock Demo</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 
      <script type="text/javascript">
$(function () {/*from w  w w .  j  ava  2  s  . co m*/
    $.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback=?', function (data) {
        $('#container').highcharts({
            chart: {
                marginRight: 50
            },
            rangeSelector: {
                selected: 1
            },
            title: {
                text: 'AAPL Stock Price'
            },
            xAxis: {
                type: 'datetime',
                crosshair: {
                    label: {
                        enabled: true,
                        padding: 8
                    }
                }
            },
            yAxis: {
                opposite: true,
                crosshair: {
                    label: {
                        enabled: true,
                        format: '{value:.2f}'
                    }
                },
                labels: {
                    align: 'left',
                    format: '{value:.2f}',
                    y: 6,
                    x: 2
                }
            },
            series: [{
                name: 'AAPL',
                data: data,
                tooltip: {
                    valueDecimals: 2
                }
            }]
        });
    });
});

      </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="http://www.highcharts.com/samples/data/usdeur.js"></script>  
   </body>
</html>

Related Tutorials