VB6.0里MSChart 控件 画两条线,MSChart 2.Column = 1绑定是Y左边 ,MSChart 2.Column = 1绑定的是Y轴

xiaofeng19850916 2011-11-11 11:31:46
可是现在左边的线可以跟着Y轴绑定了 右边的线还是没反应 请问这是怎么回事,请专家给看看,重谢,代码如下:(VB6.0)
MSChart2.TitleText = "Sillicone 使用量"


RowCount = res.RecordCount
RowI = RowCount
If res.RecordCount = 0 Then Exit Sub
ReDim ss(res.RecordCount)
With MSChart2
.RowCount = RowCount 'rs.RecordCount


.chartType = VtChChartType2dLine

.ColumnCount = 2





For i = 1 To .Plot.SeriesCollection.Count

.Plot.SeriesCollection(i).DataPoints(-1).DataPointLabel.LocationType = VtChLabelLocationTypeAbovePoint
Next

.Plot.Axis(VtChAxisIdY).ValueScale.Auto = False
.Plot.Axis(VtChAxisIdY2).ValueScale.Auto = False


If res.RecordCount > 0 Then
res.MoveFirst
Else
Exit Sub
End If
MSChart2.chartType = VtChChartType2dCombination
MSChart2.Plot.SeriesCollection.Item(1).SeriesType = VtChSeriesType2dLine
MSChart2.Plot.SeriesCollection.Item(2).SeriesType = VtChSeriesType2dBar

For i = 0 To res.RecordCount - 1
.Column = 1 '收入曲线所在列
.RowCount = res.RecordCount
.Row = i + 1
.RowLabel = CStr(res("date"))
.Plot.Axis(VtChAxisIdY).ValueScale.Maximum = res1.Fields("good_qty1").Value
.Plot.Axis(VtChAxisIdY).ValueScale.Minimum = res1.Fields("good_qty2").Value
.Data = CDec(res("good_qty"))

.ColumnLabel = "生产量" '图例说明文字


'//兼职收入显示
.Column = 2 '兼职收入曲线所在列
.Plot.Axis(VtChAxisIdY2).ValueScale.Maximum = res1.Fields("jldw1").Value
.Plot.Axis(VtChAxisIdY2).ValueScale.Minimum = res1.Fields("jldw2").Value
.Data = res("jldw")

.ColumnLabel = "计量单位" '图例说明文字
res.MoveNext
Next


If res1.State = adStateOpen Then res1.Close
Set res1 = Nothing


拜托了 在线等 急。。。。。。。。。。
...全文
342 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
贝隆 2011-11-11
  • 打赏
  • 举报
回复
Option Explicit
Dim MyData(0 To 10, 2) As Variant '必须定义为变体类型
Private Const xlXYScatterSmoothNoMarkers = 73
Private Sub Form_Load()
Dim intP As Integer
For intP = 0 To 10
MyData(intP, 0) = intP * 36 & " " '必须确保它不是数字,不然会被认为是一条线
MyData(intP, 1) = 300 * Rnd
MyData(intP, 2) = 300 * Rnd
Next intP
'波形图外观设置
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

' .Plot.AutoLayout = False
' .Plot.UniformAxis = False
Rem %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
.Plot.AutoLayout = False
.Plot.UniformAxis = False
.RowCount = 21
.ChartData = MyData
.ShowLegend = True
' .chartType = xlXYScatterSmoothNoMarkers
.chartType = VtChChartType2dLine
' .chartType = VtChChartType2dXY
.Legend.Location.LocationType = VtChLocationTypeTop
.Plot.UniformAxis = False

.ColumnCount = 2
.ColumnLabelCount = 2
.Column = 1
.ColumnLabel = "曲线1"
.Column = 2
.ColumnLabel = "曲线2"
.Refresh
End With
End Sub

Private Sub Timer1_Timer()
Dim intP As Integer
For intP = 0 To 10
MyData(intP, 0) = intP * 36 & " " '必须确保它不是数字,不然会被认为是一条线
MyData(intP, 1) = 300 * Rnd
MyData(intP, 2) = 300 * Rnd
Next intP
' ChartDemo.ChartData = MyData
MSChart1.ChartData = MyData
End Sub

1,451

社区成员

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

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