Using Chartjs, I have the following databaset and options
# dataset
public lineChartData: ChartConfiguration["data"]["datasets"] = [
{
label: "Attempts",
tension: 0.3,
pointRadius: 2,
borderColor: "#5e72e4",
borderWidth: 2,
backgroundColor: "",
data: [
{label: '2024-01-21', value: 10},
{label: '2024-01-22', value: 5},
{label: '2024-01-23', value: 8},
],
fill: true
}
];
# options
scales: {
y: {
beginAtZero: true,
},
x: {
ticks: {
display: true,
callback: (value, index) => {
console.log('value...: ', value); // Value is same as index 0,1,2,3
return value;
}
},
},
},
parsing: {
xAxisKey: 'label',
yAxisKey: 'value'
}
I want to display only the day of the date on the x-axis, hence want to customize it. But the callback method always gives the index value for the value param and adding a callback is also changing the x-axis label to display only numeric value instead of the actual label.