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
/** For this example we will use random numbers*/var r =newRandom();/** Add your data from your source - accepts double list* Below is an example from a random number*/List<double> data =newList<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;
' ' 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-1data.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
/** Add labels to your canvas* Label count should correspond to data count for charts like Bar charts*/bunifuChartCanvas1.Labels=newstring[] { "Label1","Label2","Label3","Label4","Label5" };
' ' 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
/** Beautify the chart by sepcifying the colors* Color count should correspond to data count*/List<Color> bgColors =newList<Color>();bgColors.Add(Color.Red);bgColors.Add(Color.Blue);bgColors.Add(Color.Green);bgColors.Add(Color.Gray);bgColors.Add(Color.Purple);bunifuBarChart1.BackgroundColor= bgColors;
' ' Beautify the chart by sepcifying the colors' Color count should correspond to data count' Dim bgColors AsList(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
/** Beautify the chart by sepcifying the colors* Color count should correspond to data count*/List<Color> bgColors =newList<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;
' ' Beautify the chart by sepcifying the colors' Color count should correspond to data count' Dim bgColors AsList(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
/** For this example we will use random numbers*/var r =newRandom();/** Add your data from your source - accepts double list* Below is an example from a random number*/List<double> data =newList<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=newstring[] { "Label1","Label2","Label3","Label4","Label5" };/** Beautify the chart by sepcifying the colors* Color count should correspond to data count*/List<Color> bgColors =newList<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;
' ' 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-1data.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-1bgColors.Add(Color.FromArgb(r.[Next](256), r.[Next](256), r.[Next](256))) NextbunifuPieChart.BackgroundColor= bgColors
For complete code for whole Bunifu Charts see this gist