File tree Expand file tree Collapse file tree 3 files changed +9
-11
lines changed Expand file tree Collapse file tree 3 files changed +9
-11
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " iknow-entity-browser" ,
3
- "version" : " 0.2.0 " ,
3
+ "version" : " 0.2.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 @@ -174,13 +174,6 @@ export function update (reset = false) {
174
174
edges : flattenEdges ( g )
175
175
} ;
176
176
177
- if ( reset ) {
178
- // link = link.data([]);
179
- // link.exit().remove();
180
- // node = node.data([]);
181
- // node.exit().remove();
182
- }
183
-
184
177
link = links . selectAll ( "line" ) . data ( graph . edges , ( d ) => d . target . id ) ;
185
178
link . exit ( ) . remove ( ) ;
186
179
let linkEnter = link . enter ( ) . append ( "line" )
@@ -197,10 +190,14 @@ export function update (reset = false) {
197
190
let nodeEnter = node . enter ( ) . append ( "g" )
198
191
. attr ( "class" , d => `node ${ d . type || "unknown" } ` )
199
192
. call ( dragger )
200
- . on ( "dblclick" , ( d ) => {
193
+ . on ( "dblclick" , function ( d ) {
201
194
d3 . event . stopPropagation ( ) ;
202
195
if ( d . type === "folder" && d . _children && d . _children . length ) {
203
- d . children = d . _children ;
196
+ let next = d . _children . splice ( 0 , 20 ) ,
197
+ left = parseInt ( d . label ) - 20 ;
198
+ d . children = d . children . concat ( next ) ;
199
+ d . label = left > 0 ? `${ left } more` : `Others` ;
200
+ d3 . select ( this ) . select ( "text" ) . text ( d . label ) ;
204
201
update ( ) ;
205
202
}
206
203
} )
Original file line number Diff line number Diff line change @@ -14,9 +14,10 @@ function fold (tree) {
14
14
}
15
15
let rest = tree . children . splice ( MAX_CHILDREN ) ;
16
16
tree . children . push ( {
17
- label : "..." ,
17
+ label : ` ${ rest . length } more` ,
18
18
type : "folder" ,
19
19
_children : rest ,
20
+ children : [ ] ,
20
21
radius : 10 ,
21
22
entities : [ ] ,
22
23
id : Math . random ( )
You can’t perform that action at this time.
0 commit comments