Skip to content

Commit

Permalink
Use style rather than attr for "text-anchor".
Browse files Browse the repository at this point in the history
This makes it easier to override via stylesheet.
  • Loading branch information
mbostock committed Oct 5, 2012
1 parent 59d5790 commit 60a2564
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions d3.v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -4418,7 +4418,7 @@
textEnter.attr("y", Math.max(tickMajorSize, 0) + tickPadding);
lineUpdate.attr("x2", 0).attr("y2", tickMajorSize);
textUpdate.attr("x", 0).attr("y", Math.max(tickMajorSize, 0) + tickPadding);
text.attr("dy", ".71em").attr("text-anchor", "middle");
text.attr("dy", ".71em").style("text-anchor", "middle");
pathUpdate.attr("d", "M" + range[0] + "," + tickEndSize + "V0H" + range[1] + "V" + tickEndSize);
break;
}
Expand All @@ -4431,7 +4431,7 @@
textEnter.attr("y", -(Math.max(tickMajorSize, 0) + tickPadding));
lineUpdate.attr("x2", 0).attr("y2", -tickMajorSize);
textUpdate.attr("x", 0).attr("y", -(Math.max(tickMajorSize, 0) + tickPadding));
text.attr("dy", "0em").attr("text-anchor", "middle");
text.attr("dy", "0em").style("text-anchor", "middle");
pathUpdate.attr("d", "M" + range[0] + "," + -tickEndSize + "V0H" + range[1] + "V" + -tickEndSize);
break;
}
Expand All @@ -4444,7 +4444,7 @@
textEnter.attr("x", -(Math.max(tickMajorSize, 0) + tickPadding));
lineUpdate.attr("x2", -tickMajorSize).attr("y2", 0);
textUpdate.attr("x", -(Math.max(tickMajorSize, 0) + tickPadding)).attr("y", 0);
text.attr("dy", ".32em").attr("text-anchor", "end");
text.attr("dy", ".32em").style("text-anchor", "end");
pathUpdate.attr("d", "M" + -tickEndSize + "," + range[0] + "H0V" + range[1] + "H" + -tickEndSize);
break;
}
Expand All @@ -4457,7 +4457,7 @@
textEnter.attr("x", Math.max(tickMajorSize, 0) + tickPadding);
lineUpdate.attr("x2", tickMajorSize).attr("y2", 0);
textUpdate.attr("x", Math.max(tickMajorSize, 0) + tickPadding).attr("y", 0);
text.attr("dy", ".32em").attr("text-anchor", "start");
text.attr("dy", ".32em").style("text-anchor", "start");
pathUpdate.attr("d", "M" + tickEndSize + "," + range[0] + "H0V" + range[1] + "H" + tickEndSize);
break;
}
Expand Down
4 changes: 2 additions & 2 deletions d3.v2.min.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/svg/axis.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ d3.svg.axis = function() {
textEnter.attr("y", Math.max(tickMajorSize, 0) + tickPadding);
lineUpdate.attr("x2", 0).attr("y2", tickMajorSize);
textUpdate.attr("x", 0).attr("y", Math.max(tickMajorSize, 0) + tickPadding);
text.attr("dy", ".71em").attr("text-anchor", "middle");
text.attr("dy", ".71em").style("text-anchor", "middle");
pathUpdate.attr("d", "M" + range[0] + "," + tickEndSize + "V0H" + range[1] + "V" + tickEndSize);
break;
}
Expand All @@ -73,7 +73,7 @@ d3.svg.axis = function() {
textEnter.attr("y", -(Math.max(tickMajorSize, 0) + tickPadding));
lineUpdate.attr("x2", 0).attr("y2", -tickMajorSize);
textUpdate.attr("x", 0).attr("y", -(Math.max(tickMajorSize, 0) + tickPadding));
text.attr("dy", "0em").attr("text-anchor", "middle");
text.attr("dy", "0em").style("text-anchor", "middle");
pathUpdate.attr("d", "M" + range[0] + "," + -tickEndSize + "V0H" + range[1] + "V" + -tickEndSize);
break;
}
Expand All @@ -85,7 +85,7 @@ d3.svg.axis = function() {
textEnter.attr("x", -(Math.max(tickMajorSize, 0) + tickPadding));
lineUpdate.attr("x2", -tickMajorSize).attr("y2", 0);
textUpdate.attr("x", -(Math.max(tickMajorSize, 0) + tickPadding)).attr("y", 0);
text.attr("dy", ".32em").attr("text-anchor", "end");
text.attr("dy", ".32em").style("text-anchor", "end");
pathUpdate.attr("d", "M" + -tickEndSize + "," + range[0] + "H0V" + range[1] + "H" + -tickEndSize);
break;
}
Expand All @@ -97,7 +97,7 @@ d3.svg.axis = function() {
textEnter.attr("x", Math.max(tickMajorSize, 0) + tickPadding);
lineUpdate.attr("x2", tickMajorSize).attr("y2", 0);
textUpdate.attr("x", Math.max(tickMajorSize, 0) + tickPadding).attr("y", 0);
text.attr("dy", ".32em").attr("text-anchor", "start");
text.attr("dy", ".32em").style("text-anchor", "start");
pathUpdate.attr("d", "M" + tickEndSize + "," + range[0] + "H0V" + range[1] + "H" + tickEndSize);
break;
}
Expand Down
8 changes: 4 additions & 4 deletions test/svg/axis-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ suite.addBatch({
assert.equal(tick.attr("transform"), "translate(0.2,0)");
assert.equal(text.attr("y"), -9)
assert.equal(text.attr("dy"), "0em");
assert.equal(text.attr("text-anchor"), "middle");
assert.equal(text.style("text-anchor"), "middle");
assert.equal(text.text(), "0.2");
assert.equal(line.attr("y2"), -6);
assert.equal(path.attr("d"), "M0,-6V0H1V-6");
Expand All @@ -72,7 +72,7 @@ suite.addBatch({
assert.equal(tick.attr("transform"), "translate(0,0.2)");
assert.equal(text.attr("x"), 9)
assert.equal(text.attr("dy"), ".32em");
assert.equal(text.attr("text-anchor"), "start");
assert.equal(text.style("text-anchor"), "start");
assert.equal(text.text(), "0.2");
assert.equal(line.attr("x2"), 6);
assert.equal(path.attr("d"), "M6,0H0V1H6");
Expand All @@ -87,7 +87,7 @@ suite.addBatch({
assert.equal(tick.attr("transform"), "translate(0.2,0)");
assert.equal(text.attr("y"), 9)
assert.equal(text.attr("dy"), ".71em");
assert.equal(text.attr("text-anchor"), "middle");
assert.equal(text.style("text-anchor"), "middle");
assert.equal(text.text(), "0.2");
assert.equal(line.attr("y2"), 6);
assert.equal(path.attr("d"), "M0,6V0H1V6");
Expand All @@ -102,7 +102,7 @@ suite.addBatch({
assert.equal(tick.attr("transform"), "translate(0,0.2)");
assert.equal(text.attr("x"), -9)
assert.equal(text.attr("dy"), ".32em");
assert.equal(text.attr("text-anchor"), "end");
assert.equal(text.style("text-anchor"), "end");
assert.equal(text.text(), "0.2");
assert.equal(line.attr("x2"), -6);
assert.equal(path.attr("d"), "M-6,0H0V1H-6");
Expand Down

0 comments on commit 60a2564

Please sign in to comment.