Skip to content

Commit 75fe7df

Browse files
authored
Merge pull request #79 from OCNS:feat-tweaks
Make edges not interactive, curve edges on reset
2 parents 803db6b + 55ad2d1 commit 75fe7df

File tree

3 files changed

+17
-41
lines changed

3 files changed

+17
-41
lines changed

assets/cy-style.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"line-color": "#e2e2e2",
1919
"target-arrow-color": "#e2e2e2",
2020
"color": "#1984c5",
21-
"edge-text-rotation": "autorotate"
21+
"edge-text-rotation": "autorotate",
22+
"events": "no"
2223
}
2324
},
2425
{

graph.js

Lines changed: 13 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -150,42 +150,7 @@ function showNodeDetails(node) {
150150
}
151151

152152
function highlightEdge(edge) {
153-
const details_top = document.getElementById("details_top");
154-
const details_bottom = document.getElementById("details_bottom");
155-
details_bottom.innerHTML = "";
156-
const headerElement = document.createElement("h2");
157-
headerElement.innerHTML = edge.id();
158-
159-
const sourceLink = document.createElement("a");
160-
sourceLink.href = "#";
161-
sourceLink.addEventListener("click",function(e) { edge.unselect(); edge.source().select(); });
162-
sourceLink.innerHTML = edge.source().id();
163-
164-
const targetLink = document.createElement("a");
165-
targetLink.href = "#";
166-
targetLink.addEventListener("click",function(e) { edge.unselect(); edge.target().select(); });
167-
targetLink.innerHTML = edge.target().id();
168-
169-
details_top.innerHTML = "";
170-
171-
const paragraph = document.createElement("p");
172-
paragraph.appendChild(sourceLink);
173-
const label = document.createElement("i");
174-
label.innerHTML = " " + edge.data("label") + " ";
175-
paragraph.appendChild(label);
176-
paragraph.appendChild(targetLink);
177-
details_top.appendChild(headerElement);
178-
details_top.appendChild(paragraph);
179-
// Only show the edge and the connected nodes
180-
cy.elements().forEach(n => n.style("opacity", 0.2));
181-
edge.style("opacity", 1);
182-
edge.connectedNodes().forEach(n => n.style("opacity", 1));
183-
// hide filter pane
184-
const filterPane = new bootstrap.Offcanvas('#filter_pane');
185-
// FIXME: not quite sure what is going on here, but sometimes the internal state is incorrect
186-
if (document.getElementById("filter_pane").classList.contains("show"))
187-
filterPane._isShown = true;
188-
filterPane.hide();
153+
console.log("Edge double tapped: no op");
189154
}
190155

191156
function highlightElement(event) {
@@ -237,6 +202,7 @@ function unhighlightNode(event, unselect) {
237202

238203
// return graph to initial state
239204
const return_graph_to_init = () => {
205+
cy.edges().forEach(n => {n.style("curve-style", "unbundled-bezier"); n.style("min-zoomed-font-size", 36)});
240206
cy.animate(
241207
{
242208
pan: cy_pan,
@@ -258,6 +224,7 @@ function unhighlightNode(event, unselect) {
258224
console.log("New pos: " + n.id() + ": " + n.position().x + ", " + n.position().y);
259225
}
260226
}).play());
227+
261228
};
262229

263230
return_graph_to_init();
@@ -332,7 +299,12 @@ function newEdge(name, relation) {
332299
id: name + " → " + relation["name"],
333300
source: name,
334301
target: relation["name"],
335-
label: relation["description"]
302+
label: relation["description"],
303+
style: {
304+
"event": "no",
305+
"selectable": false,
306+
"grabbable": false
307+
},
336308
}
337309
}
338310
}
@@ -358,7 +330,10 @@ function create_cy_elements(data, style) {
358330
container: document.getElementById('cy'),
359331
elements: elements,
360332
layout: { name: 'random' },
361-
style: style
333+
style: style,
334+
minZoom: 0.75,
335+
maxZoom: 4,
336+
wheelSensitivity: 0.2,
362337
});
363338
// store the meta_node, since we need to remove it when highlighting nodes
364339
meta_node = cy.$("#simulators");

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ function showDetails(data, connected) {
1919
details_top.innerHTML += "<ul>";
2020
details_top.innerHTML += "<li>Use the 'Toggle Filters' button to activate the simulation engine filter.</li>";
2121
details_top.innerHTML += "<li>Select what simulation engines you would like to show in the graph.</li>";
22-
details_top.innerHTML += "<li>Select a node/edge to see its ecosystem in the graph.</li>";
23-
details_top.innerHTML += "<li>Double click/tap on a node/edge to see details of the tool.</li>";
22+
details_top.innerHTML += "<li>Select a node to see its ecosystem in the graph.</li>";
23+
details_top.innerHTML += "<li>Double click/tap on a node to see details of the tool.</li>";
2424
details_top.innerHTML += "<li>Click outside to unselect nodes.</li>";
2525
details_top.innerHTML += "</ul>";
2626
details_top.innerHTML += "<h3 class='mt-3'>Contributing</h2>";

0 commit comments

Comments
 (0)