Skip to content

Commit c7c9698

Browse files
Folding improvements
1 parent 07fc995 commit c7c9698

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "iknow-entity-browser",
3-
"version": "0.2.0",
3+
"version": "0.2.1",
44
"description": "Visualizer for iKnow entities",
55
"main": "gulpfile.babel.js",
66
"scripts": {

src/static/js/graph/index.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,6 @@ export function update (reset = false) {
174174
edges: flattenEdges(g)
175175
};
176176

177-
if (reset) {
178-
// link = link.data([]);
179-
// link.exit().remove();
180-
// node = node.data([]);
181-
// node.exit().remove();
182-
}
183-
184177
link = links.selectAll("line").data(graph.edges, (d) => d.target.id);
185178
link.exit().remove();
186179
let linkEnter = link.enter().append("line")
@@ -197,10 +190,14 @@ export function update (reset = false) {
197190
let nodeEnter = node.enter().append("g")
198191
.attr("class", d => `node ${ d.type || "unknown" }`)
199192
.call(dragger)
200-
.on("dblclick", (d) => {
193+
.on("dblclick", function (d) {
201194
d3.event.stopPropagation();
202195
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);
204201
update();
205202
}
206203
})

src/static/js/model/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ function fold (tree) {
1414
}
1515
let rest = tree.children.splice(MAX_CHILDREN);
1616
tree.children.push({
17-
label: "...",
17+
label: `${ rest.length } more`,
1818
type: "folder",
1919
_children: rest,
20+
children: [],
2021
radius: 10,
2122
entities: [],
2223
id: Math.random()

0 commit comments

Comments
 (0)