Line Chart with Time over axisY - CanvasJS JavaScript Charts
Line Chart with 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", {
height: 500,
title: {
text: "Time over Axis Y"
},
axisY: {
minimum: (new Date(2016, 0, 25, 19, 00)).getTime(),
maximum: (new Date(2016, 0, 26, 18, 00)).getTime(),
labelFontSize: 13,
interval: ( 60 * 60 * 1000 ),
labelFormatter: function(e){
return CanvasJS.formatDate(e.value, "HH:mm");
}
},
toolTip:{
contentFormatter: function ( e ) {
return e.entries[0].dataPoint.label + "</strong></br> Time: " + CanvasJS.formatDate(e.entries[0].dataPoint.y[0], "HH:mm");
}},
data: [{
type: "line",
dataPoints: [
{ label: "A", y: (new Date(2016, 0, 25, 19, 30)).getTime() },
{ label: "B", y: (new Date(2016, 0, 26, 12, 30)).getTime() },
{ label: "C", y: (new Date(2016, 0, 26 , 17, 30)).getTime() },
]
}]
});
chart.render();