Plotting graph from datagridview

  • Thread starter Thread starter mikedp
  • Start date Start date
M

mikedp

Guest
Good day all,

I have been trying for the last 7 days and am frustrated...

I would like to plot a growth graph for children based on national percentiles. I have 5 graphs of national percentiles 5th, 25th, 50th, 75th, and 95th) which work fine.

I am trying to add another graph which inputs the child's most recent weight (from a datagrid), but the graph ends up as just a straight flat line.

Can you help me?


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

DrawLineGraph()

End Sub

'Draw a line graph

Private Sub DrawLineGraph()

Dim I As Long

With AxDraw1

'Set the graph type to a line graph
.GraphType = csXGraphTrial.TxGraphType.dgtLine

'Set some properties
.PlotAreaColor = System.Drawing.Color.White
.OriginY = 150
.YAxisNegative = 0
.YTop = 70
.YGrad = 10
.XTop = 27
.XGrad = 1.2


'Set some properties based on the check boxes

.LineWidth = 1
.PointSize = 3
.PointStyle = csXGraphTrial.TxPointStyle.dgpsDot
.ShowLine = True
'.ShowGrid = True
'.ShowLegend = True


Dim AgeTilBirth() As String = {"1w", "1m", "2m", "4m", "6m", "9m", "12m", "15m", "18m", "24m", "2.5y", "3y", "4y", "5y", "6y", "7y", "8y", "9y", "10y", "11y", "12y", "13y", "14y", "15y", "16y", "17y", "18y"}

.UseXAxisLabels = True

For I = 0 To AgeTilBirth.Length - 1
.AddXValue(I, AgeTilBirth(CInt(I)))
Next

Dim ActualWeightLine() As Double = {x}


Dim US5WeightLine() As Int32 = {18, 20, CInt(21.5), CInt(23.25), 25, CInt(26.5), 28, CInt(29.25), CInt(30.25), 32, CInt(33.75), CInt(35.25), CInt(37.5), CInt(39.5), 42, CInt(44.5), CInt(46.5), CInt(48.25), CInt(50.5), 52, 54, CInt(56.5), 59, CInt(61.5), CInt(63.25), CInt(64.5), 65}

Dim US25WeightLine() As Int32 = {CInt(19.25), CInt(20.5), CInt(22.25), CInt(24.25), CInt(25.75), CInt(27.75), 29, CInt(30.25), CInt(31.5), CInt(33.5), 35, CInt(36.75), 39, CInt(41.5), CInt(44), CInt(46.5), CInt(49), CInt(51), CInt(53), CInt(55), CInt(57), CInt(59.5), CInt(62.5), 65, CInt(66.5), 67, CInt(67.5)}

Dim US50WeightLine() As Int32 = {CInt(19.75), CInt(21.5), CInt(23), CInt(25), CInt(26.5), CInt(28.25), CInt(29.75), CInt(31.25), CInt(32.25), CInt(34.5), CInt(36), CInt(37.75), CInt(40), CInt(43), CInt(45.5), CInt(48), CInt(50.5), CInt(52.5), CInt(54.5), CInt(56.5), CInt(58.5), CInt(61.5), CInt(64.5), CInt(67), CInt(68.25), CInt(69), CInt(69.5)}

Dim US75WeightLine() As Int32 = {CInt(20.5), CInt(22.25), CInt(23.75), CInt(25.75), CInt(27.25), 29, CInt(30.5), 32, CInt(33.25), CInt(35.25), 37, CInt(38.75), CInt(41.5), 44, 47, CInt(49.5), 52, CInt(54.5), CInt(56.5), CInt(58.5), CInt(60.5), CInt(63.5), CInt(66.5), 69, CInt(70.5), 71, CInt(71.5)}


Dim US95WeightLine() As Int32 = {CInt(21.5), CInt(23.25), CInt(24.5), CInt(26.75), CInt(28.25), CInt(30.25), CInt(31.75), CInt(33.25), CInt(34.25), CInt(36.5), 38, CInt(40.5), 43, 46, CInt(48.75), CInt(51.5), CInt(54.25), CInt(56.75), 59, 61, CInt(63.5), CInt(66.5), CInt(69.5), 72, 73, CInt(73.5), 74}


'''''''''''''''''''''''''''''''''''''

'Add the data points from above data

For I = 0 To US5WeightLine.Length - 1
.AddPoint(I, US5WeightLine(CInt(I)), System.UInt32.Parse(CStr(&H0)), "US 5% Weight Line")
Next

For I = 0 To US25WeightLine.Length - 1
.AddPoint(I, US25WeightLine(CInt(I)), System.UInt32.Parse(CStr(&HFF00FF)), "US 25% Weight Line")
Next

For I = 0 To US50WeightLine.Length - 1
.AddPoint(I, US50WeightLine(CInt(I)), System.UInt32.Parse(CStr(&HFF)), "US 50% Weight Line")
Next

For I = 0 To US75WeightLine.Length - 1
.AddPoint(I, US75WeightLine(CInt(I)), System.UInt32.Parse(CStr(&HFFFF)), "US 75% Weight Line")
Next

For I = 0 To US95WeightLine.Length - 1
.AddPoint(I, US95WeightLine(CInt(I)), System.UInt32.Parse(CStr(&HFF0000)), "US 95% Weight Line")
Next

For I = 0 To ActualWeightLine.Length - 1
For j = 0 To frmGrowthList.dgvGrowth.RowCount - 1
Dim x As Integer = CInt(frmGrowthList.dgvGrowth.Rows(j).Cells(5).Value)
MsgBox(x)

.AddPoint(x, ActualWeightLine(CInt(I)), System.UInt32.Parse(CStr(&HFF00)), "Actual Weight Line")
Next
Next

'Define the title
.Title = "Weight Trend Line Graph"
.TitleTextAlign = csXGraphTrial.TxTextAlign.xgtaBottomLeft
.TitleY = .Height
.TitleFont = New Font("Arial", 10, FontStyle.Bold)

'Draw the graph
.DrawGraph()

End With

End Sub



Mike

Continue reading...
 
Back
Top