When I use percent as legend on pie graphics, it uses 1% as total instead of 100%.
Example:
Having the values 3, 5, 2 will show respectively 0.3%, 0.5%, 0.2%.
It should be 30%, 50%, 20%. It works when using marks on the pie, but it doesn't work when using as legend.
On VCL version, this problem doesn't exist!
Thanks!
Pie - Using Percent as Legend
Re: Pie - Using Percent as Legend
Hi Lourival,
I could reproduce it so I've added it to the defect list to be fixed in future releases (TJ71015388).
In the meanwhile you could use the legend's getItemText event to format the items in the legend:
I could reproduce it so I've added it to the defect list to be fixed in future releases (TJ71015388).
In the meanwhile you could use the legend's getItemText event to format the items in the legend:
Code: Select all
private com.steema.teechart.styles.Pie pie1;
private void initChart() {
pie1 = new com.steema.teechart.styles.Pie(tChart1.getChart());
pie1.add(3);
pie1.add(5);
pie1.add(2);
tChart1.getLegend().setTextStyle(com.steema.teechart.legend.LegendTextStyle.PERCENT);
tChart1.setLegendResolver(new LegendResolver() {
@Override
public Rectangle getBounds(Legend legend, Rectangle rectangle) {
return rectangle;
}
@Override
public LegendItemCoordinates getItemCoordinates(Legend legend, LegendItemCoordinates coordinates) {
return coordinates;
}
@Override
public String getItemText(Legend legend, LegendStyle legendStyle, int index, String text) {
String tmps = text.substring(0, text.length()-1).trim();
java.text.DecimalFormat df = new java.text.DecimalFormat("#.##");
tmps = tmps.replace(",", ".");
double tmpd = Double.parseDouble(tmps)*100;
return String.valueOf(df.format(tmpd)) + " %";
}
});
}
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Pie - Using Percent as Legend
Hi Yeary,
Thanks for the solution. It worked fine.
If it's possible, let me know when you fix that!
I am really thankful!
Thanks for the solution. It worked fine.
If it's possible, let me know when you fix that!
I am really thankful!
Re: Pie - Using Percent as Legend
Hi Lourival,
I've referenced this thread in the [TJ71015388] ticket. However, I recommend you to be aware at the following channels for new release announcements and what's implemented on them:
- Support forum
- RSS news feed
- Twitter
- Facebook
I've referenced this thread in the [TJ71015388] ticket. However, I recommend you to be aware at the following channels for new release announcements and what's implemented on them:
- Support forum
- RSS news feed
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Pie - Using Percent as Legend
Ok.
Thanks!
Thanks!
Re: Pie - Using Percent as Legend
Hi Yeary,
I continue having the problem. At truth, now, it's worst!
The solution works only on Percent legend. If I use any other type I will face a problem.
And it is also possible to use Percent with other information. It will cause a problem!
If you have any other way to do this, please tell me!
Thanks,
I continue having the problem. At truth, now, it's worst!
The solution works only on Percent legend. If I use any other type I will face a problem.
And it is also possible to use Percent with other information. It will cause a problem!
If you have any other way to do this, please tell me!
Thanks,
Re: Pie - Using Percent as Legend
Hi Lourival,
Of course the workaround suggested can be improved. For example you could add a condition to the getItemText event:
Of course the workaround suggested can be improved. For example you could add a condition to the getItemText event:
Code: Select all
public String getItemText(Legend legend, LegendStyle legendStyle, int index, String text) {
if (legend.getTextStyle() == LegendTextStyle.PERCENT)
{
String tmps = text.substring(0, text.length()-1).trim();
java.text.DecimalFormat df = new java.text.DecimalFormat("#.##");
tmps = tmps.replace(",", ".");
double tmpd = Double.parseDouble(tmps)*100;
return String.valueOf(df.format(tmpd)) + " %";
}
else
return text;
}
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |