Set up range selector - Javascript highcharts

Javascript examples for highcharts:Chart Range

Description

Set up range selector

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://code.jquery.com/jquery-1.9.1.js"></script> 
      <script type="text/javascript">
$(function() {/*from ww  w  .ja v a 2s  . c o  m*/
  $.getJSON('https://www.highcharts.com/samples/data/jsonp.php?filename=large-dataset.json&callback=?', function(data) {
    // Create a timer
    var start = +new Date();
    // Create the chart
    $('#container').highcharts('StockChart', {
      exporting: {
        enabled: false
      },
      rangeSelector: {
        inputPosition: {
          x: 0
        },
        buttons: [{
          type: 'day',
          count: 3,
          text: '3d'
        }, {
          type: 'week',
          count: 1,
          text: '1w'
        }, {
          type: 'month',
          count: 1,
          text: '1m'
        }, {
          type: 'month',
          count: 6,
          text: '6m'
        }, {
          type: 'year',
          count: 1,
          text: '1y'
        }, {
          type: 'all',
          text: 'All'
        }],
        selected: 3
      },
      yAxis: {
        title: {
          text: 'Temperature (?C)'
        },
        opposite: false
      },
      series: [{
        name: 'Temperature',
        data: data.data,
        pointStart: data.pointStart,
        pointInterval: data.pointInterval,
        tooltip: {
          valueDecimals: 1,
          valueSuffix: '?C'
        }
      }]
    });
  });
});

      </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: 400px; min-width: 310px"></div>  
   </body>
</html>

Related Tutorials