-
-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow PieChartView to hide labels for tiny slices #3182
Conversation
@mgod Could you take a look too? |
restarting failed builds. |
@jjatie this implementation still has the bug described in this comment: #944 (comment) However, I think adding this behavior to the system even with the edge cases described would be a huge improvement over the existing behavior of labels for tiny slices. I'm mostly adding the comment here for some future developer confused by one of these edge cases doesn't have to dig too far. |
This is a problem that will always have trade offs. There is no perfect solution. As well, the more we do to accommodate edge cases the less deterministic it will be for the consumer. @liuxuan30 I won't have time to work on this one. |
@jjatie @liuxuan30 I do feel like the original solution for #944 is better than the #2062 version, even if the measurement bug gets fixed because it's much easier to understand and debug. Basically the #944 solution lets the developer set a There are still some cases where this drawing code would leave out labels that fit in the space (slices that are small, but happen to be along the x-axis, so would fit the label) and also some cases where very long labels will extend outside their slice. I think these edge cases are much more predictable, though, than the ones with complex measuring to see if the label fits and are also much more predictable to the developer. The very long label issue would not be a case of labels disappearing for no reason, but instead something a developer can look at and realize they should limit the length of their label text. I'd be happy to put together a new PR with this behavior, but only if both of you feel like it would be a reasonable solution here. @danielgindi didn't feel like it was magical enough, but it's been more than a year without a solution at this point. We could set a default minimum angle of 10 or 20 or something, which would probably resolve the small slices get overlapping labels problem for most developers. |
@mgod I'm in support of a new proposal. I'd ask that you branch from 4.0.0 to do so. |
I'm open to a better one, if your rework could fix the issue.
I assume #2062 and #944 are the same (I didn't take a closer look), but you mentioned here #944 is better, which is weird. Before you actually get started, we need to understand the gap. |
@rofreg (the author) is my cofounder and I'd love to have him chime in if he feels like it, but, basically, both #944 and #2062 solve the problem of tiny slices getting labels, though they do it in different ways. I believe he closed #944 because #2062 still solves the tiny slices getting labels problem and it had been about a year since he'd asked for clarification on what would need to be done for #944 to be considered acceptable. #944 adds a new CGFloat property #2062 (and this PR) add a new boolean property The only reason I consider #944 to be better than #2062 is that the edge cases where labels get draw/not draw when a human would choose otherwise are easy to understand in #944 and hard to understand in #2062. I believe this would still be true in an implementation fo #2062 that measured the correct geometry to see if the label would fit and that's much, much harder to code than the current implementation here. I don't think there's a version of this code that can get to 100% good behavior all the time, but I think either implementation will do a good job most of the time. |
Codecov Report
@@ Coverage Diff @@
## master #3182 +/- ##
==========================================
+ Coverage 22.98% 23.03% +0.04%
==========================================
Files 116 116
Lines 15542 15922 +380
Branches 272 303 +31
==========================================
+ Hits 3573 3668 +95
- Misses 11933 12221 +288
+ Partials 36 33 -3
Continue to review full report at Codecov.
|
@jjatie I should be able to. |
I've opened up #3218 against the 4.0.0 branch. I tried setting some default minimum for the pie chart, but on playing with the charts a bit, having a behavior that removes text from the chart without specifically opting in to it felt pretty bad to me, so I left it at 0 for the minimum angle that gets labels hidden. |
what should we target this for? 4.0 or 3.1? |
Closing this as we move to #3218 for 4.0 branch |
reimplemented #2062
Comes from #944