Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi,
I am trying to get the Text color of the my Text Mark to be white when the value is over a 1000.
My vega-lite code is below and is not returning the color change, any help in what i am missing is appreciated.
{
"data": {"name": "dataset"},
"layer": [
{
"mark": "rect",
"encoding": {
"x": {"field": "Category",
"type": "nominal"
},
"y": {"field": "Sales", "type": "ordinal",
"bin":{"maxbins":10}},
"color": {"aggregate": "count", "field": "CustomerID"},
"tooltip": [
{"field": "Category", "type": "ordinal"},
{"aggregate": "count","field": "Metric", "type":"quantitative"}
]
}
},
{
"mark": {
"type": "text",
"dy":60,
"dx":-50
},
"encoding": {
"x": {"field": "Category",
"type": "nominal"
},
"y": {"field": "Sales", "type": "ordinal",
"bin":{"maxbins":10}},
"text": {"aggregate": "count","field": "CustomerID", "type": "quantitative"},
"color": {
"condition": {
"test": "datum['CustomerID'] < 1000",
"value": "white"},
"value": "black"
}
}
}
],
"config": {
"axis": {"grid": true, "tickBand": "extent"}
}
}
I believe you need an aggregated value in the condition
Proud to be a Super User!
@DW868990 I believe your encoding needs to be in your "mark" settings like this example from vega-lite documentation:
"mark": "text",
"encoding": {
"text": {"field": "num_cars", "type": "quantitative"},
"color": {
"condition": {"test": "datum['num_cars'] < 40", "value": "black"},
"value": "white"
}
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
113 | |
97 | |
85 | |
70 | |
61 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |