Skip to content

[Bug] pie.minAngle bug when sector is not exceeding minAngle #20603

@Ovilia

Description

@Ovilia

Version

5.5.1

Link to Minimal Reproduction

https://echarts.apache.org/examples/zh/editor.html?c=sunburst-simple&code=MYewdgzgLgBA7gSwCZQBYwLwwLYE8DCqAhgE5QB0A5gKZQDqyaAFAJQDcAUKJLKtQpVSwseQqQo0oACX6CorTt2gwSmGEwCyRNOWwIwTRClQAaGHwFCWMAFQwADOQAc1gPQwATJy7hlwAB5qRmgw7l4-PDDAuGoWcqGenAA2tDDQ4gCCYJQpalo6AAoAkrYwAIzkHmXJqdRgSFk51GrpZI25ANTqAKzdCWVO9tZ2-ajkxYq-sAAOIPpQEADiJNR1agDaHDAw6wFm0QC6Jls7qiPaY6AQTK1Q7dTWXXsqpaPkEPo3UJnZKY9RuCOJ3WZxgbyuTDqDV-DxgT38ZlBbw-Bih93-h2O212CIBBw4B28t3uagAtG9iqVHAAWboANk4aJhLW-bWZXSYHgA7H13AMhq8LuMipNIrN5hAAEJJACuzSwm2xz0xwKRQohxJhGNxap0KK-PyaGMBWNOgp0EKZRrhUR15rG-qtfxtKqVuMOBO8IGmUAQ4DUAG8ThBqCQENQIAAuGBB7bbKC4abUaMAcmm4ZTpu2SG0RGjirj21jhbjYCI2GTMBTREzJxLMAAbkRZZWyvY63GAL5ZuPF-tliupgBGtfr2ybLejHg7207HaBhZIRCQCBlUZ29kRC7jSSIQ-oSWjfbjJBA3yglc3M5gADMQCRsNoLyRUwGh52j8BO6OS3ewFAAGUEAAL0rDxqQ7bsOz0MB7mjWke2mZc4PKboTig7ZKCXaZUAQYAjw7A9qArf91wLQtj0LBMk1TWYklwJJ9GoH96wgYgaJja9C3FUjox4hZllWMAuJgDCx2gBjK0oktoFPABrSsUywoSWLHRiwGoBhjCnESxPrYDozbdt6z03sROoxS6IYpjVMLNiiA46TuLmXiYH4qUW10ns7ITFICLHONZJABThxbWyS3UzTGFQHSAtMwsDPKexjJLOdC3xWcOE7NggA

Steps to Reproduce

In the above demo, we have two pie sectors with value 2 and 10. With padAngle: 15, We first reserve 15 * 2 from 360 degrees for padding, and leaving with 360 - 15 * 2 = 330. For data 2 and 10, they should each have the angle of 330 / (2 + 10) * 2 = 55 and 330 / (2 + 10) * 10 = 275 degrees.

I use graphic.elements to draw two triangles with 55 and 275 degrees and it's clear that the pie pieces have wrong angles.

Current Behavior

The green pie piece is 45 degrees, which is the same as minAngle. But 55 degrees are larger than 45, and there is no other reason for it to be smaller.

Expected Behavior

Expected the green pie piece to be 55 degrees as the green triangle shows.

Environment

- OS:
- Browser:
- Framework:

Any additional comments?

This bug is cause by current implementation simplified as: angle = Math.max(angle, padAngle + minAngle) - padAngle. Which is not mathematically correct.

For example, in the deme's case, the piece has 55 degrees and all constrains meets (1. no piece should have an angle smaller than 45; 2. there are paddings each of 15 degrees) with it being 55 degrees and the other 275 degree and two paddings each being 15 degrees. But in fact, we are having the pieces with 45 degrees and 285 degrees with no obvious reason and breaking the ratio of data values to the angles of pie pieces.

This may be a subtle bug since the padAngle and minAngle is usually quite small. But it's always nice to make it work well in all cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions