-
Notifications
You must be signed in to change notification settings - Fork 28.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-7298] Harmonize style of new visualizations #5942
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,9 +52,9 @@ | |
*/ | ||
|
||
var VizConstants = { | ||
svgMarginX: 20, | ||
svgMarginY: 20, | ||
stageSep: 50, | ||
svgMarginX: 16, | ||
svgMarginY: 16, | ||
stageSep: 40, | ||
graphPrefix: "graph_", | ||
nodePrefix: "node_", | ||
stagePrefix: "stage_", | ||
|
@@ -63,14 +63,16 @@ var VizConstants = { | |
}; | ||
|
||
var JobPageVizConstants = { | ||
clusterLabelSize: 11, | ||
stageClusterLabelSize: 14 | ||
} | ||
clusterLabelSize: 12, | ||
stageClusterLabelSize: 14, | ||
rankSep: 40 | ||
}; | ||
|
||
var StagePageVizConstants = { | ||
clusterLabelSize: 14, | ||
stageClusterLabelSize: 18 | ||
} | ||
stageClusterLabelSize: 14, | ||
rankSep: 40 | ||
}; | ||
|
||
/* | ||
* Show or hide the RDD DAG visualization. | ||
|
@@ -149,11 +151,11 @@ function renderDagVizForStage(svgContainer) { | |
var dot = metadata.select(".dot-file").text(); | ||
var containerId = VizConstants.graphPrefix + metadata.attr("stage-id"); | ||
var container = svgContainer.append("g").attr("id", containerId); | ||
renderDot(dot, container); | ||
renderDot(dot, container, StagePageVizConstants.rankSep); | ||
|
||
// Round corners on RDDs | ||
// Round corners on rectangles | ||
svgContainer | ||
.selectAll("g.node rect") | ||
.selectAll("rect") | ||
.attr("rx", "5") | ||
.attr("ry", "5"); | ||
} | ||
|
@@ -207,7 +209,13 @@ function renderDagVizForJob(svgContainer) { | |
} | ||
|
||
// Actually render the stage | ||
renderDot(dot, container); | ||
renderDot(dot, container, JobPageVizConstants.rankSep); | ||
|
||
// Round corners on rectangles | ||
container | ||
.selectAll("rect") | ||
.attr("rx", "4") | ||
.attr("ry", "4"); | ||
|
||
// If there are any incoming edges into this graph, keep track of them to render | ||
// them separately later. Note that we cannot draw them now because we need to | ||
|
@@ -223,12 +231,13 @@ function renderDagVizForJob(svgContainer) { | |
} | ||
|
||
/* Render the dot file as an SVG in the given container. */ | ||
function renderDot(dot, container) { | ||
function renderDot(dot, container, rankSep) { | ||
var escaped_dot = dot | ||
.replace(/</g, "<") | ||
.replace(/>/g, ">") | ||
.replace(/"/g, "\""); | ||
var g = graphlibDot.read(escaped_dot); | ||
g.graph().rankSep = rankSep; | ||
var renderer = new dagreD3.render(); | ||
renderer(container, g); | ||
} | ||
|
@@ -248,12 +257,13 @@ function metadataContainer() { return d3.select("#dag-viz-metadata"); } | |
* In general, the clustering support for dagre-d3 is quite limited at this point. | ||
*/ | ||
function drawClusterLabels(svgContainer, forJob) { | ||
var clusterLabelSize, stageClusterLabelSize; | ||
if (forJob) { | ||
var clusterLabelSize = JobPageVizConstants.clusterLabelSize; | ||
var stageClusterLabelSize = JobPageVizConstants.stageClusterLabelSize; | ||
clusterLabelSize = JobPageVizConstants.clusterLabelSize; | ||
stageClusterLabelSize = JobPageVizConstants.stageClusterLabelSize; | ||
} else { | ||
var clusterLabelSize = StagePageVizConstants.clusterLabelSize; | ||
var stageClusterLabelSize = StagePageVizConstants.stageClusterLabelSize; | ||
clusterLabelSize = StagePageVizConstants.clusterLabelSize; | ||
stageClusterLabelSize = StagePageVizConstants.stageClusterLabelSize; | ||
} | ||
svgContainer.selectAll("g.cluster").each(function() { | ||
var cluster = d3.select(this); | ||
|
@@ -283,7 +293,7 @@ function drawClusterLabel(d3cluster, fontSize) { | |
.attr("x", labelX) | ||
.attr("y", labelY) | ||
.attr("text-anchor", "end") | ||
.style("font-size", fontSize) | ||
.style("font-size", fontSize + "px") | ||
.text(labelText); | ||
} | ||
|
||
|
@@ -303,12 +313,12 @@ function resizeSvg(svg) { | |
})); | ||
var endX = VizConstants.svgMarginX + | ||
toFloat(d3.max(allClusters, function(e) { | ||
var t = d3.select(e) | ||
var t = d3.select(e); | ||
return getAbsolutePosition(t).x + toFloat(t.attr("width")); | ||
})); | ||
var endY = VizConstants.svgMarginY + | ||
toFloat(d3.max(allClusters, function(e) { | ||
var t = d3.select(e) | ||
var t = d3.select(e); | ||
return getAbsolutePosition(t).y + toFloat(t.attr("height")); | ||
})); | ||
var width = endX - startX; | ||
|
@@ -338,7 +348,7 @@ function drawCrossStageEdges(edges, svgContainer) { | |
if (!dagreD3Marker.empty()) { | ||
svgContainer | ||
.append(function() { return dagreD3Marker.node().cloneNode(true); }) | ||
.attr("id", "marker-arrow") | ||
.attr("id", "marker-arrow"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oops, thanks for catching these semi-colons. |
||
svgContainer.selectAll("g > path").attr("marker-end", "url(#marker-arrow)"); | ||
svgContainer.selectAll("g.edgePaths def").remove(); // We no longer need these | ||
} | ||
|
@@ -394,12 +404,13 @@ function connectRDDs(fromRDDId, toRDDId, edgesContainer, svgContainer) { | |
toPos.x += delta; | ||
} | ||
|
||
var points; | ||
if (fromPos.y == toPos.y) { | ||
// If they are on the same rank, curve the middle part of the edge | ||
// upward a little to avoid interference with things in between | ||
// e.g. _______ | ||
// _____/ \_____ | ||
var points = [ | ||
points = [ | ||
[fromPos.x, fromPos.y], | ||
[fromPos.x + (toPos.x - fromPos.x) * 0.2, fromPos.y], | ||
[fromPos.x + (toPos.x - fromPos.x) * 0.3, fromPos.y - 20], | ||
|
@@ -413,7 +424,7 @@ function connectRDDs(fromRDDId, toRDDId, edgesContainer, svgContainer) { | |
// / | ||
// | | ||
// _____/ | ||
var points = [ | ||
points = [ | ||
[fromPos.x, fromPos.y], | ||
[fromPos.x + (toPos.x - fromPos.x) * 0.4, fromPos.y], | ||
[fromPos.x + (toPos.x - fromPos.x) * 0.6, toPos.y], | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could put this in
renderDagViz
itself to reduce the duplication, since we do it for stages tooThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah but that uses 5px and this uses 4, so it's slightly different.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh I see. I didn't realize the difference was intentional
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it's because those are smaller; it looked a bit better this way.