Skip to content

Commit 0b2c252

Browse files
committed
[SPARK-7298] Harmonize style of new visualizations
- Colors on the timeline now match the rest of the UI - The expandable buttons to show timeline view, DAG, etc are now more visible - Timeline text is smaller - DAG visualization text and colors are more consistent throughout - Fix some JavaScript style issues - Various small fixes throughout (e.g. inconsistent capitalization, some confusing names, HTML escaping, etc) Author: Matei Zaharia <[email protected]> Closes #5942 from mateiz/ui and squashes the following commits: def38d0 [Matei Zaharia] Add some tooltips 4c5a364 [Matei Zaharia] Reduce stage and rank separation slightly 43dcbe3 [Matei Zaharia] Some updates to DAG fac734a [Matei Zaharia] tweaks 6a6705d [Matei Zaharia] More fixes 67629f5 [Matei Zaharia] Various small tweaks (cherry picked from commit a1ec08f) Signed-off-by: Matei Zaharia <[email protected]>
1 parent 89d9487 commit 0b2c252

File tree

12 files changed

+255
-151
lines changed

12 files changed

+255
-151
lines changed

core/src/main/resources/org/apache/spark/ui/static/spark-dag-viz.css

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,68 +16,88 @@
1616
*/
1717

1818
#dag-viz-graph svg path {
19-
stroke: #444444;
19+
stroke: #444;
2020
stroke-width: 1.5px;
2121
}
2222

2323
#dag-viz-graph svg g.cluster rect {
24-
stroke-width: 4px;
25-
stroke-opacity: 0.5;
24+
stroke-width: 1px;
25+
}
26+
27+
#dag-viz-graph svg g.node circle {
28+
fill: #444;
2629
}
2730

28-
#dag-viz-graph svg g.node circle,
2931
#dag-viz-graph svg g.node rect {
30-
fill: #444444;
32+
fill: #C3EBFF;
33+
stroke: #3EC0FF;
34+
stroke-width: 1px;
35+
}
36+
37+
#dag-viz-graph svg g.node.cached circle {
38+
fill: #444;
3139
}
3240

33-
#dag-viz-graph svg g.node.cached circle,
3441
#dag-viz-graph svg g.node.cached rect {
35-
fill: #FF0000;
42+
fill: #B3F5C5;
43+
stroke: #56F578;
44+
stroke-width: 1px;
3645
}
3746

3847
/* Job page specific styles */
3948

4049
#dag-viz-graph svg.job marker#marker-arrow path {
41-
fill: #444444;
50+
fill: #333;
4251
stroke-width: 0px;
4352
}
4453

4554
#dag-viz-graph svg.job g.cluster rect {
46-
fill: #FFFFFF;
47-
stroke: #AADFFF;
55+
fill: #A0DFFF;
56+
stroke: #3EC0FF;
57+
stroke-width: 1px;
4858
}
4959

5060
#dag-viz-graph svg.job g.cluster[id*="stage"] rect {
51-
stroke: #FFDDEE;
52-
stroke-width: 6px;
61+
fill: #FFFFFF;
62+
stroke: #FF99AC;
63+
stroke-width: 1px;
5364
}
5465

5566
#dag-viz-graph svg.job g#cross-stage-edges path {
5667
fill: none;
5768
}
5869

5970
#dag-viz-graph svg.job g.cluster text {
60-
fill: #AAAAAA;
71+
fill: #333;
6172
}
6273

6374
/* Stage page specific styles */
6475

6576
#dag-viz-graph svg.stage g.cluster rect {
66-
fill: #F0F8FF;
67-
stroke: #AADFFF;
77+
fill: #A0DFFF;
78+
stroke: #3EC0FF;
79+
stroke-width: 1px;
6880
}
6981

7082
#dag-viz-graph svg.stage g.cluster[id*="stage"] rect {
7183
fill: #FFFFFF;
72-
stroke: #FFDDEE;
73-
stroke-width: 6px;
84+
stroke: #FFA6B6;
85+
stroke-width: 1px;
7486
}
7587

7688
#dag-viz-graph svg.stage g.node g.label text tspan {
77-
fill: #FFFFFF;
89+
fill: #333;
7890
}
7991

8092
#dag-viz-graph svg.stage g.cluster text {
81-
fill: #444444;
82-
font-weight: bold;
93+
fill: #333;
94+
}
95+
96+
#dag-viz-graph a, #dag-viz-graph a:hover {
97+
text-decoration: none;
98+
}
99+
100+
#dag-viz-graph .label {
101+
font-weight: normal;
102+
text-shadow: none;
83103
}

core/src/main/resources/org/apache/spark/ui/static/spark-dag-viz.js

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@
5252
*/
5353

5454
var VizConstants = {
55-
svgMarginX: 20,
56-
svgMarginY: 20,
57-
stageSep: 50,
55+
svgMarginX: 16,
56+
svgMarginY: 16,
57+
stageSep: 40,
5858
graphPrefix: "graph_",
5959
nodePrefix: "node_",
6060
stagePrefix: "stage_",
@@ -63,14 +63,16 @@ var VizConstants = {
6363
};
6464

6565
var JobPageVizConstants = {
66-
clusterLabelSize: 11,
67-
stageClusterLabelSize: 14
68-
}
66+
clusterLabelSize: 12,
67+
stageClusterLabelSize: 14,
68+
rankSep: 40
69+
};
6970

7071
var StagePageVizConstants = {
7172
clusterLabelSize: 14,
72-
stageClusterLabelSize: 18
73-
}
73+
stageClusterLabelSize: 14,
74+
rankSep: 40
75+
};
7476

