Highcharts Demo

author(s): Torstein Hønsi

by Black Label

HTML

<script src="https://code.highcharts.com/stock/highstock.js"></script>

<div id="container"></div>

CSS

#container {
  min-width: 310px;
  max-width: 800px;
  height: 400px;
  margin: 0 auto
}

JavaScript

const dataset = {
  "xData": [
    "2020-10-01T19:30:00.000Z",
    "2020-10-02T19:30:00.000Z",
    "2020-10-03T19:30:00.000Z",
    "2020-10-04T19:30:00.000Z",
    "2020-10-05T19:30:00.000Z"
  ],
  data: [1, 2, 3, 4, 5]
};

Highcharts.chart('container', {
  chart: {
    marginLeft: 40
  },
  title: {
    text: ''
  },
  xAxis: {
    categories: dataset.xData.map(date => {
      return Highcharts.dateFormat('%Y-%m-%d', new Date(date).getTime());
    })
  },
  yAxis: {
    title: {
      text: null
    }
  },
  series: [{
    data: dataset.data,
  }]
});