( sceneGroup, nodeData: render.RenderNodeInfo[], sceneElement )
| 85 | * @return selection of the created nodeGroups |
| 86 | */ |
| 87 | export function buildGroup( |
| 88 | sceneGroup, |
| 89 | nodeData: render.RenderNodeInfo[], |
| 90 | sceneElement |
| 91 | ) { |
| 92 | let container = tf_graph_common.selectOrCreateChild( |
| 93 | sceneGroup, |
| 94 | 'g', |
| 95 | Class.Node.CONTAINER |
| 96 | ); |
| 97 | // Select all children and join with data. |
| 98 | // (Note that all children of g.nodes are g.node) |
| 99 | let nodeGroups = (container as any) |
| 100 | .selectAll(function () { |
| 101 | return this.childNodes; |
| 102 | }) |
| 103 | .data(nodeData, (d) => { |
| 104 | // make sure that we don't have to swap shape type |
| 105 | return d.node.name + ':' + d.node.type; |
| 106 | }); |
| 107 | // ENTER |
| 108 | nodeGroups |
| 109 | .enter() |
| 110 | .append('g') |
| 111 | .attr('data-name', (d) => { |
| 112 | return d.node.name; |
| 113 | }) |
| 114 | .each(function (d) { |
| 115 | let nodeGroup = d3.select(this); |
| 116 | // index node group for quick stylizing |
| 117 | sceneElement.addNodeGroup(d.node.name, nodeGroup); |
| 118 | }) |
| 119 | .merge(nodeGroups) |
| 120 | // ENTER + UPDATE |
| 121 | .attr('class', (d) => { |
| 122 | return Class.Node.GROUP + ' ' + nodeClass(d); |
| 123 | }) |
| 124 | .each(function (d) { |
| 125 | let nodeGroup = d3.select(this); |
| 126 | // Add g.in-annotations (always add -- to keep layer order |
| 127 | // consistent.) |
| 128 | let inAnnotationBox = tf_graph_common.selectOrCreateChild( |
| 129 | nodeGroup, |
| 130 | 'g', |
| 131 | Class.Annotation.INBOX |
| 132 | ); |
| 133 | buildGroupForAnnotation( |
| 134 | inAnnotationBox, |
| 135 | d.inAnnotations, |
| 136 | d, |
| 137 | sceneElement |
| 138 | ); |
| 139 | // Add g.out-annotations (always add -- to keep layer order |
| 140 | // consistent.) |
| 141 | let outAnnotationBox = tf_graph_common.selectOrCreateChild( |
| 142 | nodeGroup, |
| 143 | 'g', |
| 144 | Class.Annotation.OUTBOX |
no test coverage detected
searching dependent graphs…