@@ -6664,12 +6664,20 @@ d3 = function() {
66646664 dx = i0 , i0 = i1 , i1 = dx ;
66656665 dx = x0 , x0 = x1 , x1 = dx ;
66666666 }
6667- if ( nice = nice ( x1 - x0 ) ) {
6668- domain [ i0 ] = nice . floor ( x0 ) ;
6669- domain [ i1 ] = nice . ceil ( x1 ) ;
6670- }
6667+ domain [ i0 ] = nice . floor ( x0 ) ;
6668+ domain [ i1 ] = nice . ceil ( x1 ) ;
66716669 return domain ;
66726670 }
6671+ function d3_scale_niceStep ( step ) {
6672+ return {
6673+ floor : function ( x ) {
6674+ return Math . floor ( x / step ) * step ;
6675+ } ,
6676+ ceil : function ( x ) {
6677+ return Math . ceil ( x / step ) * step ;
6678+ }
6679+ } ;
6680+ }
66736681 function d3_scale_polylinear ( domain , range , uninterpolate , interpolate ) {
66746682 var u = [ ] , i = [ ] , j = 0 , k = Math . min ( domain . length , range . length ) - 1 ;
66756683 if ( domain [ k ] < domain [ 0 ] ) {
@@ -6731,8 +6739,8 @@ d3 = function() {
67316739 scale . tickFormat = function ( m , format ) {
67326740 return d3_scale_linearTickFormat ( domain , m , format ) ;
67336741 } ;
6734- scale . nice = function ( ) {
6735- d3_scale_nice ( domain , d3_scale_linearNice ) ;
6742+ scale . nice = function ( m ) {
6743+ d3_scale_nice ( domain , d3_scale_linearNice ( domain , m ) ) ;
67366744 return rescale ( ) ;
67376745 } ;
67386746 scale . copy = function ( ) {
@@ -6743,16 +6751,12 @@ d3 = function() {
67436751 function d3_scale_linearRebind ( scale , linear ) {
67446752 return d3 . rebind ( scale , linear , "range" , "rangeRound" , "interpolate" , "clamp" ) ;
67456753 }
6746- function d3_scale_linearNice ( dx ) {
6747- dx = Math . pow ( 10 , Math . round ( Math . log ( dx ) / Math . LN10 ) - 1 ) ;
6748- return dx && {
6749- floor : function ( x ) {
6750- return Math . floor ( x / dx ) * dx ;
6751- } ,
6752- ceil : function ( x ) {
6753- return Math . ceil ( x / dx ) * dx ;
6754- }
6755- } ;
6754+ function d3_scale_linearNice ( domain , m ) {
6755+ return d3_scale_niceStep ( m ? d3_scale_linearTickRange ( domain , m ) [ 2 ] : d3_scale_linearNiceStep ( domain ) ) ;
6756+ }
6757+ function d3_scale_linearNiceStep ( domain ) {
6758+ var extent = d3_scaleExtent ( domain ) , span = extent [ 1 ] - extent [ 0 ] ;
6759+ return Math . pow ( 10 , Math . round ( Math . log ( span ) / Math . LN10 ) - 1 ) ;
67566760 }
67576761 function d3_scale_linearTickRange ( domain , m ) {
67586762 var extent = d3_scaleExtent ( domain ) , span = extent [ 1 ] - extent [ 0 ] , step = Math . pow ( 10 , Math . floor ( Math . log ( span / m ) / Math . LN10 ) ) , err = m / span * step ;
@@ -6794,7 +6798,23 @@ d3 = function() {
67946798 return scale ;
67956799 } ;
67966800 scale . nice = function ( ) {
6797- linear . domain ( d3_scale_nice ( domain , nice ) . map ( log ) ) ;
6801+ function floor ( x ) {
6802+ return Math . pow ( base , Math . floor ( Math . log ( x ) / Math . log ( base ) ) ) ;
6803+ }
6804+ function ceil ( x ) {
6805+ return Math . pow ( base , Math . ceil ( Math . log ( x ) / Math . log ( base ) ) ) ;
6806+ }
6807+ linear . domain ( d3_scale_nice ( domain , log === d3_scale_logp ? {
6808+ floor : floor ,
6809+ ceil : ceil
6810+ } : {
6811+ floor : function ( x ) {
6812+ return - ceil ( - x ) ;
6813+ } ,
6814+ ceil : function ( x ) {
6815+ return - floor ( - x ) ;
6816+ }
6817+ } ) . map ( log ) ) ;
67986818 return scale ;
67996819 } ;
68006820 scale . ticks = function ( ) {
@@ -6826,25 +6846,6 @@ d3 = function() {
68266846 scale . copy = function ( ) {
68276847 return d3_scale_log ( linear . copy ( ) , base , log , pow , domain ) ;
68286848 } ;
6829- function nice ( ) {
6830- return log === d3_scale_logp ? {
6831- floor : floor ,
6832- ceil : ceil
6833- } : {
6834- floor : function ( x ) {
6835- return - ceil ( - x ) ;
6836- } ,
6837- ceil : function ( x ) {
6838- return - floor ( - x ) ;
6839- }
6840- } ;
6841- }
6842- function floor ( x ) {
6843- return Math . pow ( base , Math . floor ( Math . log ( x ) / Math . log ( base ) ) ) ;
6844- }
6845- function ceil ( x ) {
6846- return Math . pow ( base , Math . ceil ( Math . log ( x ) / Math . log ( base ) ) ) ;
6847- }
68486849 return d3_scale_linearRebind ( scale , linear ) ;
68496850 }
68506851 var d3_scale_logFormat = d3 . format ( ".0e" ) ;
@@ -6882,8 +6883,8 @@ d3 = function() {
68826883 scale . tickFormat = function ( m , format ) {
68836884 return d3_scale_linearTickFormat ( domain , m , format ) ;
68846885 } ;
6885- scale . nice = function ( ) {
6886- return scale . domain ( d3_scale_nice ( domain , d3_scale_linearNice ) ) ;
6886+ scale . nice = function ( m ) {
6887+ return scale . domain ( d3_scale_nice ( domain , d3_scale_linearNice ( domain , m ) ) ) ;
68876888 } ;
68886889 scale . exponent = function ( x ) {
68896890 if ( ! arguments . length ) return exponent ;
@@ -8647,9 +8648,7 @@ d3 = function() {
86478648 return scale ;
86488649 } ;
86498650 scale . nice = function ( m ) {
8650- return scale . domain ( d3_scale_nice ( scale . domain ( ) , function ( ) {
8651- return m ;
8652- } ) ) ;
8651+ return scale . domain ( d3_scale_nice ( scale . domain ( ) , m ) ) ;
86538652 } ;
86548653 scale . ticks = function ( m , k ) {
86558654 var extent = d3_scaleExtent ( scale . domain ( ) ) ;
0 commit comments