LuciferYang commented on code in PR #43307:
URL: https://github.com/apache/spark/pull/43307#discussion_r1352676387
##########
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:
How about using d3's api uniformly?
Like
```
const arrowShaft = d3.select(arrowHead.node().parentNode).select("path");
arrowShaft.classed("linked", true);
```
?
--
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]