我现在用mschart控件与数据库结合动态生成曲线,曲线的条数是动态的,现在有个问题想请教一下大家,就是当鼠标移到某条线的某个点的时候,怎么让他把这个点的数据显示出来,如果能用tooltip的方式显示出来就最好了,还有就是怎么把数据库中时间字段与x轴绑定起来?我把其中一部分代码贴出来,大家帮我看一下,谢谢!!!
rdst.Open "select * from UserAnalyse where AnalyseName= '" & UserAnalyseName & "'", cnn, adOpenStatic
While Not rdst.EOF
n = n + 1
rdst2.Open "select * from DataToDef where MeanName='" & rdst.Fields(1).Value & "' and DataDateTime between '" & BeginTime & "' and '" & EndTime & "'order by DataDateTime", cnn, adOpenStatic
     If rdst2.BOF = True Or rdst2.EOF = True Then
             FrmResult.Chart1.AutoIncrement = False
             FrmResult.Chart1.Plot.SeriesCollection(n).ShowLine = False
             MsgBox " < " & rdst.Fields(1).Value & " > 的结果集为空!", vbOKOnly, "提示"
            linenumber = linenumber + 1
     Else
      FrmResult.Chart1.AutoIncrement = True
      FrmResult.Chart1.RowCount = rdst2.RecordCount
      rdst2.MoveLast
      rdst2.MoveFirst
     For l = 1 To rdst2.RecordCount
    
     With FrmResult
     .Chart1.Row = l
  
    .Chart1.Data = rdst2.Fields(2).Value
    .Chart1.Refresh
     
     End With
     rdst2.MoveNext
     
    
     Next l
       
       FrmResult.Chart1.Plot.SeriesCollection(n).LegendText = rdst.Fields(1).Value
       FrmResult.Chart1.Plot.SeriesCollection(n).Pen.Width = 0.05
     End If
  
     rdst.MoveNext
     
  
    
    rdst2.Close
    Wend

解决方案 »

  1.   

    偶采取先把数据在mshflexgrid中显示出来,然后用mschart画出对应的曲线,再点击曲线上的点
    该点的数值就可以在设置的text中显示出来了。请楼主参考。
    主要使用
    .RowLabel 
    Private Sub MSChart1_Click()
    Dim i As Integer
    Dim xx, j, Max, Min As Integer
    Min = 1
    Max = Val(VScroll1.Value)
    ReDim arrDatac3(Max, 8)
    With MSChart1
    For i = 1 To Max
        For j = 6 To 7
        xx = Text6.Text
    .Column = 1
    .Row = i
    .RowLabel = MSHFlexGrid1.TextMatrix(xx, j)     '''点击显示的指定曲线上的
    Text7.Text = .RowLabel
    .AllowSelections = True
    .DragMode = 0
    .Enabled = True
        Next j
    Next i
    End With
    End Sub
      

  2.   

    谢谢楼上的,还有一个问题请教一下,就是怎么把时间绑定到X轴上,比如说上面的代码中有个BeginTime和EndTime,现在规定X轴的坐标在这个时间段内,应该怎么做呢?大家帮一下忙,谢谢!