Here is a sample pbix file: https://www.dropbox.com/scl/fi/l7qs306bklj0fc2lnr0tq/deneb_tooltip.pbix?rlkey=rx2pk9mopvwqhp7bq1fp08zz5&dl=0
The code of the visual specifies 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 don't know how to change the tooltip definition dynamically depending on highlightStatus value. How can this be solved?
{
"data": {"name": "dataset"},
"layer": [
{
"mark": {
"type": "bar",
"opacity": 0.3
},
"encoding": {"x": {"field": "b"}}
},
{
"mark": {
"type": "bar",
"tooltip": {
"expr": "datum.__selected__=='off'? {'a':datum.a,'b':datum.b}:{'a':datum.a,'b':datum.b,'Highlighted':datum.b__highlight}"
}
},
"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"}
}
}
}