Directed Graph Markup Language ( DGML )
In this post, I'm going to talk about a couple ways of controlling how links are rendered in the VSTS 2010 Architecture product.
The Graph Element
At the root of every DGML document is the DirectedGraph element. The default namespace for this document, attributed to this element, is http://schemas.microsoft.com/vs/2009/dgml. There are a number of xml attributes that is supported for this element that you will be able to quickly discover through the intellisense functionality off the file, but I want to call out the Background attribute in particular.
The Background attribute allows you to set the color of the background of the graph surface itself, either by name of ARGB hex values as documented here.
For example, this snippet of DGML:
Results in this graph:
Amazing, but good to know nonetheless. :)
The Link Element
A DGML graph is fundamentally all about nodes and the links between those nodes. You'll notice in the markup above the Links element containing one Link element. You'll also notice that the rendering engine that reads this particular DGML is smart enough to understand that a link cannot exist without nodes to connect, so automatically creates a "From" node and a "To" node based on the values found in the Source and Target attributes on the Link element.
The Link element has a number of interesting attributes that are directly supported. I'll call out a few here.
In order to change the background color of a link arrowhead, set the Backround attribute to "Red". You'll get something like this:
In order to change the color of the entire link, set the Stroke attribute to your desired color. If you only specify Stroke and not Background, the arrowhead fill color will also be changed to the Stroke color value.
You can also change the thickness of the link itself by assigning a value to the StrokeThickness attribute, like so:
You can also make the link a dashed line by playing with values in the StrokeDashArray attribute. The comma delimited values are converted to doubles, and are taken in relation to the StrokeThickness value, which is 1 by default. For example, setting StrokeDashArray to 5 with a default thickness of 1 results in something like this:
You can make the dashed line much more involved by adding more values to the dash array, as specified here. Here's an example:
Just a quick taste on how to control link rendering. We'll start to build up more knowledge as we go. In a future post, I want to show the Node element, and specifically get into how grouping / nesting is supported. Stay tuned!