1👍
✅
Because in your config you specify a new axis and since you dont specify a placement it makes it a y axis, removing the axis
part will solve your issue
var canvas = document.getElementById('chart');
function genMockData() {
return {
x: moment().add(moment.duration(Math.random() * 10, 'hours')).format('YYYY-MM-DD HH:mm:ss'),
y: Math.random() * 100
}
}
new Chart(canvas, {
type: 'line',
data: {
labels: [],
datasets: [{
data: [genMockData(), genMockData(), genMockData()]
}, {
data: [genMockData(), genMockData(), genMockData()]
}]
},
options: {
scales: {
x: {
type: 'time'
}
}
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-moment@0.1.1"></script>
<canvas id="chart"></canvas>
Source:stackexchange.com