DateTime over axisY workaround - CanvasJS JavaScript Charts
DateTime over axisY workaround - CanvasJS JavaScript Charts
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: "Test"
},
axisY: {
labelFormatter: function(e){
return CanvasJS.formatDate(e.value, "MMM D - hh:mm");
}
},
toolTip:{
contentFormatter: function ( e ) {
return "<strong>" + e.entries[0].dataPoint.label + "</strong></br> Start: " + CanvasJS.formatDate(e.entries[0].dataPoint.y[0], "MMM D - hh:mm") + "</br>End : " + CanvasJS.formatDate(e.entries[0].dataPoint.y[1], "MMM D - hh:mm");
}},
axisX:{
title: "",
tickLength: 0,
margin: 0,
lineThickness: 0,
valueFormatString: " " //comment this to show numeric values
},
data: [
{
type: "rangeBar",
dataPoints: [
{ label: "ONLINE", x:1, y: [1609145063000, 1609281110000], color: "rgba(83, 223, 128, .8)"},
{ label: "ONLINE", x:1, y: [1609381110000, 1609481110000], color: "rgba(83, 223, 128, .8)"},
{ label: "ONLINE", x:1, y: [1609681110000, 1609981110000], color: "rgba(83, 223, 128, .8)"}
]
}
]
});
chart.render();