Black Lives Matter. Please consider donating to Black Girls Code today.

Would like to force color in Legend

I change the color of my green/red bars (sometimes setting them to grey), but I’d like the Legend to always show the color versions. Here is my code:

 marker: {color: Object.keys(usePF).sort().map(function(iter) { return (shouldGreyOut) ? (pf==kPass ? "green" : "red") : "lightgrey"})},

This works fine visually everywhere except the Legend. It looks like Plotly uses the color of the first element for the Legend? I’d like to override the colors in the Legend.

There’s no easy way to do that at the moment unfortunately. See https://github.com/plotly/plotly.js/issues/1560 for workaround and the most up-to-date development info.