How Do I set values in the Legend?

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Dave
Advanced
Posts: 139
Joined: Mon Sep 22, 2008 12:00 am

How Do I set values in the Legend?

Post by Dave » Wed Jun 03, 2009 9:26 am

Hi Support

Ive set up a simple application. (Im using Visual C# and Visual Studio).
Ive added a TeeChart control and a button to a windows form.

When the user presses the button the following code is run.

Steema.TeeChart.Styles.Line Line1;
Line1 = new Steema.TeeChart.Styles.Line();
tChart1.Series.Add(Line1);
Line1.FillSampleValues(20);

This adds a line to the chart. Ive 2 questions.

1. Why when there is only 1 line displayed is there 2 lines (Line1, Line2) shown in the Legend.

2. How do I set the name in the legend? ie. When I click the button to add the new line how do I set the name in the legend to lets say "Rupert"?

Thanks.

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

Post by Yeray » Wed Jun 03, 2009 1:11 pm

Hi Dave,

1. Are you sure that you haven't added another line previously (i.e. at design time)?
Here, I drop a chart and a button on a form, and if I use only the following code, it seems to work fine:

Code: Select all

        private void button1_Click(object sender, EventArgs e)
        {
            Steema.TeeChart.Styles.Line Line1;
            Line1 = new Steema.TeeChart.Styles.Line();
            tChart1.Series.Add(Line1);
            Line1.FillSampleValues(20); 
        }
If you are sure that you have no other series, please, could you 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.


2. You could do this setting a series title, for example:

Code: Select all

Line1.Title = "Rupert";
Finally, note that, by default, if you have only one series, the legend shows its points, not the series name. To change this:

Code: Select all

tChart1.Legend.LegendStyle = Steema.TeeChart.LegendStyles.Series;
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

Dave
Advanced
Posts: 139
Joined: Mon Sep 22, 2008 12:00 am

Post by Dave » Thu Jun 04, 2009 11:02 am

Thanks Yeray. Ive sorted the problem. Not sure what was happenning but its working OK now.

Post Reply