I can't seem to get Chart.js to work with dates. I have tried quite a few different methods:
let examChart = document.getElementById("examChart").getContext("2d");
let examLineChart = new Chart(examChart, {
type: "line",
data: [
{ t: new Date("2015-3-15 13:3"), y: 12 },
{ t: new Date("2015-3-25 13:2"), y: 21 },
{ t: new Date("2015-4-25 14:12"), y: 32 }
],
options: {
label: "placeholder"
}
});
And:
let examChart = document.getElementById("examChart").getContext("2d");
let examLineChart = new Chart(examChart, {
type: "line",
data: [
{ t: "2015-3-15 13:3", y: 12 },
{ t: "2015-3-25 13:2", y: 21 },
{ t: "2015-4-25 14:12", y: 32 }
],
options: {
label: "placeholder"
}
});
And:
let examChart = document.getElementById("examChart").getContext("2d");
let examLineChart = new Chart(examChart, {
type: "line",
data: [
{ t: "Sun Mar 15 2015 12:03:45 GMT+0000 (GMT Standard Time)", y: 12 },
{ t: "Wed Mar 25 2015 12:02:15 GMT+0000 (GMT Standard Time)", y: 21 },
{ t: "Sat Apr 25 2015 13:12:30 GMT+0100 (GMT Daylight Time)", y: 32 }
],
options: {
label: "placeholder"
}
});
To cover just a few of my attempts, I just can't seem to get how to set dates properly even after reading the documentation (http://www.chartjs.org/docs/latest/axes/cartesian/time.html) (they don't actually give an example)
The HTML being used:
<div class="container">
<canvas id="examChart"></canvas>
</div>
I just have no idea, although I imagine this is a rather simple problem, any help would be greatly appreciated.