Skip to content

Commit 1dfcda4

Browse files
committed
Better nicing for pow scales.
1 parent 9bf5583 commit 1dfcda4

6 files changed

Lines changed: 10 additions & 10 deletions

File tree

d3.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(function(){d3 = {version: "1.20.1"}; // semver
1+
(function(){d3 = {version: "1.20.2"}; // semver
22
if (!Date.now) Date.now = function() {
33
return +new Date;
44
};
@@ -2245,7 +2245,7 @@ d3.scale.linear = function() {
22452245
};
22462246

22472247
function d3_scale_linearNice(dx) {
2248-
dx = Math.pow(10, Math.round(Math.log(dx) / Math.log(10)) - 1);
2248+
dx = Math.pow(10, Math.round(Math.log(dx) / Math.LN10) - 1);
22492249
return {
22502250
floor: function(x) { return Math.floor(x / dx) * dx; },
22512251
ceil: function(x) { return Math.ceil(x / dx) * dx; },
@@ -2382,7 +2382,7 @@ d3.scale.pow = function() {
23822382
scale.tickFormat = tick.tickFormat;
23832383

23842384
scale.nice = function() {
2385-
return scale.domain(d3_scale_nice(scale.domain(), d3_scale_niceDefault));
2385+
return scale.domain(d3_scale_nice(scale.domain(), d3_scale_linearNice));
23862386
};
23872387

23882388
scale.exponent = function(x) {

d3.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
d3 = {version: "1.20.1"}; // semver
1+
d3 = {version: "1.20.2"}; // semver

src/scale/linear.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ d3.scale.linear = function() {
9191
};
9292

9393
function d3_scale_linearNice(dx) {
94-
dx = Math.pow(10, Math.round(Math.log(dx) / Math.log(10)) - 1);
94+
dx = Math.pow(10, Math.round(Math.log(dx) / Math.LN10) - 1);
9595
return {
9696
floor: function(x) { return Math.floor(x / dx) * dx; },
9797
ceil: function(x) { return Math.ceil(x / dx) * dx; },

src/scale/pow.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ d3.scale.pow = function() {
3131
scale.tickFormat = tick.tickFormat;
3232

3333
scale.nice = function() {
34-
return scale.domain(d3_scale_nice(scale.domain(), d3_scale_niceDefault));
34+
return scale.domain(d3_scale_nice(scale.domain(), d3_scale_linearNice));
3535
};
3636

3737
scale.exponent = function(x) {

tests/test-scale-pow.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ nice():
4343
[ 1.100, 10.900 ] -> 1.000, 11.000
4444
[ 10.900, 1.100 ] -> 11.000, 1.000
4545
[ 0.700, 11.001 ] -> 0.000, 12.000
46-
[ 123.100, 6.700 ] -> 124.000, 6.000
47-
[ 0.000, 0.490 ] -> 0.000, 1.000
46+
[ 123.100, 6.700 ] -> 130.000, 0.000
47+
[ 0.000, 0.490 ] -> 0.000, 0.500
4848
[ 0.100, 1.000, 2.500, 3.000, 10.900 ] -> 0.000, 1.000, 2.500, 3.000, 11.000
4949

0 commit comments

Comments
 (0)