Bläddra i källkod

fix: 图表复制图例显示不全问题

Karsa 1 år sedan
förälder
incheckning
9bc64d5e30
1 ändrade filer med 10 tillägg och 15 borttagningar
  1. 10 15
      src/views/dataEntry_manage/mixins/chartPublic.js

+ 10 - 15
src/views/dataEntry_manage/mixins/chartPublic.js

@@ -2231,23 +2231,18 @@ export const chartSetMixin = {
       let dynamic_copyOptions = {
         legend: {
           labelFormatter: function () {
-            let count = 0
-            let reg = ''
-            // let newName = this.name.replace(/-/g, "—").replace(/\s/g, "").replace(reg, "$1<br/>");
-            let newName=''
-            if(this.currentLang == 'ch'){
-              count = widthNum > 1000 ? 510 / 14 : 15;
-              reg = new RegExp("(.{" + parseInt(count) + "})", "g");
-              newName = this.name.replace(/-/g, "—").replace(/\s/g, "").replace(/(/g, "(").replace(/)/g, ")").replace(reg, "$1<br/>");
-            }else{
-              // '<span style="color:#999">无英文名称</span>' 没有填写指标名称 显示为空
-              if(this.name.indexOf('<span style="color:#999">无英文名称</span>')!=-1) this.name=''
-              newName = this.name.replace(/(/g, "(").replace(/)/g, ")");
-            }
-            let finalName=  newName.substring(newName.length - 6, newName.length) === "<br/>)" ? newName.slice(0, newName.length - 6) + ")" : newName;
-            return finalName;
+            let count =  Math.floor(widthNum/2/15);//多少字数换行;
+            let reg2 = new RegExp("(.{" + count + "})", "g");
+              
+            let  newName = this.name.replace(/-/g, "—").replace(/\s/g, "").replace(/(/g, "(").replace(/)/g, ")").replace(reg2, "$1<br/>");
+            return newName;
           },
           itemWidth: widthNum > 1000 ? 530 : 235,
+          itemStyle: {
+            fontSize: 10,
+            color: this.chartInfo.ChartThemeStyle&&JSON.parse(this.chartInfo.ChartThemeStyle).legendOptions.itemStyle.color,
+            textOverflow:undefined
+          },
         },
         seasonLegend: {},
       };