Skip to content

Commit 97ada71

Browse files
authored
Merge pull request #87 from Nhogs/develop
Develop
2 parents 0052d8e + 83ae3f3 commit 97ada71

15 files changed

+2631
-2487
lines changed

package-lock.json

Lines changed: 2485 additions & 2273 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "popoto",
3-
"version": "3.0.3",
3+
"version": "4.0.0",
44
"description": "Graph based search interface for Neo4j database.",
55
"keywords": [
66
"popoto",
@@ -34,7 +34,10 @@
3434
"jest": {
3535
"setupFiles": [
3636
"jest-canvas-mock"
37-
]
37+
],
38+
"moduleNameMapper": {
39+
"^d3$": "<rootDir>/node_modules/d3/dist/d3.min.js"
40+
}
3841
},
3942
"scripts": {
4043
"build": "rimraf dist && mkdir dist && json2module package.json > dist/package.js && node rollup.node && rollup -c --banner \"// Copyright (c) 2018 NHOGS Interactive.\" && npm run uglify",
@@ -43,20 +46,21 @@
4346
"uglify": "uglifyjs -b beautify=false,preamble=\"'// Copyright (c) 2018 NHOGS Interactive.'\" dist/popoto.js -c negate_iife=false -m -o dist/popoto.min.js && uglifycss css/popoto.css css/popoto-svg.css --output dist/popoto.min.css"
4447
},
4548
"dependencies": {
46-
"d3": "^5.15.0"
49+
"d3": "^7.6.1"
4750
},
4851
"devDependencies": {
4952
"babel-core": "^6.26.3",
50-
"babel-jest": "^27.0.6",
53+
"babel-jest": "^29.1.2",
5154
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
52-
"jest": "^27.0.6",
53-
"jest-canvas-mock": "^1.1.0",
55+
"jest": "^29.1.2",
56+
"jest-canvas-mock": "^2.4.0",
57+
"jest-environment-jsdom": "^29.1.2",
5458
"json2module": "^0.0.3",
5559
"rimraf": "^3.0.2",
56-
"rollup": "^2.55.1",
60+
"rollup": "^2.79.1",
5761
"rollup-plugin-copy": "^3.4.0",
5862
"rollup-plugin-node-resolve": "^5.2.0",
59-
"uglify-js": "^3.14.1",
63+
"uglify-js": "^3.17.3",
6064
"uglifycss": "^0.0.29"
6165
}
6266
}

