你好,我的msflexgrid里两列数 我想画mschart条形图 并把第一列数显示为X轴 并把数字显示出来 把第2列作为y轴, 我做了 但是X轴总是无法显示数 只能显示C1,C2....等 我怎么才能把X轴的数据显示在坐标轴下呢 请求高手帮看看 等您回答!
下面是我的代码,但是X轴无法显示数据,请高手指点!
'On Error Resume Next
'With MSFlexGridData
'ReDim arr(0 To .Rows - 1, 0 To 1)
'Dim i As Integer
'For i = 1 To .Rows - 1
' arr(i, 0) = Val(.TextMatrix(i, 0))
' arr(i, 1) = Val(.TextMatrix(i, 3))
'Next i
' End With
'DiaCSD2.MSChart1.ChartData = arr
'DiaCSD2.MSChart1.Plot.SeriesCollection(1).LegendText = "加热半径"
' With DiaCSD2.MSChart1
' .ShowLegend = True
' .TitleText = "水平井加热半径剖面解释"
' .Plot.Axis(VtChAxisIdX, 0).AxisTitle = "测 深 (m)"
' .Plot.Axis(VtChAxisIdY, 0).AxisTitle = "加热半径 单位 m"
' .Legend.Location.LocationType = VtChLocationTypeBottomRight
' End With
'DiaCSD2.Show 

解决方案 »

  1.   

    '我的X轴总是显示数
    Private Sub Command1_Click()
    Dim arrPriceQuantity(1 To 5, 1 To 3)
    Dim i As Integer
    For i = 1 To 5
       arrPriceQuantity(i, 1) = Str(i) ' Series 1
       arrPriceQuantity(i, 2) = 0 - i ' Series 2
       arrPriceQuantity(i, 3) = i ' Series 2
    Next i
    MSChart1.ChartData = arrPriceQuantityEnd SubPrivate Sub Command2_Click()
    Dim arrValues(1 To 5, 1 To 3)
    Dim i As Integer
    For i = 1 To 5
       arrValues(i, 1) = Str(i) ' Labels
       arrValues(i, 2) = 0 + i ' Series 1 values.
       arrValues(i, 3) = 2 * i ' Series 2 values.
    Next i
    MSChart1.ChartData = arrValues
      

  2.   

    If MSFlexGridData.Rows = 2 Then
      MsgBox "未输入数据,无剖面特征可显示!", vbOKOnly, "提示"
    Else
       DiaCSD.Visible = False
    On Error Resume Next
        With DiaCSD.MSChart1
            .AllowDithering = True
            .AllowDynamicRotation = True
            .AllowSelections = True
            .AllowSeriesSelection = True
            .AutoIncrement = True
            .ShowLegend = True
    '        .Plot.Axis(VtChAxisIdY).ValueScale.Auto = False
    '        .Plot.Axis(VtChAxisIdY2).ValueScale.Auto = False
    '        .Plot.Axis(VtChAxisIdY).ValueScale.Minimum = 0
    '        .Plot.Axis(VtChAxisIdY).ValueScale.Maximum = 5
    '        .Plot.Axis(VtChAxisIdY2).ValueScale.Minimum = 0
    '        .Plot.Axis(VtChAxisIdY2).ValueScale.Maximum = 5
            .Plot.Axis(VtChAxisIdX).ValueScale.MajorDivision = 5 'X轴主要网格数量
            .Plot.Axis(VtChAxisIdY).ValueScale.MajorDivision = 5 '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
            .ChartType = VtChChartType2dBar 'VtChChartType2dXY '设置图形为二维散点图
            .TitleText = "水平井吸汽剖面解释"
            .Plot.Axis(VtChAxisIdX, 0).AxisTitle = "测      深 (m)"
            .Plot.Axis(VtChAxisIdY, 0).AxisTitle = "吸汽百分数"
            .Legend.Location.LocationType = VtChLocationTypeBottomRight
        End With
        With MSFlexGridData
            ReDim MyData(1 To .Rows - 1, 0 To 1)
            Dim i As Integer
        For i = 1 To .Rows - 1
            MyData(i, 0) = Str(MSFlexGridData.TextMatrix(i, 0))
            MyData(i, 1) = Val(MSFlexGridData.TextMatrix(i, 1))
        Next i
        End With
            DiaCSD.MSChart1.ChartData = MyData
            DiaCSD.MSChart1.Plot.SeriesCollection(1).LegendText = "吸汽百分数"
            DiaCSD.Show
            End If最后答案 运行很好 大家分享一下子哦