Right-aligned legend has no margin

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Post Reply
znakeeye
Newbie
Newbie
Posts: 44
Joined: Mon Jan 07, 2013 12:00 am

Right-aligned legend has no margin

Post by znakeeye » Sat Feb 23, 2013 4:46 pm

My right-aligned legend is always 0 pixels from the right side of my chart. I would like to add a couple of pixels spacing, but can't figure out how. Looking through the source code, it seems no such feature is available.

Any ideas?

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Right-aligned legend has no margin

Post by Yeray » Mon Feb 25, 2013 1:28 pm

Hi,

You can add some Horizontal Margin between the legend and the Chart with:

Code: Select all

tChart1.getLegend().setHorizMargin(10);
Note if your Legend is TOP/BOTTOM aligned, you'll have to use setVertMargin instead:

Code: Select all

tChart1.getLegend().setAlignment(LegendAlignment.BOTTOM);
tChart1.getLegend().setVertMargin(10);
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

znakeeye
Newbie
Newbie
Posts: 44
Joined: Mon Jan 07, 2013 12:00 am

Re: Right-aligned legend has no margin

Post by znakeeye » Tue Feb 26, 2013 10:37 pm

Thanks. I tried that, but it doesn't work. However, I found a workaround:

_chart.setLegendResolver(new LegendAdapter() {
@Override
public Rectangle getBounds(Legend legend, Rectangle rectangle) {
return new Rectangle(rectangle.x, rectangle.y, rectangle.width - 6, rectangle.height);
};
});

Though, I would still consider this a bug. setHorizMargin has no effect (Android 4.2.2).

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Right-aligned legend has no margin

Post by Yeray » Wed Feb 27, 2013 2:39 pm

Hello,

It does work for me with the latest TeeChart Java for Android, v3.2012.1120:

Code: Select all

		tChart1.getAspect().setView3D(false);
		tChart1.getHeader().setVisible(false);
		Line line1 = new Line(tChart1.getChart());
		line1.fillSampleValues();
		tChart1.getLegend().setHorizMargin(100);
device-2013-02-27-153349.png
device-2013-02-27-153349.png (17.55 KiB) Viewed 15319 times
Android emulator, v4.2.2
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

znakeeye
Newbie
Newbie
Posts: 44
Joined: Mon Jan 07, 2013 12:00 am

Re: Right-aligned legend has no margin

Post by znakeeye » Fri Mar 15, 2013 4:56 pm

That looks like 100 pixels on the left. What about the right side? In my app it touches the border of the entire TChart view.

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Right-aligned legend has no margin

Post by Yeray » Mon Mar 18, 2013 2:41 pm

Hi,

You can also set some Right Margin like follows:

Code: Select all

	    tChart1.getPanel().setMarginUnits(PanelMarginUnits.PIXELS);
	    tChart1.getPanel().setMarginRight(20);
If you still find any problem with it, please arrange a simple example project we can run as-is to reproduce the problem here.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

znakeeye
Newbie
Newbie
Posts: 44
Joined: Mon Jan 07, 2013 12:00 am

Re: Right-aligned legend has no margin

Post by znakeeye » Tue Mar 19, 2013 8:17 pm

setMarginRight did the trick! Thanks!

Post Reply