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

Be 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

Reply
DW868990
Helper IV
Helper IV

VEGA - Formatting of links between nodes

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.

DW868990_0-1715784940163.png

 

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.

 

 

 




1 ACCEPTED SOLUTION
v-jianpeng-msft
Community Support
Community Support

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:

Tutorials | Vega

vjianpengmsft_0-1715832075023.png

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)

vjianpengmsft_1-1715832158112.png

Explore examples and get inspired | Observable (observablehq.com)

vjianpengmsft_2-1715832224337.png

 

 

 

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.

 

View solution in original post

1 REPLY 1
v-jianpeng-msft
Community Support
Community Support

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:

Tutorials | Vega

vjianpengmsft_0-1715832075023.png

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)

vjianpengmsft_1-1715832158112.png

Explore examples and get inspired | Observable (observablehq.com)

vjianpengmsft_2-1715832224337.png

 

 

 

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.

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.