I have a chart using chartjs. There are 31 days shown there, but due to the length of chart, the dates are deformed like this
I want the dates to show in a proper way, not like this.
How to manipulate the date, in that way that Oct is shown in the upper part and the 6th date is shown below.
Have you got any ideas? The code looks like this.
const ctx = document.getElementById('myChart').getContext('2d');
const myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: data.map(x => moment(x.date).format("MMM Do")),
datasets: [{
data: data.map(x => x.premium),
backgroundColor: '#ffec87',
borderColor: "#ffec87",
borderWidth: 2,
borderStyle: 'dotted'
}]
},
options: {
scales: {
xAxis: { grid: { display: false } },
yAxis: { grid: { borderDash: [3, 5] } }
}
}
});