Range Column Chart with Date Time over axisY - CanvasJS JavaScript Charts

Range Column Chart with Date Time over axisY - CanvasJS JavaScript Charts

by canvasjs

HTML

<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<br/><!-- Just so that JSFiddle's Result label doesn't overlap the Chart -->

<div id="chartContainer" style="height: 360px; width: 100%;"></div>

JavaScript

var chart = new CanvasJS.Chart("chartContainer", {
  title: {
    text: "Machine Operating Time"
  },
  axisY: {
    minimum: (new Date(2016, 0, 25, 17, 30)).getTime(),            
    interval: (12 * 60 * 60 * 1000),
    labelFormatter: function(e){
      return CanvasJS.formatDate(e.value, "DD-MMM h:mm TT");
    }
  },
  toolTip:{
    contentFormatter: function ( e ) {
      return "<strong>Machine " + e.entries[0].dataPoint.label + "</strong></br> Start Time: " +  CanvasJS.formatDate(e.entries[0].dataPoint.y[0], "DD-MMM h:mm TT") + "</br> Stop Time: " +  CanvasJS.formatDate(e.entries[0].dataPoint.y[1], "DD-MMM h:mm TT");  
    }},
  data: [{
      type: "rangeColumn",
      dataPoints: [
        { label: "A", y: [(new Date(2016, 0, 25, 18, 30)).getTime(), (new Date(2016, 0, 26, 11, 00)).getTime()] },
        { label: "B", y: [(new Date(2016, 0, 26, 12, 00)).getTime(), (new Date(2016, 0, 27, 14, 00)).getTime()] },
        { label: "C", y: [(new Date(2016, 0, 27, 3, 30)).getTime(), (new Date(2016, 0, 27, 14, 00)).getTime()] },
        { label: "D", y: [(new Date(2016, 0, 27, 12, 00)).getTime(), (new Date(2016, 0, 28, 14, 00)).getTime()] }  
      ]
 	}]                      
});
chart.render();