Pie charts, the most common tools used for data visualization, are circular graphs that display the proportionate contribution of each category which is represented by a pie or a slice. The magnitude of the dependent variable is proportional to the angle of the slice. These charts can be used for plotting just one series with non-zero and positive values. For example, you can use a pie chart to show the market share of various automobile companies.
FlexChart for WinForms provides pie chart through a stand alone control which is represented by the FlexPie class. You can bind the chart with data using the FlexPie.DataSource property provided by the FlexPie class. This class also provides FlexPie.Binding and FlexPie.BindingName properties for setting numeric values and labels of the pie chart slices. You can also specify the angle from where you want to start drawing the slices in the clock wise direction by setting the StartAngle property. FlexChart also lets you create following variations of pie chart:
Doughnut Chart |
Exploded Pie Chart |
Reversed Pie Chart |
---|---|---|
To create a pie chart using FlexChart:
At design-time
Using code
To create a WinForms pie chart through code, the first step after initializing the FlexPie control is to clear the default series and add a new series using the Add method. Set up the data source through the DataSource property and set the BindingName and Binding property. You can also set up the chart further by setting the other required properties such as header content, data label content etc.
Note that the above sample code uses a custom method named GetCarSales to supply data. You can set up the data source as per your requirements.
While a single pie chart is used to present the part-to-whole relationship in a group, the multiple pies are required for presenting or comparing data across various groups. For example, you can use multiple pies to compare quarterly sales figures of various car brands. With FlexChart, you can achieve this by simply setting the comma-separated field names from a data source in Binding property of the FlexPie class.