src/graph/graph.js

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@ graph.getSVGHeight = function () {
262262
/**
263263
* Function to call on SVG zoom event to update the svg transform attribute.
264264
*/
265-
graph.rescale = function () {
266-
var transform = d3.event.transform;
265+
graph.rescale = function (event) {
266+
var transform = event.transform;
267267
if (isNaN(transform.x) || isNaN(transform.y) || isNaN(transform.k)) {
268268
graph.svg.attr("transform", d3.zoomIdentity);
269269
} else {
@@ -1039,37 +1039,4 @@ graph.addRelationshipData = function (n, l, callback, values, isNegative) {
10391039

10401040
};
10411041

1042-
graph.voronoi = d3.voronoi()
1043-
.x(function (d) {
1044-
return d.x;
1045-
})
1046-
.y(function (d) {
1047-
return d.y;
1048-
});
1049-
1050-
graph.recenterVoronoi = function (nodes) {
1051-
var shapes = [];
1052-
1053-
var voronois = graph.voronoi.polygons(nodes.map(function (d) {
1054-
d.x = d.x || 0;
1055-
d.y = d.y || 0;
1056-
return d
1057-
}));
1058-
1059-
voronois.forEach(function (d) {
1060-
if (!d.length) {
1061-
return;
1062-
}
1063-
1064-
var n = [];
1065-
d.forEach(function (c) {
1066-
n.push([c[0] - d.data.x, c[1] - d.data.y]);
1067-
});
1068-
1069-
n.point = d.data;
1070-
shapes.push(n);
1071-
});
1072-
return shapes;
1073-
};
1074-
10751042
export default graph

src/graph/node/node.js

Lines changed: 24 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,9 @@ node.addNewElements = function (enteringData) {
261261
// Disable right click context menu on value nodes
262262
gNewNodeElements.filter(function (d) {
263263
return d.type === node.NodeTypes.VALUE;
264-
}).on("contextmenu", function () {
264+
}).on("contextmenu", function (event) {
265265
// Disable context menu on
266-
d3.event.preventDefault();
266+
event.preventDefault();
267267
});
268268

269269
var nodeDefs = gNewNodeElements.append("defs");
@@ -344,8 +344,8 @@ node.addForegroundElements = function (gNewNodeElements) {
344344
.attr("class", "ppt-arrow")
345345
.attr("d", "m -44.905361,-23 6.742,-6.742 c 0.81,-0.809 0.81,-2.135 0,-2.944 l -0.737,-0.737 c -0.81,-0.811 -2.135,-0.811 -2.945,0 l -8.835,8.835 c -0.435,0.434 -0.628,1.017 -0.597,1.589 -0.031,0.571 0.162,1.154 0.597,1.588 l 8.835,8.834 c 0.81,0.811 2.135,0.811 2.945,0 l 0.737,-0.737 c 0.81,-0.808 0.81,-2.134 0,-2.943 l -6.742,-6.743 z");
346346

347-
glArrow.on("click", function (clickedNode) {
348-
d3.event.stopPropagation(); // To avoid click event on svg element in background
347+
glArrow.on("click", function (event, clickedNode) {
348+
event.stopPropagation(); // To avoid click event on svg element in background
349349

350350
// On left arrow click page number is decreased and node expanded to display the new page
351351
if (clickedNode.page > 1) {
@@ -369,8 +369,8 @@ node.addForegroundElements = function (gNewNodeElements) {
369369
.attr("class", "ppt-arrow")
370370
.attr("d", "m 51.027875,-24.5875 -8.835,-8.835 c -0.811,-0.811 -2.137,-0.811 -2.945,0 l -0.738,0.737 c -0.81,0.81 -0.81,2.136 0,2.944 l 6.742,6.742 -6.742,6.742 c -0.81,0.81 -0.81,2.136 0,2.943 l 0.737,0.737 c 0.81,0.811 2.136,0.811 2.945,0 l 8.835,-8.836 c 0.435,-0.434 0.628,-1.017 0.597,-1.588 0.032,-0.569 -0.161,-1.152 -0.596,-1.586 z");
371371

372-
grArrow.on("click", function (clickedNode) {
373-
d3.event.stopPropagation(); // To avoid click event on svg element in background
372+
grArrow.on("click", function (event, clickedNode) {
373+
event.stopPropagation(); // To avoid click event on svg element in background
374374

375375
if (clickedNode.page * node.PAGE_SIZE < clickedNode.count) {
376376
clickedNode.page++;
@@ -434,14 +434,6 @@ node.updateElements = function () {
434434
return provider.node.getSize(n);
435435
});
436436

437-
// Display voronoi paths
438-
// TODO ZZZ re|move
439-
// nUdeXXX.selectAllData.selectAll(".gra").data(["unique"]).enter().append("g").attr("class", "gra").append("use");
440-
// nUdeXXX.selectAllData.selectAll("use").attr("xlink:href",function(d){
441-
// console.log("#pvoroclip-"+d3.select(this.parentNode.parentNode).datum().id);
442-
// return "#pvoroclip-"+d3.select(this.parentNode.parentNode).datum().id;
443-
// }).attr("fill","none").attr("stroke","red").attr("stroke-width","1px");
444-
445437
// TODO ZZZ move functions?
446438
toUpdateElem.filter(function (n) {
447439
return n.type !== node.NodeTypes.ROOT
@@ -450,19 +442,19 @@ node.updateElements = function () {
450442
.on("drag", dragged)
451443
.on("end", dragended));
452444

453-
function dragstarted(d) {
454-
if (!d3.event.active) graph.force.alphaTarget(0.3).restart();
445+
function dragstarted(event, d) {
446+
if (!event.active) graph.force.alphaTarget(0.3).restart();
455447
d.fx = d.x;
456448
d.fy = d.y;
457449
}
458450

459-
function dragged(d) {
460-
d.fx = d3.event.x;
461-
d.fy = d3.event.y;
451+
function dragged(event, d) {
452+
d.fx = event.x;
453+
d.fy = event.y;
462454
}
463455

464-
function dragended(d) {
465-
if (!d3.event.active) graph.force.alphaTarget(0);
456+
function dragended(event, d) {
457+
if (!event.active) graph.force.alphaTarget(0);
466458
if (d.fixed === false) {
467459
d.fx = null;
468460
d.fy = null;
@@ -897,8 +889,8 @@ node.updateForegroundElements = function () {
897889
});
898890
};
899891

900-
node.segmentClick = function (d) {
901-
d3.event.preventDefault();
892+
node.segmentClick = function (event, d) {
893+
event.preventDefault();
902894

903895
var n = d3.select(this.parentNode.parentNode).datum();
904896

@@ -919,8 +911,8 @@ node.segmentClick = function (d) {
919911
/**
920912
* Handle the mouse over event on nodes.
921913
*/
922-
node.mouseOverNode = function () {
923-
d3.event.preventDefault();
914+
node.mouseOverNode = function (event) {
915+
event.preventDefault();
924916

925917
// TODO don't work on IE (nodes unstable) find another way to move node in foreground on mouse over?
926918
// d3.select(this).moveToFront();
@@ -946,22 +938,11 @@ node.mouseOverNode = function () {
946938
}
947939
};
948940

949-
// nUdeXXX.mouseMoveNode = function () {
950-
// d3.event.preventDefault();
951-
//
952-
// var hoveredNode = d3.select(this).data()[0];
953-
//
954-
// tootip.div
955-
// .text(provider.node.getTextValue(hoveredNode, nUdeXXX.NODE_TITLE_MAX_CHARS))
956-
// .style("left", (d3.event.pageX - 34) + "px")
957-
// .style("top", (d3.event.pageY - 12) + "px");
958-
// };
959-
960941
/**
961942
* Handle mouse out event on nodes.
962943
*/
963-
node.mouseOutNode = function () {
964-
d3.event.preventDefault();
944+
node.mouseOutNode = function (event) {
945+
event.preventDefault();
965946

966947
// tootip.div.style("display", "none");
967948

@@ -987,15 +968,15 @@ node.mouseOutNode = function () {
987968
/**
988969
* Handle the click event on nodes.
989970
*/
990-
node.nodeClick = function () {
991-
if (!d3.event.defaultPrevented) { // To avoid click on drag end
971+
node.nodeClick = function (event) {
972+
if (!event.defaultPrevented) { // To avoid click on drag end
992973
var clickedNode = d3.select(this).data()[0]; // Clicked node data
993974
logger.debug("nodeClick (" + clickedNode.label + ")");
994975

995976
if (clickedNode.type === node.NodeTypes.VALUE) {
996977
node.valueNodeClick(clickedNode);
997978
} else if (clickedNode.type === node.NodeTypes.CHOOSE || clickedNode.type === node.NodeTypes.ROOT) {
998-
if (d3.event.ctrlKey) {
979+
if (event.ctrlKey) {
999980
if (clickedNode.type === node.NodeTypes.CHOOSE) {
1000981
clickedNode.isNegative = !clickedNode.hasOwnProperty("isNegative") || !clickedNode.isNegative;
1001982

@@ -1874,9 +1855,9 @@ node.getTrunkNode = function (n) {
18741855
* Function to add on node event to clear the selection.
18751856
* Call to this function on a node will remove the selected value and trigger a graph update.
18761857
*/
1877-
node.clearSelection = function () {
1858+
node.clearSelection = function (event) {
18781859
// Prevent default event like right click opening menu.
1879-
d3.event.preventDefault();
1860+
event.preventDefault();
18801861

18811862
// Get clicked node.
18821863
var clickedNode = d3.select(this).data()[0];

src/taxonomy/taxonomy.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ taxonomy.addTaxonomyChildren = function (selection) {
175175
});
176176
};
177177

178-
taxonomy.onClick = function () {
179-
d3.event.stopPropagation();
178+
taxonomy.onClick = function (event) {
179+
event.stopPropagation();
180180

181181
var label = this.attributes.value.value;
182182

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`render Should works with 1 word as text Should render correctly 1`] = `"<div><g><rect fill=\\"mocked_color_value\\" class=\\"mocked_css_class_value\\" x=\\"-53\\" y=\\"-50\\" rx=\\"5\\" ry=\\"5\\" width=\\"106\\" height=\\"100\\" transform=\\"translate(0,0) scale(0.5543250876981161)\\"></rect><text class=\\"fitted-text mocked_css_class_value\\" style=\\"text-anchor: middle; font: 10px sans-serif\\" transform=\\"translate(0,0) scale(0.5543250876981161)\\"><tspan x=\\"0\\" y=\\"3.6000000000000005\\">mockedTextValue</tspan></text></g></div>"`;
3+
exports[`render Should works with 1 word as text Should render correctly 1`] = `"<div><g><rect fill="mocked_color_value" class="mocked_css_class_value" x="-53" y="-50" rx="5" ry="5" width="106" height="100" transform="translate(0,0) scale(5.2057920629535355)"></rect><text class="fitted-text mocked_css_class_value" style="text-anchor: middle; font: 10px sans-serif" transform="translate(0,0) scale(5.2057920629535355)"><tspan x="0" y="3.6000000000000005">mockedTextValue</tspan></text></g></div>"`;
44

5-
exports[`render Should works with empty text Should render correctly 1`] = `"<div><g><rect fill=\\"mocked_color_value\\" class=\\"mocked_css_class_value\\" x=\\"-53\\" y=\\"-50\\" rx=\\"5\\" ry=\\"5\\" width=\\"6\\" height=\\"0\\" transform=\\"translate(0,0) scale(1)\\"></rect><text class=\\"fitted-text mocked_css_class_value\\" style=\\"text-anchor: middle; font: 10px sans-serif\\" transform=\\"translate(0,0) scale(1)\\"></text></g></div>"`;
5+
exports[`render Should works with empty text Should render correctly 1`] = `"<div><g><rect fill="mocked_color_value" class="mocked_css_class_value" x="-53" y="-50" rx="5" ry="5" width="6" height="0" transform="translate(0,0) scale(1)"></rect><text class="fitted-text mocked_css_class_value" style="text-anchor: middle; font: 10px sans-serif" transform="translate(0,0) scale(1)"></text></g></div>"`;
66

7-
exports[`render Should works with integer as text Should render correctly 1`] = `"<div><g><rect fill=\\"mocked_color_value\\" class=\\"mocked_css_class_value\\" x=\\"-53\\" y=\\"-50\\" rx=\\"5\\" ry=\\"5\\" width=\\"106\\" height=\\"100\\" transform=\\"translate(0,0) scale(5.892556509887896)\\"></rect><text class=\\"fitted-text mocked_css_class_value\\" style=\\"text-anchor: middle; font: 10px sans-serif\\" transform=\\"translate(0,0) scale(5.892556509887896)\\"><tspan x=\\"0\\" y=\\"3.6000000000000005\\">0</tspan></text></g></div>"`;
7+
exports[`render Should works with integer as text Should render correctly 1`] = `"<div><g><rect fill="mocked_color_value" class="mocked_css_class_value" x="-53" y="-50" rx="5" ry="5" width="106" height="100" transform="translate(0,0) scale(8.304547985373997)"></rect><text class="fitted-text mocked_css_class_value" style="text-anchor: middle; font: 10px sans-serif" transform="translate(0,0) scale(8.304547985373997)"><tspan x="0" y="3.6000000000000005">0</tspan></text></g></div>"`;
88

9-
exports[`render Should works with multiple words as text Should render correctly 1`] = `"<div><g><rect fill=\\"mocked_color_value\\" class=\\"mocked_css_class_value\\" x=\\"-53\\" y=\\"-50\\" rx=\\"5\\" ry=\\"5\\" width=\\"106\\" height=\\"100\\" transform=\\"translate(0,0) scale(1.2422599874998832)\\"></rect><text class=\\"fitted-text mocked_css_class_value\\" style=\\"text-anchor: middle; font: 10px sans-serif\\" transform=\\"translate(0,0) scale(1.2422599874998832)\\"><tspan x=\\"0\\" y=\\"-8.399999999999999\\">mocked</tspan><tspan x=\\"0\\" y=\\"3.6000000000000005\\">text</tspan><tspan x=\\"0\\" y=\\"15.600000000000001\\">value</tspan></text></g></div>"`;
9+
exports[`render Should works with multiple words as text Should render correctly 1`] = `"<div><g><rect fill="mocked_color_value" class="mocked_css_class_value" x="-53" y="-50" rx="5" ry="5" width="106" height="100" transform="translate(0,0) scale(4.805693313322127)"></rect><text class="fitted-text mocked_css_class_value" style="text-anchor: middle; font: 10px sans-serif" transform="translate(0,0) scale(4.805693313322127)"><tspan x="0" y="3.6000000000000005">mocked text value</tspan></text></g></div>"`;
1010

11-
exports[`render Should works with multiple words on same span Should render correctly 1`] = `"<div><g><rect fill=\\"mocked_color_value\\" class=\\"mocked_css_class_value\\" x=\\"-53\\" y=\\"-50\\" rx=\\"5\\" ry=\\"5\\" width=\\"106\\" height=\\"100\\" transform=\\"translate(0,0) scale(1.0942202738310212)\\"></rect><text class=\\"fitted-text mocked_css_class_value\\" style=\\"text-anchor: middle; font: 10px sans-serif\\" transform=\\"translate(0,0) scale(1.0942202738310212)\\"><tspan x=\\"0\\" y=\\"-8.399999999999999\\">mocked</tspan><tspan x=\\"0\\" y=\\"3.6000000000000005\\">text</tspan><tspan x=\\"0\\" y=\\"15.600000000000001\\">a value</tspan></text></g></div>"`;
11+
exports[`render Should works with multiple words on same span Should render correctly 1`] = `"<div><g><rect fill="mocked_color_value" class="mocked_css_class_value" x="-53" y="-50" rx="5" ry="5" width="106" height="100" transform="translate(0,0) scale(3.6637165272365584)"></rect><text class="fitted-text mocked_css_class_value" style="text-anchor: middle; font: 10px sans-serif" transform="translate(0,0) scale(3.6637165272365584)"><tspan x="0" y="-2.3999999999999995">mocked text a</tspan><tspan x="0" y="9.600000000000001">value</tspan></text></g></div>"`;
1212

13-
exports[`render Should works with undefined text Should render correctly 1`] = `"<div><g><rect fill=\\"mocked_color_value\\" class=\\"mocked_css_class_value\\" x=\\"-53\\" y=\\"-50\\" rx=\\"5\\" ry=\\"5\\" width=\\"6\\" height=\\"0\\" transform=\\"translate(0,0) scale(1)\\"></rect><text class=\\"fitted-text mocked_css_class_value\\" style=\\"text-anchor: middle; font: 10px sans-serif\\" transform=\\"translate(0,0) scale(1)\\"></text></g></div>"`;
13+
exports[`render Should works with undefined text Should render correctly 1`] = `"<div><g><rect fill="mocked_color_value" class="mocked_css_class_value" x="-53" y="-50" rx="5" ry="5" width="6" height="0" transform="translate(0,0) scale(1)"></rect><text class="fitted-text mocked_css_class_value" style="text-anchor: middle; font: 10px sans-serif" transform="translate(0,0) scale(1)"></text></g></div>"`;

test/graph/node/__snapshots__/textRender.test.js.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
exports[`Test TEXT_Y default value to center text vertically 1`] = `8`;
44

5-
exports[`render Should works with empty text Should render correctly 1`] = `"<div><g><rect fill=\\"mocked_color_value\\" class=\\"mocked_css_class_value\\" x=\\"-53\\" y=\\"-50\\" rx=\\"5\\" ry=\\"5\\" width=\\"6\\" height=\\"0\\"></rect><text x=\\"0\\" y=\\"8\\" text-anchor=\\"middle\\" class=\\"mocked_css_class_value2\\"></text></g></div>"`;
5+
exports[`render Should works with empty text Should render correctly 1`] = `"<div><g><rect fill="mocked_color_value" class="mocked_css_class_value" x="-53" y="-50" rx="5" ry="5" width="6" height="0"></rect><text x="0" y="8" text-anchor="middle" class="mocked_css_class_value2"></text></g></div>"`;
66

7-
exports[`render Should works with integer text Should render correctly 1`] = `"<div><g><rect fill=\\"mocked_color_value\\" class=\\"mocked_css_class_value\\" x=\\"-53\\" y=\\"-50\\" rx=\\"5\\" ry=\\"5\\" width=\\"6\\" height=\\"0\\"></rect><text x=\\"0\\" y=\\"8\\" text-anchor=\\"middle\\" class=\\"mocked_css_class_value2\\">0</text></g></div>"`;
7+
exports[`render Should works with integer text Should render correctly 1`] = `"<div><g><rect fill="mocked_color_value" class="mocked_css_class_value" x="-53" y="-50" rx="5" ry="5" width="6" height="0"></rect><text x="0" y="8" text-anchor="middle" class="mocked_css_class_value2">0</text></g></div>"`;
88

99
exports[`render Should works with normal simple text MouseOver should remove correctly the parent clip path 1`] = `"url(#node-viewmocked_id_clip_path_value)"`;
1010

@@ -14,6 +14,6 @@ exports[`render Should works with normal simple text Mouseout after the mouseove
1414

1515
exports[`render Should works with normal simple text Mouseout after the mouseover should reAdd correctly the parent clip path 2`] = `"url(#node-viewmocked_id_clip_path_value)"`;
1616

17-
exports[`render Should works with normal simple text Should render correctly 1`] = `"<div><g clip-path=\\"url(#node-viewmocked_id_clip_path_value)\\"><rect fill=\\"mocked_color_value\\" class=\\"mocked_css_class_value\\" x=\\"-53\\" y=\\"-50\\" rx=\\"5\\" ry=\\"5\\" width=\\"106\\" height=\\"100\\"></rect><text x=\\"0\\" y=\\"8\\" text-anchor=\\"middle\\" class=\\"mocked_css_class_value2\\">mocked text value</text></g></div>"`;
17+
exports[`render Should works with normal simple text Should render correctly 1`] = `"<div><g clip-path="url(#node-viewmocked_id_clip_path_value)"><rect fill="mocked_color_value" class="mocked_css_class_value" x="-53" y="-50" rx="5" ry="5" width="106" height="100"></rect><text x="0" y="8" text-anchor="middle" class="mocked_css_class_value2">mocked text value</text></g></div>"`;
1818

19-
exports[`render Should works with undefined text Should render correctly 1`] = `"<div><g><rect fill=\\"mocked_color_value\\" class=\\"mocked_css_class_value\\" x=\\"-53\\" y=\\"-50\\" rx=\\"5\\" ry=\\"5\\" width=\\"6\\" height=\\"0\\"></rect><text x=\\"0\\" y=\\"8\\" text-anchor=\\"middle\\" class=\\"mocked_css_class_value2\\"></text></g></div>"`;
19+
exports[`render Should works with undefined text Should render correctly 1`] = `"<div><g><rect fill="mocked_color_value" class="mocked_css_class_value" x="-53" y="-50" rx="5" ry="5" width="6" height="0"></rect><text x="0" y="8" text-anchor="middle" class="mocked_css_class_value2"></text></g></div>"`;

0 commit comments

Comments
 (0)