fixed legend width

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
ctusch
Newbie
Newbie
Posts: 34
Joined: Fri Aug 27, 2004 4:00 am

fixed legend width

Post by ctusch » Tue Dec 02, 2008 5:26 pm

Hello,

how can I set a fixed legend width? When I try so in the VS designer it always resets the Width value although I have set AutoSize to false.

Thanks in advance!

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

Post by Narcís » Wed Dec 03, 2008 12:22 pm

Hi ctusch,

As you can see on this thread there's a problem with that. As Pep suggests, using code below works fine.

Code: Select all

		public Form1()
		{
			InitializeComponent();
			InitializeChart();
		}

		void InitializeChart()
		{
			Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
			line1.FillSampleValues();

			tChart1.Legend.CustomPosition = true;
			tChart1.Legend.Left = 10;
			tChart1.Legend.Top = 10;

			tChart1.Legend.CheckBoxes = true;

			tChart1.Legend.Height = 50;
			tChart1.Legend.Width = 50;
			tChart1.Legend.AutoSize = false;
		
			tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
		}

		void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
		{
			tChart1.Legend.Transparent = true;
			tChart1.Graphics3D.Rectangle(10, 10, 250, 250);
			tChart1.Legend.Paint();
		}
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

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

Post by Narcís » Wed Dec 03, 2008 12:51 pm

Hi ctusch,

As an update, we found that disabling checkboxes code below works fine without the need of the AfterDraw event.

Code: Select all

		void InitializeChart()
		{
			Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
			line1.FillSampleValues();

			tChart1.Legend.CustomPosition = true;
			tChart1.Legend.Left = 10;
			tChart1.Legend.Top = 10;

			tChart1.Legend.AutoSize = false;
			tChart1.Legend.Height = 150;
			tChart1.Legend.Width = 150;
		}
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

ctusch
Newbie
Newbie
Posts: 34
Joined: Fri Aug 27, 2004 4:00 am

Post by ctusch » Thu Dec 04, 2008 12:58 pm

Hello Narcis,

thanks for your answer. Finally I've found the reason (i.e. the checkboxes) why I couldn't reproduce the bug when I posted about my problem back in May. Disabling the checkboxes is okay for now but do you have an estimate when the bug will get fixed?

A further problem I have: I want the Height of the Legend to be the same as when autosized, i.e. so it fits its content. Is there a way to get the height of all the text in the legend so I can set it manually?

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

Post by Narcís » Thu Dec 04, 2008 1:13 pm

Hello ctusch,
thanks for your answer. Finally I've found the reason (i.e. the checkboxes) why I couldn't reproduce the bug when I posted about my problem back in May. Disabling the checkboxes is okay for now but do you have an estimate when the bug will get fixed?
Yes, this issue (TF02013331) was fixed yesterday so you can expect this to be fixed for the next maintenance release due out in two weeks.
A further problem I have: I want the Height of the Legend to be the same as when autosized, i.e. so it fits its content. Is there a way to get the height of all the text in the legend so I can set it manually?
Yes, you can do this:

Code: Select all

			Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
			line1.FillSampleValues();

			tChart1.Draw();

			int tmp = tChart1.Legend.Height;
			tChart1.Legend.CustomPosition = true;
			tChart1.Legend.Left = 10;
			tChart1.Legend.Top = 10;

			tChart1.Legend.AutoSize = false;
			tChart1.Legend.Height = 150;
			tChart1.Legend.Width = tmp; 
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

ctusch
Newbie
Newbie
Posts: 34
Joined: Fri Aug 27, 2004 4:00 am

Post by ctusch » Thu Dec 04, 2008 1:19 pm

Narcis,

could you explain what your code fragment should do? I don't get it (also it doesn't work).

EDIT: I'd like to add that I do not use CustomPosition at the moment.

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

Post by Narcís » Thu Dec 04, 2008 1:47 pm

Hi ctusch,

Sorry, I assigned tmp to Width when I should have assigned it to Height. The idea is drawing the chart so that automatic legend is calculated then get its Height and use it for custom dimensions setting. This works fine here:

Code: Select all

			Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
			line1.FillSampleValues();

			tChart1.Draw();

			int tmp = tChart1.Legend.Height;
			//tChart1.Legend.CustomPosition = true;
			//tChart1.Legend.Left = 10;
			//tChart1.Legend.Top = 10;

			tChart1.Legend.AutoSize = false;
			tChart1.Legend.Height = tmp;
			tChart1.Legend.Width = 150;
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

ctusch
Newbie
Newbie
Posts: 34
Joined: Fri Aug 27, 2004 4:00 am

Post by ctusch » Thu Dec 04, 2008 4:36 pm

Works very well, thanks!

Post Reply