Skip to content

Commit

Permalink
[SPARK-7658] [STREAMING] [WEBUI] Update the mouse behaviors for the t…
Browse files Browse the repository at this point in the history
…imeline 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]>
  • Loading branch information
zsxwing authored and tdas committed May 18, 2015
1 parent a833209 commit 39add3d
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,7 @@
span.expand-input-rate {
cursor: pointer;
}

tr.batch-table-cell-highlight > td {
background-color: #D6FFE4 !important;
}
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ function drawTimeline(id, data, minX, maxX, minY, maxY, unitY, batchInterval) {
.attr("class", "line")
.attr("d", line);

// If the user click one point in the graphs, jump to the batch row and highlight it. And
// recovery the batch row after 3 seconds if necessary.
// We need to remember the last clicked batch so that we can recovery it.
var lastClickedBatch = null;
var lastTimeout = null;

// Add points to the line. However, we make it invisible at first. But when the user moves mouse
// over a point, it will be displayed with its detail.
svg.selectAll(".point")
Expand All @@ -154,6 +160,7 @@ function drawTimeline(id, data, minX, maxX, minY, maxY, unitY, batchInterval) {
.attr("stroke", "white") // white and opacity = 0 make it invisible
.attr("fill", "white")
.attr("opacity", "0")
.style("cursor", "pointer")
.attr("cx", function(d) { return x(d.x); })
.attr("cy", function(d) { return y(d.y); })
.attr("r", function(d) { return 3; })
Expand All @@ -175,7 +182,29 @@ function drawTimeline(id, data, minX, maxX, minY, maxY, unitY, batchInterval) {
.attr("opacity", "0");
})
.on("click", function(d) {
window.location.href = "batch/?id=" + d.x;
if (lastTimeout != null) {
window.clearTimeout(lastTimeout);
}
if (lastClickedBatch != null) {
clearBatchRow(lastClickedBatch);
lastClickedBatch = null;
}
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 batchSelector = $("#batch-" + d.x);
var topOffset = batchSelector.offset().top - 15;
if (topOffset < 0) {
topOffset = 0;
}
$('html,body').animate({scrollTop: topOffset}, 200);
});
}

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

svg.append("g")
.attr("class", "y axis")
Expand Down Expand Up @@ -279,3 +311,11 @@ $(function() {
$(this).find('.expand-input-rate-arrow').toggleClass('arrow-open').toggleClass('arrow-closed');
}
});

function highlightBatchRow(batch) {
$("#batch-" + batch).parent().addClass("batch-table-cell-highlight");
}

function clearBatchRow(batch) {
$("#batch-" + batch).parent().removeClass("batch-table-cell-highlight");
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ private[ui] abstract class BatchTableBase(tableId: String, batchInterval: Long)
val formattedSchedulingDelay = schedulingDelay.map(SparkUIUtils.formatDuration).getOrElse("-")
val processingTime = batch.processingDelay
val formattedProcessingTime = processingTime.map(SparkUIUtils.formatDuration).getOrElse("-")
val batchTimeId = s"batch-$batchTime"

<td sorttable_customkey={batchTime.toString}>
<td id={batchTimeId} sorttable_customkey={batchTime.toString}>
<a href={s"batch?id=$batchTime"}>
{formattedBatchTime}
</a>
Expand Down

0 comments on commit 39add3d

Please sign in to comment.