No matter what I change in options, my chart labels never change.
My example data and the function:
aggs_date = {
'2022-01-20T08:00:00.000Z': 31,
'2022-01-20T09:00:00.000Z': 157,
'2022-01-20T10:00:00.000Z': 171,
'2022-01-20T11:00:00.000Z': 153,
'2022-01-20T12:00:00.000Z': 175,
'2022-01-20T13:00:00.000Z': 169,
'2022-01-20T14:00:00.000Z': 186,
}
var lineChart = new Chart(lineChartctx, {
type: 'line',
data: {
labels: Object.keys(aggs_date),
datasets: [{
label: 'News over Time',
data: Object.values(aggs_date),
fill: false,
borderColor: 'rgb(75, 192, 192)',
}],
},
options: {
scales: {
xAxes: [{
type: 'time',
time: {
displayFormats: {
unit: 'day',
}
}
}]
}
}
});
I have tried a lot in the xAxes options but nothing changes. My browser console also always gives me Invalid scale configuration for scale: xAxes.
for example this, because sometimes there are too many labels.
time: {
autoSkip: true,
maxTicksLimit: 10
}
Is it possible that chart js doesn't recognize the isodate format? Do I need to format the date beforehand? I thought chart js should be able to recognize a iso date.
I want to be able to limit the number of labels on the xaxes and also be able to format the output to for example only show the Date in YYYY-MM-DD format or YYYY-MM-DD HH::mm, depending if a time is available.