echarts icon indicating copy to clipboard operation
echarts copied to clipboard

Pie Charts if all the data are 0, should show blank, not evenly divided the pie.

Open Hongmei225 opened this issue 10 years ago • 11 comments

问题简述 (One-line summary)

If there are for example 4 data elements and the values are all 0, it should show a blank pie, not a pie evenly divided by 4.

版本及环境 (Version & Environment)

  • ECharts 版本 (ECharts version): v3.1.10
  • 浏览器类型和版本 (Browser version): any browser
  • 操作系统类型和版本 (OS Version): windows7

current pie chart: Uploading piecurrent.p
piecurrent
ng…

重现步骤 (Steps to reproduce)

1.use the option provided to draw the piechart

期望结果 (Expected behaviour)

expected

可能哪里有问题 (What went wrong)

When sum is 0, assume all the parts are 2pi/N. In fact, 0 means occupy nothing no matter sum is 0 or not. The user should see nothing except the circle boundary to show no data at all.

ECharts配置项 (ECharts option)

option = {
                series: [
                  {
                      type: "pie",
                      radius: "65%",
                      itemStyle: {
                          normal: {
                              borderColor: '#fff',
                              borderWidth: '0'
                          },
                          emphasis: {
                              borderColor: '#fff',
                              borderWidth: '0'
                          }
                      },
                      label: {
                          normal: {
                              show: false
                          }
                      },
                      center: ["50%", "43%"],
                      data: [
                        {
                            "name": "21-40%",
                            "value": "0"
                        },
                        {
                            "name": "41-60%",
                            "value": "0"
                        },
                        {
                            "name": "61-80%",
                            "value": "0"
                        },
                        {
                            "name": "81-100%",
                            "value": "0"
                        }
                      ]
                  }
                ],
                color: [
                  "#FF8C00",
                  "#FFD700",
                  "#6B8E23",
                  "#3D3D3D"
                ],
                title: {
                    show: true,
                    text: "Sample",
                    left: "center",
                    top: "top"
                },
                legend: {
                    data: [
                      "21-40%",
                      "41-60%",
                      "61-80%",
                      "81-100%"
                    ],
                    left: 'center',
                    bottom: '10',
                    borderWidth: 1,
                    borderColor: '#FAAC58',
                },
                tooltip: {
                    show: true,
                    showContent: true,
                    trigger: 'item',
                    formatter: '{b}:<br />{c}',
                }

}

其他信息 (Other comments)

Hongmei225 avatar May 23 '16 11:05 Hongmei225

I am also facing the same issue. please fix it in the next release

jakkireddy avatar Jun 16 '16 08:06 jakkireddy

same problem here..

waliddoch avatar Feb 19 '19 12:02 waliddoch

This issue is closed due to not being active. Please feel free to open it again (for the author) or create a new one and reference this (for others) if you have further questions.

echarts-bot avatar Jun 28 '19 08:06 echarts-bot

Any updates?

Lipus-a avatar Nov 30 '20 21:11 Lipus-a

Any update on this . looking for the same solution

AbhaysinghBhosale avatar Mar 04 '21 12:03 AbhaysinghBhosale

stillShowZeroSum = true

AbhaysinghBhosale avatar Mar 08 '21 11:03 AbhaysinghBhosale

Try transform the data to [null, 0] instead of [0, 0]

Zhuzhenghao avatar May 11 '21 05:05 Zhuzhenghao

+1

fseitun avatar Sep 30 '21 14:09 fseitun

+1

stephen-bri avatar May 17 '22 22:05 stephen-bri

Waiting for this feature

Alexenon avatar Jul 04 '23 09:07 Alexenon

https://stackoverflow.com/a/78188257/15167500

When checking the numerical values upon data transmission, if it verifies and transmits null instead of 0 values, the chart interprets null as empty and will not display the respective set.

const values = [0, 0, 0, 0, 1];
const names = ['A', 'B', 'C', 'D', 'E'];

const data = values.map((v, i) => ({ name: names[i], value: v === 0 ? null : v }));

/* Result:
[
  { name: 'A', value: null },
  { name: 'B', value: null },
  { name: 'C', value: null },
  { name: 'D', value: null },
  { name: 'E', value: 1 }
]
*/

If all values are 0, then I believe it logically distributes the segments evenly in the circle, as they all represent equally zero value. Therefore, their ratio remains the same. I would rather introduce an option to interpret 0 as null in the diagram or not. Until such an option exists, this can be done manually as well.

rozsazoltan avatar Mar 19 '24 18:03 rozsazoltan