I have a set of data that looks like this:
{
sf_zoo : {
giraffes: 10,
lions: 5,
},
la_zoo : {
giraffes: 5,
lions: null,
}
}
I want this data to produce a bar chart similar to this one, but with 3 legends instead of the 2:
Codepen: https://codepen.io/bleah1/pen/KKGNqVW?editors=1010
In the codepen example, I added a value of 2 to la_zoo.lions
just so the bar can be displayed.
The issue is that I can’t figure out how to display a third legend that should be gray and read “No data”.
I want a bar chart that has two grouped bars, that can be colored red, blue or gray and 3 legends that correspond to those 3 colors: red, blue and gray.
I’ve tried using the colorbar
prop of data[type=bar].marker
but I can’t separate the colorbar into 3 distinct colors: https://codepen.io/bleah1/pen/MWPbomO?editors=1010
I’ve also tried adding a dummy trace, but this only adds a third bar to each trace and hides it: https://codepen.io/bleah1/pen/yLRVXoP?editors=1010