@@ -42,18 +42,12 @@ export default class Target{
4242 } ) ;
4343
4444 //add SVG container
45- var svg = d3 . select ( this . id ) . call ( zoom ) . append ( "svg:g" ) ;
46- svg . append ( "defs" ) . append ( "marker" )
47- . attr ( "id" , "endArrow" )
48- . attr ( "viewBox" , "0 -5 10 10" )
49- . attr ( "refX" , 6 )
50- . attr ( "markerWidth" , 6 )
51- . attr ( "markerHeight" , 6 )
52- . attr ( "orient" , "auto" )
53- . append ( "path" )
54- . attr ( "d" , "M0,-5L10,0L0,5" )
55- . attr ( "fill" , "#999" )
56- . attr ( "opacity" , "0.5" ) ;
45+ let svg = d3 . select ( this . id )
46+ . call ( zoom )
47+ . append ( "svg:g" ) ;
48+
49+ //def objects are not displayed until referenced
50+ let defs = svg . append ( "svg:defs" ) ;
5751
5852 let force = ( this . layout = d3 . layout . force ( ) )
5953 . charge ( - 400 )
@@ -84,18 +78,44 @@ export default class Target{
8478 . attr ( "r" , 7 ) //radius
8579 . call ( force . drag ) ;
8680
87- // Filter out links if the "show" flag is false
81+ // Filter out links if the "show" flag is false
8882 let linksEnter = svg . selectAll ( ".link" )
8983 . data ( graph . links . filter ( link => link . show ) )
9084 . enter ( ) ;
9185
86+ function marker ( isBlank ) {
87+
88+ let fill = isBlank ? "none" : "#999" ;
89+ let id = "arrow" + fill . replace ( "#" , "" ) ;
90+
91+ defs . append ( "svg:marker" )
92+ . attr ( "id" , id )
93+ . attr ( "viewBox" , "0 -5 10 10" )
94+ . attr ( "refX" , 6 )
95+ . attr ( "markerWidth" , 6 )
96+ . attr ( "markerHeight" , 6 )
97+ . attr ( "orient" , "auto" )
98+ . append ( "svg:path" )
99+ . attr ( "d" , "M0,-5L10,0L0,5" )
100+ . attr ( "stroke" , "#999" )
101+ . attr ( "fill" , fill ) ;
102+
103+ return "url(#" + id + ")" ;
104+ }
105+
92106 // Optional links will be rendered as dashed lines
107+ // Blank edges will be rendered with an unfilled arrow
93108 let links = linksEnter . append ( "path" )
94109 . attr ( "class" , ( l ) => {
95110 if ( l . optional ) {
96111 return "link dashed-link" ;
97112 }
98113 return "link"
114+ } )
115+ . attr ( "d" , "M0,-5L10,0L0,5" )
116+ . attr ( "marker-end" , ( l ) => {
117+ let isBlank = l [ "componentRoles" ] . length === 0 && l [ "componentIDs" ] . length === 0 ;
118+ return marker ( isBlank ) ;
99119 } ) ;
100120
101121 //place SBOL svg on links
0 commit comments