高手指点,如何在饼图/柱状图上标注百分比(AxMsChart),在线!!

max415 2006-04-25 04:04:18
高手指点,如何在饼图/柱状图上标注百分比(AxMsChart),在线!!
...全文
971 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
mustbelove 2007-04-03
  • 打赏
  • 举报
回复
下面是vb的代码,你可以自己修改一下,试试。

MSChart饼图显示百分比 分类:VB编程画饼图所需要的数据都在数组里面:
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


RUN_ 2006-05-10
  • 打赏
  • 举报
回复
帮顶一下,我是在旁边标注的。
tianjin_programer 2006-05-09
  • 打赏
  • 举报
回复
帮顶了
cxytrue790310 2006-05-08
  • 打赏
  • 举报
回复
For i = 1 To .Plot.SeriesCollection.Count
With .Plot.SeriesCollection(i).DataPoints(-1).DataPointLabel
.LocationType = MSChart20Lib.VtChLabelLocationType.VtChLabelLocationTypeOutside
.LineStyle = MSChart20Lib.VtChLabelLineStyle.VtChLabelLineStyleBent
.Component = 2 'VtChLabelComponentPercent
.PercentFormat = "0%"
.VtFont.Size = 10
End With
Next i

4,819

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 图表区
社区管理员
  • 图表区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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