Hi @CasperSteve
To answer your question, yes, you can use dataset colours instead of hard-coded colours. Here’s a Vega-Lite solution:
The scale-null key:value pair in the color block of the encoding block is what makes this work.
Here’s the code:
{
"data": {"name": "dataset"},
"columns": 2,
"hconcat": [
{
"name": "COLUMN_1",
"transform": [
{
"filter": "datum['Capacity_type_Rank'] < 10"
}
],
"mark": {
"type": "bar",
"height": {"band": 0.9},
"x": 20,
"stroke": "black",
"strokeWidth": 0.5
},
"encoding": {
"y": {
"field": "Capacity_type",
"type": "nominal",
"sort": {
"op": "sum",
"field": "Capacity_type_Rank",
"order": "ascending"
},
"axis": {
"title": null,
"orient": "right",
"labelAlign": "left",
"domain": false,
"ticks": false
}
},
"color": {
"field": "Capacity_type_Hex_color_code",
"type": "nominal",
"scale": null
}
}
},
{
"name": "COLUMN_2",
"transform": [
{
"filter": "datum['Capacity_type_Rank'] >= 10"
}
],
"mark": {
"type": "bar",
"height": {"band": 0.9},
"x": 20,
"stroke": "black",
"strokeWidth": 0.5
},
"encoding": {
"y": {
"field": "Capacity_type",
"type": "nominal",
"sort": {
"op": "sum",
"field": "Capacity_type_Rank",
"order": "ascending"
},
"axis": {
"title": null,
"orient": "right",
"labelAlign": "left",
"domain": false,
"ticks": false
}
},
"color": {
"field": "Capacity_type_Hex_color_code",
"type": "nominal",
"scale": null
}
}
}
]
}
Hope it helps.
Greg
eDNA Forum - Deneb Legend (Vega-Lite).pbix (1.5 MB)