March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi,
I have created a tree visualisation in VEGA within the deneb visual, and i am just looking for a little bit of VEGA help as i am currently on the learning curve of from Vega-Lite to Vega.
Now basically what i am trying to achieve is to format the color or the dash of the links between nodes based on a field in my data, the field is called relationship.
For example when the relationship field is X, i need the link between nodes to either be dashed or red.
The snippet of VEGA below is the path mark that i used to create the links between nodes.
{
"type": "path",
"from": {"data": "links"},
"encode": {
"update": {
"path": {"field": "path"},
"stroke": {"value": "#ccc"}
}
}
},
Any help is very much appreciated.
@giammariam not sure if this is something you could lend any advice to, TIA.
Solved! Go to Solution.
Hi, @DW868990
Maybe you can try the following VEGA code:
{
"type": "path",
"from": {"data": "links"},
"encode": {
"update": {
"path": {"field": "path"},
"stroke": {
"condition": [
{"test": "datum.relationship == 'X'", "value": "red"},
{"test": "datum.relationship == 'Y'", "value": "blue"} // Example for another condition
],
"value": "#ccc" // Default color
},
"strokeDash": {
"condition": [
{"test": "datum.relationship == 'X'", "value": [5, 5]} // Example for dashed line
],
"value": null // Default to solid line
}
}
}
}
It is recommended that you read the official VEGA tutorial:
As you learn VEGA, we recommend that you read up on other excellent VEGA code:
Vega Data Visualization Examples - Power of Business Intelligence (powerofbi.org)
Explore examples and get inspired | Observable (observablehq.com)
How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Jianpeng Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @DW868990
Maybe you can try the following VEGA code:
{
"type": "path",
"from": {"data": "links"},
"encode": {
"update": {
"path": {"field": "path"},
"stroke": {
"condition": [
{"test": "datum.relationship == 'X'", "value": "red"},
{"test": "datum.relationship == 'Y'", "value": "blue"} // Example for another condition
],
"value": "#ccc" // Default color
},
"strokeDash": {
"condition": [
{"test": "datum.relationship == 'X'", "value": [5, 5]} // Example for dashed line
],
"value": null // Default to solid line
}
}
}
}
It is recommended that you read the official VEGA tutorial:
As you learn VEGA, we recommend that you read up on other excellent VEGA code:
Vega Data Visualization Examples - Power of Business Intelligence (powerofbi.org)
Explore examples and get inspired | Observable (observablehq.com)
How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Jianpeng Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
128 | |
90 | |
75 | |
56 | |
53 |
User | Count |
---|---|
200 | |
104 | |
101 | |
67 | |
55 |