高手进 ,数据库 图表问题 MSChart控件

a040285 2010-05-25 10:33:34
aeeess数据库中有一个表其中的字段有 (时间,总功率,总发电量)
窗体中有一个MSChart1控件 ,下面是我写的一点连接代码:

str = "D:\Program Files\光伏逆变器监控系统\date\"
pstr = "Provider=Microsoft.Jet.OLEDB.4.0;"
pstr = pstr & "Persist Security Info=False;"
pstr = pstr & "Data Source=" & str & "历史数据库.mdb"
connb.Open pstr
Rsb.CursorLocation = adUseClient
Rsb.Open "MyTable", connb, adOpenKeyset, adLockPessimistic

请高手帮忙续写下代码
我想让图表曲线显示,怎么设置好,图表能背景透明吗?
...全文
163 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
chinaboyzyq 2010-05-25
  • 打赏
  • 举报
回复

Str = "D:\Program Files\光伏逆变器监控系统\date\"
pstr = "Provider=Microsoft.Jet.OLEDB.4.0;"
pstr = pstr & "Persist Security Info=False;"
pstr = pstr & "Data Source=" & Str & "历史数据库.mdb"
connb.Open pstr
Rsb.CursorLocation = adUseClient
Rsb.Open "MyTable", connb, adOpenKeyset, adLockPessimistic
'---------------------------------------------------------------------------
Dim iValue(), i As Integer, j As Integer, iRow As Long, iCol As Integer
iRow = Rsb.RecordCount - 1
icow = Rsb.Fields.Count - 1
Rsb.MoveFirst
ReDim iValue(iRow, icow)
For i = 0 To iRow
For j = 0 To iCol
iValue(i, j) = Rsb.Fields(j)
Next
Rsb.MoveNext
Next

MSChart1.chartType = VtChChartType2dLine
MSChart1.ColumnCount = 2
MSChart1.ChartData = iValue
chinaboyzyq 2010-05-25
  • 打赏
  • 举报
回复

Str = "D:\Program Files\光伏逆变器监控系统\date\"
pstr = "Provider=Microsoft.Jet.OLEDB.4.0;"
pstr = pstr & "Persist Security Info=False;"
pstr = pstr & "Data Source=" & Str & "历史数据库.mdb"
connb.Open pstr
Rsb.CursorLocation = adUseClient
Rsb.Open "MyTable", connb, adOpenKeyset, adLockPessimistic
'---------------------------------------------------------------------------
Dim iValue(), i As Integer, j As Integer, iRow As Long, iCol As Integer
iRow = Rsb.RecordCount - 1
icow = Rsb.Fields.Count - 1
Rsb.MoveFirst
ReDim iValue(iRow, icow)
For i = 0 To iRow
For j = 0 To iCol
iValue(i, j) = Rsb.Fields(j)
Next
Rsb.MoveNext
Next

MSChart1.chartType = VtChChartType2dLine
MSChart1.ColumnCount = 2
MSChart1.ChartData = Values


a040285 2010-05-25
  • 打赏
  • 举报
回复
背景色透明不了呀!

怎么能当单击到某一点时,显示该点的数据值与时间???
chinaboyzyq 2010-05-25
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 a040285 的回复:]

还有点问题: MSChart的控件的背景怎么透明化,其中显示的C1,C2怎么改成字段名并改变显示的位置,
[/Quote]

Private Sub Command1_Click()
MSChart1.Backdrop.Fill.Brush.Style = VtBrushStyleNull '底背景背景透明
MSChart1.Legend.Backdrop.Fill.Brush.Style = VtBrushStyleNull '图列背景透明

MSChart1.Legend.Location.LocationType = VtChLocationTypeBottom '改变图列位置
MSChart1.ShowLegend = True '显示图列
MSChart1.Plot.SeriesCollection(1).LegendText = rsd(1).Name '系列一(C1)的名称
MSChart1.Plot.SeriesCollection(2).LegendText = rsd(2).Name '系列二(C2)的名称


'LocationType 常数
'
'常数 示例
'VtChLocationTypeTop 顶部
'VtChLocationTypeTopLeft 左上角
'VtChLocationTypeTopRight 右上角
'VtChLocationTypeLeft 左边
'VtChLocationTypeRight 右边
'VtChLocationTypeBottom 底部
'VtChLocationTypeBottomLeft 左下角
'VtChLocationTypeBottomRight 右下角
'VtChLocationTypeCustom

End Sub
a040285 2010-05-25
  • 打赏
  • 举报
回复
还有点问题: MSChart的控件的背景怎么透明化,其中显示的C1,C2怎么改成字段名并改变显示的位置,

1,453

社区成员

发帖
与我相关
我的任务
社区描述
VB 控件
社区管理员
  • 控件
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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