Skip to content
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

sunburst improvements #184

Merged
merged 4 commits into from
Mar 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions panoramix/assets/javascripts/modules/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
var d3 = require('d3');

/*
Utility function that takes a d3 svg:text selection and a max width, and splits the
text's text across multiple tspan lines such that any given line does not exceed max width

If text does not span multiple lines AND adjustedY is passed, will set the text to the passed val
*/
function wrapSvgText(text, width, adjustedY) {
var lineHeight = 1; // ems

text.each(function () {
var text = d3.select(this),
words = text.text().split(/\s+/),
word,
line = [],
lineNumber = 0,
x = text.attr("x"),
y = text.attr("y"),
dy = parseFloat(text.attr("dy")),
tspan = text.text(null)
.append("tspan")
.attr("x", x)
.attr("y", y)
.attr("dy", dy + "em");

var didWrap = false;

for (var i = 0; i < words.length; i++) {
word = words[i];
line.push(word);
tspan.text(line.join(" "));

if (tspan.node().getComputedTextLength() > width) {
line.pop(); // remove word that pushes over the limit
tspan.text(line.join(" "));
line = [word];
tspan = text.append("tspan")
.attr("x", x)
.attr("y", y)
.attr("dy", ++lineNumber * lineHeight + dy + "em")
.text(word);

didWrap = true;
}
}
if (!didWrap && typeof adjustedY !== "undefined") {
tspan.attr("y", adjustedY);
}
});
}

module.exports = {
wrapSvgText: wrapSvgText
};
43 changes: 29 additions & 14 deletions panoramix/assets/visualizations/sunburst.css
Original file line number Diff line number Diff line change
@@ -1,24 +1,39 @@
.sunburst text.middle{
text-anchor: middle;
.sunburst text {
shape-rendering: crispEdges;
}

.sunburst #sequence {
.sunburst path {
stroke: #333;
stroke-width: 0.5px;
}

.sunburst #legend {
padding: 10px 0 0 3px;
.sunburst .center-label {
text-anchor: middle;
fill: #000;
pointer-events: none;
}
.sunburst .path-percent {
font-size: 4em;
}
.sunburst .path-metrics {
font-size: 1.75em;
}
.sunburst .path-ratio {
font-size: 1.2em;
}

.sunburst #sequence text, #legend text {
.sunburst .breadcrumbs text {
font-weight: 600;
fill: #fff;
font-size: 1.2em;
text-anchor: middle;
fill: #000;
}

.sunburst path {
stroke: #fff;
/* dashboard specific */
.dashboard .sunburst text {
font-size: 1em;
}

.sunburst #percentage {
.dashboard .sunburst .path-percent {
font-size: 2.5em;
}

.dashboard .sunburst .path-metrics {
font-size: 1em;
}
Loading