Adding legend to series

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Anthony
Newbie
Newbie
Posts: 35
Joined: Wed Feb 25, 2004 5:00 am
Location: WL| Delft Hydraulics, Holland
Contact:

Adding legend to series

Post by Anthony » Tue Jan 11, 2005 10:24 am

Hi,

I would ike to add strings for the legend of my series.

My code looks like:
Steema.TeeChart.Styles.Line line;
for (int iPar=0;iPar<noPars;iPar++)
{
// parameter iPar
iTime= 0; // only first time level
float[] xValues = new float[noLocs];
float[] yValues = new float[noLocs];
line = new Steema.TeeChart.Styles.Line();
tChart1.Series.Add(new Steema.TeeChart.Styles.Line());
for (int iLoc=0;iLoc<noLocs;iLoc++)
{
// location iLoc
xValues[iLoc] = iLoc;
yValues[iLoc] = gsSeries[iPar,iLoc,iTime];
}
tChart1.Series[iPar].Add(xValues,yValues);
tChart1.Series[iPar].Chart = tChart1.Chart;
tChart1.BackColor = Color.Azure;
}

but how and where to add the legend *gsParameters[iPar]* defined in

string[] gsParameters;

So, *gsParameters[iPar]* is the legend string for series with number *iPar*.

Thanks,
Antoon Koster
Netherlands

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Tue Jan 11, 2005 10:44 am

Hi Antoon,

how about using :
tChart1.Series[iPar].Add(xValues,yValues,gsParameters[iPar]);
?

Anthony
Newbie
Newbie
Posts: 35
Joined: Wed Feb 25, 2004 5:00 am
Location: WL| Delft Hydraulics, Holland
Contact:

Post by Anthony » Tue Jan 11, 2005 11:07 am

Hi Pep,

Thanks for your quick reply, but it did not work.

The compiler complained about invalid arg 1,2 and 3. I guess, because there is no overloaded method taking System.Array, System.Array and string (legend) as arguments.

I found some overloaded method taking a string, but that's is the string connected to a data point in series, but not the legend for the complete series.

Some *further* help would be nice !

Thanks,
Antoon

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Tue Jan 11, 2005 11:24 am

Hi Antoon,

I'm sorry, I mistake me. In that case, using Arrays you should use the StringList as in the following example :

Code: Select all

private void Form1_Load(object sender, System.EventArgs e)
{
float[] xValues = new float[5]; 
float[] yValues = new float[5]; 
Steema.TeeChart.Styles.StringList labels = new Steema.TeeChart.Styles.StringList(5);
labels[0] = "a1";
labels[1] = "a2";
labels[2] = "a3";
labels[3] = "a4";
labels[4] = "a5";		
line1.Add(xValues,yValues);
line1.Labels = labels;
}

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 Jan 11, 2005 11:25 am

Hi Anthony,

As you have already populated your series it may be enough for you using:

Code: Select all

tChart1.Series[iPar].Title=gsParameters[iPar];
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

Anthony
Newbie
Newbie
Posts: 35
Joined: Wed Feb 25, 2004 5:00 am
Location: WL| Delft Hydraulics, Holland
Contact:

Post by Anthony » Tue Jan 11, 2005 12:52 pm

Hi,

It works great !

BTW, last 2 questions ..

1) If I maximize my window including the TeeChart component, the TeeChart component is not resized . Why ??

2) Normally I have two or more series connected to both vertical axes, but sometimes there is only one single series to display. In that case I only see one (left) axis. How can I establish that I always see two vertical axis ?

Thanks.
Antoon Koster
Netherlands

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 Jan 11, 2005 2:20 pm

Hi Anthony,
1) If I maximize my window including the TeeChart component, the TeeChart component is not resized . Why ??


You should set TChart anchors editing it's properties in view designer mode.
2) Normally I have two or more series connected to both vertical axes, but sometimes there is only one single series to display. In that case I only see one (left) axis. How can I establish that I always see two vertical axis ?
You can force both vertical axis to appear using the code above for the remaining series.

Code: Select all

tChart1.Series[1].VertAxis=Steema.TeeChart.Styles.VerticalAxis.Both;
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

Anthony
Newbie
Newbie
Posts: 35
Joined: Wed Feb 25, 2004 5:00 am
Location: WL| Delft Hydraulics, Holland
Contact:

Post by Anthony » Tue Jan 11, 2005 5:19 pm

Hi,

Still a question about the TChart' s anchor properties you mentioned.

If I am in design mode with the form including my TChart component, and then right-click and go to Properties in the Context Menu, then the TeeChart editor is launched. In this case I expect a Property Window, with an attribute *anchor* for editing, or is the *anchor* part of TeeChart editor ? And if so, where (on which tab page) can I find that property ??

Thanks again.

Antoon Koster
WL|Delft Hydraulics
Netherlands

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 Jan 12, 2005 9:36 am

Hi Antoon,

You will find the anchor property in the VS.NET property editor for the TChart component you dropped in your form, not in the TeeChart Editor.
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