Page 1 of 1

fixed legend width

Posted: Tue Dec 02, 2008 5:26 pm
by 9338755
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!

Posted: Wed Dec 03, 2008 12:22 pm
by narcis
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();
		}

Posted: Wed Dec 03, 2008 12:51 pm
by narcis
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;
		}

Posted: Thu Dec 04, 2008 12:58 pm
by 9338755
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?

Posted: Thu Dec 04, 2008 1:13 pm
by narcis
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; 

Posted: Thu Dec 04, 2008 1:19 pm
by 9338755
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.

Posted: Thu Dec 04, 2008 1:47 pm
by narcis
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;

Posted: Thu Dec 04, 2008 4:36 pm
by 9338755
Works very well, thanks!