I have a dot layer (citta) and I want to style the dots based on the values I read in livello field.
Currently the colors are assigned automatically, but I have 4 categorical values (“Livello0”, “Livello1”, “Livello2” and “Livello3”) and I would like to assign distinct custom color to each one.
In the documentation I have read about channel and scale, but I’m not able to use them and reach my goal.
Is there some “hello world” Observable Plot example that I can use?
I don’t understand, however, why it must be inserted outside the reference layer.
And if I had two dot layers, with two distinctive styles to apply, how should I write the instruction to apply style “1” to layer “a” and style “2” to layer “b”?
The point of the “grammar of graphics” is that there is a unique meaning for each visual variable, in that case a single and shared scale for colors. If you need to specify a color scale for a specific mark, though, you can do so by giving explicit colors in the mark:
If you look at your complete code, you’ll notice that you’ve specified color twice. Your second color specification looks like so:
color: { legend: true, zero: true },
I guess that second specification comes from the template you started with. You’ve got to get rid of it, though, since it’s overriding the color specification that you want.