anuj_web
06-05-2007, 05:21 AM
My code to generate a graph mschart1(in the form frmgraph) from msflexgrid(in the form frmtables)
1)frmtables has a control array of four msflexgrid
2)each table is generated for a specific value of a variable x
3)each table consists of four variables a(col1 of flexgrid),b(col2)....
4)b varies according to 'a'
my problems:
5)i want to generate a graph in which a is represented on x axis and four column labels represent the four tables(four values of x) and y axis represents the variable b(for optpdrop) ,thus four curves are drawn ,each curve 'a vs b' for values in each table
6)I want to scale the axes according to the first and last values of variable(x axis) and variable b (y axis) in the specific table
Private Sub cmdgengraph_Click()
a = range + 1 'range is th no of rows in msflexgrid
ReDim xpdrop(1 To a, 4)
For i = 1 To a
frmtables.MSFlexGrid1(0).Row = i
frmtables.MSFlexGrid1(0).Col = 0
xpdrop(i, 0) = frmtables.MSFlexGrid1(0).Text
Next i
For i = 1 To a
For j = 0 To 3
frmtables.MSFlexGrid1(0).Row = i
frmtables.MSFlexGrid1(j).Col = 4
xpdrop(i, j + 1) = frmtables.MSFlexGrid1(j).Text
Next j
Next i
With frmgraph.MSChart1
.Visible = True
.ChartData = xpdrop
.ShowLegend = True
.chartType = VtChChartType2dLine
.Plot.UniformAxis = False
.ColumnLabelCount = 4
.Refresh
End With
MSChart1.RowCount = a
MSChart1.Row = 1
MSChart1.RowLabel = 1
MSChart1.ColumnCount = 4
MSChart1.Column = 1
MSChart1.ColumnLabel = frmtables.lblflex2(0).Caption
MSChart1.Column = 2
MSChart1.ColumnLabel = frmtables.lblflex2(1).Caption
MSChart1.Column = 3
MSChart1.ColumnLabel = frmtables.lblflex2(2).Caption
MSChart1.Column = 4
MSChart1.ColumnLabel = frmtables.lblflex2(3).Caption
If optpdrop.Value = True Then
yvar = "PRESSURE DROP (N/Msq.)"
Me.MSChart1.Plot.UniformAxis = False
With frmgraph.MSChart1.Plot.Axis(VtChAxisIdY).ValueScale
.Auto = False
.Minimum = 0
.Maximum = 600
End With
Me.MSChart1.Plot.UniformAxis = False
With frmgraph.MSChart1.Plot.Axis(VtChAxisIdX).ValueScale
.Auto = False
.Minimum = xmin
.Maximum = xmax
End With
MSChart1.Plot.Axis(MSChart20Lib.VtChAxisId.VtChAxisIdY).AxisTitle.Text = yvar
else
End If
MSChart1.Plot.Axis(MSChart20Lib.VtChAxisId.VtChAxisIdY).AxisTitle.Text = yvar
End Sub
There are no errors but the graph is not generated the way i want .Please someone spare some time to help me out of this mess
1)frmtables has a control array of four msflexgrid
2)each table is generated for a specific value of a variable x
3)each table consists of four variables a(col1 of flexgrid),b(col2)....
4)b varies according to 'a'
my problems:
5)i want to generate a graph in which a is represented on x axis and four column labels represent the four tables(four values of x) and y axis represents the variable b(for optpdrop) ,thus four curves are drawn ,each curve 'a vs b' for values in each table
6)I want to scale the axes according to the first and last values of variable(x axis) and variable b (y axis) in the specific table
Private Sub cmdgengraph_Click()
a = range + 1 'range is th no of rows in msflexgrid
ReDim xpdrop(1 To a, 4)
For i = 1 To a
frmtables.MSFlexGrid1(0).Row = i
frmtables.MSFlexGrid1(0).Col = 0
xpdrop(i, 0) = frmtables.MSFlexGrid1(0).Text
Next i
For i = 1 To a
For j = 0 To 3
frmtables.MSFlexGrid1(0).Row = i
frmtables.MSFlexGrid1(j).Col = 4
xpdrop(i, j + 1) = frmtables.MSFlexGrid1(j).Text
Next j
Next i
With frmgraph.MSChart1
.Visible = True
.ChartData = xpdrop
.ShowLegend = True
.chartType = VtChChartType2dLine
.Plot.UniformAxis = False
.ColumnLabelCount = 4
.Refresh
End With
MSChart1.RowCount = a
MSChart1.Row = 1
MSChart1.RowLabel = 1
MSChart1.ColumnCount = 4
MSChart1.Column = 1
MSChart1.ColumnLabel = frmtables.lblflex2(0).Caption
MSChart1.Column = 2
MSChart1.ColumnLabel = frmtables.lblflex2(1).Caption
MSChart1.Column = 3
MSChart1.ColumnLabel = frmtables.lblflex2(2).Caption
MSChart1.Column = 4
MSChart1.ColumnLabel = frmtables.lblflex2(3).Caption
If optpdrop.Value = True Then
yvar = "PRESSURE DROP (N/Msq.)"
Me.MSChart1.Plot.UniformAxis = False
With frmgraph.MSChart1.Plot.Axis(VtChAxisIdY).ValueScale
.Auto = False
.Minimum = 0
.Maximum = 600
End With
Me.MSChart1.Plot.UniformAxis = False
With frmgraph.MSChart1.Plot.Axis(VtChAxisIdX).ValueScale
.Auto = False
.Minimum = xmin
.Maximum = xmax
End With
MSChart1.Plot.Axis(MSChart20Lib.VtChAxisId.VtChAxisIdY).AxisTitle.Text = yvar
else
End If
MSChart1.Plot.Axis(MSChart20Lib.VtChAxisId.VtChAxisIdY).AxisTitle.Text = yvar
End Sub
There are no errors but the graph is not generated the way i want .Please someone spare some time to help me out of this mess