You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by "Ovilia (via GitHub)" <gi...@apache.org> on 2024/12/19 09:45:24 UTC

[I] [Bug] pie.minAngle bug when sector is not exceeding minAngle [echarts]

Ovilia opened a new issue, #20603:
URL: https://github.com/apache/echarts/issues/20603

   ### 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-oSWjfbjJBA3yglc3M5gADMQCRsNoLyRUwGh52j8BO6OS3ewFAAGUEAAL0rDxqQ7bsOz0MB7mjWke2mZc4PKboTig7ZKCXaZUAQYAjw7A9qArf91wLQtj0LBMk1TWYklwJJ9GoH96wgYgaJja9C3FUjox4hZllWMAuJgDCx2gBjK0oktoFPABrSsUywoSWLHRiwGoBhjCnESxPrYDozbdt6z03sROoxS6IYpjVMLNiiA46TuLmXiYH4qUW10ns7ITFICLHONZJABThxbWyS3U
 zTGFQHSAtMwsDPKexjJLOdC3xWcOE7NggA
   
   ### 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
   
   Expected the green pie piece to be 55 degrees as the green triangle shows.
   
   ### Expected 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.
   
   ### Environment
   
   ```markdown
   - OS:
   - Browser:
   - Framework:
   ```
   
   
   ### Any additional comments?
   
   This bug is cause by [current implementation](https://github.com/apache/echarts/blob/104df1bce95183ef89e604b5173fc48b8fef367e/src/chart/pie/pieLayout.ts#L174-L176) 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 no be a subtle bug since the `padAngle` and `minAngle` is usually quite small. But it's always nice to make it works well in all cases.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org