File tree Expand file tree Collapse file tree 3 files changed +25
-7
lines changed Expand file tree Collapse file tree 3 files changed +25
-7
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " iknow-entity-browser" ,
3
- "version" : " 0.5.0 " ,
3
+ "version" : " 0.5.1 " ,
4
4
"description" : " Visualizer for iKnow entities" ,
5
5
"main" : " gulpfile.babel.js" ,
6
6
"scripts" : {
Original file line number Diff line number Diff line change 15
15
< i id ="undoButton " class ="ui icon-undo "> </ i >
16
16
< i id ="redoButton " class ="ui icon-redo "> </ i >
17
17
</ div >
18
- < svg id ="graph "> </ svg >
18
+ < svg id ="graph ">
19
+ < defs >
20
+ < marker id ="svgLineArrow-related " markerWidth ="10 " markerHeight ="10 " refX ="7 " refY ="3 " orient ="auto " markerUnits ="strokeWidth ">
21
+ < path d ="M0,0 L0,6 L9,3 z " fill ="#ffb840 "/>
22
+ </ marker >
23
+ < marker id ="svgLineArrow-similar " markerWidth ="10 " markerHeight ="10 " refX ="7 " refY ="3 " orient ="auto " markerUnits ="strokeWidth ">
24
+ < path d ="M0,0 L0,6 L9,3 z " fill ="#7ca1ff "/>
25
+ </ marker >
26
+ < marker id ="svgLineArrow-other " markerWidth ="10 " markerHeight ="10 " refX ="7 " refY ="3 " orient ="auto " markerUnits ="strokeWidth ">
27
+ < path d ="M0,0 L0,6 L9,3 z " fill ="#f00 "/>
28
+ </ marker >
29
+ </ defs >
30
+ </ svg >
19
31
< div id ="table ">
20
32
< i id ="tableToggle " class ="ui icon-list "> </ i >
21
33
< div id ="rightTopIcons ">
Original file line number Diff line number Diff line change @@ -66,14 +66,19 @@ function newSimulation () {
66
66
. on ( "tick" , ticked ) ;
67
67
}
68
68
69
+ const ARROW_FWD = 2 ;
70
+
69
71
function ticked ( ) {
70
72
if ( ! link )
71
73
return ;
72
74
link
73
- . attr ( "x1" , d => d . source . x )
74
- . attr ( "y1" , d => d . source . y )
75
- . attr ( "x2" , d => d . target . x )
76
- . attr ( "y2" , d => d . target . y ) ;
75
+ . attr ( "x1" , d => {
76
+ d . dir = Math . atan2 ( d . target . y - d . source . y , d . target . x - d . source . x ) ;
77
+ return d . source . x + Math . cos ( d . dir ) * d . source . radius ;
78
+ } )
79
+ . attr ( "y1" , d => d . source . y + Math . sin ( d . dir ) * d . source . radius )
80
+ . attr ( "x2" , d => d . target . x - Math . cos ( d . dir ) * ( d . target . radius + ARROW_FWD ) )
81
+ . attr ( "y2" , d => d . target . y - Math . sin ( d . dir ) * ( d . target . radius + ARROW_FWD ) ) ;
77
82
node
78
83
. attr ( "transform" , ( d ) => `translate(${ d . x } ,${ d . y } )` )
79
84
}
@@ -206,7 +211,8 @@ export function update (g = lastGraph, reset = false) {
206
211
: d . type === "related"
207
212
? "related"
208
213
: "other"
209
- ) ;
214
+ )
215
+ . attr ( "marker-end" , d => `url(#svgLineArrow-${ d . type } )` ) ;
210
216
link = linkEnter . merge ( link ) ;
211
217
212
218
node = nodes . selectAll ( ".node" ) . data ( graph . nodes , function ( d ) { return this . _id || d . id ; } ) ;
You can’t perform that action at this time.
0 commit comments