Page 1 of 1
Legend Positioning and Entriy styling
Posted: Wed Mar 06, 2019 8:52 am
by 17185819
Hi,
I have a few questions concerning Legends:
1.) How can i vertically center legends with RIGHT alignment.
2.) How can I display only the n largest entries from a pie chart in the legend
3.) How can I truncate the displayed string in the legend if the number of characters exceed a certain umber?
Thanks for the supprt.
Re: Legend Positioning and Entriy styling
Posted: Fri Mar 08, 2019 11:59 am
by 17185819
To get the limited legend, I have impolemented the following (Psudocode)
Code: Select all
Pie series = new Pie()
Pie legendSeries = new Pie();
chart.addSeries(series)
chart.addSeries(legendSeries)
legendSeries.setVisible(false)
for key,value in list:
series.add(value, key, color)
if index<5:
legendSeries.add(value, key.substring(0,10), color)
chart.getLegend().setVisible(false);
extralegend = new ExtraLegend(chart.getChart());
extralegend.setSeries(legendSeries);
extralegend.getLegend().setVisible(false);
The problem is now that i ge a NPE:
java.lang.NullPointerException
at com.steema.teechart.drawing.Graphics3D.pointInEllipse(Graphics3D.java:783)
at com.steema.teechart.styles.Circular.clicked(Circular.java:247)
at com.steema.teechart.styles.Pie.clicked(Pie.java:1816)
at com.steema.teechart.styles.Series.clicked(Series.java:3339)
at com.steema.teechart.tools.MarksTip.findClickedSeries(MarksTip.java:198)
at com.steema.teechart.tools.MarksTip.mouseEvent(MarksTip.java:228)
at com.steema.teechart.Chart.broadcastMouseEvent(Chart.java:1016)
at com.steema.teechart.Chart.broadcastMouseEvent(Chart.java:1005)
at com.steema.teechart.Chart.mouseMoved(Chart.java:1406)
at com.steema.teechart.TChart.processMouseMotionEvent(TChart.java:1265)
at com.steema.teechart.TChart$3.handleEvent(TChart.java:378)
...
Am i doing something conceptually wrong?
Btw. I was inspired by this thread:
viewtopic.php?f=10&t=14982&p=66405&hilit=legend#p66405
EDIT
I was further able detect that the exception does not occur if i do not set
So somehow it wants to react to the hidden series?
EDIT 2
Fixed psudo code to set correct visibility of second series
Re: Legend Positioning and Entriy styling
Posted: Fri Mar 08, 2019 2:26 pm
by 17185819
Ok I have been able to more or less resolve this by doing something like:
Code: Select all
ie series = new Pie()
Pie legendSeries = new Pie();
chart.addSeries(series)
chart.addSeries(legendSeries)
legendSeries.setVisible(false)
for key,value in list:
series.add(value, key, color)
if index<5:
legendSeries.add(value, key.substring(0,10), color)
chart.getLegend().setVisible(true);
chart.getLegend().setSeries(legendSeries)
However when activating tooltips with
I get above NPE.
Could this be an actual bug?
Re: Legend Positioning and Entriy styling
Posted: Fri Mar 08, 2019 3:11 pm
by 17185819
I was now able to resolve the issue by replacing
by
Code: Select all
final MarksTip toolTips = new MarksTip();
toolTips.setSeries(series);
toolTips.setChart(chart.getChart());