eclipse / swtchart

Eclipse Public License 2.0
44 stars 41 forks source link

Improve Pie- and Doughnut Chart Labels and Layout #286

Open eselmeister opened 2 years ago

eselmeister commented 2 years ago

Have a look at the examples:

https://github.com/buchen/portfolio/pull/2597 https://gist.github.com/digedag/a708844ba36927aa9f74e831b78a6f4c

himanshu-balasamanta commented 2 years ago
eselmeister commented 2 years ago

The ComplexPieChartExample is a good test case to improve the above mentioned issues.

Screenshot from 2022-03-15 07-46-18

Let's discuss and coordinate the activities. Please let me know if you need help.

himanshu-balasamanta commented 2 years ago

Hi. Here by centring the chart, you mean something like this? As in no legend but only data is displayed on hover? image

himanshu-balasamanta commented 2 years ago

And as about displaying data on pie slices, what if we run into the problem faced below? image

himanshu-balasamanta commented 2 years ago

And as about displaying data on pie slices, what if we run into the problem faced below?

I mean, even if I do orient the text to be in accordance with pie slice, it can still become cluttered right?

himanshu-balasamanta commented 2 years ago

Does Something like this seem a good solution to centring the chart? ie. only show values on hover. image

himanshu-balasamanta commented 2 years ago

As about orienting the data aligned with pie slices, not a problem, can be done like this

eselmeister commented 2 years ago

The following example looks good:

https://github.com/buchen/portfolio/pull/2597 https://user-images.githubusercontent.com/1877409/152893547-a2b5900c-ddc5-42e3-a207-4ebe44e95ea2.png

@Himanshu-Balasamanta Do you think, it's possible to get something similar as above?

himanshu-balasamanta commented 2 years ago

It most certainly is. I will get on to working on it.

eselmeister commented 2 years ago

Great! Let me know if you need any assistance.

buchen commented 1 year ago

BTW, I have experimented with the labels - see the screenshot below

Bildschirm­foto 2022-12-04 um 06 59 46
eselmeister commented 1 year ago

Hi Andreas,

cool, that looks good! Can you create a Pull Request?

Best, Philip

On 04.12.22 07:02, Andreas Buchen wrote:

BTW, I have experimented with the labels https://github.com/buchen/portfolio/blob/master/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/util/chart/PieChart.java#L94-L154

  • see the screenshot below

Bildschirm­foto 2022-12-04 um 06 59 46 https://user-images.githubusercontent.com/587976/205476949-8874a9aa-8e13-476e-b562-85741e4530ed.png

— Reply to this email directly, view it on GitHub https://github.com/eclipse/swtchart/issues/286#issuecomment-1336329363, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFHUTZ36CQEU5YX4KWWUA3WLQXWDANCNFSM5QQJWSSQ. You are receiving this because you authored the thread.Message ID: @.***>

--

OpenChrom - the open source alternative for chromatography / mass spectrometry
Dr. Philip Wenig » Founder ***@***.***  »http://www.openchrom.net
csprunk commented 1 year ago

Thanks a lot for improving these!

  • centering the chart
  • aligning and shorten the labels
  • enable an export option to *.csv like in bar-, line- and scatter plots Anything else?

Not sure if it fits this issue or if it is even working as intended, but I noticed that the SWT charts enforce a minimum covered angle of 1 degree per item. If the plot contains too many items that should take less than 1 degree the results can look wrong, drawn angles for parent are off.

Context: org.eclipse.swtchart/src/org/eclipse/swtchart/model/Node.java, updateAngularBounds(), angleCovered and required.

I think a fix would either require to forego the 1 degree limit and/or to drop slices that are too small.

buchen commented 1 year ago

@csprunk writes:

Not sure if it fits this issue or if it is even working as intended, but I noticed that the SWT charts enforce a minimum covered angle of 1 degree per item.

It is a problem also for me. See here.

This is my understanding: the underlaying GraphicsContext SWT GC#fillArc only supports integers for startAngle and arcAngle. The current code applies an heuristic which then fails for many small slices.

buchen commented 1 year ago

@csprunk @eselmeister

the SWT charts enforce a minimum covered angle of 1 degree per item

For my project, I have done an alternative implementation. Instead of forcing the slices to be at least 1 degree, I am first assigning "free degrees" to the slices with 0 arc length (for example if rounding error lead to less than 360 degrees) and then I am inserting gaps to at least indicate that there is at least one slice not drawn. Because my data is typically sorted by size, there is one gap at the end.

Not sure if that works as general behavior. So far I am quite happy with the resulting charts. If you are interested, I could try to make a contribution (the existing algorithm in Node runs after each update - thus has to handle incomplete charts as well)

eselmeister commented 1 year ago

@buchen That sounds reasonable. I would be happy if you would like to contribute your alternative implementation. We could add an option to the chart settings, whether to use the current or your implementation. Let me know if you need assistance.