Hello, I now have a requirement that a node has more than one dependent child node, the parent node has location information, but the number of child nodes is determined by configuration; that is, the current JSON data has the LOC attribute of the parent node and the parent node, but want the child node to automatically generate and follow the parent node, how to implement It is better now
I don’t understand your requirements. Are you just asking for a way to make sure that when the user drags a parent node that all of the children move along with it?
If so, you can set DraggingTool.dragsTree to true. For example, during Diagram initialization:
$(go.Diagram, . . .,
{
"draggingTool.dragsTree": true,
. . .
Some samples demonstrate this, such as Incremental Tree
That’s not what I meant.
For example, I have a node, and he has his own child nodes, or they are composite relationships or itemarrays.
The data of the main node are as follows
nodeDataArray = [
{ ‘category’: ‘configuration’, ‘key’: 5, ‘source’: ‘加工中心’, ‘text’: ‘加工中心’, ‘loc’: ‘484.203125 577’ },
{ ‘category’: ‘general’, ‘text’: ‘说明’, ‘figure’: ‘Diamond’, ‘fill’: ‘#7EC0EE’, ‘key’: 8 },
{ ‘category’: ‘general’, ‘text’: ‘说明’, ‘figure’: ‘Diamond’, ‘fill’: ‘#7EC0EE’, ‘key’: 9 },
{ ‘category’: ‘general’, ‘text’: ‘说明’, ‘figure’: ‘Diamond’, ‘fill’: ‘#7EC0EE’, ‘key’: 10 }
]
linkDataArray = [
{‘from’: 5, ‘to’: 8},{‘from’: 5, ‘to’: 9},{‘from’: 5, ‘to’: 10}
]
My configuration node has location information, and the other nodes are affiliated, so how do I layout them to look like a whole?
I still don’t know what you mean – perhaps showing some sketches or screenshots would have helped.
Maybe you want node 5 to be a Group and have nodes 8, 9, and 10 be members of the group. Each Group can have its own Layout, as the value of Group.layout, so it can arrange its members however you like. Then the user can move the whole group. Or you can call Group.move programmatically.
Expect similar effects as follows
Operational steps, first of all, generate a primary node, by configuring attribute information to the primary node, the primary node has several attached nodes. The data configured is similar to the one mentioned last time. Finally, render according to the configured information.
The problem is, the primary node has a positioning coordinate, the subsidiary node does not have a coordinate, how to render it looks like a combination or a whole
Is the square gray node always going to be the “root” of a tree? Are you using TreeLayout?
If so, you can set TreeLayout.arrangement to go.TreeLayout.ArrangementFixedRoots
. TreeLayout | GoJS API
That way those “root” nodes stay wherever they are and the subtree is positioned relative to that “root” node.