-
Notifications
You must be signed in to change notification settings - Fork 0
/
ChartDTO.cs
198 lines (191 loc) · 6.2 KB
/
ChartDTO.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using ScottPlot;
using WinformScottPlotMultiChart.Model;
namespace WinformScottPlotMultiChart
{
public class ChartDTO
{
public ChartDTO()
{
ChartForm = new Model.ChartFormModel();
GetData();
GetAllReadings();
}
private IList<PlotPoint> AllData { get; set; }
public Model.ChartFormModel ChartForm { get; set; }
public IList<PlotPoint> PlotData { get; set; }
private void GetAllReadings()
{
AllData = File.ReadAllLines(@"Readings.txt").Select(FromTsv).ToList();
}
private PlotPoint FromTsv(string tsvLine)
{
string[] values = tsvLine.Split('\t');
var pp = new PlotPoint();
pp.Series = values[0];
pp.XVal = Convert.ToDouble(values[1]);
pp.YVal = Convert.ToDouble(values[2]);
return pp;
}
private void GetData()
{
ChartForm = new Model.ChartFormModel
{
Id = 1,
Title = "SAMPLE DATA",
Subtitle = "SOMEWHERE DAM - Telecoordinometers (Section 4-5)",
ChartNum = 4,
Charts = new List<ChartModel>
{
new ChartModel
{
FormId = 0,
Id = 0,
Title = null,
YAxisTitle = "<-V mm M->",
YMin = -5,
YMax = 15,
ShowLegend = true,
HeightQuote = 30f,
ChartData = new List<ChartDataModel>
{
new ChartDataModel
{
ChartId = 0,
Id = 0,
PlotType = PlotTypes.Scatter,
PlotColor = "Red",
Label = "Straight Pendulum",
Series = "Series2"
}
},
ChartNotes = new List<ChartNoteModel>()
},
new ChartModel
{
FormId = 0,
Id = 1,
Title = null,
YAxisTitle = "<-L mm R->",
YMin = -10,
YMax = 10,
ShowLegend = false,
HeightQuote = 20f,
ChartData = new List<ChartDataModel>
{
new ChartDataModel
{
ChartId = 1,
Id = 1,
PlotType = PlotTypes.Scatter,
PlotColor = "Red",
Label = null,
Series = "Series1"
}
},
ChartNotes = new List<ChartNoteModel>
{
new ChartNoteModel
{
ChartId = 1,
Id = 0,
X = null,
Y = 8.84,
Tag = "Max value",
TextAlignment = TextAlignment.upperRight,
NoteColor = "Red"
},
new ChartNoteModel
{
ChartId = 1,
Id = 1,
X = null,
Y = -3.08,
Tag = "Min value",
TextAlignment = TextAlignment.upperRight,
NoteColor = "Red"
}
}
},
new ChartModel
{
FormId = 0,
Id = 2,
Title = null,
YAxisTitle = "<-M mm V->",
YMin = -5,
YMax = 15,
ShowLegend = true,
HeightQuote = 30f,
ChartData = new List<ChartDataModel>
{
new ChartDataModel
{
ChartId = 2,
Id = 2,
PlotType = PlotTypes.Scatter,
PlotColor = "Green",
Label = "Reverse Pendulum",
Series = "Series4"
}
},
ChartNotes = new List<ChartNoteModel>
{
new ChartNoteModel
{
ChartId = 2,
Id = 0,
X = null,
Y = 0.70,
Tag = "Max value",
TextAlignment = TextAlignment.upperRight,
NoteColor = "Red"
},
new ChartNoteModel
{
ChartId = 2,
Id = 1,
X = null,
Y = -1.98,
Tag = "Min value",
TextAlignment = TextAlignment.upperRight,
NoteColor = "Red"
}
}
},
new ChartModel
{
FormId = 0,
Id = 3,
Title = null,
YAxisTitle = "<-V mm M->",
YMin = -3,
YMax = 3,
ShowLegend = false,
HeightQuote = 20f,
ChartData = new List<ChartDataModel>
{
new ChartDataModel
{
ChartId = 3,
Id = 3,
PlotType = PlotTypes.Scatter,
PlotColor = "Green",
Label = null,
Series = "Series3"
}
},
ChartNotes = new List<ChartNoteModel>()
}
}
};
}
public void GetReadings(string src)
{
PlotData = AllData.Where(x => x.Series.Equals(src, StringComparison.InvariantCultureIgnoreCase)).ToList();
}
}
}