Page 1 of 1

How Do I set values in the Legend?

Posted: Wed Jun 03, 2009 9:26 am
by 13050364
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.

Posted: Wed Jun 03, 2009 1:11 pm
by yeray
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;

Posted: Thu Jun 04, 2009 11:02 am
by 13050364
Thanks Yeray. Ive sorted the problem. Not sure what was happenning but its working OK now.