fix: 修复图表带有e时total无法显示的问题

This commit is contained in:
陈劲松
2020-12-24 18:45:12 +08:00
committed by chenjinsong
parent 4cfd2221f4
commit 22e2ecb719
4 changed files with 35 additions and 10 deletions

View File

@@ -830,7 +830,7 @@
if(val===0){
val = Number(item.data[1]).toExponential(2);
}
sum +=val;
sum += self.numberWithEConvent(val);
str += `<div style="white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;display: flex; justify-content: space-between; min-width: 150px; max-width: 600px; line-height: 18px; font-size: 12px;">`;
str += `<div style="max-width: 500px;white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;"><span style='display:inline-block;margin-right:5px;border-radius:10px;width:15px;height:5px;background-color: ${color};}'></span>${tip?(tip.alias?tip.alias:tip.name):item.seriesName} </div>`;
str += `<div style="padding-left: 10px;">`;
@@ -1004,7 +1004,7 @@
if(val===0){
val = Number(item.data[1]).toExponential(2);
}
sum +=val;
sum += self.numberWithEConvent(val);
str += `<div style="white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;display: flex; justify-content: space-between; min-width: 150px; max-width: 600px; line-height: 18px; font-size: 12px;">`;
str += `<div style="max-width: 500px;white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;"><span style='display:inline-block;margin-right:5px;border-radius:10px;width:15px;height:5px;background-color: ${color};}'></span>${tip?(tip.alias?tip.alias:tip.name):item.seriesName} </div>`;
str += `<div style="padding-left: 10px;">`;

View File

@@ -737,7 +737,7 @@
if(val===0){
val = Number(item.data[1]).toExponential(2);
}
sum +=val;
sum += self.numberWithEConvent(val);
str += `<div style="white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;display: flex; justify-content: space-between; min-width: 150px; max-width: 600px; line-height: 18px; font-size: 12px;">`;
str += `<div style="max-width: 500px;white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;"><span style='display:inline-block;margin-right:5px;border-radius:10px;width:15px;height:5px;background-color: ${color};}'></span>${tip?(tip.alias?tip.alias:tip.name):item.seriesName} </div>`;
str += `<div style="padding-left: 10px;">`;
@@ -969,7 +969,7 @@
if(val===0){
val = Number(item.data[1]).toExponential(2);
}
sum +=val;
sum += self.numberWithEConvent(val);
str += `<div style="white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;display: flex; justify-content: space-between; min-width: 150px; max-width: 600px; line-height: 18px; font-size: 12px;">`;
str += `<div style="max-width: 500px;white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;"><span style='display:inline-block;margin-right:5px;border-radius:10px;width:15px;height:5px;background-color: ${color};}'></span>${tip?(tip.alias?tip.alias:tip.name):item.seriesName} </div>`;
str += `<div style="padding-left: 10px;">`;
@@ -1132,7 +1132,7 @@
if(val===0){
val = Number(item.data[1]).toExponential(2);
}
sum +=val;
sum += self.numberWithEConvent(val);
str += `<div style="white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;display: flex; justify-content: space-between; min-width: 150px; max-width: 600px; line-height: 18px; font-size: 12px;">`;
str += `<div style="max-width: 500px;white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;"><span style='display:inline-block;margin-right:5px;border-radius:10px;width:15px;height:5px;background-color: ${color};}'></span>${tip?(tip.alias?tip.alias:tip.name):item.seriesName} </div>`;
str += `<div style="padding-left: 10px;">`;
@@ -1803,7 +1803,6 @@
let copy=JSON.parse(JSON.stringify(data.data));
copy = copy.map(t=>parseFloat(t[1]))
let sum = eval(copy.join('+'));
item['total'] = sum;
}
})

View File

@@ -636,7 +636,7 @@
if(val===0){
val = Number(item.data[1]).toExponential(2);
}
sum +=val;
sum += self.numberWithEConvent(val);
str += `<div style="white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;display: flex; justify-content: space-between; min-width: 150px; max-width: 600px; line-height: 18px; font-size: 12px;">`;
str += `<div style="max-width: 200px;white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;"><span style='display:inline-block;margin-right:5px;border-radius:10px;width:15px;height:5px;background-color: ${color};}'></span>${tip?(tip.alias?tip.alias:tip.name):item.seriesName} </div>`;
str += `<div style="padding-left: 10px;">`;
@@ -894,7 +894,7 @@
if(val===0){
val = Number(item.data[1]).toExponential(2);
}
sum +=val;
sum += self.numberWithEConvent(val);
str += `<div style="white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;display: flex; justify-content: space-between; min-width: 150px; max-width: 600px; line-height: 18px; font-size: 12px;">`;
str += `<div style="max-width: 500px;white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;"><span style='display:inline-block;margin-right:5px;border-radius:10px;width:15px;height:5px;background-color: ${color};}'></span>${tip?(tip.alias?tip.alias:tip.name):item.seriesName} </div>`;
str += `<div style="padding-left: 10px;">`;
@@ -1051,7 +1051,7 @@
if(val===0){
val = Number(item.data[1]).toExponential(2);
}
sum +=val;
sum += self.numberWithEConvent(val);
str += `<div style="white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;display: flex; justify-content: space-between; min-width: 150px; max-width: 600px; line-height: 18px; font-size: 12px;">`;
str += `<div style="max-width: 500px;white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis;"><span style='display:inline-block;margin-right:5px;border-radius:10px;width:15px;height:5px;background-color: ${color};}'></span>${tip?(tip.alias?tip.alias:tip.name):item.seriesName} </div>`;
str += `<div style="padding-left: 10px;">`;

View File

@@ -156,7 +156,33 @@ Vue.mixin({
vm.tools.showTopBtn = wrap.scrollTop > 50;
vm.tools.tableHover = wrap.scrollTop > 50;
}, 100));
},
numberWithEConvent(num) {
if (num) {
if ((("" + num).indexOf('E') != -1) || (("" + num).indexOf('e') != -1)) {
let regExp = new RegExp('^((\\d+.?\\d+)[Ee]{1}(\\d+))$', 'ig');
let result = regExp.exec(num);
let resultValue = "";
let power = "";
if (result != null) {
resultValue = result[2];
power = result[3];
result = regExp.exec(num);
}
if (resultValue != "") {
if (power != "") {
let powVer = Math.pow(10, power);
resultValue = resultValue * powVer;
return resultValue;
}
}
} else {
return num;
}
}
return 0;
},
},
computed: {
getMenuList() {