You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@echarts.apache.org by GitBox <gi...@apache.org> on 2019/04/10 03:07:02 UTC

[GitHub] [incubator-echarts] quick-sort opened a new issue #10248: 使用dataset数据时,series.label.formatter使用function(params){},params.value的值为dataset中所有列,而不是该series对应的那一列的数据

quick-sort opened a new issue #10248: 使用dataset数据时,series.label.formatter使用function(params){},params.value的值为dataset中所有列,而不是该series对应的那一列的数据
URL: https://github.com/apache/incubator-echarts/issues/10248
 
 
   ### Version
   4.2.1
   
   ### Steps to reproduce
   https://echarts.baidu.com/examples/editor.html?c=dataset-simple1
   
   option = {
       legend: {},
       tooltip: {},
       dataset: {
           dimensions: ['product', '2015', '2016', '2017'],
           source: [
               {product: 'Matcha Latte', '2015': 43.3, '2016': 85.8, '2017': 93.7},
               {product: 'Milk Tea', '2015': 83.1, '2016': 73.4, '2017': 55.1},
               {product: 'Cheese Cocoa', '2015': 86.4, '2016': 65.2, '2017': 82.5},
               {product: 'Walnut Brownie', '2015': 72.4, '2016': 53.9, '2017': 39.1}
           ]
       },
       xAxis: {type: 'category'},
       yAxis: {},
       // Declare several bar series, each will be mapped
       // to a column of dataset.source by default.
       series: [
           {type: 'bar',
           encode: {x: 'product', y:'2015'},
               label: {
                   show: true,
                   formatter: a => JSON.stringify(a.value)
               }
           }
       ]
   };
   
   猜测问题出在https://github.com/apache/incubator-echarts/blob/master/src/chart/bar/helper.js#L29
   参数中缺一个dimIndex的参数,其它图表类型下也存在类似问题,不仅仅是bar
   最终参数传递到
   https://github.com/apache/incubator-echarts/blob/master/src/model/mixin/dataFormat.js#L87
   
   建议参考
   https://github.com/apache/incubator-echarts/blob/master/src/chart/helper/labelHelper.js#L33
   可获取该series对应的列的值
   
   ### What is expected?
   series.label.formatter = function(params){}
   params.value应该是该series对应的列的值
   
   ### What is actually happening?
   params.value获得的是所有列的值的数组
   
   <!-- This issue is generated by echarts-issue-helper. 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


With regards,
Apache Git Services

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