I understand that I can use "color": {"value": "#ff9900"}
to change the colours of the marks but is it possible to have different colours for different range of values? Can I use if
statements to achieve that and if so, could you tell me how or point me to a Notebook or tutorial that illustrates this please?
In Vega-Lite you can specify the color encoding just like any other, with a key accessor, a scale etc.
For example in https://observablehq.com/@mbostock/vega-lite-scatterplot
you could change the encoding definition to
encoding: {
color: {field: "Origin", type: "ordinal", scale: {range: ["black", "steelblue", "orange"]}},
x: {field: "Horsepower", type: "quantitative"},
y: {field: "Miles_per_Gallon", type: "quantitative"},
}
Iām sorry I donāt know enough about vega-lite for your other questions; Iāve add āvega liteā in their titles in the hope that it will attract other people who can help
Thanks, Philippe, for the edit.
Iām afraid thatās not what Iām looking for. Please allow me to clarify my questionā¦ Say my data was:
0: Object {caseId: "1", total: "10"} 1: Object {caseId: "2", total: "5"} 3: Object {caseId: "3", total: "9"} 4: Object {caseId: "4", total: "3"} 5: Object {caseId: "5", total: "2"}
And I wanted the mark to be blue where total <=5
and red where total > 5
, how or where do I specify this condition?
in the same notebook try
"color": {
"condition": {"test": "datum['Horsepower'] < 100", "value": "black"},
"value": "red"
},
It works! Thank you! Now Iāll just have to figure out the formatting so itāll work in my script.