You can create a pie plot chart using code or the designer. The following image shows a Pie Plot type chart.
For details on the API, see PiePlotArea class.
The following class is also available when creating Pie plot type charts:
Using Code
- Use the PieSeries class to add data to a Chart control.
- Use the PiePlotArea class to create the plot area.
- Set the location and size of the plot area.
- Add the series to the plot area.
- Create a label and legend for the chart.
- Create a chart model and add the plot area, label, and legend to the model.
- Create a chart and add the chart model to it.
Example
The following example demonstrates using unbound data to create a Pie chart.
C# | Copy Code |
---|---|
PieSeries series = new PieSeries(); series.SeriesName = "Series 0"; series.Values.Add(1.0); series.Values.Add(2.0); series.Values.Add(4.0); series.Values.Add(8.0); PiePlotArea plotArea = new PiePlotArea(); plotArea.Location = new PointF(0.2f, 0.2f); plotArea.Size = new SizeF(0.6f, 0.6f); plotArea.Series.Add(series); LabelArea label = new LabelArea(); label.Text = "Pie Chart"; label.Location = new PointF(0.5f, 0.02f); label.AlignmentX = 0.5f; label.AlignmentY = 0.0f; LegendArea legend = new LegendArea(); legend.Location = new PointF(0.98f, 0.5f); legend.AlignmentX = 1.0f; legend.AlignmentY = 0.5f; ChartModel model = new ChartModel(); model.LabelAreas.Add(label); model.LegendAreas.Add(legend); model.PlotAreas.Add(plotArea); chart2DControl1.Model = model; |
VB | Copy Code |
---|---|
Dim series As New FarPoint.Win.Chart.PieSeries() series.SeriesName = "Series 0" series.Values.Add(1.0) series.Values.Add(2.0) series.Values.Add(4.0) series.Values.Add(8.0) Dim plotArea As New FarPoint.Win.Chart.PiePlotArea() plotArea.Location = New PointF(0.2F, 0.2F) plotArea.Size = New SizeF(0.6F, 0.6F) plotArea.Series.Add(series) Dim label As New FarPoint.Win.Chart.LabelArea() label.Text = "Pie Chart" label.Location = New PointF(0.5F, 0.02F) label.AlignmentX = 0.5F label.AlignmentY = 0.0F Dim legend As New FarPoint.Win.Chart.LegendArea() legend.Location = New PointF(0.98F, 0.5F) legend.AlignmentX = 1.0F legend.AlignmentY = 0.5F Dim model As New FarPoint.Win.Chart.ChartModel() model.LabelAreas.Add(label) model.LegendAreas.Add(legend) model.PlotAreas.Add(plotArea) chart2DControl1.Model = model |
Using the Chart Designer
- Select the PlotArea Collection editor.
- Click the drop-down button on the right side of the Add button (lower, left side of dialog).
- Select the PiePlotArea option and set properties as needed.