You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by GitBox <gi...@apache.org> on 2021/04/12 09:34:06 UTC

[GitHub] [echarts] zcsoniubi opened a new issue #14648: legend图例监听之后设置柱状图堆叠的总数...当不是最后一个series时...label显示的数据会发生闪烁

zcsoniubi opened a new issue #14648:
URL: https://github.com/apache/echarts/issues/14648


   不要关..我去https://ecomfe.github.io/echarts-issue-helper/这个提示我内容过长...垃圾
   echarts: v5.0.2
   
   vue 项目
   
   ```html
   <div :ref="echartsAll[0]" :id="echartsAll[0]" style="height: 380px"></div>
   ```
   
   ```javascript
   data(){
   return {
   echartsAll: {
           //站点数量
           0: 'echartsBindNum'
         }
   }
   };
   monted(){
   let res = {
           "msg": "操作成功",
           "allTotal": 634,
           "code": 0,
           "siteTotal": 63,
           "data": [{
             "customerNum": 18,
             "fullName": "1村",
             "id": "1128905378558525031",
             "shortName": "1村",
             "siteNum": 2
           }, {
             "customerNum": 31,
             "fullName": "2村",
             "id": "1128905378558525032",
             "shortName": "2村",
             "siteNum": 2
           }, {
             "customerNum": 16,
             "fullName": "3村",
             "id": "1128905378558525033",
             "shortName": "3村",
             "siteNum": 2
           }, {
             "customerNum": 0,
             "fullName": "4社",
             "id": "1128905378558525034",
             "shortName": "4社",
             "siteNum": 1
           }, {
             "customerNum": 0,
             "fullName": "5服务中心",
             "id": "1128905378558525035",
             "shortName": "5服务中心",
             "siteNum": 1
           }, {
             "customerNum": 20,
             "fullName": "6村",
             "id": "1128905378558525036",
             "shortName": "6村",
             "siteNum": 2
           }, {
             "customerNum": 0,
             "fullName": "7企业办",
             "id": "1128905378558525037",
             "shortName": "7企业办",
             "siteNum": 1
           }, {
             "customerNum": 0,
             "fullName": "8食品站",
             "id": "1128905378558525038",
             "shortName": "8食品站",
             "siteNum": 1
           }, {
             "customerNum": 20,
             "fullName": "9村",
             "id": "1128905378558525039",
             "shortName": "9村",
             "siteNum": 2
           }, {
             "customerNum": 81,
             "fullName": "10关",
             "id": "1128905378558525040",
             "shortName": "10关",
             "siteNum": 2
           }],
           "phoneTotal": 571,
           "timestamp": "20210412143634",
           "parms": {
             "orgId": ["1128905378558525030"],
             "token": ["96ffb0f11aa64879826135ebffbae5280d090381d7d74448976ad83443f0e983"]
           }
         };
   
   this.drawEchartsBindNum(res);
   
   }
   
   drawEchartsBindNum(data) {
         let siteNum = data.siteTotal,
             phoneNum = data.phoneTotal;
         let selectData = ['机顶盒', '手机'];
         let selectShowAll = {
           [selectData[0]]: !0,
           [selectData[1]]: !0
         };
         let xName = [],
             data1 = [],
             data2 = [];
         data.data.forEach(function (item, i) {
           xName.push(item.shortName);
           data1.push(item.siteNum);
           data2.push(item.customerNum);
         });
         let option = {
           title: {
             text: '绑定总数:' + data.allTotal
           },
           tooltip: {
             trigger: 'axis'
           },
           legend: {
             formatter: function (name) {
               return name === '机顶盒' ? name + ':' + siteNum : name + ':' + phoneNum
             }
           },
           grid: {
             left: '10%',
             right: 40
           },
           dataZoom: [
             {
               type: 'slider',
               show: !0,
               xAxisIndex: [0],
               start: 0,
               end: 100
             },
             {
               type: 'inside',
               xAxisIndex: [0],
               start: 0,
               end: 100
             }
           ],
           xAxis: {
             data: xName
           },
           yAxis: {
             type: 'value',
             minInterval: 1,
             splitLine: {
               show: !1
             },
             axisLine: {
               show: !0
             }
           },
           series: [
             {
               type: 'bar',
               name: selectData[0],
               stack: '站点个数',
               data: data1,
               barMaxWidth: 25,
               label: {
                 show: !1,
                 position: 'top',
                 formatter: function (params) {
                   return params.value + (selectShowAll['手机'] ? data2[params.dataIndex] : 0)
                 }
               }
             },
             {
               type: 'bar',
               name: selectData[1],
               stack: '站点个数',
               data: data2,
               barMaxWidth: 25,
               label: {
                 show: !0,
                 position: 'top',
                 formatter: function (params) {
                   return params.value + (selectShowAll['机顶盒'] ? data1[params.dataIndex] : 0)
                 }
               }
             }
           ]
         };
         const echartsAll = this.echartsAll;
         this[echartsAll[0]].setOption(option);
         let vm = this;
         this[echartsAll[0]].on('legendselectchanged', function (e) {
           for (let i in e.selected) {
             if (e.selected.hasOwnProperty(i)) {
               selectShowAll[i] = e.selected[i]
             }
           }
           option.series[0].label.show = !selectShowAll['手机'];
           vm[echartsAll[0]].setOption(option);
         })
       }
   
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [echarts] echarts-bot[bot] closed issue #14648: legend图例监听之后设置柱状图堆叠的总数...当不是最后一个series时...label显示的数据会发生闪烁

Posted by GitBox <gi...@apache.org>.
echarts-bot[bot] closed issue #14648:
URL: https://github.com/apache/echarts/issues/14648


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [echarts] echarts-bot[bot] commented on issue #14648: legend图例监听之后设置柱状图堆叠的总数...当不是最后一个series时...label显示的数据会发生闪烁

Posted by GitBox <gi...@apache.org>.
echarts-bot[bot] commented on issue #14648:
URL: https://github.com/apache/echarts/issues/14648#issuecomment-817653086


   This issue is not created using [issue template](https://ecomfe.github.io/echarts-issue-helper/) so I'm going to close it. 🙊
   Sorry for this, but it helps save our maintainers' time so that more developers get helped.
   Feel free to create another issue using the issue template.
   
   If you think you have already made your point clear without the template, or your problem cannot be covered by it, you may re-open this issue again.
   
   这个 issue 未使用 [issue 模板](https://ecomfe.github.io/echarts-issue-helper/?lang=zh-cn) 创建,所以我将关闭此 issue。
   为此带来的麻烦我深表歉意,但是请理解这是为了节约社区维护者的时间,以更高效地服务社区的开发者群体。
   如果您愿意,请使用 issue 模板重新创建 issue。
   
   如果您认为虽然没有使用模板,但您已经提供了复现问题的充分描述,或者您的问题无法使用模板表达,也可以重新 open 这个 issue。


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org