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

Legend.Width

Post by ctusch » Tue May 27, 2008 2:12 pm

Hi,

I want my legend to be of a fixed size so I set AutoSize to false. But always when I try to set the Width property it resets itself back to its old value. What am I doing wrong?

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 May 27, 2008 2:59 pm

Hi ctusch,

Could you please send us a simple example project we can run "as-is" to reproduce the problem here?

You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

Thanks in advance.
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 » Wed May 28, 2008 10:00 am

Hi Narcis,

I wasn't able to reproduce my exact problem inside a demo app but another problem appeared there (I've uploaded the project): When I set Legend.AutoSize to false the legend won't display at all. I don't know if these two problems are related.

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 May 28, 2008 10:35 am

Hi ctusch,

Thanks for the example project. I could reproduce the issue here and it's probable they are related. I've added the bug (TF02013088) to our defect lst to be fixed for next releases. In the meantime you can set custom legend position:

Code: Select all

        public Form1()
        {
            InitializeComponent();

            Line line = new Line();

            this.tChart1.Series.Add(line);
            line.Add(1, 0);
            line.Add(2, 2);
            line.Add(3, 3);
            line.Add(4, 3);

						tChart1.Legend.AutoSize = false;

						tChart1.Panel.MarginRight = 20;
						tChart1.Legend.CustomPosition = true;
						Bitmap bmp = tChart1.Bitmap;
						Rectangle rect = tChart1.Chart.ChartRect;
						tChart1.Legend.Left = rect.Right + 10;
						tChart1.Legend.Top = rect.Top;
        }
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 » Wed May 28, 2008 11:27 am

Alright, thanks!

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

Post by ctusch » Wed May 28, 2008 12:26 pm

Narcis,

now I seem to experience the same problem as before. I changed the code of the sample project as you posted but I get bad results. I've uploaded you two screen shots, one after program startup and the other after rescaling the window. Aren't you experiencing the same problems?

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 May 28, 2008 12:41 pm

Hi ctusch,

Yes, in that case you'll need to use AfterDraw and Resize events like this:

Code: Select all

        public Form1()
        {
            InitializeComponent();

            Line line = new Line();

            this.tChart1.Series.Add(line);
            line.Add(1, 0);
            line.Add(2, 2);
            line.Add(3, 3);
            line.Add(4, 3);

						tChart1.Legend.AutoSize = false;

						tChart1.Panel.MarginRight = 20;
						tChart1.Legend.CustomPosition = true;
						Bitmap bmp = tChart1.Bitmap;						
        }

				private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
				{
					Rectangle rect = tChart1.Chart.ChartRect;
					tChart1.Legend.Left = rect.Right + 10;
					tChart1.Legend.Top = rect.Top;
				}

				private void tChart1_Resize(object sender, EventArgs e)
				{
					Bitmap bmp = tChart1.Bitmap;
				}
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 » Wed May 28, 2008 1:40 pm

Narcis,

I was able to set the Legend.Width after calling tChart1.Bitmap. Now I'm still having the problem that the legend doesn't keep itself at a fixed distance from the right border. I've uploaded two screen shots for you again.

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 May 28, 2008 2:45 pm

Hi ctusch,

In that case you can implement AfterDraw event like this:

Code: Select all

				private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
				{
					Rectangle rect = tChart1.Chart.ChartRect;
					//tChart1.Legend.Left = tChart1.Width - 100;
					tChart1.Legend.Left = tChart1.Width - tChart1.Legend.Width;
					tChart1.Legend.Top = rect.Top;
				}
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 » Thu May 29, 2008 8:37 am

Hi ctusch,

As an update, a TeeChart for .NET developers pointed me out that he doesn't think TF02013088 is a bug. When you set AutoSize to false, you have to set the width and height manually. The following code works as expected:

Code: Select all

		public Form1()
		{
			InitializeComponent();
			InitializeChart();
		}
				
		private void InitializeChart()
		{
			Steema.TeeChart.Styles.Line line = new Steema.TeeChart.Styles.Line();

			this.tChart1.Series.Add(line);
			line.Add(1, 0);
			line.Add(2, 2);
			line.Add(3, 3);
			line.Add(4, 3);

			tChart1.Legend.Width = 50;
			tChart1.Legend.Height = 100;
			tChart1.Legend.AutoSize = false;
		}
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 » Thu May 29, 2008 8:39 am

Hi ctusch,

As an update, a TeeChart for .NET developers pointed me out that he doesn't think TF02013088 is a bug. When you set AutoSize to false, you have to set the width and height manually. The following code works as expected:

Code: Select all

		public Form1()
		{
			InitializeComponent();
			InitializeChart();
		}
				
		private void InitializeChart()
		{
			Steema.TeeChart.Styles.Line line = new Steema.TeeChart.Styles.Line();

			this.tChart1.Series.Add(line);
			line.Add(1, 0);
			line.Add(2, 2);
			line.Add(3, 3);
			line.Add(4, 3);

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

Post Reply