bonsoir
voici mon code pour tracer le courbe avec zedgraph:
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked = True Then
Dim zgc As ZedGraphControl
Dim myPane As GraphPane = zgc.GraphPane
' Set the titles and axis labels
myPane.Title.Text = "Essai De Décharge Des Piles"
myPane.YAxis.Title.Text = "Tension"
myPane.XAxis.Title.Text = "Temps"
myPane.XAxis.Type = AxisType.Date
myPane.XAxis.Scale.Format = "HH:mm:ss"
myPane.XAxis.Scale.MinorUnit = DateUnit.Hour
myPane.XAxis.Scale.MajorUnit = DateUnit.Day
' Make up some data points from the Sine function
Dim list = New PointPairList()
Try
' Generate a blue curve with circle symbols, and "My Curve 2" in the legend
Dim myCurve As LineItem = myPane.AddCurve("My Curve", list, Color.Blue, SymbolType.Circle)
' Fill the area under the curve with a white-red gradient at 45 degrees
Createvaleurs(ZedGraphControl1)
list.Add(x, y)
list.Add(x0, y0)
list.Add(x1, y1)
list.Add(x2, y2)
list.Add(x3, y3)
' Make the symbols opaque by filling them with white
myCurve.Symbol.Fill = New Fill(Color.Blue)
' Fill the axis background with a color gradient
myPane.Chart.Fill = New Fill(Color.White, Color.LightGoldenrodYellow, 45.0F)
' Fill the pane background with a color gradient
myPane.Fill = New Fill(Color.White, Color.FromArgb(220, 220, 255), 45.0F)
' Calculate the Axis Scale Ranges
zgc.AxisChange()
zgc.Refresh()
Catch ex As Exception
End Try
Else
Dim zgc As ZedGraphControl
Dim myPane As GraphPane = zgc.GraphPane
' Set the titles and axis labels
myPane.Title.Text = "Essai De Décharge De La Pile"
myPane.YAxis.Title.Text = "Tension"
myPane.XAxis.Title.Text = "Temps"
myPane.XAxis.Type = AxisType.Date
myPane.XAxis.Scale.Format = "HH:mm:ss"
myPane.XAxis.Scale.MinorUnit = DateUnit.Hour
myPane.XAxis.Scale.MajorUnit = DateUnit.Day
' Make up some data points from the Sine function
Dim list = New PointPairList()
Try
' Generate a blue curve with circle symbols, and "My Curve 2" in the legend
Dim myCurve As LineItem = myPane.AddCurve("My Curve", list, Color.White, SymbolType.Circle)
' Fill the area under the curve with a white-red gradient at 45 degrees
Createcourbe(ZedGraphControl1)
list.Add(x, y)
list.Add(x0, y0)
list.Add(x1, y1)
list.Add(x2, y2)
list.Add(x3, y3)
' Make the symbols opaque by filling them with white
myCurve.Symbol.Fill = New Fill(Color.White)
' Fill the axis background with a color gradient
myPane.Chart.Fill = New Fill(Color.White, Color.LightGoldenrodYellow, 45.0F)
' Fill the pane background with a color gradient
myPane.Fill = New Fill(Color.White, Color.FromArgb(220, 220, 255), 45.0F)
zgc.AxisChange()
myCurve.Clear()
zgc.Refresh()
Catch ex As Exception
End Try
zgc.IsShowPointValues = True 'Validation info par survol de la courbe avec la souris
End If
End Sub
mais après l'éxécution une message avertissement apparaisse :"Warning 1 Variable 'zgc' is used before it has been assigned a value. A null reference exception could result at runtime." et "Warning 2 Variable 'zgc' is used before it has been assigned a value. A null reference exception could result at runtime."