Lineseries Looping
Posted: Tue Oct 03, 2006 4:36 pm
I am using an sql query to count the number of series that I am to include in my chart. I would like to load these series dynamically. How can I set up a for/next loop to add series to the chart. I tried the following code below, but it overwrites the previous series. Any help would be greatly appreciated.
Dim ydata(14) As Integer
ydata(0) = 0
ydata(1) = 100
ydata(2) = 200
ydata(3) = 300
ydata(4) = 400
ydata(5) = 500
ydata(6) = 600
ydata(7) = 700
ydata(8) = 800
ydata(9) = 900
ydata(10) = 1000
ydata(11) = 1100
ydata(12) = 1200
ydata(13) = 1275
TChart1.Axes.Bottom.Automatic = False
TChart1.Axes.Bottom.Maximum = 2
TChart1.Axes.Bottom.Minimum = -2
TChart1.Axes.Bottom.Increment = 0.5
TChart1.Axes.Left.Increment = 100
Dim J As Integer
For J = 0 To 1
' If the LineSeries object doesn't exist, then create a fresh one to use below.
If LineSeries Is Nothing Then
LineSeries = New Steema.TeeChart.Styles.HorizLine
End If
' Add points to the line series
'LineSeries.Add(elev1(J), ydata(0))
LineSeries.Add(elev1(0), ydata(0))
LineSeries.Add(elev2(0), ydata(1))
LineSeries.Add(elev3(0), ydata(2))
LineSeries.Add(elev4(0), ydata(3))
LineSeries.Add(elev4(0), ydata(4))
LineSeries.Add(elev6(0), ydata(5))
LineSeries.Add(elev7(0), ydata(6))
LineSeries.Add(elev8(0), ydata(7))
LineSeries.Add(elev9(0), ydata(8))
LineSeries.Add(elev10(0), ydata(9))
LineSeries.Add(elev11(0), ydata(10))
LineSeries.Add(elev12(0), ydata(11))
LineSeries.Add(elev13(0), ydata(12))
LineSeries.Add(elev14(0), ydata(13))
' Add / Apply the line series to chart / graph
'** ENTER CODE HERE FOR APPLYING LINESERIES TO CHART
TChart1.Series.Add(LineSeries)
' After the line series has been added to the chart / graph, destroy it
LineSeries = Nothing
Next J
Dim ydata(14) As Integer
ydata(0) = 0
ydata(1) = 100
ydata(2) = 200
ydata(3) = 300
ydata(4) = 400
ydata(5) = 500
ydata(6) = 600
ydata(7) = 700
ydata(8) = 800
ydata(9) = 900
ydata(10) = 1000
ydata(11) = 1100
ydata(12) = 1200
ydata(13) = 1275
TChart1.Axes.Bottom.Automatic = False
TChart1.Axes.Bottom.Maximum = 2
TChart1.Axes.Bottom.Minimum = -2
TChart1.Axes.Bottom.Increment = 0.5
TChart1.Axes.Left.Increment = 100
Dim J As Integer
For J = 0 To 1
' If the LineSeries object doesn't exist, then create a fresh one to use below.
If LineSeries Is Nothing Then
LineSeries = New Steema.TeeChart.Styles.HorizLine
End If
' Add points to the line series
'LineSeries.Add(elev1(J), ydata(0))
LineSeries.Add(elev1(0), ydata(0))
LineSeries.Add(elev2(0), ydata(1))
LineSeries.Add(elev3(0), ydata(2))
LineSeries.Add(elev4(0), ydata(3))
LineSeries.Add(elev4(0), ydata(4))
LineSeries.Add(elev6(0), ydata(5))
LineSeries.Add(elev7(0), ydata(6))
LineSeries.Add(elev8(0), ydata(7))
LineSeries.Add(elev9(0), ydata(8))
LineSeries.Add(elev10(0), ydata(9))
LineSeries.Add(elev11(0), ydata(10))
LineSeries.Add(elev12(0), ydata(11))
LineSeries.Add(elev13(0), ydata(12))
LineSeries.Add(elev14(0), ydata(13))
' Add / Apply the line series to chart / graph
'** ENTER CODE HERE FOR APPLYING LINESERIES TO CHART
TChart1.Series.Add(LineSeries)
' After the line series has been added to the chart / graph, destroy it
LineSeries = Nothing
Next J