lapDog opened a new issue #11205: Stack堆叠柱图在X轴对应多个柱状条的时候无法获取柱状索引
URL: https://github.com/apache/incubator-echarts/issues/11205
 
 
   ### Version
   4.2.1
   
   ### Steps to reproduce
   堆叠柱状图在X轴(维度)对应多个指标时候,在使用tooltip formmat回调的时候无法获取当前柱子的索引(无法匹配指标).相关数据及配置如下:
   
   var measureData = [
                {
                        aggregatorName: "去重数",
                        field: "xx1",
                        fieldName: "平均处置时长",
                        unit:"小时"
                },
                {
                        aggregatorName: "去重数",
                        field: "xx2",
                        fieldName: "受理数",
                        unit:"件"
                }
   ];
   
   var option = {
        "tooltip": {
                "trigger": "axis",
                "axisPointer": {
                        "type": "shadow"
        },
        formatter: function (params) {
               var colorSpan = color => '<span 
style="display:inline-block;margin-right:5px;border-radius:10px;width:9px;height:9px;background-color:'
   color   '"></span>';
               let rez = '<p>'   params[0].axisValue   '</p>';
               console.log(params); //quite useful for debug
               params.forEach(item => {
   
                //TODO 我需要获取当前这个柱子在stack中的的索引
   
                //just test but failed
                   var seriesId = String(item.seriesId);
                   var index = seriesId.trim().split(" ")[1];
                   var measure = measureData[index];
   
                   //console.log(item); //quite useful for debug
                   var xx = '<p>'     colorSpan(item.color)   ' '   
measure.fieldName   '_'   item.seriesName   ': '   item.data   measure.unit   
'</p>'
                   rez  = xx;
               });
   
               return rez;      
        },
        "legend": {
                "type": "scroll",
                "data": ["咨询", "投诉", "求决", "其他", "咨询", "投诉", "求决", "其他"]
        },
        "grid": {
                "left": "3%",
                "right": "4%",
                "bottom": "3%",
                "containLabel": true
        },
        "xAxis": [{
                "type": "category",
                "data": ["街道1", "街道2", "街道3", "街道4", "街道5", "街道6"]
        }],
        "yAxis": [{
                "type": "value"
        }],
        "series": [{
                "name": "咨询",
                "type": "bar",
                "stack": "平均处置时长",
                "barMaxWidth": "30px",
                "data": [2.0266, 0, 0, 0, 0, 0]
        }, {
                "name": "投诉",
                "type": "bar",
                "stack": "平均处置时长",
                "barMaxWidth": "30px",
                "data": [1.6674, 3.7226, 2.7217, 1.6684, 2.2107, 1.3616]
        }, {
                "name": "求决",
                "type": "bar",
                "stack": "平均处置时长",
                "barMaxWidth": "30px",
                "data": [0.8988, 0, 0, 0, 0, 0]
        }, {
                "name": "其他",
                "type": "bar",
                "stack": "平均处置时长",
                "barMaxWidth": "30px",
                "data": [0, 0, 0, 1.7018, 0, 0]
        }, {
                "name": "咨询",
                "type": "bar",
                "stack": "受理数",
                "barMaxWidth": "30px",
                "data": [5, 0, 0, 0, 0, 0]
        }, {
                "name": "投诉",
                "type": "bar",
                "stack": "受理数",
                "barMaxWidth": "30px",
                "data": [33, 31, 29, 22, 23, 8]
        }, {
                "name": "求决",
                "type": "bar",
                "stack": "受理数",
                "barMaxWidth": "30px",
                "data": [1, 0, 0, 0, 0, 0]
        }, {
                "name": "其他",
                "type": "bar",
                "stack": "受理数",
                "barMaxWidth": "30px",
                "data": [0, 0, 0, 2, 0, 0]
        }]
   }
   
   ### What is expected?
   在tooltip formmat函数中获取params的所属柱子的索引
   
   ### What is actually happening?
   无法区别
   
   ---
   在多指标的情况,多个柱子无法区别当前柱子的索引,我看了官网文档及SO等并没有解决方案,希望给予支持。万分感谢。
   
   <!-- 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:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to