Skip to content

Commit 5041eaa

Browse files
Fixed critical bug with autorotate logic
1 parent 0aa4a24 commit 5041eaa

116 files changed

Lines changed: 5611 additions & 206 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"dependencies": {
1010
"d3": ">=3.5.2"
1111
},
12-
"version": "2.1.4",
12+
"version": "2.1.5",
1313
"homepage": "dimplejs.org",
1414
"authors": [
1515
"johnkiernander <[email protected]>"

dist/dimple.latest.js

Lines changed: 49 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
// Create the stub object
4040
var dimple = {
41-
version: "2.1.4",
41+
version: "2.1.5",
4242
plot: {},
4343
aggregateMethod: {}
4444
};
@@ -1925,60 +1925,62 @@
19251925
});
19261926
}
19271927
// Rotate labels, this can only be done once the formats are set
1928-
if (axis.autoRotateLabel && (axis.measure === null || axis.measure === undefined)) {
1929-
if (axis === firstX) {
1930-
// If the gaps are narrower than the widest label display all labels horizontally
1931-
widest = 0;
1932-
axis.shapes.selectAll("text").each(function () {
1933-
var w = this.getComputedTextLength();
1934-
widest = (w > widest ? w : widest);
1935-
});
1936-
if (widest > chartWidth / axis.shapes.selectAll("text")[0].length) {
1937-
rotated = true;
1938-
axis.shapes.selectAll("text")
1939-
.style("text-anchor", "start")
1940-
.each(function () {
1941-
var rec = this.getBBox();
1942-
d3.select(this)
1943-
.attr("transform", "rotate(90," + rec.x + "," + (rec.y + (rec.height / 2)) + ") translate(-5, 0)");
1944-
});
1945-
} else {
1946-
// For redraw operations we need to clear the transform
1947-
rotated = false;
1948-
axis.shapes.selectAll("text")
1949-
.style("text-anchor", "middle")
1950-
.attr("transform", "");
1951-
}
1952-
} else if (axis.position === "x") {
1953-
// If the gaps are narrower than the widest label display all labels horizontally
1954-
widest = 0;
1955-
axis.shapes.selectAll("text")
1956-
.each(function () {
1928+
if (axis.measure === null || axis.measure === undefined) {
1929+
if (axis.autoRotateLabel) {
1930+
if (axis === firstX) {
1931+
// If the gaps are narrower than the widest label display all labels horizontally
1932+
widest = 0;
1933+
axis.shapes.selectAll("text").each(function () {
19571934
var w = this.getComputedTextLength();
19581935
widest = (w > widest ? w : widest);
19591936
});
1960-
if (widest > chartWidth / axis.shapes.selectAll("text")[0].length) {
1961-
rotated = true;
1937+
if (widest > chartWidth / axis.shapes.selectAll("text")[0].length) {
1938+
rotated = true;
1939+
axis.shapes.selectAll("text")
1940+
.style("text-anchor", "start")
1941+
.each(function () {
1942+
var rec = this.getBBox();
1943+
d3.select(this)
1944+
.attr("transform", "rotate(90," + rec.x + "," + (rec.y + (rec.height / 2)) + ") translate(-5, 0)");
1945+
});
1946+
} else {
1947+
// For redraw operations we need to clear the transform
1948+
rotated = false;
1949+
axis.shapes.selectAll("text")
1950+
.style("text-anchor", "middle")
1951+
.attr("transform", "");
1952+
}
1953+
} else if (axis.position === "x") {
1954+
// If the gaps are narrower than the widest label display all labels horizontally
1955+
widest = 0;
19621956
axis.shapes.selectAll("text")
1963-
.style("text-anchor", "end")
19641957
.each(function () {
1965-
var rec = this.getBBox();
1966-
d3.select(this)
1967-
.attr("transform", "rotate(90," + (rec.x + rec.width) + "," + (rec.y + (rec.height / 2)) + ") translate(5, 0)");
1958+
var w = this.getComputedTextLength();
1959+
widest = (w > widest ? w : widest);
19681960
});
1969-
} else {
1970-
// For redraw operations we need to clear the transform
1971-
rotated = false;
1972-
axis.shapes.selectAll("text")
1973-
.style("text-anchor", "middle")
1974-
.attr("transform", "");
1961+
if (widest > chartWidth / axis.shapes.selectAll("text")[0].length) {
1962+
rotated = true;
1963+
axis.shapes.selectAll("text")
1964+
.style("text-anchor", "end")
1965+
.each(function () {
1966+
var rec = this.getBBox();
1967+
d3.select(this)
1968+
.attr("transform", "rotate(90," + (rec.x + rec.width) + "," + (rec.y + (rec.height / 2)) + ") translate(5, 0)");
1969+
});
1970+
} else {
1971+
// For redraw operations we need to clear the transform
1972+
rotated = false;
1973+
axis.shapes.selectAll("text")
1974+
.style("text-anchor", "middle")
1975+
.attr("transform", "");
1976+
}
19751977
}
1978+
} else {
1979+
rotated = false;
1980+
axis.shapes.selectAll("text")
1981+
.style("text-anchor", "middle")
1982+
.attr("transform", "");
19761983
}
1977-
} else {
1978-
rotated = false;
1979-
axis.shapes.selectAll("text")
1980-
.style("text-anchor", "middle")
1981-
.attr("transform", "");
19821984
}
19831985
if (axis.titleShape !== null && axis.titleShape !== undefined) {
19841986
axis.titleShape.remove();

dist/dimple.latest.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)