Ngone51 commented on a change in pull request #27927: [SPARK-31081][UI][SQL] 
Make display of stageId/stageAttemptId/taskId of sql metrics toggleable
URL: https://github.com/apache/spark/pull/27927#discussion_r394422625
 
 

 ##########
 File path: 
sql/core/src/main/resources/org/apache/spark/sql/execution/ui/static/spark-sql-viz.js
 ##########
 @@ -158,3 +184,48 @@ function getAbsolutePosition(d3selection) {
   }
   return { x: _x, y: _y };
 }
+
+/*
+ * Helper function for postprocess for additional metrics.
+ */
+function postprocessForAdditionalMetrics() {
+  // With dagre-d3, we can choose normal text (default) or HTML as a label 
type.
+  // HTML label for node works well but not for cluster so we need to choose 
the default label type
+  // and manipulate DOM.
+  $("g.cluster text tspan")
+    .each(function() {
+      var originalText = $(this).text();
+        if (originalText.indexOf(labelSeparator) > 0) {
+          var newTexts = originalText.split(labelSeparator);
+          var thisD3Node = d3.selectAll($(this));
+          thisD3Node.text(newTexts[0]);
+          thisD3Node.append("tspan").attr("class", 
"stageId-and-taskId-metrics").text(newTexts[1]);
+          $(this).append(newTexts[2]);
+        } else {
+          return originalText;
+        }
+  });
+
+  var checkboxNode = $("#stageId-and-taskId-checkbox");
+  checkboxNode.click(function() {
+      onClickAdditionalMetricsCheckbox($(this));
+  });
+  var isChecked = window.localStorage.getItem("stageId-and-taskId-checked") == 
"true";
+  $("#stageId-and-taskId-checkbox").prop("checked", isChecked);
+  $(".stageId-and-taskId-metrics").hide();
+  onClickAdditionalMetricsCheckbox(checkboxNode);
+}
+
+/*
+ * Helper function which defines the action on click the checkbox.
+ */
+function onClickAdditionalMetricsCheckbox(checkboxNode) {
+  var additionalMetrics = $(".stageId-and-taskId-metrics");
+  var isChecked = checkboxNode.prop("checked");
+  if (isChecked) {
+      additionalMetrics.show();
+  } else {
+      additionalMetrics.hide();
+  }
 
 Review comment:
   nit: indent

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to