Quantcast
Channel: GoJS - Northwoods Software
Viewing all articles
Browse latest Browse all 7069

How to resize nodes dynamically in Incremental Tree

$
0
0

@phreq wrote:

I have created an Incremental Tree in this way:

myDiagram.nodeTemplate =
  $(go.Node, "Spot",
   {
    selectionObjectName: "PANEL",
    isTreeExpanded: true,
    isTreeLeaf: true
   },
   // the node's outer shape, which will surround the text
   $(go.Panel, "Horizontal",
   { name: "PANEL" },
   $(go.Shape, "Circle",
   { fill: "whitesmoke", stroke: "black" },
    new go.Binding("fill", "color", function (dist) {
    return go.Brush.randomColor();//blues[dist];
    })),
    $(go.TextBlock,
    { font: "6pt sans-serif" },
     new go.Binding("text", "text"))
     ),
     // the expand/collapse button, at the top-right corner
     $("TreeExpanderButton",
     {
      width: 20, height: 20,
      alignment: go.Spot.TopRight,
      alignmentFocus: go.Spot.Center
      },
    { visible: true })  // end TreeExpanderButton
    );  // end Node

And adding the data in it as:

item = {}
item["key"] = 1;
item["text"] = "Test1";
item["cnt"] = 50;
item["color"] = go.Brush.randomColor();
item["parent"] = 0;
item["share"] = 0;
nodeDataArray.push(item);
myDiagram.model = new go.TreeModel(nodeDataArray);

It is making the tree as:

However, I want to change the shape of all these nodes based on the share value. This could be percentage of any default value. So how can I change the size of all the nodes after inserting all the nodes in it. Also, can anyone tell me, how to place this text on the nodes and not outside of it, I want all the nodes to have a default size at the start, then resize all of them based on the share. The text could flow outside of the shape.

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 7069

Trending Articles