Problems with series in a for/next structure

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Rookie_SP
Newbie
Newbie
Posts: 7
Joined: Fri Nov 15, 2002 12:00 am
Location: Spain

Problems with series in a for/next structure

Post by Rookie_SP » Mon Jun 21, 2004 1:18 pm

A couple of probably stupid questions with obvious answers but... sorry guys, not for me. Can anybody help me?

I need to create and delete series in run time with a number of them dynamically changing with the results of some calculations in VB.NET but I am having problems. My idea was using a for/next structure but something does not work. How can I create am array or collection of seriex with an index? Same to delete themand referto them by that index.

I am trying to change as well the format of all the series in a chart using a For/next structure in Vb.NET but although one by one referring to the name I have no problem using something like: "Polar1.Pointer.Visible = False" series by series I seem unable to find how to do it referign to the each series with an index. Any ideas?

Thanks

Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Post by Christopher » Mon Jun 28, 2004 1:07 pm

Hi ..
I need to create and delete series in run time with a number of them dynamically changing with the results of some calculations in VB.NET but I am having problems. My idea was using a for/next structure but something does not work. How can I create am array or collection of seriex with an index? Same to delete themand referto them by that index.


Try:
TChart1.Series.RemoveAt(2)
and
TChart1.Series.Add(New Steema.TeeChart.Styles.Line)
I am trying to change as well the format of all the series in a chart using a For/next structure in Vb.NET but although one by one referring to the name I have no problem using something like: "Polar1.Pointer.Visible = False" series by series I seem unable to find how to do it referign to the each series with an index. Any ideas?


Try:
For Each s As Steema.TeeChart.Styles.Series In TChart1.Series
s.FillSampleValues(10)
Next
Thank you!

Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/

Rookie_SP
Newbie
Newbie
Posts: 7
Joined: Fri Nov 15, 2002 12:00 am
Location: Spain

Post by Rookie_SP » Mon Jun 28, 2004 2:06 pm

Thanks Chris, that solves one of the problems since I can deal with the series collection with a variable number of elements.

My next (maybe trivial but not for me) problem is asigning different properties to the series depending on the index of that element in the collection.

Series3D1.LinePen.Color = Color.Black
Series3D1.Pointer.visible= true


Work just fine but how do I make it work JUST for some known series from the whole collection that I can refer through its position?

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

Post by Pep » Tue Jun 29, 2004 7:46 am

Hi Rokie,
Work just fine but how do I make it work JUST for some known series from the whole collection that I can refer through its position?
You can use :
TChart1(position).ColorEach = True

Rookie_SP
Newbie
Newbie
Posts: 7
Joined: Fri Nov 15, 2002 12:00 am
Location: Spain

Post by Rookie_SP » Tue Jun 29, 2004 6:28 pm

Sure Pep

TChart1.Series(position).ColorEach = True

works too and so I do in some cases but some other properties do not seem to be accesible that way so:

seriestitle.LinePen.Color = Color.Black
seriestitle.Pointer.Visible = false


where seriestitle is the name of the series works BUT:

Tchart1.series(position).LinePen.Color = Color.Black
Tchart1.series(position).Pointer.Visible = false


does not since I can not access the LinePen and Pointer properties that way.

So... that is my problem to make my runtime series creation and formatting fully automatic.

There has to be a pretty simple answer but I do not seem to be enough "object oriented" to see it.

Heeelp!! :?

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

Post by Pep » Tue Jun 29, 2004 9:00 pm

Hi,

in that case you should use similar code to the following :

(tChart1.Series[position] as Steema.TeeChart.Styles.Line).Pointer.Visible = true;

Rookie_SP
Newbie
Newbie
Posts: 7
Joined: Fri Nov 15, 2002 12:00 am
Location: Spain

Post by Rookie_SP » Wed Jun 30, 2004 10:37 am

Well, from the next code


For position = 0 To 10
Tchart1.Series.Add(New Steema.TeeChart.Styles.Points3D)
Tchart1.Series(position).Title = "Series3D" & CStr(position)
Tchart1.Series(position).ColorEach = True
(Tchart1.Series(position) as Steema.TeeChart.Styles.Points3D ).pointer.visible=true
Next position


All works except

(Tchart1.Series(position) as Steema.TeeChart.Styles.Points3D ).pointer.visible=true

That gives a sintax error. It does not seem to accept the "as Steema.TeeChart......"


8O :?:

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

Post by Pep » Wed Jun 30, 2004 11:41 am

Hi,

yes, because this code is to be used unde C#, in VB you must do :

Code: Select all

        For position = 0 To 10
            TChart1.Series.Add(New Steema.TeeChart.Styles.Points3D)
            TChart1.Series(position).Title = "Series3D" & CStr(position)
            TChart1.Series(position).ColorEach = True
            TChart1.Series(position).FillSampleValues(10)
            CType(TChart1.Series(position), Steema.TeeChart.Styles.Points3D).Pointer.Visible = True
        Next position

Rookie_SP
Newbie
Newbie
Posts: 7
Joined: Fri Nov 15, 2002 12:00 am
Location: Spain

Post by Rookie_SP » Wed Jun 30, 2004 12:13 pm

Thanks Pep

That solves all my problems and makes me a happy man today!

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

Post by Pep » Wed Jun 30, 2004 1:32 pm

ok, I'm glad to hear this.. :wink:

Post Reply