Controlling the color scale in Vega-Lite API { pretty please? :) }

Example notebook here. There you can select a portion of the grey selector chart to zoom in timewise on the colorful display chart. The legend on the right will only display entries for data actually in the display table. You can drag the selection right and left in the selector chart, and as you do, the legend changes what’s being shown becuase the display chart’s data changes. This is good.

What I wish I could control, though, is the color-to-activity mapping. Right now, the first item in the legend is always blue, and the second always orange and the third always be red, and so on.

I would like to be able to unchangingly have A0000 be blue and A0001 be orange and A0002 be red, and so on. Without this, it gets confusing to track what’s going on as I pan through time.

An attempt to use a custom scale is in that notebook; it makes the legend fail to function as it was (listing everything rather than just the set in view).

Any ideas?

This is one possible approach: Controlling the color scale in Vega-Lite API / Mario Delgado / Observable

1 Like

Hello @MarioDelgadoSr! Sorry for the long delay. I tink your approach is dead on… sort the list! Thank you for sharing.

1 Like