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,
Here is my Deneb code:
{
"data": {"name": "dataset"},
"layer": [
{
"mark": {
"type": "bar",
"opacity": 0.3
},
"encoding": {
"x": {"field": "b"},
"tooltip": [
{"field": "a"},
{"field": "b"},
{"field": "b__highlight", "title": "Highlighted"}
]
}
},
{
"mark": {
"type": "bar",
"tooltip": true
},
"encoding": {
"x": {
"field": "b__highlight"
},
"tooltip": [
{"field": "a"},
{"field": "b"},
{"field": "b__highlight", "title": "Highlighted"}
],
"opacity": {
"condition": {
"test": {
"field": "__selected__",
"equal": "off"
},
"value": 0
},
"value": 1
}
}
}
],
"encoding": {
"y": {
"field": "a",
"type": "nominal"
},
"x": {
"type": "quantitative",
"axis": {"title": "b"}
}
}
}
There are two layers. Each layer has its own tooltip definition.
What I'd like is to have the ability to dynamically change the definition of the tooltip in the 2d layer.
For example, if "b_highlightStatus" = "on" then the definition should be as following:
"tooltip": [
{"field": "a"},
{"field": "b"},
{"field": "b__highlight", "title": "Highlighted"}
]
... and if "b_highlightStatus" <> "on" then the definition should read as:
"tooltip": [
{"field": "a"},
{"field": "b"}
]
I tried to use exp & params but could not succeed.
I would be grateful for a short example of how to solve the issue.
Thanks
Solved! Go to Solution.
the code I was looking for looks like the following
{
"data": {"name": "dataset"},
"layer": [
{
"mark": {
"type": "bar",
"opacity": 0.3,
"tooltip": {
"expr": "datum.b__highlight==null? {'a':datum['a'],'b':datum.b}:{'a':datum.a,'b':datum.b,'Highlighted':datum.b__highlight}"
}
},
"encoding": {"x": {"field": "b"}}
},
{
"mark": {
"type": "bar",
"tooltip": {
"expr": "datum.b__highlightStatus=='on'? {'a':datum.a,'b':datum.b,'Highlighted':datum.b__highlight}:{'a':datum.a,'b':datum.b}"
}
},
"encoding": {
"x": {"field": "b__highlight"},
"opacity": {
"condition": {
"test": {
"field": "__selected__",
"equal": "off"
},
"value": 0
},
"value": 1
}
}
}
],
"encoding": {
"y": {
"field": "a",
"type": "nominal"
},
"x": {
"type": "quantitative",
"axis": {"title": "b"}
}
}
}
Hey @Sergiy ,
please prepare a pbix that contains sample data, but still represents your data model (tables, relationships, calculated columns, and measures). Upload the pbix to OneDrive, Google Drive, or Dropbox, and share the link.
Regards,
Tom
Hi @TomMartens .
I uploaded a sample file:
The code is a bit different, but the idea is the same.
There are two layers. Each layer has its own tooltip definition.
What I'd like is to have the ability to dynamically change the definition of the tooltip in the 2d layer.
For example, if "b_highlightStatus" = "on" then the definition should be as following:
"tooltip": [
{"field": "a"},
{"field": "b"},
{"field": "b__highlight", "title": "Highlighted"}
]
... and if "b_highlightStatus" <> "on" then the definition should read as:
"tooltip": [
{"field": "a"},
{"field": "b"}
]
the code I was looking for looks like the following
{
"data": {"name": "dataset"},
"layer": [
{
"mark": {
"type": "bar",
"opacity": 0.3,
"tooltip": {
"expr": "datum.b__highlight==null? {'a':datum['a'],'b':datum.b}:{'a':datum.a,'b':datum.b,'Highlighted':datum.b__highlight}"
}
},
"encoding": {"x": {"field": "b"}}
},
{
"mark": {
"type": "bar",
"tooltip": {
"expr": "datum.b__highlightStatus=='on'? {'a':datum.a,'b':datum.b,'Highlighted':datum.b__highlight}:{'a':datum.a,'b':datum.b}"
}
},
"encoding": {
"x": {"field": "b__highlight"},
"opacity": {
"condition": {
"test": {
"field": "__selected__",
"equal": "off"
},
"value": 0
},
"value": 1
}
}
}
],
"encoding": {
"y": {
"field": "a",
"type": "nominal"
},
"x": {
"type": "quantitative",
"axis": {"title": "b"}
}
}
}
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 |
---|---|
108 | |
105 | |
87 | |
74 | |
66 |
User | Count |
---|---|
124 | |
113 | |
96 | |
80 | |
72 |