I am trying to write code that will load an XML document, transform the data, and apply one of the pre-defined layouts provided with GoDiagram. The code runs without error (as far as I can tell), but I am still getting a blank diagram in my web page. Additional note - I have placed the GoView in a user control and I placed the user control in my web page.
Here is the code from my user control.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim conn As New SqlConnection(ConfigurationManager.ConnectionStrings("connUSCG_WPM").ConnectionString())
Dim cmnd As New SqlCommand("sp_GetOrgChartXML", conn)
cmnd.CommandType = CommandType.StoredProcedure
cmnd.Parameters.Add("@ID", SqlDbType.Int)
cmnd.Parameters("@ID").Value = mID
Try
conn.Open()
Dim xmlDoc As New XmlDocument()
xmlDoc.LoadXml(cmnd.ExecuteScalar())
If xmlDoc.HasChildNodes() Then
GoView1.EnableViewState = True
GoView1.Document.Clear()
GoView1.StartTransaction()
Dim r As New GoXmlReader()
r.AddTransformer(New XMLTransformBasicNode())
r.AddTransformer(New XMLTransformLink())
r.RootObject = GoView1.Document
r.Consume(xmlDoc)
GoView1.FinishTransaction("load xml source")
End If
GoView1.StartTransaction()
Dim layout As New GoLayoutLayeredDigraph()
layout.DirectionOption = GoLayoutDirection.Down
layout.Document = GoView1.Document
layout.PerformLayout()
GoView1.FinishTransaction("layered-digraph autolayout")
Catch
End Try
End Sub
The XMLTransformBasicNode, and XMLTransformLink classes are classes I have written based on the examples provided in the GoSamples. It is interesting that, if I place a break point in the constructor of either XMLTransformBasicNode.vb or XMLTransformLink.vb, the break point is hit…so I know that the constructors are called. However, if I put breakpoints in either XMLTransformBasicNode.ConsumeAttributes or XMLTransformLink.ConsumeAttributes, those subroutines are never called. So I think the problem is at the line “r.Consume(xmlDoc)” in the code above.
I apologize for the long message.
Thank you for any help you can provide.
Wow.
You are amazing.
The elements are named “Scene” and “Link” and I had “scene” and “link” in my transformer code. So, that was the problem.
Thank you for that.
So, now I can see my diagram.
I now have the issue that only one node is being displayed, when I know there are many more nodes than that. I believe I need to implement a ConsumeChild (what a terrible routine name! ) similar to this example from the sample projects:
Yes, that is what I have: a nested xml document…it is generated from a recursive SQL function in my database. I am having some trouble getting it to display the information correctly, however. It looks like it is essentially placing all the nodes on top of each other, and I am not sure why. I placed my ConsumeChild routines in XMLTransformBasicNode.vb and XMLTransformLink.vb and, it seems to be adding all the nodes.
Another question: If a node has multiple children, does it need to have a different port for each link to each of its children? Or, can a parent have one port from which it links to, for example, four children?
Are you generating a “tree” diagram? If so, your override of ConsumeChild should Add the resulting node to your document, not to the “parent” node. I guess you have separate elements, so your ConsumeChild doesn’t have to create the link and connect the nodes and then Add the link to the document. In fact, in this case, you probably don’t want to be using GoSubGraph at all. Look at the TreeApp sample for an example of what I mean.
Also, if you are producing a tree-structured diagram, you might find the GoLayoutTree algorithm better than GoLayoutLayeredDigraph, since GoLayoutTree has all kinds of features that are naturally specific to trees.
Alternatively, if you really do need to use GoSubGraph or GoSubGraphBase, then you need to recursively apply the layout to the contents of the GoSubGraph. This is documented in the Layout User Guide, and I think is demonstrated in SubGraphApp.
Yes, you can have any number of links connected at a single port.
I can use a tree diagram. I think that, in your samples, I saw it mentioned that I could specify the “orientation” of the tree…either parent to the left and children to the right, or parent on top and children below…is that correct?
I am implementing an org chart, so I would like the default layout to be:
PARENT
|
CHILD1
| |
GRANDCHILD1 GRANDCHILD2
etc.
But offer the user the ability to switch to a layout like:
PARENT
CHILD1
GRANDCHILD1
GRANDCHILD2
CHILD2
GRANDCHILD3
I currently have the diagram showing nodes with titles (YEAH!). They are in the “Parent to the right and children to the left” orientation, and I don’t have the links working yet but…this is real progress.