knowm / XChart

XChart is a light-weight Java library for plotting data.
http://knowm.org/open-source/xchart
Apache License 2.0
1.5k stars 396 forks source link

Give the possibility to supply a custom label generator for pie charts #847

Open ggiambo opened 5 months ago

ggiambo commented 5 months ago

See #698.

Demo of PieChart02 with labels showing percentage:

Before immagine

After immagine

timmolter commented 3 months ago

Thanks for putting in the effort to change the implementation from your previous PR. Can you change the demo to be in the same format at in https://github.com/knowm/XChart/blob/a9f75d4178d52dbd3688e06072e6dde701026532/xchart-demo/src/main/java/org/knowm/xchart/demo/charts/date/DateChart09.java#L67, i.e.


            x -> startTime.plusDays(x.longValue()).format(cursorXFormatter)

, without needing to define chart.getSeriesMap().values()?

ggiambo commented 3 months ago

Hi @timmolter I'm not sure I full understand your request. I guess you want to avoid the call to Chart#getSeriesMap, that is marked for removal, am I right? In commit 44f6a189d4e5f22beb4d5a4598203e703038eb29 I tried to gather the total without accessing to the whole series map.