Skip to content

Commit

Permalink
Hidden Title Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkiernander committed Sep 13, 2013
1 parent f139e7b commit b4376b5
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 49 deletions.
50 changes: 26 additions & 24 deletions dist/dimple.v1.1.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -1387,31 +1387,33 @@ var dimple = {
}

// Add a title for the axis
axis.titleShape = this._group.append("text").attr("class", "axis title");
axis.titleShape
.attr("x", titleX)
.attr("y", titleY)
.attr("text-anchor", "middle")
.attr("transform", rotate)
.text((axis.categoryFields === null || axis.categoryFields === undefined || axis.categoryFields.length === 0 ? axis.measure : axis.categoryFields.join("/")))
.each(function () {
if (!chart.noFormats) {
d3.select(this)
.style("font-family", "sans-serif")
.style("font-size", (chartHeight / 35 > 10 ? chartHeight / 35 : 10) + "px");
}
});
if (!axis.hidden) {
axis.titleShape = this._group.append("text").attr("class", "axis title");
axis.titleShape
.attr("x", titleX)
.attr("y", titleY)
.attr("text-anchor", "middle")
.attr("transform", rotate)
.text((axis.categoryFields === null || axis.categoryFields === undefined || axis.categoryFields.length === 0 ? axis.measure : axis.categoryFields.join("/")))
.each(function () {
if (!chart.noFormats) {
d3.select(this)
.style("font-family", "sans-serif")
.style("font-size", (chartHeight / 35 > 10 ? chartHeight / 35 : 10) + "px");
}
});

// Offset Y position to baseline. This previously used dominant-baseline but this caused
// browser inconsistency
if (axis === firstX) {
axis.titleShape.each(function () {
d3.select(this).attr("y", titleY + this.getBBox().height / 1.65);
});
} else if (axis === firstY) {
axis.titleShape.each(function () {
d3.select(this).attr("x", titleX + this.getBBox().height / 1.65);
});
// Offset Y position to baseline. This previously used dominant-baseline but this caused
// browser inconsistency
if (axis === firstX) {
axis.titleShape.each(function () {
d3.select(this).attr("y", titleY + this.getBBox().height / 1.65);
});
} else if (axis === firstY) {
axis.titleShape.each(function () {
d3.select(this).attr("x", titleX + this.getBBox().height / 1.65);
});
}
}
// }
}, this);
Expand Down
Loading

0 comments on commit b4376b5

Please sign in to comment.