I’ve got bar charts with multiple labels and zero data values for some labels.
I need to hide zero-values in chart and draw bars in the middle of current label value. How can i do it?
Here source code:
var chartDebugData = {
labels: ["2021-11-16", "2021-11-17", "2021-11-18"],
datasets: [
{
label: "Data1",
backgroundColor: "rgba(161, 198, 76, 0.5)",
borderColor: "rgba(161, 198, 76)",
data: [
66,
77,
0,
],
borderWidth: 2,
},
{
label: "Data2",
backgroundColor: "rgba(107, 228, 46, 0.5)",
borderColor: "rgba(107, 228, 46)",
data: [
55,
0,
82,
],
borderWidth: 2,
},
]
}
const canvasEl = document.getElementById("charts");
// Draw graph
new Chart(canvasEl, {
type: 'bar',
data: chartDebugData,
options: {
barValueSpacing: 5,
},
});
JSFiddle: https://jsfiddle.net/70n3h1r4/4/