MSChart饼图显示百分比-------牵手的博客

画饼图所需要的数据都在数组里面:
dim dataArray(0 to iMax, 0 to 1)

其中dataArray(i,0)是标题
    dataArray(i,0)是数字

代码如下:

            MSChart.chartType = VtChChartType2dPie ' 画饼图
           
            MSChart.Visible = True
            MSChart.AllowSelections = False
            MSChart.ShowLegend = True
            MSChart.TitleText = "百分比图"
           
            ' 为Chart控件的各行各列赋值
            MSChart.RowCount = 1
            MSChart.ColumnCount = iMax + 1
            MSChart.RowLabel = ""
            For i = 0 To iMax
                MSChart.Row = 1
                MSChart.Column = i + 1
                MSChart.Data = dataArray(i, 1)
                MSChart.ColumnLabel = dataArray(i, 0)
            Next
这段代码能画出漂亮的饼图来,但是,显示不出来个部分所占的百分比。
-----------------------------------------------------------------------------------------------------

MSChar显示百分比:

Private Sub Form_Load()
      With MSChart1
         .ChartType = VtChChartType2dPie

      For i = 1 To 3
         .Row = 1
         .Column = i
         .Data = i * 100
      Next

      With .DataGrid
         .RowLabelCount = 1
         .ColumnCount = 3
         .RowCount = 1
         For i = 1 To .ColumnCount
            .ColumnLabel(i, 1) = "Column " & i
         Next i
         .RowLabel(1, 1) = "Data as a Percentage"
      End With

      For i = 1 To .Plot.SeriesCollection.Count
         With .Plot.SeriesCollection(i).DataPoints(-1).DataPointLabel
            .LocationType = VtChLabelLocationTypeOutside
            .Component = VtChLabelComponentPercent
            .PercentFormat = "0%"
            .VtFont.Size = 10
         End With
      Next i

      End With

End Sub

 
  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值