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/21 10:08:54 UTC

[GitHub] [echarts] nanxi1994 opened a new issue #14736: 一对多的形变添加textContent会导致图表不能显示

nanxi1994 opened a new issue #14736:
URL: https://github.com/apache/echarts/issues/14736


   ### Version
   5.1.0
   
   ### Reproduction link
   [https://codepen.io/nanxi1994/pen/ExZLNNB](https://codepen.io/nanxi1994/pen/ExZLNNB)
   
   ### Steps to reproduce
   var PIE_COLORS = [
       '#e06343', '#37a354', '#b55dba', '#b5bd48', '#8378EA', '#96BFFF'
   ];
   var ANIMATION_DURATION_UPDATE = 1500;
   
   var RAW_DATA = [[1425139200000,34,0.13,2,"MD","ZD","P0"],[1425225600000,28,0.71,1.5,"MB","ZD","P1"],[1425312000000,23,0.9,2.8,"MA","ZC","P2"],[1425398400000,21,0.58,6,"MB","ZC","P3"],[1425484800000,14,0.1,1.6,"MC","ZA","P4"],[1425571200000,21,0.6,7.7,"MC","ZA","P5"],[1425657600000,23,0.31,2.6,"MC","ZC","P6"],[1425744000000,34,0.74,2.4,"MD","ZE","P7"],[1425830400000,14,0.59,2.3,"MB","ZD","P8"],[1425916800000,18,0.85,5.1,"MB","ZB","P9"],[1426003200000,36,0.96,1.2,"MC","ZC","P10"],[1426089600000,18,0.28,2.5,"MA","ZC","P11"],[1426176000000,20,0.62,6,"MB","ZD","P12"],[1426262400000,32,0.79,1.7,"MB","ZA","P13"],[1426348800000,17,0.58,4.4,"MD","ZB","P14"],[1426435200000,23,0.77,3,"MB","ZA","P15"],[1426521600000,39,0.87,4.6,"MC","ZA","P16"],[1426608000000,15,0.7,6,"MB","ZC","P17"]];
   
   
   $.when(
       $.getScript('https://cdn.jsdelivr.net/npm/echarts-simple-transform@1.0.0/dist/ecSimpleTransform.min.js')
   ).done(function () {
   
       init();
   
       var currentIsPie = false;
       setScatterOption();
   
       setInterval(function () {
           if (currentIsPie) {
               currentIsPie = false;
               setScatterOption();
           }
           else {
               currentIsPie = true;
               setPieOption();
           }
       }, 3000);
   
   });
   
   
   
   function init() {
   
       echarts.registerTransform(ecSimpleTransform.aggregate);
   
       var baseOption = {
           dataset: [{
               id: 'raw_dataset',
               dimensions: ['DATE', 'COUNT', 'PRICE', 'WEIGHT', 'M_TAG', 'Z_TAG', 'ID'],
               source: RAW_DATA
           }, {
               id: 'mTagSum_dataset',
               fromDatasetId: 'raw_dataset',
               transform: {
                   type: 'ecSimpleTransform:aggregate',
                   config: {
                       resultDimensions: [
                           { from: 'COUNT', method: 'sum' },
                           { from: 'PRICE', method: 'sum' },
                           { from: 'WEIGHT', method: 'sum' },
                           { from: 'M_TAG' }
                       ],
                       groupBy: 'M_TAG'
                   }
               }
           }],
           tooltip: {}
       };
   
       myChart.setOption(baseOption, { lazyUpdate: true });
   }
   
   function setScatterOption() {
       var option = {
           grid: {
               containLabel: true
           },
           xAxis: {
               name: 'PRICE'
           },
           yAxis: {
               name: 'COUNT'
           },
           series: {
               type: 'custom',
               coordinateSystem: 'cartesian2d',
               animationDurationUpdate: ANIMATION_DURATION_UPDATE,
               datasetId: 'raw_dataset',
               encode: {
                   itemName: 'ID',
                   x: 'PRICE',
                   y: 'COUNT',
                   tooltip: ['PRICE', 'COUNT', 'WEIGHT']
               },
               renderItem: function (params, api) {
                   var pos = api.coord([
                       api.value('PRICE'),
                       api.value('COUNT')
                   ]);
                   return {
                       type: 'circle',
                       morph: true,
                       shape: {
                           cx: pos[0],
                           cy: pos[1],
                           r: 10
                       },
                       style: {
                           text:api.value('COUNT'),
                           fill: '#5470c6'
                       },
                       transition: ['shape', 'style']
                   };
               }
           }
       };
   
       myChart.setOption(option, {
           replaceMerge: ['xAxis', 'yAxis'],
           transition: {
               from: { seriesIndex: 0, dimension: 'M_TAG' },
               to: { seriesIndex: 0, dimension: 'M_TAG' }
           }
       });
   }
   
   function setPieOption() {
       var option = {
           series: {
               type: 'custom',
               coordinateSystem: 'none',
               animationDurationUpdate: ANIMATION_DURATION_UPDATE,
               datasetId: 'mTagSum_dataset',
               encode: {
                   itemName: 'ID',
                   value: 'COUNT',
                   tooltip: ['PRICE', 'COUNT', 'WEIGHT']
               },
               renderItem: function (params, api) {
                   var context = params.context;
                   if (!context.layout) {
                       context.layout = true;
                       var totalValue = 0;
                       for (var i = 0; i < params.dataInsideLength; i++) {
                           totalValue += api.value('COUNT', i);
                       }
                       var angles = [];
                       var colors = [];
                       var currentAngle = -Math.PI / 2;
                       for (var i = 0; i < params.dataInsideLength; i++) {
                           colors.push(PIE_COLORS[i]);
                           var angle = api.value('COUNT', i) / totalValue * Math.PI * 2;
                           angles.push([currentAngle, angle + currentAngle - 0.01]);
                           currentAngle += angle;
                       }
                       context.angles = angles;
                       context.colors = colors;
                   }
   
                   var width = myChart.getWidth();
                   var height = myChart.getHeight();
                   return {
                       type: 'sector',
                       morph: true,
                       shape: {
                           cx: width / 2,
                           cy: height / 2,
                           r: Math.min(width, height) / 3,
                           r0: Math.min(width, height) / 5,
                           startAngle: context.angles[params.dataIndex][0],
                           endAngle: context.angles[params.dataIndex][1],
                           clockwise: true
                       },
                       style: {
                           text:api.value('COUNT'),
                           fill: context.colors[params.dataIndex]
                       },
                       transition: ['shape', 'style']
                   };
               }
           }
       };
   
       myChart.setOption(option, {
           replaceMerge: ['xAxis', 'yAxis', 'viusalMap'],
           transition: {
               from: { seriesIndex: 0, dimension: 'M_TAG' },
               to: { seriesIndex: 0, dimension: 'M_TAG' }
           }
       });
   }
   
   
   官方示例图自定义系列中的聚合分割形变图,添加styte.text就可以复现
   
   ### What is expected?
   显示标签
   
   ### What is actually happening?
   图形不能正常显示
   
   ---
   一对一、多对一的形变都可以正常显示,只有一对多形变时会产生这个问题
   
   <!-- This issue is generated by echarts-issue-helper. DO NOT REMOVE -->
   <!-- This issue is in English. DO NOT REMOVE -->


-- 
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 #14736: 一对多的形变添加textContent会导致图表不能显示

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






-- 
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] pissang commented on issue #14736: 一对多的形变添加textContent会导致图表不能显示

Posted by GitBox <gi...@apache.org>.
pissang commented on issue #14736:
URL: https://github.com/apache/echarts/issues/14736#issuecomment-938309035


   Should be fixed in 5.2.0


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org

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] pissang closed issue #14736: 一对多的形变添加textContent会导致图表不能显示

Posted by GitBox <gi...@apache.org>.
pissang closed issue #14736:
URL: https://github.com/apache/echarts/issues/14736


   


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org

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