yaooqinn commented on code in PR #43307:
URL: https://github.com/apache/spark/pull/43307#discussion_r1352987532
##########
sql/core/src/main/resources/org/apache/spark/sql/execution/ui/static/spark-sql-viz.js:
##########
@@ -269,3 +270,47 @@ function togglePlanViz() { // eslint-disable-line
no-unused-vars
planVizContainer().style("display", "none");
}
}
+
+/*
+ * Light up the selected node and its linked nodes and edges.
+ */
+function setupSelectionForSparkPlanNode(g) {
+ const linkedNodes = new Map();
+ const linkedEdges = new Map();
+
+ g.edges().forEach(function (e) {
+ const edge = g.edge(e);
+ const from = g.node(e.v);
+ const to = g.node(e.w);
+ collectLinks(linkedNodes, from.id, to.id);
+ collectLinks(linkedNodes, to.id, from.id);
+ collectLinks(linkedEdges, from.id, edge.arrowheadId);
+ collectLinks(linkedEdges, to.id, edge.arrowheadId);
+ });
+
+ linkedNodes.forEach((linkedNodes, selectNode) => {
+ d3.select("#" + selectNode).on("click", () => {
+ planVizContainer()
+ .selectAll("*")
+ .classed("selected", false)
+ .classed("linked", false);
+ d3.select("#" + selectNode + " rect").classed("selected", true);
+ linkedNodes.forEach((linkedNode) => {
+ d3.select("#" + linkedNode + " rect").classed("linked", true);
+ });
+ linkedEdges.get(selectNode).forEach((linkedEdge) => {
+ const arrowHead = d3.select("#" + linkedEdge + " path");
+ arrowHead.classed("linked", true);
+ const arrowShaft =
$(arrowHead.node()).parents("g.edgePath").children("path");
Review Comment:
The head and shaft are not at the same level, in order to get their common
ancestor with the d3 selection API, we need to hard code like
```javascript
d3.select(d3.select(arrowHead.node().parentNode).node().parentNode).select("path")
```
It appears not future-proofing. The suitable way is using edge ID, but it
seems not supported by both graphdot-lib and dagre-d3 yet. In this scenario,
jQuery appears to be a suitable option based on our typical usage in UI.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]