const data = {
labels: [
new Date(86400000), // Day 1
new Date(2 * 86400000), // Day 2
new Date(3 * 86400000), // Day 3
new Date(4 * 86400000), // Day 4
new Date(6 * 86400000), // Day 6
new Date(7 * 86400000), // Day 7
new Date(13 * 86400000), // Day 13
],
datasets: [
{
label: "My First dataset",
data: [1, 3, 4, 5, 6, 7, 8],
},
],
};
let ctx = document.querySelector("canvas").getContext("2d");
let chart = new Chart(ctx, {
type: "line",
data: data,
options: {
scales: {
x: {
type: "time",
}
},
},
});
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected] /cdn-cgi/l/email-protection"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected] /cdn-cgi/l/email-protection"></script>
<title>repl.it</title>
</head>
<body>
<canvas></canvas>
<script src="new.ts"></script>
</body>
</html>