VB用mschart画成一个一个点,连成折线图。

novrljw 2009-09-15 10:04:56
用mschart可不可以画成一个一个点的状况呢?把这些点连在一起。画成折线图。
下面的代码是画出柱状图,请问怎么画折线图呢。

Option Explicit


Private Sub cmd_close_Click()
Unload Me
End Sub

Private Sub cmd_pic_Click()
Dim s As String, i As Long, ss() As String
Dim cn As New adodb.Connection
Dim rs As New adodb.Recordset
cn.CursorLocation = adUseClient

cn.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=sample;Data Source=."
rs.Open "select number,sdatetime,data from udata", cn, adOpenStatic, adLockOptimistic

If rs.RecordCount = 0 Then Exit Sub
ReDim ss(rs.RecordCount)
With MSChart1
.RowCount = rs.RecordCount
.ColumnCount = 1
.chartType = VtChChartType2dBar
For i = 1 To rs.RecordCount
.Row = i
.Data = rs.Fields("data")
.RowLabel = rs.Fields("sdatetime")
rs.MoveNext
Next i
End With

rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Sub

Private Sub Form_Load()

Adodc1.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=sample;Data Source=."
End Sub

Private Sub Form_Resize()
MSChart1.Width = Me.Width - 1000
MSChart1.Left = (Me.Width - MSChart1.Width) / 2
End Sub
...全文
409 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
贝隆 2009-09-15
  • 打赏
  • 举报
回复
chinaboyzyq 2009-09-15
  • 打赏
  • 举报
回复 1
MSChart1.chartType = VtChChartType2dLine
MSChart1.Plot.SeriesCollection.Item(1).SeriesMarker.Auto = False
With MSChart1.Plot.SeriesCollection.Item(1).DataPoints.Item(-1).Marker
.Visible = True '显示标记
.Size = 50 '标记大小
.Style = VtMarkerStyleFilledCircle '标记样式
.FillColor.Automatic = False
.FillColor.Set 0, 255, 255 '填充色
End With
孤独剑_LPZ 2009-09-15
  • 打赏
  • 举报
回复
不要曲线要折线图吗,也可以改用picturebox直接画,
MSChart1.chartType = VtChChartType2dXY 这种方式可以研究一下
jhone99 2009-09-15
  • 打赏
  • 举报
回复
Private Sub Command1_Click()
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset

cn.CursorLocation = adUseClient
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\test.mdb;Persist Security Info=False"

rs.Open "select f1,f2 from t1", cn, adOpenStatic, adLockOptimistic

If rs.RecordCount > 0 Then
MSChart1.chartType = VtChChartType2dXY
Set MSChart1.DataSource = rs
End If

rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing


End Sub
novrljw 2009-09-15
  • 打赏
  • 举报
回复
怎样做动态的绘图呢?就是坐标可以放大缩小
孤独剑_LPZ 2009-09-15
  • 打赏
  • 举报
回复
只需要将 .chartType = VtChChartType2dBar
改成
.chartType = VtChChartType2dLine '就是折线图

1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