custom legend bounds before drawing

TeeChart for ActiveX, COM and ASP
Post Reply
jbell
Newbie
Newbie
Posts: 9
Joined: Thu Apr 09, 2009 12:00 am

custom legend bounds before drawing

Post by jbell » Mon Apr 13, 2009 2:12 pm

I'm using V8.0.0.5 in MSVC 2008, trying to position the legend using the custom position settings. I would like to align the right side of the legend with something, say, the right side of the chart. I need the width of the legend when I draw it in its new location, but ShapeBounds returns the previous width which may include clipping or use a different font. Is there a way of determining the size of the legend box before I draw it?

Thanks,
JBell

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Apr 14, 2009 9:42 am

Hi JBell,

You can use this code in form's initialization:

Code: Select all

	m_Chart1.GetLegend().SetCustomPosition(true);
	m_Chart1.GetEnvironment().InternalRepaint();
And implement chart's OnAfterDraw event like this:

Code: Select all

	int width = m_Chart1.GetLegend().GetShapeBounds().GetRight() - 
				m_Chart1.GetLegend().GetShapeBounds().GetLeft();
	int left = m_Chart1.GetAxis().GetBottom().GetIEndPos() - width;
	m_Chart1.GetLegend().SetLeft(left);
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

jbell
Newbie
Newbie
Posts: 9
Joined: Thu Apr 09, 2009 12:00 am

Post by jbell » Tue Apr 14, 2009 6:49 pm

InternalRepaint is what I was missing, thanks.

JBell

Post Reply