fix:处理Y轴单位问题

This commit is contained in:
zhangyu
2020-09-22 16:14:37 +08:00
parent ffcdbe09df
commit 9e6643bf80
2 changed files with 37 additions and 6 deletions

View File

@@ -643,9 +643,9 @@ export default {
if(type==='Data'){ if(type==='Data'){
if(value>1){ if(value>1){
while(value>1000){ while(value>1024){
pow++; pow++;
value=value/1000 value=value/1024
} }
if(flow==='ceil'){ if(flow==='ceil'){
@@ -701,8 +701,39 @@ export default {
} }
}, },
Interval:function(value,copies,type){ Interval:function(value,copies,type){
if(type==='Data' || type==='DataRate' || type==='Misc'){ console.log(value,'Interval');
if(value<1024&&type==='Data'){
let interVal=value/copies; let interVal=value/copies;
return interVal
}
if(value<1000&&(type==='DataRate' || type==='Misc')){
let interVal=value/copies;
return interVal
}
if(type==='Data'){
let interVal=value/copies;
let pow=0;
if(interVal){
while(interVal>1024){
pow++;
interVal=interVal/1024;
}
interVal=Math.ceil(interVal)*Math.pow(1024,pow);
}
interVal = interVal || 1;
console.log(interVal);
return interVal
}
if(type==='DataRate' || type==='Misc'){
let interVal=value/copies;
let pow=0;
if(interVal){
while(interVal>1000){
pow++;
interVal=interVal/1000;
}
interVal=Math.ceil(interVal)*Math.pow(1000,pow);
}
interVal = interVal || 1; interVal = interVal || 1;
console.log(interVal); console.log(interVal);
return interVal return interVal

View File

@@ -511,7 +511,6 @@
maxValue=chartDataFormat.formatDatas(maxValue,unit.type,'ceil',unit.ascii); maxValue=chartDataFormat.formatDatas(maxValue,unit.type,'ceil',unit.ascii);
minValue=chartDataFormat.formatDatas(minValue,unit.type,'floor',unit.ascii); minValue=chartDataFormat.formatDatas(minValue,unit.type,'floor',unit.ascii);
let oldValue=maxValue; let oldValue=maxValue;
console.log(maxValue,'123123');
let dot=0; let dot=0;
if(maxValue==1){ if(maxValue==1){
dot++; dot++;
@@ -528,13 +527,13 @@
maxValue=Math.ceil(oldValue)/Math.pow(10,dot); maxValue=Math.ceil(oldValue)/Math.pow(10,dot);
dot++; dot++;
} }
let copies=chartDataFormat.copies(oldValue); let copies=chartDataFormat.copies(oldValue,unit.type);
console.log(oldValue,copies,maxValue); console.log(oldValue,copies,maxValue);
let oldDot=2; let oldDot=2;
if(maxValue<=1){ if(maxValue<=1){
oldDot=dot>6?6:dot; oldDot=dot>6?6:dot;
} }
// console.log(unit.compute(maxValue),unit.compute(minValue)); console.log(maxValue,copies,'123123');
var option = { var option = {
title:{ title:{
show:false, show:false,
@@ -754,6 +753,7 @@
show:false show:false
}, },
minInterval: chartDataFormat.Interval(maxValue,copies,unit.type), minInterval: chartDataFormat.Interval(maxValue,copies,unit.type),
maxInterval: chartDataFormat.Interval(maxValue,copies,unit.type),
axisTick: { axisTick: {
show: false, show: false,
}, },