JavaScript
var chart = new CanvasJS.Chart("chartContainer", {
title:{
text: "Simple Date-Time Chart"
},
axisX:{
labelFormatter: function (e) {
return CanvasJS.formatDate( e.label, "DD/MM/YYYY HH:mm:ss");
},
},
toolTip: {
contentFormatter: function (e) {
var content = " ";
for (var i = 0; i < e.entries.length; i++) {
content += "<span style='color:" + e.chart.selectedColorSet[i] + ";'>" + CanvasJS.formatDate(e.entries[i].dataPoint.label, "DD/MM/YYYY HH:mm:ss") + "</span>" + ": " + e.entries[i].dataPoint.y;
content += "<br/>";
}
return content;
}
},
data: [
{
type: "area",
dataPoints: [//array
{ label: new Date(2015, 01, 1, 11, 30, 0 ), y: 26},
{ label: new Date(2015, 01, 2, 11, 30, 0 ), y: 38},
{ label: new Date(2015, 01, 3, 11, 30, 0 ), y: 43},
{ label: new Date(2015, 01, 4, 11, 30, 0 ), y: 29},
{ label: new Date(2015, 01, 5, 11, 30, 0 ), y: 41},
{ label: new Date(2015, 01, 6, 11, 30, 0 ), y: 54},
{ label: new Date(2015, 01, 7, 11, 30, 0 ), y: 66},
{ label: new Date(2015, 01, 8, 11, 30, 0 ), y: 60},
{ label: new Date(2015, 01, 9, 11, 30, 0 ), y: 53},
{ label: new Date(2015, 01, 10, 11, 30, 0 ), y: 60}
]
}
]
});
chart.render();