@@ -373,8 +373,7 @@ axes.autoBin = function(data,ax,nbins,is2d) {
373
373
// piggyback off autotick code to make "nice" bin sizes
374
374
var dummyax = {
375
375
type : ax . type === 'log' ? 'linear' : ax . type ,
376
- range :[ datamin , datamax ] ,
377
- exponentbase : ax . exponentbase
376
+ range :[ datamin , datamax ]
378
377
} ;
379
378
axes . autoTicks ( dummyax , size0 ) ;
380
379
var binstart = axes . tickIncrement (
@@ -691,7 +690,7 @@ function autoTickRound(ax) {
691
690
else {
692
691
if ( ! isNumeric ( dtick ) ) dtick = Number ( dtick . substr ( 1 ) ) ;
693
692
// 2 digits past largest digit of dtick
694
- ax . _tickround = 2 - Math . floor ( Math . log ( dtick ) / Math . LN10 + 0.01 ) ;
693
+ ax . _tickround = 2 - Math . floor ( Math . log ( dtick ) / Math . log ( ax . exponentbase ) + 0.01 ) ;
695
694
696
695
if ( ax . type === 'log' ) {
697
696
maxend = Math . pow ( 10 , Math . max ( ax . range [ 0 ] , ax . range [ 1 ] ) ) ;
@@ -1021,6 +1020,7 @@ function numFormat(v, ax, fmtoverride, hover) {
1021
1020
exponentFormat = fmtoverride || ax . exponentformat || 'B' ,
1022
1021
exponent = ax . _tickexponent ,
1023
1022
base = ax . exponentbase || 10 ,
1023
+ isBase10 = ( base === 10 ) ,
1024
1024
tickformat = ax . tickformat ;
1025
1025
1026
1026
// special case for hover: set exponent just for this value, and
@@ -1045,7 +1045,7 @@ function numFormat(v, ax, fmtoverride, hover) {
1045
1045
if ( tickformat ) return d3 . format ( tickformat ) ( v ) . replace ( / - / g, '\u2212' ) ;
1046
1046
1047
1047
// 'epsilon' - rounding increment
1048
- var e = Math . pow ( 10 , - tickRound ) / 2 ;
1048
+ var e = Math . pow ( base , - tickRound ) / 2 ;
1049
1049
1050
1050
// exponentFormat codes:
1051
1051
// 'e' (1.2e+6, default)
@@ -1069,8 +1069,8 @@ function numFormat(v, ax, fmtoverride, hover) {
1069
1069
v += e ;
1070
1070
// take out a common exponent, if any
1071
1071
// Special case for base 2 to follow "SI"
1072
- if ( exponent && base === 2 ) {
1073
- v = v / 1024 ;
1072
+ if ( exponent && base === 2 && exponentFormat === 'SI' ) {
1073
+ v = v / 1024 ;
1074
1074
1075
1075
// To make 1024 -> 1k
1076
1076
exponent -= 9 ;
@@ -1105,13 +1105,13 @@ function numFormat(v, ax, fmtoverride, hover) {
1105
1105
1106
1106
if ( exponentFormat === 'e' ||
1107
1107
( ( exponentFormat === 'SI' || exponentFormat === 'B' ) &&
1108
- ( exponent > 12 || exponent < - 15 ) ) ) {
1108
+ ( exponent > 12 || exponent < - 15 ) ) && isBase10 ) {
1109
1109
v += 'e' + signedExponent ;
1110
- } else if ( exponentFormat === 'E' && base === 10 ) {
1110
+ } else if ( exponentFormat === 'E' ) {
1111
1111
v += 'E' + signedExponent ;
1112
- } else if ( exponentFormat === 'B' && exponent === 9 && base === 10 ) {
1112
+ } else if ( exponentFormat === 'B' && exponent === 9 ) {
1113
1113
v += 'B' ;
1114
- } else if ( ( exponentFormat === 'SI' || exponentFormat === 'B' ) && ( base === 2 || base === 10 ) ) {
1114
+ } else if ( exponentFormat === 'SI' || exponentFormat === 'B' ) {
1115
1115
v += SIPREFIXES [ exponent / 3 + 5 ] ;
1116
1116
} else {
1117
1117
v += '×' + base + '<sup>' + signedExponent + '</sup>' ;
0 commit comments