7577
/*
7678
* Show or hide the RDD DAG visualization.
@@ -149,11 +151,11 @@ function renderDagVizForStage(svgContainer) {
149151
var dot = metadata.select(".dot-file").text();
150152
var containerId = VizConstants.graphPrefix + metadata.attr("stage-id");
151153
var container = svgContainer.append("g").attr("id", containerId);
152-
renderDot(dot, container);
154+
renderDot(dot, container, StagePageVizConstants.rankSep);
153155

154-
// Round corners on RDDs
156+
// Round corners on rectangles
155157
svgContainer
156-
.selectAll("g.node rect")
158+
.selectAll("rect")
157159
.attr("rx", "5")
158160
.attr("ry", "5");
159161
}
@@ -207,7 +209,13 @@ function renderDagVizForJob(svgContainer) {
207209
}
208210

209211
// Actually render the stage
210-
renderDot(dot, container);
212+
renderDot(dot, container, JobPageVizConstants.rankSep);
213+
214+
// Round corners on rectangles
215+
container
216+
.selectAll("rect")
217+
.attr("rx", "4")
218+
.attr("ry", "4");
211219

212220
// If there are any incoming edges into this graph, keep track of them to render
213221
// them separately later. Note that we cannot draw them now because we need to
@@ -223,12 +231,13 @@ function renderDagVizForJob(svgContainer) {
223231
}
224232

225233
/* Render the dot file as an SVG in the given container. */
226-
function renderDot(dot, container) {
234+
function renderDot(dot, container, rankSep) {
227235
var escaped_dot = dot
228236
.replace(/&lt;/g, "<")
229237
.replace(/&gt;/g, ">")
230238
.replace(/&quot;/g, "\"");
231239
var g = graphlibDot.read(escaped_dot);
240+
g.graph().rankSep = rankSep;
232241
var renderer = new dagreD3.render();
233242
renderer(container, g);
234243
}
@@ -248,12 +257,13 @@ function metadataContainer() { return d3.select("#dag-viz-metadata"); }
248257
* In general, the clustering support for dagre-d3 is quite limited at this point.
249258
*/
250259
function drawClusterLabels(svgContainer, forJob) {
260+
var clusterLabelSize, stageClusterLabelSize;
251261
if (forJob) {
252-
var clusterLabelSize = JobPageVizConstants.clusterLabelSize;
253-
var stageClusterLabelSize = JobPageVizConstants.stageClusterLabelSize;
262+
clusterLabelSize = JobPageVizConstants.clusterLabelSize;
263+
stageClusterLabelSize = JobPageVizConstants.stageClusterLabelSize;
254264
} else {
255-
var clusterLabelSize = StagePageVizConstants.clusterLabelSize;
256-
var stageClusterLabelSize = StagePageVizConstants.stageClusterLabelSize;
265+
clusterLabelSize = StagePageVizConstants.clusterLabelSize;
266+
stageClusterLabelSize = StagePageVizConstants.stageClusterLabelSize;
257267
}
258268
svgContainer.selectAll("g.cluster").each(function() {
259269
var cluster = d3.select(this);
@@ -283,7 +293,7 @@ function drawClusterLabel(d3cluster, fontSize) {
283293
.attr("x", labelX)
284294
.attr("y", labelY)
285295
.attr("text-anchor", "end")
286-
.style("font-size", fontSize)
296+
.style("font-size", fontSize + "px")
287297
.text(labelText);
288298
}
289299

@@ -303,12 +313,12 @@ function resizeSvg(svg) {
303313
}));
304314
var endX = VizConstants.svgMarginX +
305315
toFloat(d3.max(allClusters, function(e) {
306-
var t = d3.select(e)
316+
var t = d3.select(e);
307317
return getAbsolutePosition(t).x + toFloat(t.attr("width"));
308318
}));
309319
var endY = VizConstants.svgMarginY +
310320
toFloat(d3.max(allClusters, function(e) {
311-
var t = d3.select(e)
321+
var t = d3.select(e);
312322
return getAbsolutePosition(t).y + toFloat(t.attr("height"));
313323
}));
314324
var width = endX - startX;
@@ -338,7 +348,7 @@ function drawCrossStageEdges(edges, svgContainer) {
338348
if (!dagreD3Marker.empty()) {
339349
svgContainer
340350
.append(function() { return dagreD3Marker.node().cloneNode(true); })
341-
.attr("id", "marker-arrow")
351+
.attr("id", "marker-arrow");
342352
svgContainer.selectAll("g > path").attr("marker-end", "url(#marker-arrow)");
343353
svgContainer.selectAll("g.edgePaths def").remove(); // We no longer need these
344354
}
@@ -394,12 +404,13 @@ function connectRDDs(fromRDDId, toRDDId, edgesContainer, svgContainer) {
394404
toPos.x += delta;
395405
}
396406

407+
var points;
397408
if (fromPos.y == toPos.y) {
398409
// If they are on the same rank, curve the middle part of the edge
399410
// upward a little to avoid interference with things in between
400411
// e.g. _______
401412
// _____/ \_____
402-
var points = [
413+
points = [
403414
[fromPos.x, fromPos.y],
404415
[fromPos.x + (toPos.x - fromPos.x) * 0.2, fromPos.y],
405416
[fromPos.x + (toPos.x - fromPos.x) * 0.3, fromPos.y - 20],
@@ -413,7 +424,7 @@ function connectRDDs(fromRDDId, toRDDId, edgesContainer, svgContainer) {
413424
// /
414425
// |
415426
// _____/
416-
var points = [
427+
points = [
417428
[fromPos.x, fromPos.y],
418429
[fromPos.x + (toPos.x - fromPos.x) * 0.4, fromPos.y],
419430
[fromPos.x + (toPos.x - fromPos.x) * 0.6, toPos.y],

0 commit comments

Comments
 (0)