浏览代码

fix intervals (#352)

tags/v1.6.3
David Schnurr 3 年前
committed by GitHub
父节点
当前提交
10de973608
找不到此签名对应的密钥 GPG 密钥 ID: 4AEE18F83AFDEB23
共有 1 个文件被更改,包括 9 次插入1 次删除
  1. +9
    -1
      src/js/utils/intervals.js

+ 9
- 1
src/js/utils/intervals.js 查看文件

@@ -69,7 +69,15 @@ function getChartIntervals(maxValue, minValue=0) {
normalMaxValue = normalMaxValue.toFixed(6); normalMaxValue = normalMaxValue.toFixed(6);


let intervals = getChartRangeIntervals(normalMaxValue, normalMinValue); let intervals = getChartRangeIntervals(normalMaxValue, normalMinValue);
intervals = intervals.map(value => value * Math.pow(10, exponent));
intervals = intervals.map(value => {
// For negative exponents we want to divide by 10^-exponent to avoid
// floating point arithmetic bugs. For instance, in javascript
// 6 * 10^-1 == 0.6000000000000001, we instead want 6 / 10^1 == 0.6
if (exponent < 0) {
return value / Math.pow(10, -exponent);
}
return value * Math.pow(10, exponent);
});
return intervals; return intervals;
} }




正在加载...
取消
保存