Skip to content

[Bug] Pie Incorrect percentage display #17745

@chiyu1996

Description

@chiyu1996

Version

5.4.0

Link to Minimal Reproduction

https://codepen.io/chiyu1996/pen/RwyqoEy

Steps to Reproduce

var chartDom = document.getElementById('main');
var myChart = echarts.init(chartDom);
var option;

option = {
tooltip: {
trigger: 'item',
formatter: '{a}
{b}: {c} ({d}%)'
},
legend: {
data: [
'Direct',
'Marketing',
'Search Engine',
'Email',
'Union Ads',
'Video Ads',
'Baidu',
'Google',
'Bing',
'Others'
]
},
series: [
{
name: 'Access From',
type: 'pie',
selectedMode: 'single',
radius: [0, '30%'],
label: {
position: 'inner',
fontSize: 14
},
labelLine: {
show: false
},
data: [
{ value: 1548, name: 'Search Engine' },
{ value: 775, name: 'Direct' },
{ value: 679, name: 'Marketing', selected: true }
]
},
{
name: 'Access From',
type: 'pie',
radius: ['45%', '60%'],
labelLine: {
length: 30
},
label: {
formatter: '{a|{a}}{abg|}\n{hr|}\n {b|{b}:}{c} {per|{d}%} ',
backgroundColor: '#F6F8FC',
borderColor: '#8C8D8E',
borderWidth: 1,
borderRadius: 4,
rich: {
a: {
color: '#6E7079',
lineHeight: 22,
align: 'center'
},
hr: {
borderColor: '#8C8D8E',
width: '100%',
borderWidth: 1,
height: 0
},
b: {
color: '#4C5058',
fontSize: 14,
fontWeight: 'bold',
lineHeight: 33
},
per: {
color: '#fff',
backgroundColor: '#4C5058',
padding: [3, 4],
borderRadius: 4
}
}
},
data: [
{ value: 0, name: 'Baidu' },
{ value: 0, name: 'Direct' },
{ value: 0, name: 'Email' },
{ value: 0, name: 'Google' },
{ value: 0, name: 'Union Ads' },
{ value: 0, name: 'Bing' },
{ value: 0, name: 'Video Ads' },
{ value: 0, name: 'Others' }
]
}
]
};

option && myChart.setOption(option);

Current Behavior

When all pie chart data are 0, the percentage is displayed as undefined

Expected Behavior

in v5.3.3, the percentage is displayed as 0

Environment

- OS:
- Browser:
- Framework:

Any additional comments?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions