Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Braching out a chart based on the number of nodes (Read 2604 times)
itsky
YaBB Newbies
*
Offline



Posts: 6
Joined: Apr 1st, 2006
Braching out a chart based on the number of nodes
Jun 6th, 2006 at 2:01pm
Print Post  
I'm writing a web-based application using the FlowChart.dll binary.   The page is dymanically drawn and can show a wide range of child nodes.  Sometimes there can be 1000 or more objects to draw.  Currently, they all draw in one vertical line.  I would like to have it create a separate branch for each group of 250 child nodes:

Parent Node --->  ChildNode/ChildNode/... (up to 250)
|
|--->  ChildNode/ChildNode/... (up to 250)
|
|--->  ChildNode/ChildNode/.... (to to 250)
|
v
(up to ten groups).

Is there an easy way to do this?  I have tried changing the X coordinate for each group, but they all still draw in the same veritcal line.  Snipet of code:

Main function for adding child nodes:

Private Function addUndiscoveredClientChild(ByVal parentNode As MindFusion.FlowChartX.Box, ByVal Clients As ArrayList, ByVal parentGroup As MindFusion.FlowChartX.Group) As MindFusion.FlowChartX.BoxCollection

       btnVisio.Visible = True
       btnJPEG.Visible = True
       Dim bxCollection As New MindFusion.FlowChartX.BoxCollection
       'Response.Write("clientgroup: " & iGroupNumber & "<BR>")
       Dim iCount As Integer = 0

       For Each obj As Object In Clients
           iCount = iCount + 1
           Dim iGroup As Integer = 0
           Dim childNode As MindFusion.FlowChartX.Box
           If iCount > 0 And iCount <= 250 Then
               iGroup = 0
           End If
           If iCount > 250 And iCount <= 500 Then
               iGroup = 1
           End If
           childNode = fc.CreateBox(iGroup * 50, 0, 100, 50)
           parentGroup.AttachToCorner(childNode, 0)

           Dim link As MindFusion.FlowChartX.Arrow = fc.CreateArrow(parentNode, childNode)
           link.ArrowHead = MindFusion.FlowChartX.ArrowHead.BowArrow
           childNode.Image = System.Drawing.Image.FromFile(Server.MapPath("Images\client.jpg"))
           link.FrameColor = System.Drawing.Color.Yellow
           link.FillColor = System.Drawing.Color.LightGray
           childNode.Font = New System.Drawing.Font("Courier", 7)
           childNode.Tag = obj.ToString
           childNode.TextFormat.FormatFlags = StringFormatFlags.NoWrap
           childNode.TextFormat.LineAlignment = StringAlignment.Far
           childNode.Transparent = True
           childNode.Text = obj.ToString
           childNode.TextColor = System.Drawing.Color.SteelBlue
           'childNode.PicturePos = MindFusion.WebChart.ImageAlign.TopCenter
           childNode.ImageAlign = MindFusion.FlowChartX.ImageAlign.TopCenter
           'childNode.PicturePos = MindFusion.FlowChartX.ImageAlign.TopCenter
           rearrangeclient(parentNode, iGroup)
           bxCollection.Add(childNode)
       Next

       Response.Write("count: " & iCount)
       Return bxCollection
End Function

Code to rearrange the clients:

Private Sub rearrangeclient(ByVal Node As Node, ByVal iGroupNumber As Integer)
       If treeLayout Is Nothing Then
           treeLayout = New TreeLayout '(Node, TreeLayoutType.Cascading, False, TreeLayoutArrowType.Cascading2, TreeLayoutDirection.LeftToRight, 40, 15, True, 0, 90)
           treeLayout.ArrowStyle = TreeLayoutArrowType.Cascading2
           treeLayout.KeepGroupLayout = False
           treeLayout.KeepRootPosition = True
           treeLayout.Root = Node
           treeLayout.XGap = 10 + (iGroupNumber + 50)
           treeLayout.YGap = 50
           treeLayout.Type = TreeLayoutType.Cascading
           treeLayout.NodeDistance = 15
           treeLayout.LevelDistance = 40
           treeLayout.Direction = TreeLayoutDirection.LeftToRight
           treeLayout.Anchoring = Anchoring.Ignore
           treeLayout.ReversedArrows = False
           'treeLayout = New TreeLayout(Node, TreeLayoutType.Cascading, False, TreeLayoutArrowType.Cascading3, TreeLayoutDirection.TopToBottom, 110, 5, True, 10, 90)

       End If

       treeLayout.Arrange(fc)
    End Sub

Any suggestions would be greatly appreciated.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Braching out a chart based on the number of no
Reply #1 - Jun 6th, 2006 at 5:15pm
Print Post  
This might help:

[code]
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  Dim i As Integer

  ' create some test boxes
  For i = 0 To 1000
    fc.CreateBox(0, 0, 20, 20)
  Next

  ' this will be the parent box
  Dim parentBox As Box = fc.Boxes(0)

  ' create row groups for next boxes
  Dim numBoxes = fc.Boxes.Count
  Dim rowContainer As Box
  For i = 1 To numBoxes - 1
    If i Mod 250 = 1 Then
     rowContainer = fc.CreateBox(0, 0, 30 * 250, 20)

     ' only the row containers link to the parentBox
     fc.CreateArrow(parentBox, rowContainer)
     rowContainer.Transparent = True
    End If

    Dim aBox As Box = fc.Boxes(i)
    aBox.IgnoreLayout = True
    aBox.Move(((i - 1) Mod 250) * 30, 0)
    aBox.AttachTo(rowContainer, AttachToNode.TopLeft)

    If i Mod 250 <> 1 Then fc.CreateArrow(fc.Boxes(i - 1), aBox)
  Next

  ' create a tree from the parent box and the row containers
  Dim tl As New TreeLayout
  tl.Type = TreeLayoutType.Cascading
  tl.Direction = TreeLayoutDirection.LeftToRight
  tl.ArrowStyle = TreeLayoutArrowType.Cascading2
  tl.Root = parentBox
  tl.Arrange(fc)

  fc.FitDocToObjects(10)
End Sub
[/code]
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Braching out a chart based on the number of no
Reply #2 - Jun 6th, 2006 at 5:22pm
Print Post  
What that code does is create a container box for every group of 250 boxes and attach the boxes to the container. All containers are linked to the parent box, and none of the other boxes are linked to the parent. Then the tree layout treats only the row containers as children of the parent and produces something close to what you need.

The problem is that the tree layout cannot separate items from the same tree level into multiple levels, and all your boxes are on the same level, so you must do that explicitly as shown above.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Braching out a chart based on the number of no
Reply #3 - Jun 6th, 2006 at 5:28pm
Print Post  
the result looks like this

  
Back to top
 
IP Logged
 
itsky
YaBB Newbies
*
Offline



Posts: 6
Joined: Apr 1st, 2006
Re: Braching out a chart based on the number of no
Reply #4 - Jun 6th, 2006 at 5:38pm
Print Post  
Thanks, that is exactly what I'm looking to do.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint