Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
NishPatel
Resolver II
Resolver II

Vega Lite Parameter in Color Scale Type

Hi, Trying to implement dynamic color scale type using parameter but it's working. Tryed all different ways using "expr' and "param". When I hard code quantile or linear it works. Please help. Below is my code...

 

{
"height": 400,
"data": {"name": "dataset"},
"params": [
{
"name": "Button",
"value": "quantile",
"bind": {
"input": "radio",
"options": [
"quantile",
"linear"
]
}
},
{
"name": "selectDate",
"select": {
"type": "interval",
"encodings": ["x"]
}
}
],
"layer": [
{
"mark": {
"type": "bar",
"stroke": "black",
"offset": 250
},
"encoding": {
"x": {
"bin": {
"maxbins": 220,
"minstep": 1
},
"field": "in Euro",
"type": "quantitative",
"axis": {
"orient": "top",
"title": null,
"offset": 0
}
},
"y": {
"aggregate": "count",
"axis": null,
"scale": {"reverse": true}
},
"color": {
"value": "lightgray",
"legend": null,
"condition": {
"test": {
"param": "selectDate"
},
"field": "in Euro",
"type": "quantitative",
"scale": {
"scheme": "spectral",
"type": {
"expr": "Button === 'quantile' ? 'quantile' : 'linear'"
}
}
}
},
"tooltip": {
"field": "Region",
"type": "nominal"
}
}
}
]
}

5 REPLIES 5
lbendlin
Super User
Super User

please provide sample data and complete sample code for the Deneb visual.

Above is my complete code and this is my sample data set.

RegionRegionCodeVariablein EuroEuro pro Nutzfläche
Eisenstadt10101Gesamt4799.4519487575
Rust10201Gesamt3012.6954716930
Breitenbrunn10301Gesamt2024.6056413349
Donnerskirchen10302Gesamt2558.8933153308
Großhöflein10303Gesamt2274.9773632342
Hornstein10304Gesamt1617.311349884
Klingenbach10305Gesamt1057.198184837
Leithaprodersdorf10306Gesamt2769.8416921474
Mörbisch am See10307Gesamt2340.9301578313
Müllendorf10308Gesamt1122.2584371003
Neufeld an der Leitha10309Gesamt1297.191196725
Oggau am Neusiedler See10310Gesamt2115.89912175
Oslip10311Gesamt1672.8233621485
Purbach am Neusiedler See10312Gesamt2039.0431585239
Sankt Margarethen im Burgenland10313Gesamt2733.8140022317
Schützen am Gebirge10314Gesamt1691.3397062857
Siegendorf10315Gesamt1684.918396851
Steinbrunn10316Gesamt1209.040529595

Surprisingly "type"  does not allow expressions.

 

Type | Vega-Lite

 

@dm-p surely that is an oversight?  (or hopefully a misunderstanding on my part)

Whether it is an oversight or not, it is a design choice by the language authors - if you want this to be dynamic, I'd suggest creating an issue for Vega-Lite.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.