Skip to content
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

Pie chart polyline should be optional #582

Open
what-am-i-doing opened this issue Aug 3, 2024 · 0 comments
Open

Pie chart polyline should be optional #582

what-am-i-doing opened this issue Aug 3, 2024 · 0 comments

Comments

@what-am-i-doing
Copy link

what-am-i-doing commented Aug 3, 2024

The pie chart in ImPlot has a feature where it adds a polyline around the edges of each pie slice for anti-aliasing. If you have not enabled multisampling in Dear ImGui, then this polyline is necessary to get AA. However, because it makes the pie slices larger, it causes them to occlude each other slightly, causing visible misalignment. If you do have multisampling in Dear ImGui, then they're completely unnecessary.

I have attached a comparison image. 8 samples = MSAA 8x. 1 sample = MSAA 1x (basically no multisampling). Polyline off = function RenderPieSlice had its final line "draw_list.AddPolygon..." commented out. Polyline off = left normal. AA fill on = Dear ImGui's Anti-Aliased Fill style option left on. AA fill off = the opposite.

pie chart comparison

To further emphasize the alignment/distortion issues caused by the polyline (see how the horizontal lines don't line up):

pie chart comparison cross

Something you'll probably notice in the main example image is that the polyline makes the pie chart's slices larger, causing the top slice to occlude the ones below it (observe how it seems to occupy the middle and stick past the others into the green area), and slice sizes to be distorted from what they should be. Interesting to note is that even with the polyline off, Dear ImGui's AA fill still seems to cause size distortions, albeit not as severe.

The most accurate pie slice sizes, and the ones that look best in terms of not having weird distortions, are the ones with both the polyline disabled and Dear ImGui's AA fill turned off. Of course, the one with no polyline, no AA fill, and no multisampling does have severe aliasing - but the one with multisampling, no polyline, and no AA fill looks correct. Dear ImGui's AA fill is easy to turn off from within an application, but disabling the pie chart polyline requires editing the source code.

I would suggest that there be a way to disable the pie chart's polyline / border, such as by adding another ImPlotPieChartFlags_ value, say ImPlotPieChartFlags_NoSliceBorder, and passing the flags from PlotPieChart further into RenderPieSlice, and then skipping the polyline if ImPlotPieChartFlags_NoSliceBorder was set. I'm afraid I'm not a programmer by trade and I don't know how to do pull/push/etc requests on GitHub so I can only describe the suggested changes and I do apologize for that. I don't want this to come across as "please do my work for me"; I have made the changes to my local copy (in my case, I just removed the polyline altogether) and I'm happy with how it looks, so this is more just a general suggestion that general users of the library might find helpful, or in particular, anyone else who ran across this visual issue.

It wouldn't necessarily be useful for everyone, but if someone already has multisampling enabled in Dear ImGui (and multisampling does have really low overhead for forward rendering engines on modern hardware) then being able to turn off the polyline does make pie charts look a lot better.

P.S. Thanks for making this excellent library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant