0👍
You can define data.labels
and make sure that data.datasets.data
has the same number of entries, null
for missing values.
let config = {
type: "bar",
data: {
labels: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "october", "November", "December"],
datasets: [{
label: "cost of goods sold",
data: [0, 20, 40, 50, null, null, null, null, null, null, null, null]
}]
}
};
new Chart('chart', config);
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.8.0/chart.min.js"></script>
<canvas id="chart" height="80"></canvas>
- Chartjs-Chart.js sum of the last 3h datavalues in a line chart
- Chartjs-Chart.js 2.0 – Tooltip is showing incomplete data on hover
Source:stackexchange.com