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
1
Bunifu.Charts.WinForms.ChartTypes.BunifuBarChart bunifuChart= new Bunifu.Charts.WinForms.ChartTypes.BunifuBarChart();
Copied!
1
Dim bunifuChart As Bunifu.Charts.WinForms.ChartTypes.BunifuBarChart = New Bunifu.Charts.WinForms.ChartTypes.BunifuBarChart()
Copied!

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
1
/*
2
* For this example we will use random numbers
3
*/
4
var r = new Random();
5
6
/*
7
* Add your data from your source - accepts double list
8
* Below is an example from a random number
9
*/
10
List<double> data = new List<double>();
11
for (int i = 0; i < 5; i++)
12
{
13
data.Add(r.NextDouble());
14
}
15
/*
16
* Set your data
17
*/
18
bunifuBarChart1.Data = data;
19
20
/*
21
* Specify the target canvas
22
*/
23
bunifuBarChart1.TargetCanvas = bunifuChartCanvas1;
Copied!
1
'
2
' For this example we will use random numbers
3
'
4
Dim r = New Random()
5
6
'
7
' Add your data from your source - accepts double list
8
' Below is an example from a random number
9
'
10
Dim data As List(Of Double) = New List(Of Double)()
11
12
For i As Integer = 0 To 5 - 1
13
data.Add(r.NextDouble())
14
Next
15
16
'
17
' Set your data
18
'
19
bunifuBarChart1.Data = data
20
21
'
22
' Specify the target canvas
23
'
24
bunifuBarChart1.TargetCanvas = bunifuChartCanvas1
Copied!

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
1
/*
2
* Add labels to your canvas
3
* Label count should correspond to data count for charts like Bar charts
4
*/
5
bunifuChartCanvas1.Labels = new string[] { "Label1", "Label2", "Label3", "Label4", "Label5" };
6
Copied!
1
'
2
' Add labels to your canvas
3
' Label count should correspond to data count for charts like Bar charts
4
'
5
bunifuChartCanvas1.Labels = New String() {"Label1", "Label2", "Label3", "Label4", "Label5"}
Copied!

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
1
/*
2
* Beautify the chart by sepcifying the colors
3
* Color count should correspond to data count
4
*/
5
List<Color> bgColors = new List<Color>();
6
bgColors.Add(Color.Red);
7
bgColors.Add(Color.Blue);
8
bgColors.Add(Color.Green);
9
bgColors.Add(Color.Gray);
10
bgColors.Add(Color.Purple);
11
12
bunifuBarChart1.BackgroundColor = bgColors;
Copied!
1
'
2
' Beautify the chart by sepcifying the colors
3
' Color count should correspond to data count
4
'
5
Dim bgColors As List(Of Color) = New List(Of Color)()
6
bgColors.Add(Color.Red)
7
bgColors.Add(Color.Blue)
8
bgColors.Add(Color.Green)
9
bgColors.Add(Color.Gray)
10
bgColors.Add(Color.Purple)
11
bunifuBarChart1.BackgroundColor = bgColors
Copied!
Or generate random colors
C#
VB
1
/*
2
* Beautify the chart by sepcifying the colors
3
* Color count should correspond to data count
4
*/
5
List<Color> bgColors = new List<Color>();
6
for (int i = 0; i < data.Count; i++)
7
{
8
bgColors.Add(Color.FromArgb(r.Next(256), r.Next(256), r.Next(256)));
9
}
10
11
bunifuPieChart.BackgroundColor = bgColors;
12
Copied!
1
'
2
' Beautify the chart by sepcifying the colors
3
' Color count should correspond to data count
4
'
5
Dim bgColors As List(Of Color) = New List(Of Color)()
6
7
For i As Integer = 0 To data.Count - 1
8
bgColors.Add(Color.FromArgb(r.[Next](256), r.[Next](256), r.[Next](256)))
9
Next
10
11
bunifuPieChart.BackgroundColor = bgColors
Copied!
Here is the complete code
C#
VB
1
/*
2
* For this example we will use random numbers
3
*/
4
var r = new Random();
5
6
/*
7
* Add your data from your source - accepts double list
8
* Below is an example from a random number
9
*/
10
List<double> data = new List<double>();
11
for (int i = 0; i < 5; i++)
12
{
13
data.Add(r.NextDouble());
14
}
15
/*
16
* Set your data
17
*/
18
bunifuBarChart1.Data = data;
19
20
/*
21
* Specify the target canvas
22
*/
23
bunifuBarChart1.TargetCanvas = bunifuChartCanvas1;
24
25
/*
26
* Add labels to your canvas
27
* Label count should correspond to data count for charts like Bar charts
28
*/
29
bunifuChartCanvas1.Labels = new string[] { "Label1", "Label2", "Label3", "Label4", "Label5" };
30
/*
31
* Beautify the chart by sepcifying the colors
32
* Color count should correspond to data count
33
*/
34
List<Color> bgColors = new List<Color>();
35
for (int i = 0; i < data.Count; i++)
36
{
37
bgColors.Add(Color.FromArgb(r.Next(256), r.Next(256), r.Next(256)));
38
}
39
40
bunifuPieChart.BackgroundColor = bgColors;
41
42
Copied!
1
'
2
' For this example we will use random numbers
3
'
4
Dim r = New Random()
5
6
'
7
' Add your data from your source - accepts double list
8
' Below is an example from a random number
9
'
10
Dim data As List(Of Double) = New List(Of Double)()
11
12
For i As Integer = 0 To 5 - 1
13
data.Add(r.NextDouble())
14
Next
15
16
'
17
' Set your data
18
'
19
bunifuBarChart1.Data = data
20
21
'
22
' Specify the target canvas
23
'
24
bunifuBarChart1.TargetCanvas = bunifuChartCanvas1
25
26
'
27
' Add labels to your canvas
28
' Label count should correspond to data count for charts like Bar charts
29
'
30
bunifuChartCanvas1.Labels = New String() {"Label1", "Label2", "Label3", "Label4", "Label5"}
31
'
32
' Beautify the chart by sepcifying the colors
33
' Color count should correspond to data count
34
'
35
Dim bgColors As List(Of Color) = New List(Of Color)()
36
37
For i As Integer = 0 To data.Count - 1
38
bgColors.Add(Color.FromArgb(r.[Next](256), r.[Next](256), r.[Next](256)))
39
Next
40
41
bunifuPieChart.BackgroundColor = bgColors
Copied!
For complete code for whole Bunifu Charts see this gist