Skip to content

Commit 39add3d

Browse files
zsxwingtdas
authored andcommitted
[SPARK-7658] [STREAMING] [WEBUI] Update the mouse behaviors for the timeline graphs
1. If the user click one point of a batch, scroll down to the corresponding batch row and highlight it. And recovery the batch row after 3 seconds if necessary. 2. Add "#batches" in the histogram graphs. ![screen shot 2015-05-14 at 7 36 19 pm](https://cloud.githubusercontent.com/assets/1000778/7646108/84f4a014-fa73-11e4-8c13-1903d267e60f.png) ![screen shot 2015-05-14 at 7 36 53 pm](https://cloud.githubusercontent.com/assets/1000778/7646109/8b11154a-fa73-11e4-820b-8ece9fa6ee3e.png) ![screen shot 2015-05-14 at 7 36 34 pm](https://cloud.githubusercontent.com/assets/1000778/7646111/93828272-fa73-11e4-89f8-580670144d3c.png) Author: zsxwing <[email protected]> Closes #6168 from zsxwing/SPARK-7658 and squashes the following commits: c242b00 [zsxwing] Change 5 seconds to 3 seconds 31fd0aa [zsxwing] Remove the mouseover highlight feature 06c6f6f [zsxwing] Merge branch 'master' into SPARK-7658 2eaff06 [zsxwing] Merge branch 'master' into SPARK-7658 108d56c [zsxwing] Update the mouse behaviors for the timeline graphs (cherry picked from commit 0b6f503) Signed-off-by: Tathagata Das <[email protected]>
1 parent a833209 commit 39add3d

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed

streaming/src/main/resources/org/apache/spark/streaming/ui/static/streaming-page.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,7 @@
6060
span.expand-input-rate {
6161
cursor: pointer;
6262
}
63+
64+
tr.batch-table-cell-highlight > td {
65+
background-color: #D6FFE4 !important;
66+
}

streaming/src/main/resources/org/apache/spark/streaming/ui/static/streaming-page.js

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@ function drawTimeline(id, data, minX, maxX, minY, maxY, unitY, batchInterval) {
146146
.attr("class", "line")
147147
.attr("d", line);
148148

149+
// If the user click one point in the graphs, jump to the batch row and highlight it. And
150+
// recovery the batch row after 3 seconds if necessary.
151+
// We need to remember the last clicked batch so that we can recovery it.
152+
var lastClickedBatch = null;
153+
var lastTimeout = null;
154+
149155
// Add points to the line. However, we make it invisible at first. But when the user moves mouse
150156
// over a point, it will be displayed with its detail.
151157
svg.selectAll(".point")
@@ -154,6 +160,7 @@ function drawTimeline(id, data, minX, maxX, minY, maxY, unitY, batchInterval) {
154160
.attr("stroke", "white") // white and opacity = 0 make it invisible
155161
.attr("fill", "white")
156162
.attr("opacity", "0")
163+
.style("cursor", "pointer")
157164
.attr("cx", function(d) { return x(d.x); })
158165
.attr("cy", function(d) { return y(d.y); })
159166
.attr("r", function(d) { return 3; })
@@ -175,7 +182,29 @@ function drawTimeline(id, data, minX, maxX, minY, maxY, unitY, batchInterval) {
175182
.attr("opacity", "0");
176183
})
177184
.on("click", function(d) {
178-
window.location.href = "batch/?id=" + d.x;
185+
if (lastTimeout != null) {
186+
window.clearTimeout(lastTimeout);
187+
}
188+
if (lastClickedBatch != null) {
189+
clearBatchRow(lastClickedBatch);
190+
lastClickedBatch = null;
191+
}
192+
lastClickedBatch = d.x;
193+
highlightBatchRow(lastClickedBatch)
194+
lastTimeout = window.setTimeout(function () {
195+
lastTimeout = null;
196+
if (lastClickedBatch != null) {
197+
clearBatchRow(lastClickedBatch);
198+
lastClickedBatch = null;
199+
}
200+
}, 3000); // Clean up after 3 seconds
201+
202+
var batchSelector = $("#batch-" + d.x);
203+
var topOffset = batchSelector.offset().top - 15;
204+
if (topOffset < 0) {
205+
topOffset = 0;
206+
}
207+
$('html,body').animate({scrollTop: topOffset}, 200);
179208
});
180209
}
181210

@@ -218,6 +247,9 @@ function drawHistogram(id, values, minY, maxY, unitY, batchInterval) {
218247
svg.append("g")
219248
.attr("class", "x axis")
220249
.call(xAxis)
250+
.append("text")
251+
.attr("transform", "translate(" + (margin.left + width - 40) + ", 15)")
252+
.text("#batches");
221253

222254
svg.append("g")
223255
.attr("class", "y axis")
@@ -279,3 +311,11 @@ $(function() {
279311
$(this).find('.expand-input-rate-arrow').toggleClass('arrow-open').toggleClass('arrow-closed');
280312
}
281313
});
314+
315+
function highlightBatchRow(batch) {
316+
$("#batch-" + batch).parent().addClass("batch-table-cell-highlight");
317+
}
318+
319+
function clearBatchRow(batch) {
320+
$("#batch-" + batch).parent().removeClass("batch-table-cell-highlight");
321+
}

streaming/src/main/scala/org/apache/spark/streaming/ui/AllBatchesTable.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ private[ui] abstract class BatchTableBase(tableId: String, batchInterval: Long)
4444
val formattedSchedulingDelay = schedulingDelay.map(SparkUIUtils.formatDuration).getOrElse("-")
4545
val processingTime = batch.processingDelay
4646
val formattedProcessingTime = processingTime.map(SparkUIUtils.formatDuration).getOrElse("-")
47+
val batchTimeId = s"batch-$batchTime"
4748

48-
<td sorttable_customkey={batchTime.toString}>
49+
<td id={batchTimeId} sorttable_customkey={batchTime.toString}>
4950
<a href={s"batch?id=$batchTime"}>
5051
{formattedBatchTime}
5152
</a>

0 commit comments

Comments
 (0)