s = "Select Sex,count(*) From Persons " _ & "Where OP='" & sUserID & "' or sGroup='共享' group by Sex order by Sex desc" Set rs = GetRs(s) If rs.RecordCount = 0 Then Exit Sub ReDim ss(rs.RecordCount) With MSChart(0) '设置图形显示的类型 .Row = 1 '设置当前活动的图形 .RowCount = 1 '设置显示的图形数 .ColumnCount = rs.RecordCount '设置标签数 .FootnoteText = "" .chartType = VtChChartType2dLine ' .TitleText = "" .RowLabel = "比例分布" End With
For i = 1 To MSChart(0).ColumnCount ss(0) = "无" If IsNull(rs.Fields.Item(0).Value) = False Then _ ss(0) = CStr(rs(0).Value) '设置图形显示的数据 With MSChart(0) .Column = i .ColumnLabel = ss(0) ' .Data = Val(rs(1).Value) '填充当前活动列的值 End With iSum = iSum + Val(rs(1).Value) rs.MoveNext Next
Option Explicit '对于二维散点图来说,第一列代表了X轴坐标,第二列代表了Y轴坐标 '因此在定义二维数据时,第二维定义为0到1,第一维代表了第几点数据,可根据数据点数变化 '下面以数据点数有21点为列子 Dim MyData(360, 1) As Variant Dim DataT(360, 1) As Variant Private Const PI = 3.1415926 Dim intC As Integer Dim dblStep As DoublePrivate Sub Command1_Click() Timer1.Enabled = Not Timer1.Enabled If Timer1.Enabled Then Command1.Caption = "停止示波器" If Not Timer1.Enabled Then Command1.Caption = "启动示波器" End SubPrivate Sub Form_Load() Dim I As Integer dblStep = 8 * PI / 360 '-----x轴坐标值-----Y轴坐标值---------- For I = 0 To 360 MyData(I, 0) = I MyData(I, 1) = 149 * Sin(dblStep * I) + 150 Next I For I = 0 To 360 DataT(I, 0) = I DataT(I, 1) = 149 * Cos(dblStep * I) + 150 Next I intC = 1 '波形图外观设置 With MSChart1 .TitleText = "速度 m/min" ' '设置图线的外观 .Plot.SeriesCollection(1).Pen.Width = 40 .Plot.SeriesCollection(1).Pen.Style = VtPenStyleSolid ' '设置XY轴 .Plot.Axis(VtChAxisIdX).ValueScale.Auto = False .Plot.Axis(VtChAxisIdY).ValueScale.Auto = False '// 设置最大值 .Plot.Axis(VtChAxisIdX).ValueScale.Maximum = 360 .Plot.Axis(VtChAxisIdY).ValueScale.Maximum = 300 '// 设置最小值 .Plot.Axis(VtChAxisIdY).ValueScale.Minimum = 0 .Plot.Axis(VtChAxisIdX).ValueScale.Minimum = 0 '// .Plot.Axis(VtChAxisIdX).ValueScale.MajorDivision = 6 'X轴主要网格数量 .Plot.Axis(VtChAxisIdY).ValueScale.MajorDivision = 6 'Y轴主要网格数量 .Plot.Axis(VtChAxisIdX).ValueScale.MinorDivision = 0 'X轴次要网格数量 .Plot.Axis(VtChAxisIdY).ValueScale.MinorDivision = 0 'Y轴次要网格数量 ' .Plot.Axis(VtChAxisIdX).AxisGrid.MajorPen.Style = VtPenStyleDotted ' .Plot.Axis(VtChAxisIdY).AxisGrid.MajorPen.Style = VtPenStyleDotted MSChart1.Plot.AutoLayout = False MSChart1.Plot.UniformAxis = False MSChart1.chartType = VtChChartType2dXY '设置图形为二维散点图 MSChart1.ChartData = MyData '数据 End With End SubPrivate Sub Timer1_Timer() Dim intP As Integer For intP = 0 To 359 MyData(intP, 1) = MyData(intP + 1, 1) Next intP MyData(360, 1) = 149 * Sin(intC * dblStep) + 150 intC = (intC + 1) Mod 360 MSChart1.ChartData = MyData End Sub
plotline二维坐标曲线activex控件
控件用MsChart,在Microsoft Chart Control 6.0(OLEDB)。 在窗体上放一个mschart控件,name属性为:mctChartPrivate Sub Form_Load() Dim CData(1 To 2, 1 To 24) As Variant '二维数组放你的折线图数据 mctChart.chartType = VtChChartType2dLine '设置mctchart 为二维折线图 For i=1 To 12 CData(1,i)=i '1代表第一个数据 Next i For i=13 To 24 '2代表第二个数据 CData(2,i)=i Next i mctChart.ChartData = CData End Sub
& "Where OP='" & sUserID & "' or sGroup='共享' group by Sex order by Sex desc"
Set rs = GetRs(s)
If rs.RecordCount = 0 Then Exit Sub
ReDim ss(rs.RecordCount)
With MSChart(0)
'设置图形显示的类型
.Row = 1 '设置当前活动的图形
.RowCount = 1 '设置显示的图形数
.ColumnCount = rs.RecordCount '设置标签数
.FootnoteText = ""
.chartType = VtChChartType2dLine '
.TitleText = ""
.RowLabel = "比例分布"
End With
For i = 1 To MSChart(0).ColumnCount
ss(0) = "无"
If IsNull(rs.Fields.Item(0).Value) = False Then _
ss(0) = CStr(rs(0).Value)
'设置图形显示的数据
With MSChart(0)
.Column = i
.ColumnLabel = ss(0) '
.Data = Val(rs(1).Value) '填充当前活动列的值
End With
iSum = iSum + Val(rs(1).Value)
rs.MoveNext
Next
'对于二维散点图来说,第一列代表了X轴坐标,第二列代表了Y轴坐标
'因此在定义二维数据时,第二维定义为0到1,第一维代表了第几点数据,可根据数据点数变化
'下面以数据点数有21点为列子
Dim MyData(360, 1) As Variant
Dim DataT(360, 1) As Variant
Private Const PI = 3.1415926
Dim intC As Integer
Dim dblStep As DoublePrivate Sub Command1_Click()
Timer1.Enabled = Not Timer1.Enabled
If Timer1.Enabled Then Command1.Caption = "停止示波器"
If Not Timer1.Enabled Then Command1.Caption = "启动示波器"
End SubPrivate Sub Form_Load()
Dim I As Integer
dblStep = 8 * PI / 360
'-----x轴坐标值-----Y轴坐标值----------
For I = 0 To 360
MyData(I, 0) = I
MyData(I, 1) = 149 * Sin(dblStep * I) + 150
Next I
For I = 0 To 360
DataT(I, 0) = I
DataT(I, 1) = 149 * Cos(dblStep * I) + 150
Next I
intC = 1
'波形图外观设置
With MSChart1
.TitleText = "速度 m/min"
' '设置图线的外观
.Plot.SeriesCollection(1).Pen.Width = 40
.Plot.SeriesCollection(1).Pen.Style = VtPenStyleSolid
' '设置XY轴
.Plot.Axis(VtChAxisIdX).ValueScale.Auto = False
.Plot.Axis(VtChAxisIdY).ValueScale.Auto = False
'// 设置最大值
.Plot.Axis(VtChAxisIdX).ValueScale.Maximum = 360
.Plot.Axis(VtChAxisIdY).ValueScale.Maximum = 300
'// 设置最小值
.Plot.Axis(VtChAxisIdY).ValueScale.Minimum = 0
.Plot.Axis(VtChAxisIdX).ValueScale.Minimum = 0
'//
.Plot.Axis(VtChAxisIdX).ValueScale.MajorDivision = 6 'X轴主要网格数量
.Plot.Axis(VtChAxisIdY).ValueScale.MajorDivision = 6 'Y轴主要网格数量
.Plot.Axis(VtChAxisIdX).ValueScale.MinorDivision = 0 'X轴次要网格数量
.Plot.Axis(VtChAxisIdY).ValueScale.MinorDivision = 0 'Y轴次要网格数量
' .Plot.Axis(VtChAxisIdX).AxisGrid.MajorPen.Style = VtPenStyleDotted
' .Plot.Axis(VtChAxisIdY).AxisGrid.MajorPen.Style = VtPenStyleDotted
MSChart1.Plot.AutoLayout = False
MSChart1.Plot.UniformAxis = False
MSChart1.chartType = VtChChartType2dXY '设置图形为二维散点图
MSChart1.ChartData = MyData '数据
End With
End SubPrivate Sub Timer1_Timer()
Dim intP As Integer
For intP = 0 To 359
MyData(intP, 1) = MyData(intP + 1, 1)
Next intP
MyData(360, 1) = 149 * Sin(intC * dblStep) + 150
intC = (intC + 1) Mod 360
MSChart1.ChartData = MyData
End Sub
在窗体上放一个mschart控件,name属性为:mctChartPrivate Sub Form_Load()
Dim CData(1 To 2, 1 To 24) As Variant '二维数组放你的折线图数据
mctChart.chartType = VtChChartType2dLine '设置mctchart 为二维折线图
For i=1 To 12
CData(1,i)=i '1代表第一个数据
Next i
For i=13 To 24 '2代表第二个数据
CData(2,i)=i
Next i
mctChart.ChartData = CData
End Sub
MSChart 控件就好。