Click here to Skip to main content
16,020,186 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to use y axes as datetime and x axes as interger. i used zedgraph control.

i used the following code


VB
         Imports ZedGraph
Public Class Form6
  Dim frames As Integer
  Dim time1 As TimeSpan()
  Public Sub New(ByVal no_frame As Integer, ByVal time() As TimeSpan)
      InitializeComponent()
      frames = no_frame
      time1 = time
  End Sub
  Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      CreateGraph(ZedGraphControl1)
      SetSize()
  End Sub
  Private Sub CreateGraph(ByVal zgc As ZedGraphControl)
      Dim myPane As GraphPane = zgc.GraphPane
      myPane.Title.Text = "Waste of Bandwidth in Stop and Wait Protocol"
      myPane.XAxis.Title.Text = "No of Frames"
      myPane.YAxis.Title.Text = "Time"
      myPane.YAxis.Type = AxisType.Date
      ' Make up some data points from the Sine function
      Dim list = New PointPairList()
      Dim x As Integer
      Dim y(100) As TimeSpan
      For x = 1 To frames
          y(x) = time1(x)
          list.Add(x, y(x))
      Next x
      ' 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
      myCurve.Line.Fill = New Fill(Color.White, Color.Red, 45.0F)
      ' 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)
      ' Calculate the Axis Scale Ranges
      zgc.AxisChange()
  End Sub
  Private Sub Form1_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Resize
      SetSize()
  End Sub
  Private Sub SetSize()
      ZedGraphControl1.Location = New Point(10, 10)
      ' Leave a small margin around the outside of the control
      ZedGraphControl1.Size = New Size(ClientRectangle.Width - 20, ClientRectangle.Height - 20)
  End Sub
    End Class


error for the above code


Public Sub Add(x As Double(), y As Double())':

Argument matching parameter 'x' cannot convert from 'Integer' to 'Double()'.

Argument matching parameter 'y' cannot convert from 'TimeSpan' to 'Double()'.

'Public Overrides Sub Add(x As Double, y As Double)':

Argument matching parameter 'y' cannot convert from 'TimeSpan' to 'Double'.




what is the solution for this ?
Posted

1 solution

i solved

VB
<pre lang="vb">


      Imports ZedGraph
       Public Class Form6
       Dim frames As Integer
Dim time1 As TimeSpan()
Dim str As String
Public Sub New(ByVal no_frame As Integer, ByVal time() As TimeSpan)
    InitializeComponent()
    frames = no_frame
    time1 = time
End Sub
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    CreateGraph(ZedGraphControl1)
    SetSize()
End Sub

Private Sub CreateGraph(ByVal zgc As ZedGraphControl)
    Dim myPane As GraphPane = zgc.GraphPane
    myPane.Title.Text = "Waste of Bandwidth in Stop and Wait Protocol"
    myPane.XAxis.Title.Text = "No of Frames"
    myPane.YAxis.Title.Text = "Time"
    'myPane.YAxis.Type = AxisType.Date
    'myPane.YAxis.Scale.Format = "HH:mm:ss:fff"

    ' Make up some data points from the Sine function
    Dim list = New PointPairList()
    Dim x As Double
    Dim y(100) As Double
    For x = 1 To frames
        y(x) = (Convert.ToDouble(time1(x).TotalSeconds))
        list.Add(x, y(x))
    Next x
    ' 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
    myCurve.Line.Fill = New Fill(Color.White, Color.Red, 45.0F)
    ' 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)
    ' Calculate the Axis Scale Ranges
    zgc.AxisChange()
End Sub
Private Sub Form1_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Resize
    SetSize()
End Sub
Private Sub SetSize()
    ZedGraphControl1.Location = New Point(10, 10)
    ' Leave a small margin around the outside of the control
    ZedGraphControl1.Size = New Size(ClientRectangle.Width - 20, ClientRectangle.Height - 20)
End Sub


End Class
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900