提交 f585243a 编写于 作者: K kener

数值轴优化 用户同时设定min、max优先级更高

上级 5bd71930
......@@ -449,7 +449,7 @@ define(function (require) {
* 极值计算
*/
function _calculateValue() {
if (isNaN(option.min) || isNaN(option.max)) {
if (isNaN(option.min - 0) || isNaN(option.max - 0)) {
// 有一个没指定都得算
// 数据整形
var oriData; // 原始数据
......@@ -571,32 +571,38 @@ define(function (require) {
}
}
}
//console.log(_min,_max,'vvvvv111111')
_min = isNaN(option.min - 0)
? (_min - Math.abs(_min * option.boundaryGap[0]))
: (option.min - 0); // 指定min忽略boundaryGay[0]
_max = isNaN(option.max - 0)
? (_max + Math.abs(_max * option.boundaryGap[1]))
: (option.max - 0); // 指定max忽略boundaryGay[1]
if (_min == _max) {
if (_max === 0) {
// 修复全0数据
_max = option.power > 0 ? option.power : 1;
}
// 修复最大值==最小值时数据整形
else if (_max > 0) {
_min = _max / option.splitNumber;
}
else { // _max < 0
_max = _max / option.splitNumber;
}
}
_reformValue(option.scale);
}
else {
_hasData = true;
// 用户指定min max就不多管闲事了
_min = option.min - 0; // 指定min忽略boundaryGay[0]
_max = option.max - 0; // 指定max忽略boundaryGay[1]
customerDefine = true;
_customerValue();
}
//console.log(_min,_max,'vvvvv111111')
_min = isNaN(option.min)
? (_min - Math.abs(_min * option.boundaryGap[0]))
: option.min; // 指定min忽略boundaryGay[0]
_max = isNaN(option.max)
? (_max + Math.abs(_max * option.boundaryGap[1]))
: option.max; // 指定max忽略boundaryGay[1]
if (_min == _max) {
if (_max === 0) {
// 修复全0数据
_max = option.power > 0 ? option.power : 1;
}
// 修复最大值==最小值时数据整形
else if (_max > 0) {
_min = _max / option.splitNumber;
}
else { // _max < 0
_max = _max / option.splitNumber;
}
}
_reformValue(option.scale);
}
/**
......@@ -783,6 +789,18 @@ define(function (require) {
}
_reformLabelData();
}
function _customerValue() {
var splitNumber = option.splitNumber;
var precision = option.precision;
var splitGap = (_max - _min) / splitNumber;
_valueList = [];
for (var i = 0; i <= splitNumber; i++) {
_valueList.push((_min + splitGap * i).toFixed(precision) - 0);
}
_reformLabelData();
}
function _reformLabelData() {
_valueLabel = [];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册