' get chart data
Dim data As
DataView = _dataSet.Tables["Products"].DefaultView
data.Sort =
"UnitPrice"
data.RowFilter =
"CategoryID = 1" ' beverages
' configure chart
C1Chart1.Reset()
C1Chart1.BackColor
= Color.White
C1Chart1.ChartArea.Style.Font
= new Font("Tahoma", 8)
C1Chart1.ChartGroups(0).ChartType
= Chart2DTypeEnum.Pie
' get series collection (pies have one series per
slice)
Dim dscoll As
ChartDataSeriesCollection = C1Chart1.ChartGroups(0).ChartData.SeriesList
dscoll.Clear()
' populate the series
Dim i As
Integer
For i = 0 To
data.Count - 1
Dim series As
ChartDataSeries = dscoll.AddNewSeries()
series.PointData.Length
= 1
series.Y(0) =
data(i)("UnitPrice")
series.Label =
String.Format("{0} ({1:c})", data(i)("ProductName"), data(i)("UnitPrice"))
Next I
' show pie legend
C1Chart1.Legend.Visible
= True
C1Chart1.Legend.Text
= "Product Unit Prices"
' hide legend, configure labels
C1Chart1.Legend.Visible
= false
Dim s As Style =
C1Chart1.ChartLabels.DefaultLabelStyle
s.Font = new
Font("Tahoma", 7)
s.BackColor =
SystemColors.Info
s.Opaque =
true
s.Border.BorderStyle
= BorderStyleEnum.Solid
' attach labels to each slice
Dim i As
Integer
For i = 0 To
data.Count - 1
Dim lbl As
C1.Win.C1Chart.Label = C1Chart1.ChartLabels.LabelsCollection.AddNewLabel()
lbl.Text =
string.Format("{0} ({1:c})", data(i)("ProductName"), data(i)("UnitPrice"))
lbl.Compass = LabelCompassEnum.Radial
lbl.Offset
= 20
lbl.Connected = True
lbl.Visible = True
lbl.AttachMethod = AttachMethodEnum.DataIndex
Dim am As
AttachMethodData = lbl.AttachMethodData
am.GroupIndex = 0
am.SeriesIndex = I
am.PointIndex = 0
Next i
Regards,
Andrew