mirror of https://github.com/vitalif/dimple
Use tick step to calculate a smarter _getFormat when values are small.
Thanks to flot library for algorithm (https://github.com/flot/flot/blob/master/jquery.flot.js#L1696) Closes #124.master
parent
ecadee96df
commit
a89d33176e
|
@ -40,7 +40,7 @@
|
|||
return (n === 0 ? 0 : d3.format(",." + dp + "f")(n / Math.pow(1000, chunks)) + suffix);
|
||||
};
|
||||
} else {
|
||||
dp = (len <= 1 ? 1 : 0);
|
||||
dp = -Math.floor(Math.log(this._tick_step) / Math.LN10);
|
||||
returnFormat = d3.format(",." + dp + "f");
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -218,6 +218,8 @@
|
|||
step = ticks[1] - ticks[0];
|
||||
// Get the remainder
|
||||
remainder = ((this._max - this._min) % step).toFixed(0);
|
||||
// Store the tick step if needed to calculate _getFormat.
|
||||
this._tick_step = step;
|
||||
|
||||
// If the remainder is not zero
|
||||
if (remainder !== 0) {
|
||||
|
|
Loading…
Reference in New Issue