Highcharts Demo

author(s): Torstein Hønsi

by nehamahajan

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highcharts/10.3.2/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>

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

CSS

#container {
    height: 400px;
}

JavaScript

Highcharts.setOptions({
	global: {
  	useUTC: false
  }
});

Highcharts.chart('container', {

    xAxis: {
        type: 'datetime',
        labels: {
          formatter: function() {
          	console.log(this.value);
          	console.log(Highcharts.dateFormat('%l:%M %P', this.value));
            const midnight = (Highcharts.dateFormat('%l:%M %P', this.value) === '12:00 am');
            if (midnight) {
              return moment(this.value).format('D. MMM');
            }
            else {
              return moment(this.value).format('LT');
            }
          }
        },
    },

    series: [{
        data: [
        {x: 1669313611896, y: 0.05501},
        {x: 1669314172103, y: 0.10107},
        {x: 1669314732310, y: 0.10403},
        {x: 1669315292517, y: 0.05576},
        {x: 1669315852724, y: 0.1064},
        {x: 1669316412931, y: 0.07158},
        {x: 1669316973138, y: 0.0733},
        {x: 1669317533345, y: 0.1412},
        {x: 1669318093552, y: 0.07523},
        {x: 1669318653759, y: 0.10308},
        {x: 1669319213966, y: 0.05315},
        {x: 1669319774173, y: 0.07412},
        {x: 1669320334380, y: 0.20622},
        {x: 1669320894587, y: 0.06619},
        {x: 1669321454794, y: 0.1031},
        {x: 1669322015001, y: 0.10403},
        {x: 1669322575208, y: 0.05385},
        {x: 1669323135415, y: 0.10095},
        {x: 1669323695622, y: 0.10092},
        {x: 1669324255829, y: 0.05556},
        {x: 1669324816036, y: 0.10266},
        {x: 1669325376243, y: 0.072},
        {x: 1669325936450, y: 0.10251},
        {x: 1669326496657, y: 0.07138},
        {x: 1669327056864, y: 0.10264},
        {x: 1669327617071, y: 0.10097},
        {x: 1669328177278, y: 0.05469},
        {x: 1669328737485, y: 0.10107},
        {x: 1669329297693, y: 0.10432},
        {x: 1669329857900, y: 0.05613},
        {x: 1669330418107, y: 0.10241},
        {x: 1669330978314, y: 0.07447},
        {x: 1669331538521, y: 0.0699},
        {x: 1669332098728, y: 0.10166},
       ...