Page 1 of 1
Problems with series in a for/next structure
Posted: Mon Jun 21, 2004 1:18 pm
by 8121724
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
Posted: Mon Jun 28, 2004 1:07 pm
by Chris
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
Posted: Mon Jun 28, 2004 2:06 pm
by 8121724
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?
Posted: Tue Jun 29, 2004 7:46 am
by Pep
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
Posted: Tue Jun 29, 2004 6:28 pm
by 8121724
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!!
Posted: Tue Jun 29, 2004 9:00 pm
by Pep
Hi,
in that case you should use similar code to the following :
(tChart1.Series[position] as Steema.TeeChart.Styles.Line).Pointer.Visible = true;
Posted: Wed Jun 30, 2004 10:37 am
by 8121724
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
Posted: Wed Jun 30, 2004 11:41 am
by Pep
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
Posted: Wed Jun 30, 2004 12:13 pm
by 8121724
Thanks Pep
That solves all my problems and makes me a happy man today!
Posted: Wed Jun 30, 2004 1:32 pm
by Pep
ok, I'm glad to hear this..