Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic WebChart and Layout (Read 2364 times)
awanvil
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 3
Joined: Aug 18th, 2006
WebChart and Layout
Aug 24th, 2006 at 12:11pm
Print Post  
My company recently purchased the FlowChart.Net product and will be using it in a web application to represent a visual model of our factory flow.

I wanted to know if there was a way to have the nodes auto flow in the container box. What I am doing is creating a base container box that each node will be placed in. Rather then try to hard code each node I am pulling the data from a db.

What is throw me is that each area that I will be showing has a different number of node. I am wanting the display the nodes from left to right. When I reach the end of the container i would like to wrap the rest of the nodes down several line.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: WebChart and Layout
Reply #1 - Aug 24th, 2006 at 12:54pm
Print Post  
Hi,

If the contained boxes are of the same size, you can use this method to arrange them in rows:

Code
Select All
private void arrangeBoxes(BoxCollection boxes, SizeF boxSize, RectangleF layoutArea, float offset)
{
  int boxesPerRow = (int)Math.Floor(layoutArea.Width / (boxSize.Width + offset));
  float x = layoutArea.X + offset;
  float y = layoutArea.Y + offset;
  for (int i = 0; i < boxes.Count; ++i)
  {
    boxes[i].Move(x, y);
    x += boxSize.Width + offset;

    if ((i + 1) % boxesPerRow == 0)
    {
     // wrap to next row
     x = layoutArea.X + offset;
     y += boxSize.Height + offset;
    }
  }
}
 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
awanvil
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 3
Joined: Aug 18th, 2006
Re: WebChart and Layout
Reply #2 - Aug 24th, 2006 at 3:53pm
Print Post  
Thanks that was exactly what i was looking for. After getting this to work and it brought up another question.

I have added arrows to each node, I do have one question is there a way to control the flow of the arrow. When the node is that last one on a row the arrow will cross several node to connect to the one . Is there a way to alow wrap the arrow in a more linear format. I might be asking too much.

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: WebChart and Layout
Reply #3 - Aug 25th, 2006 at 4:34am
Print Post  
You could either explicitly set the coordinates of the arrow control points, or use the auto-routing feature as shown below:

Code
Select All
private void arrangeBoxes(BoxCollection boxes, SizeF boxSize, RectangleF layoutArea, float offset)
{
  fc.RoutingOptions.GridSize = offset / 5;
  fc.RoutingOptions.TurnCost = 10;
  fc.RoutingOptions.LengthCost = 50;
  fc.RoutingOptions.NodeVicinityCost = 10;

  int boxesPerRow = (int)Math.Floor(layoutArea.Width / (boxSize.Width + offset));
  float x = layoutArea.X + offset;
  float y = layoutArea.Y + offset;

  for (int i = 0; i < boxes.Count; ++i)
  {
    boxes[i].Move(x, y);
    x += boxSize.Width + offset;

    if (i % boxesPerRow == 0 && boxes[i].IncomingArrows.Count > 0)
    {
     // this arrow comes from the last box of the previous row
     boxes[i].IncomingArrows[0].Style = ArrowStyle.Cascading;
     boxes[i].IncomingArrows[0].Route();
    }

    if ((i + 1) % boxesPerRow == 0)
    {
     // wrap to next row
     x = layoutArea.X + offset;
     y += boxSize.Height + offset;
    }
  }
}
 



Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint