-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
77 lines (61 loc) · 2.23 KB
/
Program.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
using System.Drawing;
using Charting.Window;
//*--------------------Fast charting-----------------------*/
GraphCreator.Start(x => x * x, "y = x^2");
GraphCreator.Start(Math.Sqrt, "Sqrt(x)");
GraphCreator.Start(new[] { (1d, 30d), (2d, 25d), (3d, 10d) },
InterpolationAlgorithm.CatmullRomSpline,
"Points");
//*========================================================*/
//*------------------Using GraphBuilder--------------------*/
//function
var builder = new GraphBuilder();
builder
.SetFunction(Math.Cos)
.SetName("Cos(x)")
.SetDx(0.01)
.SetRange(-10, 10)
.SetColor(Color.Blue);
var graph = new GraphCreator(builder);
graph.Start();
//point function
var points = new List<(double, double)>();
points.Add((1, 2)); points.Add((2, 8)); points.Add((3, 4));
var graphPointsBuilder = new GraphBuilder()
.SetPoints(points)
.SetName("Points")
.UseInterpolationAlgorithm(InterpolationAlgorithm.CanonicalSpline);
new GraphCreator(graphPointsBuilder, new DesignBuilder().SetTitle("Points")).
Start();
//*========================================================*/
//*--------------------Several graphs----------------------*/
var pointsBuilder = new GraphBuilder().SetPoints(points).SetColor(Color.Red);
var graphBuilder = new GraphBuilder()
.SetFunction(x => 2 * x)
.SetName("2x")
.SetDx(0.01)
.SetRange(-20, 20);
var graphs = new GraphCreator(new[] {builder, graphBuilder, pointsBuilder });
graphs.Start();
//*========================================================*/
/*--------------------Live charting-----------------------*/
var liveBuilder = new GraphBuilder()
.SetColor(Color.Yellow);
var liveDesignBuilder = new DesignBuilder()
.SetVisiblePoints(25)
.SetBackColor(Color.Black)
.SetBorderColor(Color.LightGreen)
.SetTextColor(Color.LightGreen)
.SetTitleColor(Color.LightGreen)
.SetTitle("Your data");
var liveGraph = new GraphCreator(liveBuilder, liveDesignBuilder);
liveGraph.Start();
var rand = new Random();
for (int i = 0; i < 100; i++)
{
liveBuilder.AddPoint((i, 100 * rand.NextDouble()));
liveGraph.Update();
Thread.Sleep(100);
}
/*========================================================*/
Console.ReadKey(); //Don't forget about this if you don't use await