-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathVisualizer.cs
84 lines (81 loc) · 3.25 KB
/
Visualizer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms.DataVisualization.Charting;
namespace Classes
{
class Visualizer
{
/* Visualizing data
*
*/
public void chart(Chart chart, string SeriesName, string[] x, int[] y, string chartType = "Column")
{
if (chart.Series[0].Name == "Series1")
{
//remove default series
chart.Series.Remove(chart.Series["Series1"]);
}
//add new series
chart.Series.Add(SeriesName);
//chart Type
switch (chartType)
{
case "Area":
chart.Series[SeriesName].ChartType = SeriesChartType.Area;
break;
case "Bar":
chart.Series[SeriesName].ChartType = SeriesChartType.Bar;
break;
case "BoxPlot":
chart.Series[SeriesName].ChartType = SeriesChartType.BoxPlot;
break;
case "Bubble":
chart.Series[SeriesName].ChartType = SeriesChartType.Bubble;
break;
case "Candlestick":
chart.Series[SeriesName].ChartType = SeriesChartType.Candlestick;
break;
case "Doughnut":
chart.Series[SeriesName].ChartType = SeriesChartType.Doughnut;
break;
case "ErrorBar":
chart.Series[SeriesName].ChartType = SeriesChartType.ErrorBar;
break;
case "FastLine":
chart.Series[SeriesName].ChartType = SeriesChartType.FastLine;
break;
case "FastPoint":
chart.Series[SeriesName].ChartType = SeriesChartType.FastPoint;
break;
case "Funnel":
chart.Series[SeriesName].ChartType = SeriesChartType.Funnel;
break;
case "Kagi":
chart.Series[SeriesName].ChartType = SeriesChartType.Kagi;
break;
case "Line":
chart.Series[SeriesName].ChartType = SeriesChartType.Line;
break;
case "Pie":
chart.Series[SeriesName].ChartType = SeriesChartType.Pie;
break;
case "Point":
chart.Series[SeriesName].ChartType = SeriesChartType.Point;
break;
default:
chart.Series[SeriesName].ChartType = SeriesChartType.Column;
break;
}
int count = 0;
//pass the legend & value
foreach (string addx in x)
{
chart.Series[SeriesName].Points.AddXY(addx, y[count]);
count++;
}
}
}
}