Page 1 of 1
Adding legend to series
Posted: Tue Jan 11, 2005 10:24 am
by 9080952
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
Posted: Tue Jan 11, 2005 10:44 am
by Pep
Hi Antoon,
how about using :
tChart1.Series[iPar].Add(xValues,yValues,gsParameters[iPar]);
?
Posted: Tue Jan 11, 2005 11:07 am
by 9080952
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
Posted: Tue Jan 11, 2005 11:24 am
by Pep
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;
}
Posted: Tue Jan 11, 2005 11:25 am
by narcis
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];
Posted: Tue Jan 11, 2005 12:52 pm
by 9080952
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
Posted: Tue Jan 11, 2005 2:20 pm
by narcis
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;
Posted: Tue Jan 11, 2005 5:19 pm
by 9080952
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
Posted: Wed Jan 12, 2005 9:36 am
by narcis
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.