Last active
April 27, 2021 04:33
-
-
Save k33ptoo/49342eaefb4950e233ec29d547041411 to your computer and use it in GitHub Desktop.
Bunifu Charts Overall Rendering Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* A Bunifu Charts Get Started code | |
* Copyright 2021 Bunifu Framework. | |
*/ | |
public static void renderBarchart(Bunifu.Charts.WinForms.BunifuChartCanvas bunifuChartCanvas) | |
{ | |
Bunifu.Charts.WinForms.ChartTypes.BunifuBarChart bunifuBarChart = new Bunifu.Charts.WinForms.ChartTypes.BunifuBarChart(); | |
/* | |
* 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 | |
*/ | |
bunifuBarChart.Data = data; | |
/* | |
* Specify the target canvas | |
*/ | |
bunifuBarChart.TargetCanvas = bunifuChartCanvas; | |
/* | |
* Add labels to your canvas | |
* Label count should correspond to data count for charts like Bar charts | |
*/ | |
bunifuChartCanvas.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))); | |
} | |
bunifuBarChart.BackgroundColor = bgColors; | |
} | |
public static void renderDoughtnut(Bunifu.Charts.WinForms.BunifuChartCanvas bunifuChartCanvas) | |
{ | |
Bunifu.Charts.WinForms.ChartTypes.BunifuDoughnutChart bunifuBarChart = new Bunifu.Charts.WinForms.ChartTypes.BunifuDoughnutChart(); | |
/* | |
* 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 | |
*/ | |
bunifuBarChart.Data = data; | |
/* | |
* Specify the target canvas | |
*/ | |
bunifuBarChart.TargetCanvas = bunifuChartCanvas; | |
/* | |
* Add labels to your canvas | |
* Label count should correspond to data count for charts like Bar charts | |
*/ | |
bunifuChartCanvas.Labels = new string[] { "Label1", "Label2", "Label3", "Label4", "Label5" }; | |
/* | |
* Hide grid lines | |
*/ | |
bunifuChartCanvas.XAxesGridLines = false; | |
bunifuChartCanvas.YAxesGridLines = false; | |
/* | |
* 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))); | |
} | |
bunifuBarChart.BackgroundColor = bgColors; | |
} | |
public static void renderBubbleChart(Bunifu.Charts.WinForms.BunifuChartCanvas bunifuChartCanvas) | |
{ | |
Bunifu.Charts.WinForms.ChartTypes.BunifuBubbleChart bunifuBubbleChart = new Bunifu.Charts.WinForms.ChartTypes.BunifuBubbleChart(); | |
/* | |
* For this example we will use random values | |
*/ | |
var r = new Random(); | |
/* | |
* Add your data from your source - accepts 3D points | |
* Below is an example from a random values | |
*/ | |
List<Bunifu.Charts.WinForms.Point3D> point3Ds = new List<Bunifu.Charts.WinForms.Point3D>(); | |
for (int i = 0; i < 5; i++) | |
{ | |
Bunifu.Charts.WinForms.Point3D point3D = new Bunifu.Charts.WinForms.Point3D(); | |
point3D.X = r.Next(0, 20); | |
point3D.Y = r.Next(0, 20); | |
point3D.Radius = r.Next(0, 20); | |
point3Ds.Add(point3D); | |
} | |
Bunifu.Charts.WinForms.Point3D[] data = point3Ds.ToArray(); | |
/* | |
* Set your data | |
*/ | |
bunifuBubbleChart.Data = data; | |
/* | |
* Specify the target canvas | |
*/ | |
bunifuBubbleChart.TargetCanvas = bunifuChartCanvas; | |
/* | |
* Beautify the chart by sepcifying the color | |
*/ | |
bunifuBubbleChart.BackgroundColor = Color.FromArgb(r.Next(256), r.Next(256), r.Next(256)); | |
} | |
public static void renderHorizontalChart(Bunifu.Charts.WinForms.BunifuChartCanvas bunifuChartCanvas) | |
{ | |
Bunifu.Charts.WinForms.ChartTypes.BunifuHorizontalBarChart bunifuHChart = new Bunifu.Charts.WinForms.ChartTypes.BunifuHorizontalBarChart(); | |
/* | |
* 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 | |
*/ | |
bunifuHChart.Data = data; | |
/* | |
* Specify the target canvas | |
*/ | |
bunifuHChart.TargetCanvas = bunifuChartCanvas; | |
/* | |
* Add labels to your canvas | |
* Label count should correspond to data count for charts like Bar charts | |
*/ | |
bunifuChartCanvas.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))); | |
} | |
bunifuHChart.BackgroundColor = bgColors; | |
} | |
public static void renderLineChart(Bunifu.Charts.WinForms.BunifuChartCanvas bunifuChartCanvas) | |
{ | |
Bunifu.Charts.WinForms.ChartTypes.BunifuLineChart bunifuLineChart = new Bunifu.Charts.WinForms.ChartTypes.BunifuLineChart(); | |
/* | |
* 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>(); | |
data.Add(-30); | |
for (int i = 0; i < 5; i++) | |
{ | |
data.Add(r.Next(0, 50)); | |
} | |
/* | |
* Set your data | |
*/ | |
bunifuLineChart.Data = data; | |
/* | |
* Specify the target canvas | |
*/ | |
bunifuLineChart.TargetCanvas = bunifuChartCanvas; | |
/* | |
* Add labels to your canvas | |
* Label count should correspond to data count for charts like Bar charts | |
*/ | |
bunifuChartCanvas.Labels = new string[] { "Label1", "Label2", "Label3", "Label4", "Label5" }; | |
/* | |
* Beautify the chart by sepcifying the colors | |
*/ | |
bunifuLineChart.BackgroundColor = Color.FromArgb(r.Next(256), r.Next(256), r.Next(256)); | |
bunifuLineChart.BorderColor = Color.FromArgb(r.Next(256), r.Next(256), r.Next(256)); | |
} | |
public static void renderRadarChart(Bunifu.Charts.WinForms.BunifuChartCanvas bunifuChartCanvas) | |
{ | |
Bunifu.Charts.WinForms.ChartTypes.BunifuRadarChart bunifuRadarChart = new Bunifu.Charts.WinForms.ChartTypes.BunifuRadarChart(); | |
/* | |
* 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 | |
*/ | |
bunifuRadarChart.Data = data; | |
/* | |
* Hide grid lines | |
*/ | |
bunifuChartCanvas.XAxesGridLines = false; | |
bunifuChartCanvas.YAxesGridLines = false; | |
/* | |
* Specify the target canvas | |
*/ | |
bunifuRadarChart.TargetCanvas = bunifuChartCanvas; | |
/* | |
* Add labels to your canvas | |
* Label count should correspond to data count for charts like Bar charts | |
*/ | |
bunifuChartCanvas.Labels = new string[] { "Label1", "Label2", "Label3", "Label4", "Label5" }; | |
/* | |
* Beautify the chart by sepcifying the colors | |
*/ | |
bunifuRadarChart.BackgroundColor = Color.FromArgb(r.Next(256), r.Next(256), r.Next(256)); | |
bunifuRadarChart.BorderColor = Color.FromArgb(r.Next(256), r.Next(256), r.Next(256)); | |
} | |
public static void renderPolarChart(Bunifu.Charts.WinForms.BunifuChartCanvas bunifuChartCanvas) | |
{ | |
Bunifu.Charts.WinForms.ChartTypes.BunifuPolarAreaChart bunifuPolarChart = new Bunifu.Charts.WinForms.ChartTypes.BunifuPolarAreaChart(); | |
/* | |
* 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 | |
*/ | |
bunifuPolarChart.Data = data; | |
/* | |
* Specify the target canvas | |
*/ | |
bunifuPolarChart.TargetCanvas = bunifuChartCanvas; | |
/* | |
* Hide grid lines | |
*/ | |
bunifuChartCanvas.XAxesGridLines = false; | |
bunifuChartCanvas.YAxesGridLines = false; | |
/* | |
* Add labels to your canvas | |
* Label count should correspond to data count for charts like Bar charts | |
*/ | |
bunifuChartCanvas.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))); | |
} | |
bunifuPolarChart.BackgroundColor = bgColors; | |
} | |
public static void renderPieChart(Bunifu.Charts.WinForms.BunifuChartCanvas bunifuChartCanvas) | |
{ | |
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 = bunifuChartCanvas; | |
/* | |
* Hide grid lines | |
*/ | |
bunifuChartCanvas.XAxesGridLines = false; | |
bunifuChartCanvas.YAxesGridLines = false; | |
/* | |
* Add labels to your canvas | |
* Label count should correspond to data count for charts like Bar charts | |
*/ | |
bunifuChartCanvas.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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment