Skip to content

Commit

Permalink
[SPARK-31128][WEBUI] Fix Uncaught TypeError in streaming statistics page
Browse files Browse the repository at this point in the history
### What changes were proposed in this pull request?

There is a minor issue in #26201
In the streaming statistics page, there is such error
```
streaming-page.js:211 Uncaught TypeError: Cannot read property 'top' of undefined
at SVGCircleElement.<anonymous> (streaming-page.js:211)
at SVGCircleElement.__onclick (d3.min.js:1)
```
in the console after clicking the timeline graph.
![image](https://user-images.githubusercontent.com/1097932/76479745-14b26280-63ca-11ea-9079-0065321795f9.png)

This PR is to fix it.
### Why are the changes needed?

Fix the error of javascript execution.

### Does this PR introduce any user-facing change?

No, the error shows up in the console.

### How was this patch tested?

Manual test.

Closes #27883 from gengliangwang/fixSelector.

Authored-by: Gengliang Wang <gengliang.wang@databricks.com>
Signed-off-by: Gengliang Wang <gengliang.wang@databricks.com>
  • Loading branch information
gengliangwang committed Mar 13, 2020
1 parent 1c8526d commit 0f46325
Showing 1 changed file with 21 additions and 18 deletions.
Expand Up @@ -190,29 +190,32 @@ function drawTimeline(id, data, minX, maxX, minY, maxY, unitY, batchInterval) {
.attr("r", function(d) { return isFailedBatch(d.x) ? "2" : "3";});
})
.on("click", function(d) {
if (lastTimeout != null) {
window.clearTimeout(lastTimeout);
}
if (lastClickedBatch != null) {
clearBatchRow(lastClickedBatch);
lastClickedBatch = null;
}
lastClickedBatch = d.x;
highlightBatchRow(lastClickedBatch);
lastTimeout = window.setTimeout(function () {
lastTimeout = null;
var batchSelector = $("#batch-" + d.x);
// If there is a corresponding batch row, scroll down to it and highlight it.
if (batchSelector.length > 0) {
if (lastTimeout != null) {
window.clearTimeout(lastTimeout);
}
if (lastClickedBatch != null) {
clearBatchRow(lastClickedBatch);
lastClickedBatch = null;
}
}, 3000); // Clean up after 3 seconds

var batchSelector = $("#batch-" + d.x);
var topOffset = batchSelector.offset().top - 15;
if (topOffset < 0) {
topOffset = 0;
lastClickedBatch = d.x;
highlightBatchRow(lastClickedBatch);
lastTimeout = window.setTimeout(function () {
lastTimeout = null;
if (lastClickedBatch != null) {
clearBatchRow(lastClickedBatch);
lastClickedBatch = null;
}
}, 3000); // Clean up after 3 seconds

var topOffset = batchSelector.offset().top - 15;
if (topOffset < 0) {
topOffset = 0;
}
$('html,body').animate({scrollTop: topOffset}, 200);
}
$('html,body').animate({scrollTop: topOffset}, 200);
});
}

Expand Down

0 comments on commit 0f46325

Please sign in to comment.