borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Process Owner (UserName))Next Topic (Multi user Programs with ADO) New Topic New Poll Post Reply
AndreaVB Forum : VB General : Hi, plot 3 curves using visual basic instead of 1 curve only!
Poster Message
erickk
Level: Trainee

Registered: 11-08-2006
Posts: 2

icon Hi, plot 3 curves using visual basic instead of 1 curve only!

Hi gd evening everyone
  
  I wish to know how to modify the Visual Basic 2005 program in order to plot 3 curves from the Zedgraph Application instead of one?
  
Currently if i load the program, i can plot one curve in the application. When I click data IDs in the listboxes, it will show a temperature graph individually.
  
  Can anyone kindly post or send me the modified Visual Basic 2005 code that can plot 3 curves together in one graph in the application.
I really appreciate if anyone can help me and solve my problem as i have been trying very hard for the past few weeks.
  
  Thank you very much!
  
  Best warmest regards,
  Eric Koh, email: sunapple28@yahoo.com (can send me the code to this email, thank you!)
  
   Below, is the code for the Visual Basic Code to plot 1 curve only.


#Region "Plotting TemperatureRecord Graph"
    Public Sub getLoggerTemperature(ByVal intDataLoggerID As Integer)
        Dim i As Integer
        Dim firstRow As Integer
        Dim dt, dtmax, tempdate As Date
        'set dtmax to last record of temperture in database
        dtmax = Me.HSMSDataSet.Tables("TemperatureRecord").Rows(Me.HSMSDataSet.Tables("TemperatureRecord").Rows.Count - 1)("dtDataLoggerDateTime")
        'convert dtmax datetime to date
        dtmax = CDate(dtmax.ToShortDateString)
        'loop through database 0 step -1
        For i = Me.HSMSDataSet.Tables("TemperatureRecord").Rows.Count - 1 To 0 Step -1
            'check for the particular logger
            If Me.HSMSDataSet.Tables("TemperatureRecord").Rows(i)("intDataLoggerID") = intDataLoggerID Then
                'get temperture of logger
                dt = Me.HSMSDataSet.Tables("TemperatureRecord").Rows(i)("dtDataLoggerDateTime")
                'convert particular record of temperture from datatime to date
                dt = CDate(dt.ToShortDateString)
                'check whether if current is smaller than dtmax
                If dt < dtmax Then
                    'set firstrow as current row index
                    firstRow = i - 1
                    Exit For
                End If
            End If
        Next
        'loop through database again
        For i = firstRow To Me.HSMSDataSet.Tables("TemperatureRecord").Rows.Count - 1
            'check for particular logger
            If Me.HSMSDataSet.Tables("TemperatureRecord").Rows(i)("intDataLoggerID") = intDataLoggerID Then
                'get datetime of all reocords for the logger
                tempdate = Me.HSMSDataSet.Tables("TemperatureRecord").Rows(i)("dtDataLoggerDatetime")
                
'convert datetime to date
tempdate = CDate(tempdate.ToShortDateString)
'compare current date and lastest date(dtmax)
If tempdate = dtmax Then
'if current date = lastest date, add temperture to arraylist arryTemperaturePtGraph
                    arryTemperaturePtGraph.Add(Me.HSMSDataSet.Tables("TemperatureRecord").Rows(i)("realEarTemperature"))
                    'if current date = lastest date, add datetime to arraylist arryDateTimePtGraph
                    arryDateTimePtGraph.Add(Me.HSMSDataSet.Tables("TemperatureRecord").Rows(i)("dtDataLoggerDateTime"))
                End If
            End If
        Next
    End Sub
#End Region


'Plotting temperature graph
Dim arryTemperaturePtGraph As ArrayList = New ArrayList

Private Sub CreateGraph(ByVal zgc As ZedGraphControl)

        Dim myPane As GraphPane = zgc.GraphPane

        ' Set the title and axis labels
        myPane.Title = "Temperature Record"
        myPane.XAxis.Title = "No. Of Temperature Taken"
        myPane.YAxis.Title = "Temperature (oC)"
        

        ' Create points for three BarItems
        Dim list1 As New PointPairList()

        ' Use random data values
        Dim i As Integer, rand As New Random()
        Dim y As Double, x1 As Double
        For i = 1 To arryTemperaturePtGraph.Count
            y = i
            x1 = arryTemperaturePtGraph.Item(i - 1)
            'note: to rotate the curve's axis- use list1.Add(x1,y)
            list1.Add(y, x1)

        Next i

        
        Dim Curve As CurveItem = myPane.AddCurve("Temperature/Step", list1, Color.Blue, SymbolType.Diamond)

'Show the X and Y grids
        myPane.XAxis.IsShowGrid = True
        myPane.YAxis.IsShowGrid = True

        ' Set BarBase to the YAxis for horizontal bars
        myPane.BarBase = BarBase.Y
        ' Make the bars stack instead of cluster
        myPane.BarType = BarType.Stack

        ' Fill the axis background with a color gradient
        myPane.AxisFill = New Fill(Color.YellowGreen, _
              Color.FromArgb(255, 255, 166), 45.0F)


        zgc.AxisChange()

        'Create TextItem's to provide labels for each bar
        CreateBarLabels(myPane, True, "Yes")
    End Sub
sunapple28@yahoo.comsunapple28@yahoo.com

____________________________
erickk...thanks for helpin me, I REALLY APPRECIATE IT!!
Thanks a million!!

11-08-2006 at 05:19 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VB General : Hi, plot 3 curves using visual basic instead of 1 curve only!
Previous Topic (Process Owner (UserName))Next Topic (Multi user Programs with ADO) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder