Bunifu Pie chart

Overview

Bunifu Pie chart is a circular chart which display data in the form of single-series sectors from a two-dimensional circle. It renders the y-axis values as slices in a pie. These slices are rendered in proportion to the whole, which is simply the sum of all the y values in the series suitable to visualize proportional data (in terms of percentage or fraction). The x axis values in the data series are represented as categorical, qualitative data. One data series is usually recommended in the rendering of pie charts.

Getting Started

This section explains you the steps required to start creating a simple bar chart and demonstrate the basic usage of the chart control.

Step 1: Drag the canvas control to the form from the toolbox. In the property section set both XAxesGridLines and YAxesGridlines properties to have a false value

Step 2: From the toolbox drag and drop the Bunifu Pie component to the form

Step 3: Add data to the Pie component as demonstrated in quick tips

Step 4: On the target property of the Pie component select bunifuCanvas1 as the target component

Step 5: Run the application

Code

C#
VB
C#
void renderPieChart()
{
Bunifu.Charts.WinForms.ChartTypes.BunifuPieChart bunifuPieChart = new Bunifu.Charts.WinForms.ChartTypes.BunifuPieChart();
/*
* For this example we will use random numbers
*/
var r = new Random();
/*
* Add your data from your source - accepts double list
* Below is an example from a random number
*/
List<double> data = new List<double>();
for (int i = 0; i < 5; i++)
{
data.Add(r.Next(0,50));
}
/*
* Set your data
*/
bunifuPieChart.Data = data;
/*
* Specify the target canvas
*/
bunifuPieChart.TargetCanvas = bunifuChartCanvas1;
/*
* Hide grid lines
*/
bunifuChartCanvas1.XAxesGridLines = false;
bunifuChartCanvas1.YAxesGridLines = false;
/*
* Add labels to your canvas
* Label count should correspond to data count for charts like Bar charts
*/
bunifuChartCanvas1.Labels = new string[] { "Label1", "Label2", "Label3", "Label4", "Label5" };
/*
* Beautify the chart by sepcifying the colors
* Color count should correspond to data count
*/
List<Color> bgColors = new List<Color>();
for (int i = 0; i < data.Count; i++)
{
bgColors.Add(Color.FromArgb(r.Next(256), r.Next(256), r.Next(256)));
}
bunifuPieChart.BackgroundColor = bgColors;
}
VB
Private Sub renderPieChart()
Dim bunifuPieChart As Bunifu.Charts.WinForms.ChartTypes.BunifuPieChart = New Bunifu.Charts.WinForms.ChartTypes.BunifuPieChart()
'
' For this example we will use random numbers
'
Dim r = New Random()
'
' Add your data from your source - accepts double list
' Below is an example from a random number
'
Dim data As List(Of Double) = New List(Of Double)()
For i As Integer = 0 To 5 - 1
data.Add(r.[Next](0, 50))
Next
'
' Set your data
'
bunifuPieChart.Data = data
'
' Specify the target canvas
'
bunifuPieChart.TargetCanvas = bunifuChartCanvas1
'
' Hide grid lines
'
bunifuChartCanvas1.XAxesGridLines = False
bunifuChartCanvas1.YAxesGridLines = False
'
' Add labels to your canvas
' Label count should correspond to data count for charts like Bar charts
'
bunifuChartCanvas1.Labels = New String() {"Label1", "Label2", "Label3", "Label4", "Label5"}
'
' Beautify the chart by sepcifying the colors
' Color count should correspond to data count
'
Dim bgColors As List(Of Color) = New List(Of Color)()
For i As Integer = 0 To data.Count - 1
bgColors.Add(Color.FromArgb(r.[Next](256), r.[Next](256), r.[Next](256)))
Next
bunifuPieChart.BackgroundColor = bgColors
End Sub

Pie stylings & customizations

BackgroundColor

Gets and sets a color value property to the pie’s segment background

(This should correspond with the collection size)

BorderColor

Gets and sets a color value property to the pie’s segment borders

BorderWidth

Gets and sets an integer value that can modify the width of the pie’s segment border.

Working with Data

TargetCanvas

Gets and sets the canvas that will render Bunifu pie chart

Data

Gets and sets an array of numbers as the datasets for Bunifu pie chart

Label

Gets and sets the text to draw on the chart’s legend

Pie Interactivity

HoverBackgroundColor

Gets and sets a color value property to apply on the pie’s background in the event of a mouse hover on a pie segment.

HoverBorderColor

Gets and sets a color value property to apply on the bar’s border in the event of a mouse hover on a pie segment.

HoverBorderWidth

Gets and sets an integer value that can modify the width of the bar’s border when the mouse hovers on a pie segment.