Skip to content

Commit

Permalink
Fixed critical bug with autorotate logic
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkiernander committed Jul 13, 2015
1 parent 0aa4a24 commit 5041eaa
Show file tree
Hide file tree
Showing 116 changed files with 5,611 additions and 206 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dependencies": {
"d3": ">=3.5.2"
},
"version": "2.1.4",
"version": "2.1.5",
"homepage": "dimplejs.org",
"authors": [
"johnkiernander <[email protected]>"
Expand Down
96 changes: 49 additions & 47 deletions dist/dimple.latest.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

// Create the stub object
var dimple = {
version: "2.1.4",
version: "2.1.5",
plot: {},
aggregateMethod: {}
};
Expand Down Expand Up @@ -1925,60 +1925,62 @@
});
}
// Rotate labels, this can only be done once the formats are set
if (axis.autoRotateLabel && (axis.measure === null || axis.measure === undefined)) {
if (axis === firstX) {
// If the gaps are narrower than the widest label display all labels horizontally
widest = 0;
axis.shapes.selectAll("text").each(function () {
var w = this.getComputedTextLength();
widest = (w > widest ? w : widest);
});
if (widest > chartWidth / axis.shapes.selectAll("text")[0].length) {
rotated = true;
axis.shapes.selectAll("text")
.style("text-anchor", "start")
.each(function () {
var rec = this.getBBox();
d3.select(this)
.attr("transform", "rotate(90," + rec.x + "," + (rec.y + (rec.height / 2)) + ") translate(-5, 0)");
});
} else {
// For redraw operations we need to clear the transform
rotated = false;
axis.shapes.selectAll("text")
.style("text-anchor", "middle")
.attr("transform", "");
}
} else if (axis.position === "x") {
// If the gaps are narrower than the widest label display all labels horizontally
widest = 0;
axis.shapes.selectAll("text")
.each(function () {
if (axis.measure === null || axis.measure === undefined) {
if (axis.autoRotateLabel) {
if (axis === firstX) {
// If the gaps are narrower than the widest label display all labels horizontally
widest = 0;
axis.shapes.selectAll("text").each(function () {
var w = this.getComputedTextLength();
widest = (w > widest ? w : widest);
});
if (widest > chartWidth / axis.shapes.selectAll("text")[0].length) {
rotated = true;
if (widest > chartWidth / axis.shapes.selectAll("text")[0].length) {
rotated = true;
axis.shapes.selectAll("text")
.style("text-anchor", "start")
.each(function () {
var rec = this.getBBox();
d3.select(this)
.attr("transform", "rotate(90," + rec.x + "," + (rec.y + (rec.height / 2)) + ") translate(-5, 0)");
});
} else {
// For redraw operations we need to clear the transform
rotated = false;
axis.shapes.selectAll("text")
.style("text-anchor", "middle")
.attr("transform", "");
}
} else if (axis.position === "x") {
// If the gaps are narrower than the widest label display all labels horizontally
widest = 0;
axis.shapes.selectAll("text")
.style("text-anchor", "end")
.each(function () {
var rec = this.getBBox();
d3.select(this)
.attr("transform", "rotate(90," + (rec.x + rec.width) + "," + (rec.y + (rec.height / 2)) + ") translate(5, 0)");
var w = this.getComputedTextLength();
widest = (w > widest ? w : widest);
});
} else {
// For redraw operations we need to clear the transform
rotated = false;
axis.shapes.selectAll("text")
.style("text-anchor", "middle")
.attr("transform", "");
if (widest > chartWidth / axis.shapes.selectAll("text")[0].length) {
rotated = true;
axis.shapes.selectAll("text")
.style("text-anchor", "end")
.each(function () {
var rec = this.getBBox();
d3.select(this)
.attr("transform", "rotate(90," + (rec.x + rec.width) + "," + (rec.y + (rec.height / 2)) + ") translate(5, 0)");
});
} else {
// For redraw operations we need to clear the transform
rotated = false;
axis.shapes.selectAll("text")
.style("text-anchor", "middle")
.attr("transform", "");
}
}
} else {
rotated = false;
axis.shapes.selectAll("text")
.style("text-anchor", "middle")
.attr("transform", "");
}
} else {
rotated = false;
axis.shapes.selectAll("text")
.style("text-anchor", "middle")
.attr("transform", "");
}
if (axis.titleShape !== null && axis.titleShape !== undefined) {
axis.titleShape.remove();
Expand Down
2 changes: 1 addition & 1 deletion dist/dimple.latest.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 5041eaa

Please sign in to comment.