Quick Tips

Getting Started fast with Bunifu Charts

To get started quickly after installing and licensing Bunifu charts here are some of the tips to get you started quickly.

After loading the components to toolbox

Step 1

Find BunifuChartCanvas and drag and drop to your form of user control designer(see below)

Step 2

Next find your preferred chart component - drag and drop to your form or user control(see below)

You can as well use code below

C#
VB
C#
Bunifu.Charts.WinForms.ChartTypes.BunifuBarChart bunifuChart= new Bunifu.Charts.WinForms.ChartTypes.BunifuBarChart();
VB
Dim bunifuChart As Bunifu.Charts.WinForms.ChartTypes.BunifuBarChart = New Bunifu.Charts.WinForms.ChartTypes.BunifuBarChart()

Step 3

Select the chart component and specify the canvas and your data by using the designer or code(see below)

Designer

Code

C#
VB
C#
/*
* 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.NextDouble());
}
/*
* Set your data
*/
bunifuBarChart1.Data = data;
/*
* Specify the target canvas
*/
bunifuBarChart1.TargetCanvas = bunifuChartCanvas1;
VB
'
' 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.NextDouble())
Next
'
' Set your data
'
bunifuBarChart1.Data = data
'
' Specify the target canvas
'
bunifuBarChart1.TargetCanvas = bunifuChartCanvas1

Step 4

You'll need to specify the Labels for charts like Bar chart, so select your canvas and go to Labels Property and add your labels per line

Designer

Code

C#
VB
C#
/*
* 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" };
VB
'
' 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"}

Step 5

Finally you'll need to beautify your chart by changing the background for each value. This can be done using code or by using the designer(see below)

Designer

Code

C#
VB
C#
/*
* Beautify the chart by sepcifying the colors
* Color count should correspond to data count
*/
List<Color> bgColors = new List<Color>();
bgColors.Add(Color.Red);
bgColors.Add(Color.Blue);
bgColors.Add(Color.Green);
bgColors.Add(Color.Gray);
bgColors.Add(Color.Purple);
bunifuBarChart1.BackgroundColor = bgColors;
VB
'
' Beautify the chart by sepcifying the colors
' Color count should correspond to data count
'
Dim bgColors As List(Of Color) = New List(Of Color)()
bgColors.Add(Color.Red)
bgColors.Add(Color.Blue)
bgColors.Add(Color.Green)
bgColors.Add(Color.Gray)
bgColors.Add(Color.Purple)
bunifuBarChart1.BackgroundColor = bgColors

Or generate random colors

C#
VB
C#
/*
* 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
'
' 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

Here is the complete code

C#
VB
C#
/*
* 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.NextDouble());
}
/*
* Set your data
*/
bunifuBarChart1.Data = data;
/*
* Specify the target canvas
*/
bunifuBarChart1.TargetCanvas = bunifuChartCanvas1;
/*
* 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
'
' 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.NextDouble())
Next
'
' Set your data
'
bunifuBarChart1.Data = data
'
' Specify the target canvas
'
bunifuBarChart1.TargetCanvas = bunifuChartCanvas1
'
' 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

For complete code for whole Bunifu Charts see this gist