A few implementation questions

Dec 23, 2009 at 4:49 AM

I'm working on a project that visualizes video game entities that fire outputs to other entities. NodeXL is working well for this, but I have a few questions...

1. How do I completely change the look of vertices? I already have a custom Vertex class and use SetValue for the basic fill color and such, but I'm looking to design a custom shape. Can this be done with XAML?

2. Some of my vertices have multiple edges that all extend to the same vertex. At the moment, these overlap and only one edge becomes visible. How can I split them apart?

3. My window consists of a grid, containing a menu in the first row and the NodeXL control in the second. When I zoom into the graph, it actually extends the control and covers the menu. How can I fix this?

4. My graphs can potentially contain a lot of information that needs to be readable without dragging vertices around to uncover others. I've started using the HarelKorenFastMultiscaleLayout class because it seems to produce the most readable graphs. However, because the graph is limited to the size of the control, vertices start to overlap and labels become hidden regardless of the layout. Can I somehow generate graphs that extend beyond the bounds of the control so they remain as readable as possible? Can scrollbars be enabled on the control for panning in this situation?

5. Can I use more than one label on an edge? I'd like to show a label at the beginning of an edge and a label at the end. Also, is it possible to enable labels on loop edges?

I realize this is probably a lot to ask, but I'm not very familiar with the library, so I don't know what is possible and what isn't. I appreciate any help you can give me!

Dec 23, 2009 at 6:51 AM
Edited Dec 23, 2009 at 6:55 AM

1.  I assume that you do not want to have to modify the NodeXL source code to add a custom shape.  In that case, you can make a vertex look like anything you want by displaying it as an image that you provide.  To do this, you need to programmatically set the ReservedMetadataKeys.PerVertexShape key on the vertex to VertexShape.Image, and set the ReservedMetadataKeys.PerVertexImage key on the vertex to your image.  The image must be a System.Windows.Media.ImageSource.  You can share the same image among multiple vertices.  You cannot do any of this via XAML.

2. You cannot separate duplicate edges, which are edges that connect the same vertex pair.  We've talked about adding a duplicate-edge routing feature, but it's a difficult problem and we haven't gotten to it.  In our own Excel 2007 template, we recommend that people merge duplicate edges (NodeXL, Data, Prepare Data, Merge Duplicate Edges) and then use NodeXL Visual Properties, Autofill Columns to fill the Edge Width column based on the resulting Edge Weight.  The result is that duplicate edges get replaced by a single wide edge.  Perhaps you could follow the same approach in your application?

3. Use something like the following to constrain the zoomed NodeXLControl's contents.  This is a two-column Grid with a TextBox in the left column and a NodeXLControl in the right column.  The DockPanel, which is above the NodeXLControl in the z-order, covers the zoomed contents.  (I bet there is a better way to do this; perhaps someone else knows.)

<Window x:Class="WpfApplication1.Window1"
    Title="Window1" Height="300" Width="300" xmlns:my="clr-namespace:Microsoft.NodeXL.Visualization.Wpf;assembly=Microsoft.NodeXL.Control.Wpf" Loaded="Window_Loaded">
    <Grid ShowGridLines="True">
            <RowDefinition />
            <ColumnDefinition />
            <ColumnDefinition />
        <my:NodeXLControl Grid.Column="1" Name="nodeXLControl1"  />
        <DockPanel Name="dockPanel1" Background="White">
            <TextBox Height="23" Name="textBox1" Width="120">TextBox</TextBox>

4. No, you can't generate graphs that extend beyond the bounds of the control, but you can make the control larger and create a scrollable viewport into the graph by using a System.Windows.Controls.ScrollViewer.  I haven't actually tried this.

5. No, you cannot have more than one label on an edge, and you cannot control the label position.  (We didn't have edge labels until just recently.)  You can, however, have an edge label that consists of multiple lines.  NodeXL currently ignores labels on self-loops because there is no room on the edge to draw them.

-- Tony