Highcharts Demo

author(s): Torstein Hønsi

HTML

<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://code.highcharts.com/stock/highstock.js"></script>
<script src="https://code.highcharts.com/stock/modules/exporting.js"></script>
<script src="https://code.highcharts.com/stock/modules/export-data.js"></script>


<div id="container" style="height: 400px; min-width: 310px"></div>

JavaScript

$.getJSON('https://cdn.rawgit.com/highcharts/highcharts/057b672172ccc6c08fe7dbb27fc17ebca3f5b770/samples/data/usdeur.json', function(data) {

  var startDate = new Date(data[data.length - 1][0]), // Get year of last data point
    minRate = 1,
    maxRate = 0,
    startPeriod,
    date,
    rate,
    index;

  startDate.setMonth(startDate.getMonth() - 3); // a quarter of a year before last data point
  startPeriod = Date.UTC(startDate.getFullYear(), startDate.getMonth(), startDate.getDate());

  for (index = data.length - 1; index >= 0; index = index - 1) {
    date = data[index][0]; // data[i][0] is date
    rate = data[index][1]; // data[i][1] is exchange rate
    if (date < startPeriod) {
      break; // stop measuring highs and lows
    }
    if (rate > maxRate) {
      maxRate = rate;
    }
    if (rate < minRate) {
      minRate = rate;
    }
  }

  // Create the chart
  Highcharts.stockChart('container', {

    rangeSelector: {
      selected: 1
    },

    title: {
      text: 'USD to EUR exchange rate'
    },
    plotOptions: {
      series: {
        dataGrouping: {
          enabled: false
        }
      }
    },
    series: [{
      name: 'GEOTIMB',
      data: [
        [1522540800000, 3.1],
        [1522541100000, 0.53],
        [1522541400000, 1.42],
        [1522541700000, 0.48],
        [1522542000000, 0.27],
        [1522542300000, 1.82],
        [1522542600000, 1.03],
        [1522542900000, 0.21],
        [1522543200000, 2.66],
        [1522543500000, 3.92],
        [1522543800000, 0.91],
        [1522544100000, 0.34],
        [1522544400000, 4.27],
        [1522544700000, 3.16],
        [1522545000000, 0.87],
        [1522545300000, 0.24],
        [1522545600000, 0.87],
        [1522545900000, 0.18],
        [1522546200000, 2.24],
        [1522546500000, 4.59],
        [1522546800000, 4.13],
        [1522547100000, 0.37],
        [1522547400000, 1.03],
        [1522547700000, 3.85],
        [1522548000000, 4.63],
        [1522548300000,...