I’m using a pie/doughbut chart and lets say I have 3 pieces of data I want to show in my chart: ['value 1', 'value 2', 'value 3']
. I want to make sure each value always has the same label and color for consistency. So, if all 3 values are greater than 0 I can just pass labels and colors like:
{
type: 'doughnut',
data: {
labels: ['label 1', 'label 2', 'label 3'],
datasets: [
{
data: ['value 1', 'value 2', 'value 3'],
backgroundColor: ['color 1', 'color 2', 'color 3'],
hoverOffset: 4,
},
],
},
options: {
radius: 80,
plugins: {
legend: false,
},
},
}
and everything works fine. However, if value 2
is 0 then value 3
will be given the label label 2
and color color 2
. I’m looking for a way to pass my data to ensure my values always have the same label and color. I’ve tried the object examples from the docs and neither render a chart even when directly copy and pasted.