apache / echarts

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

[Bug] Pie Chart slices data labels percentage decimal values are different when compared with pie chart in Excel for Same Data #20033

Open DilipSingh06 opened 2 months ago

DilipSingh06 commented 2 months ago

Version

5.5.0

Link to Minimal Reproduction

https://jsfiddle.net/j4zaouqg/1/

Steps to Reproduce

<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">

Brand | Dollars-CY-NR -- | -- MARS HALLOWEEN FUN SIZE DSP 128/19.55 OZ | $17,575,019.62 SNICKERS STD 48/1.86 OZ | $11,808,228.56 M&MS PEANUT SHARE SIZE 24/3.27 OZ | $7,742,048.94 KIT KAT KS 24/3 OZ | $7,570,503.55 REESES CUP KS 24/2.8 OZ | $7,535,862.50 FASTBREAK KS 18/3.5 OZ | $6,508,903.08 REESES BIG CUP KS 16/2.8 OZ | $6,461,155.17 SNICKERS 2 TO GO 24/3.29 OZ | $6,114,186.00 REESES CUP STD 36/1.5 OZ | $5,810,792.40 OTHERS | $189,262,395.95

1) Plot a pie chart with the above data in Echarts and also in Excel directly. 2) If you notice the "SNICKERS 2 TO GO 24/3.29 OZ" data label in Excel shows as 2.30% whereas in the Echarts it shows as 2.29%.

Current Behavior

There is a difference in percentage decimal values when we try to plot pie chart in excel vs in echarts with the same data. This difference increases when the data is more and the number of slices gets restricted to less numbers.

As per our investigation we saw that excel is rounding the number to the given precision but echarts is trimming it to the given precison.

Please find the screenshots for the same. Plotted Pie chart with same data in Echarts website using Echarts Existing Samples and modifying the data. Echarts Website Sample Pie Chart

Plotted Pie chart with same data in Our Project using Echarts library. Echarts Pie Chart

Plotted Pie chart with same data in Excel. Excel pie chart

Expected Behavior

There should not be any difference in the percentage decimal values when the data is same.

Environment

- OS:
- Browser:
- Framework:

Any additional comments?

No response

echarts-bot[bot] commented 2 months ago

I'm sorry to close this issue for it lacks the necessary title. Please provide a descriptive and as concise as possible title to describe your problems or requests and then the maintainers or I will reopen this issue.

Every good bug report or feature request starts with a title. Your issue title is a critical element as it's the first thing maintainers see.

A good issue title makes it easier for maintainers to understand what the issue is, easily locate it, and know what steps they'll need to take to fix it.

Moreover, it's better to include keywords, as this makes it easier to find the issue self and similar issues in searches.

Ovilia commented 2 months ago

This is probably because Pie Seris of Apache ECharts uses Largest remainders method. Source code is here.

If you add the percentage result from Excel, you can see that the total is 100.01, while ECharts ensures the total to always be 100.