Lineseries Looping

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
phil1995
Newbie
Newbie
Posts: 31
Joined: Fri Dec 16, 2005 12:00 am
Location: Hattiesburg, Ms.
Contact:

Lineseries Looping

Post by phil1995 » 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

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 Oct 04, 2006 10:21 am

Hi phil1995,

You can do something like this:

Code: Select all

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim i As Int16

        For i = 0 To 10
            TChart1.Series.Add(New Steema.TeeChart.Styles.Line)
            TChart1(i).FillSampleValues()
        Next
    End Sub
or this:

Code: Select all

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim i As Int16

        For i = 0 To 10
            Dim Line1 As New Steema.TeeChart.Styles.Line(TChart1.Chart)
            Line1.FillSampleValues()
        Next
    End Sub
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