【发布时间】:2018-01-03 11:57:44
【问题描述】:
我以这种方式创建了一个增量树:
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
并将其中的数据添加为:
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);
但是,我想根据份额值更改所有这些节点的形状。这可以是任何默认值的百分比。那么如何在插入所有节点后更改所有节点的大小。另外,谁能告诉我,如何将此文本放在节点上而不是在它之外,我希望所有节点在开始时都具有默认大小,然后根据共享调整所有节点的大小。文本可以在形状之外流动。
【问题讨论】:
标签: javascript gojs