apache / echarts

Apache ECharts is a powerful, interactive charting and data visualization library for browser
https://echarts.apache.org
Apache License 2.0
60.36k stars 19.61k forks source link

[Bug] pie tooltip.formatter lable.formatter params[0].dimensionNames value is empty when use enode option since v5.2.0, v5.1.2 is ok #20244

Open merfais opened 2 months ago

merfais commented 2 months ago

Version

since 5.2

Link to Minimal Reproduction

https://echarts.apache.org/examples/en/editor.html?code=PYBwLglsB2AEC8sDeAoWsAmBDMWDOApmAFywDaa6ylVsewArgE4DGBpFttZA5ALJZoDLABtYAdWBMA1jwA0sAIwAWBTwDEAMW0B2AAx75sAKwBdOTS68AktDwgCLSDCOLja9ToAiegMxeAQSNlc0tufiwIaDACaEE2V18PbQA2AGEDYNMw2FCuTAgAW1i8KDsOHPQeLCcIADcIMABPAH0mAnwYFpYcAgBzKVa44vlK2Grahua2jvpobt6BplaIDFH8qprIKdb2zvmemKXWlmARRiZ1jZ4MZhwynhzs2gBfSjy6AiYIAjwK2lQ-WaDlIPBAPyutCYWAwEAYf3IPGUegApEYePo0R9aLFThh2NQNrBGgRCgA5LDFUFbeqNXazLqHfqDFrDAiQrh1UQMAk3O7OaCPfIvCxA4BnSAgUiAjYAMykhRwMSYAAoCABKQlE2CnOxnAgAOnOfTV6rGb2Foq4JMKAGVmiICTL8qdzkxSCqAB6a-AAPmQsHaYGYcE9BuwuDIACZTABuWAWriJ9CJj6OvqxDDSkWwMDikSS7MoF6xoA&version=5.3.0

Steps to Reproduce

option = {
  dataset: [
    {
      source: [
        ['Manual Work', 14, '#FFF700', 5],
        ['Inspection', 15, '#7D03DA', 4],
        ['Maintenance', 13, '#FF6C00', 4]
      ],
      dimensions: [
        'activity_reason_category_name',
        'activity_reason_category_id',
        'activity_reason_category_colour',
        'duration'
      ]
    }
  ],
  series: [
    {
      type: 'pie',
      radius: ['40%', '70%'],
      encode: {
        itemName: 'activity_reason_category_name',
        value: 'duration'
      },
      tooltip: {
        formatter(e) {
          console.log(e)
        }
      },
      itemStyle: {
        color: (x) => { return x.data[2]; }
      }
    }
  ],
  legend: {}, tooltip: {}
};

Current Behavior

{
    "componentType": "series",
    "componentSubType": "pie",
    "componentIndex": 0,
    "seriesType": "pie",
    "seriesIndex": 0,
    "seriesId": "\u0000series\u00000\u00000",
    "seriesName": "series\u00000",
    "name": "Maintenance",
    "dataIndex": 2,
    "data": [
        "Maintenance",
        13,
        "#FF6C00",
        4
    ],
    "value": [
        "Maintenance",
        13,
        "#FF6C00",
        4
    ],
    "color": "#FF6C00",
    "dimensionNames": [],  // this is empty
    "encode": {
        "value": [
            3
        ]
    },
    "$vars": [
        "seriesName",
        "name",
        "value",
        "percent"
    ],
    "percent": 30.77,
    "marker": "<span style=\"display:inline-block;margin-right:4px;border-radius:10px;width:10px;height:10px;background-color:#FF6C00;\"></span>"
}

Expected Behavior

{
    "componentType": "series",
    "componentSubType": "pie",
    "componentIndex": 0,
    "seriesType": "pie",
    "seriesIndex": 0,
    "seriesId": "\u0000series\u00000\u00000",
    "seriesName": "series\u00000",
    "name": "Maintenance",
    "dataIndex": 2,
    "data": [
        "Maintenance",
        13,
        "#FF6C00",
        4
    ],
    "value": [
        "Maintenance",
        13,
        "#FF6C00",
        4
    ],
    "color": "#FF6C00",
    "dimensionNames": [],  // expect ['activity_reason_category_name', 'activity_reason_category_id', 'activity_reason_category_colour', 'duration']
    "encode": {
        "value": [
            3
        ]
    },
    "$vars": [
        "seriesName",
        "name",
        "value",
        "percent"
    ],
    "percent": 30.77,
    "marker": "<span style=\"display:inline-block;margin-right:4px;border-radius:10px;width:10px;height:10px;background-color:#FF6C00;\"></span>"
}

Environment

- OS: any
- Browser: any
- Framework: any

Any additional comments?

No response

helgasoft commented 2 months ago

The observation is correct - discrepancy between versions 5.1.2- and 5.2.0+. However I could not find any note about dimensionNames in the API, in such case this is not a bug, just an internal update. Also, dimensionNames is redundant for pies since only the value counts. And dimensionNames is already known from dataset.dimensions.