@@ -60,9 +60,9 @@ function onSelectNode(node: GraphNodeDatum | null): void {
6060}
6161
6262function groupColors(group : string ): string {
63- if (group === LaunchActionType .ARG ) return ' limegreen '
64- if (group === LaunchActionType .NODE ) return ' dodgerblue '
65- if (group === LaunchActionType .INCLUDE ) return ' chocolate '
63+ if (group === LaunchActionType .ARG ) return ' #f6f294 '
64+ if (group === LaunchActionType .NODE ) return ' #00bd7e '
65+ if (group === LaunchActionType .INCLUDE ) return ' #7fafe3 '
6666 return ' gray'
6767}
6868
@@ -71,6 +71,9 @@ function buildModelElement(): SVGElement {
7171 // const color = d3.scaleOrdinal(d3.schemeCategory10)
7272 const color = groupColors
7373
74+ const nodeStrokeColor = (d : GraphNodeDatum ): string => color (d .group )
75+ const nodeFillColor = (d : GraphNodeDatum ): string => (d .dark ? ' var(--color-background)' : ' #666' )
76+
7477 // The force simulation mutates links and nodes, so create a copy
7578 // so that re-evaluating this cell produces the same result.
7679 const links = props .model .links .map ((d ) => ({ ... d }))
@@ -118,13 +121,14 @@ function buildModelElement(): SVGElement {
118121 .attr (' orient' , ' auto' )
119122 .append (' path' )
120123 .attr (' d' , ' M0,-3L6,0L0,3' )
121- .style (' stroke' , ' #999' )
122- .style (' fill' , ' #999' )
124+ .style (' stroke' , ' var(--color-text)' )
125+ .style (' stroke-opacity' , 0.6 )
126+ .style (' fill' , ' var(--color-text)' )
123127
124128 // Add a line for each link
125129 const link = svg
126130 .append (' g' )
127- .attr (' stroke' , ' #999 ' )
131+ .attr (' stroke' , ' var(--color-text) ' )
128132 .attr (' stroke-opacity' , 0.6 )
129133 .selectAll (' line' )
130134 .data (links )
@@ -135,14 +139,14 @@ function buildModelElement(): SVGElement {
135139 // Add a circle for each node
136140 const node = svg
137141 .append (' g' )
138- .attr (' stroke-width' , 1.5 )
142+ .attr (' stroke-width' , 2 )
139143 .selectAll <SVGCircleElement , GraphNodeDatum >(' circle' )
140144 .data (nodes )
141145 .join (' circle' )
142146 .attr (' r' , (d ) => (d .level || 0 ) * 5 + 10 )
143- .attr (' stroke' , ( d ) => (d .dark ? ' #999 ' : ' #fff ' ))
147+ .attr (' stroke' , nodeStrokeColor ) // (d.dark ? '#333 ' : color(d.group ))
144148 .attr (' stroke-dasharray' , (d ) => (! d .condition ? ' ' : ' 2 1' ))
145- .attr (' fill' , ( d ) => color ( d . group ) )
149+ .attr (' fill' , nodeFillColor )
146150
147151 node .append (' title' ).text ((d ) => d .name || d .id )
148152
@@ -163,12 +167,10 @@ function buildModelElement(): SVGElement {
163167 if (k === i ) {
164168 return
165169 }
166- d3 .select <SVGCircleElement , GraphNodeDatum >(node .nodes ()[k ]).attr (' fill' , (d ) =>
167- color (d .group ),
168- )
170+ d3 .select <SVGCircleElement , GraphNodeDatum >(node .nodes ()[k ]).attr (' fill' , nodeFillColor (prev ))
169171 }
170172 onSelectNode (datum )
171- d3 .select (el ).attr (' fill' , ' #c9c9c9 ' )
173+ d3 .select (el ).attr (' fill' , nodeStrokeColor ( datum ) )
172174 }
173175
174176 node .on (' click' , (e /* , d*/ ) => {
@@ -185,9 +187,7 @@ function buildModelElement(): SVGElement {
185187 const prev = selectedNode .value
186188 if (prev != null ) {
187189 const k = prev .index !
188- d3 .select <SVGCircleElement , GraphNodeDatum >(node .nodes ()[k ]).attr (' fill' , (d ) =>
189- color (d .group ),
190- )
190+ d3 .select <SVGCircleElement , GraphNodeDatum >(node .nodes ()[k ]).attr (' fill' , nodeFillColor (prev ))
191191 onSelectNode (null )
192192 }
193193 })
0 commit comments