Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.
Public Class Form1
'Declare variables
'-----------------------------------------------------
Private Structure PointType
Dim X As Double
Dim Y As Double
End Structure
Dim Reg As New RegressionObject
Private LastEndPoint As New Point(0, 0)
'Graph lines and points
Dim regLine As New Series
Dim points As New Series
'The radius
Const R = 100
'Point
Dim P(0 To 200) As PointType
'Array that holds X and Y values for graphing
Dim MyData() As Single = New Single() {69400, 2500, 109000, 5000, 207900, 7500, 297200, 10000, 346500, 12500}
'Scale graph to stay within the picturebox
Dim HorizontalScaleFactor As Single
'The array for the points on the graph
Dim DataPoints(MyData.Length - 1) As PointF
'Points where the number labels are drawn
Dim labels As PointF
'The font
Dim drawFont As New Font("Arial", 16)
Dim cordFont As New Font("Arial", 8)
'Regression degrees
Dim deg As Integer
Dim flag As Boolean
Dim loaded As Boolean
'FORM LOAD
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For i As Integer = 1 To 10
degBox.Items.Add(i)
Next
loaded = False
flag = False
degBox.Text = "3"
Reg.Degree = deg
End Sub
'This updates the picturebox everytime it is redrawn
Private Sub picboxPulseCurve_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles picboxPulseCurve.Paint
Dim i As Integer
e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
'e.Graphics.DrawCure(ve(Pens.Blue, DataPoints))
regLine.Name = "Regression Curve"
regLine.ChartType = SeriesChartType.Spline
regLine.Color = Color.Maroon
With Reg
Using pn As New Pen(Color.Red, 2)
For i = 0 To .XYCount
DrawACircle(e, pn, New Point(P(i).X, P(i).Y), R / 10)
Next i
End Using
LastEndPoint = New Point(0, .RegVal(CDbl(Me.ClientRectangle.Height)))
Dim CurrentPoint As Point
For i = 0 To Me.ClientRectangle.Width Step R
CurrentPoint = New Point(i, .RegVal(CDbl(i)))
Using pn As New Pen(Color.BlueViolet, 3)
e.Graphics.DrawLine(pn, LastEndPoint, CurrentPoint)
End Using
e.Graphics.DrawLine(Pens.Red, 0, MyData.Max + 150, 0, 0)
e.Graphics.DrawLine(Pens.Red, MyData.Max + 150, 0, 0, 0)
If (flag = False) Then
regLine.Points.AddXY(-CurrentPoint.X, -CurrentPoint.Y)
End If
LastEndPoint = CurrentPoint
Next i
If (flag = False) Then
graph.Series.Add(regLine)
graph.Series.Add(points)
End If
End With
End Sub
'Draws a circle at the given points
Private Sub DrawACircle(ByVal e As System.Windows.Forms.PaintEventArgs, ByVal P As Pen, ByVal center As Point, ByVal radius As Integer)
' Create a bounding rectangle and make its center the center of our point
' Then make its width 2 * the radius
' Then draw our ellipse
points.Name = "Points"
points.ChartType = SeriesChartType.Point
points.Color = Color.Black
Dim rect As New Rectangle(center, New Size(0, 0))
For i = -3000 To MyData.Max + 150 Step 50
labels = New Point(i, 0)
e.Graphics.DrawString(i.ToString(), drawFont, Brushes.Black, labels)
e.Graphics.DrawLine(Pens.Black, i, 0, i, MyData.Max + 150)
Next
For i = -3000 To MyData.Max + 150 Step 50
labels = New Point(0, i)
e.Graphics.DrawString(i.ToString(), drawFont, Brushes.Black, labels)
e.Graphics.DrawLine(Pens.Black, 0, i, MyData.Max + 150, i)
Next
rect.Inflate(radius, radius)
e.Graphics.DrawEllipse(P, rect)
e.Graphics.DrawString(center.X.ToString() + " " + center.Y.ToString(), cordFont, Brushes.Black, New PointF(center.X + 8, center.Y))
If (flag = False) Then
points.Points.AddXY(-center.X, -center.Y)
End If
End Sub
'This button resets the graphs and data
Private Sub resetBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles resetBtn.Click
flag = False
regLine.Points.Clear()
points.Points.Clear()
graph.Series.Clear()
txtBox.ResetText()
Reg.Init()
MsgBox("Data has been reset!")
End Sub
'This populates the program with graph points that are loaded from a file
'It also resets the graphs and data
Private Sub PopulateDataPointsArray(ByVal PictureBoxWidth As Integer)
'Scale the graph to fit the picture box:
HorizontalScaleFactor = CSng(PictureBoxWidth / DataPoints.Length)
picboxPulseCurve.Width = MyData.Max + 150
picboxPulseCurve.Height = MyData.Max + 150
If (flag = False) Then
regLine.Points.Clear()
points.Points.Clear()
graph.Series.Clear()
End If
txtBox.ResetText()
Reg.Init()
'Populate the DataPoints array:
For i As Integer = 0 To DataPoints.Length - 2
DataPoints(i).X = MyData(i)
DataPoints(i).Y = MyData(i + 1)
txtBox.Text += ("X: " + MyData(i).ToString() + " Y: " + MyData(i + 1).ToString() + vbNewLine)
With Reg
.XYAdd(DataPoints(i).X, DataPoints(i).Y)
P(.XYCount).X = DataPoints(i).X
P(.XYCount).Y = DataPoints(i).Y
End With
Next
Me.Refresh()
End Sub
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
If you are experiencing a similar issue, please ask a related question
Join the community of 500,000 technology professionals and ask your questions.