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 Incomplete legend for multiple colored bars in one trace · Issue #1560 · plotly/plotly.js · GitHub for workaround and the most up-to-date development info.