Microsoft KB Archive/230484

= How To Label Pie Slices as Percentages in MSChart Pie Chart =

Article ID: 230484

Article Last Modified on 7/1/2004

-

APPLIES TO


 * Microsoft Visual Basic 5.0 Professional Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 5.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q230484



SUMMARY
When creating a Pie chart using the MSChart control, you might wish to label each "slice" of the pie as a percentage of the total. This article demonstrates how to do this.



MORE INFORMATION
The following example illustrates how to accomplish this task:  Start a new Standard EXE project in Visual Basic. Form1 is created by default. From the Project menu, choose Components, check Microsoft Chart Control, and click OK. Add an instance of the MSChart control to Form1.  Add the following code to Form1: 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 the project.

Keywords: kbhowto kbctrl KB230484

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.