[983] | 1 | using System;
|
---|
[869] | 2 | using System.Drawing;
|
---|
[1326] | 3 | using System.Threading;
|
---|
[861] | 4 | using NUnit.Framework;
|
---|
| 5 |
|
---|
| 6 | namespace HeuristicLab.Visualization.Test {
|
---|
| 7 | [TestFixture]
|
---|
| 8 | public class LineChartTests {
|
---|
[1038] | 9 | private ChartDataRowsModel model;
|
---|
| 10 |
|
---|
| 11 | [SetUp]
|
---|
| 12 | public void SetUp() {
|
---|
| 13 | model = new ChartDataRowsModel();
|
---|
| 14 | }
|
---|
| 15 |
|
---|
[861] | 16 | [Test]
|
---|
[1981] | 17 | public void TestLineChartWithManyDataPoints() {
|
---|
[1038] | 18 | LineChartTestForm f = new LineChartTestForm(model);
|
---|
[861] | 19 |
|
---|
[869] | 20 | IDataRow row1 = new DataRow();
|
---|
| 21 | IDataRow row2 = new DataRow();
|
---|
| 22 | IDataRow row3 = new DataRow();
|
---|
[861] | 23 |
|
---|
[1962] | 24 | row1.RowSettings.Color = Color.Red;
|
---|
| 25 | row2.RowSettings.Color = Color.Green;
|
---|
| 26 | row3.RowSettings.Color = Color.Blue;
|
---|
[861] | 27 |
|
---|
[1962] | 28 | row1.RowSettings.Thickness = 3;
|
---|
| 29 | row2.RowSettings.Thickness = 4;
|
---|
| 30 | row3.RowSettings.Thickness = 5;
|
---|
[869] | 31 |
|
---|
[1962] | 32 | row1.RowSettings.Label = "Simon";
|
---|
| 33 | row2.RowSettings.Label = "Gertschi";
|
---|
| 34 | row3.RowSettings.Label = "Maxi";
|
---|
[1049] | 35 |
|
---|
[1972] | 36 | row1.RowSettings.Style = DrawingStyle.Solid;
|
---|
| 37 | row2.RowSettings.Style = DrawingStyle.Solid;
|
---|
| 38 | row3.RowSettings.Style = DrawingStyle.Dashed;
|
---|
[980] | 39 |
|
---|
[1607] | 40 |
|
---|
[1038] | 41 | model.AddDataRow(row1);
|
---|
| 42 | model.AddDataRow(row2);
|
---|
| 43 | model.AddDataRow(row3);
|
---|
[869] | 44 |
|
---|
| 45 | row1.AddValue(10);
|
---|
| 46 | row1.AddValue(5);
|
---|
| 47 | row1.AddValue(7);
|
---|
| 48 | row1.AddValue(3);
|
---|
| 49 | row1.AddValue(10);
|
---|
| 50 | row1.AddValue(2);
|
---|
| 51 |
|
---|
| 52 | row2.AddValue(5);
|
---|
| 53 | row2.AddValue(6);
|
---|
| 54 | row2.AddValue(5);
|
---|
| 55 |
|
---|
| 56 | row3.AddValue(2);
|
---|
| 57 | row3.AddValue(2);
|
---|
| 58 | row3.AddValue(2);
|
---|
| 59 | row3.AddValue(2);
|
---|
| 60 | row3.AddValue(2);
|
---|
| 61 |
|
---|
[983] | 62 | Random rand = new Random();
|
---|
| 63 |
|
---|
[1038] | 64 | for (int i = 0; i < 10000; i++) {
|
---|
[1607] | 65 | row1.AddValue(rand.NextDouble() * 10);
|
---|
| 66 | row2.AddValue(rand.NextDouble() * 10);
|
---|
| 67 | row3.AddValue(rand.NextDouble() * 10);
|
---|
[983] | 68 | }
|
---|
| 69 |
|
---|
[861] | 70 | f.ShowDialog();
|
---|
| 71 | }
|
---|
[1607] | 72 |
|
---|
[983] | 73 | [Test]
|
---|
[1981] | 74 | public void TestGrid() {
|
---|
| 75 | LineChartTestForm f = new LineChartTestForm(model);
|
---|
| 76 |
|
---|
| 77 | model.XAxis.ShowGrid = true;
|
---|
| 78 | model.XAxis.GridColor = Color.Red;
|
---|
| 79 |
|
---|
| 80 | model.DefaultYAxis.ShowGrid = true;
|
---|
| 81 | model.DefaultYAxis.GridColor = Color.Blue;
|
---|
| 82 |
|
---|
| 83 | IDataRow row1 = new DataRow();
|
---|
| 84 | row1.RowSettings.Label = "row1";
|
---|
| 85 |
|
---|
| 86 | model.AddDataRow(row1);
|
---|
| 87 |
|
---|
| 88 | row1.AddValue(0);
|
---|
| 89 | row1.AddValue(10);
|
---|
| 90 |
|
---|
| 91 | f.ShowDialog();
|
---|
| 92 | }
|
---|
| 93 |
|
---|
| 94 | [Test]
|
---|
| 95 | public void TestShowMarkers() {
|
---|
| 96 | LineChartTestForm f = new LineChartTestForm(model);
|
---|
| 97 |
|
---|
| 98 | IDataRow row1 = new DataRow();
|
---|
| 99 | row1.RowSettings.Label = "row1";
|
---|
| 100 | row1.RowSettings.Color = Color.Red;
|
---|
| 101 | row1.RowSettings.ShowMarkers = true;
|
---|
| 102 |
|
---|
| 103 | IDataRow row2 = new DataRow();
|
---|
| 104 | row2.RowSettings.Label = "row2";
|
---|
| 105 | row2.RowSettings.Color = Color.Blue;
|
---|
| 106 | row2.RowSettings.ShowMarkers = false;
|
---|
| 107 |
|
---|
| 108 | model.AddDataRow(row1);
|
---|
| 109 | model.AddDataRow(row2);
|
---|
| 110 |
|
---|
| 111 | for (int i = 0; i < 10; i++) {
|
---|
| 112 | row1.AddValue(i);
|
---|
| 113 | row2.AddValue(i*2);
|
---|
| 114 | }
|
---|
| 115 |
|
---|
| 116 | f.ShowDialog();
|
---|
| 117 | }
|
---|
| 118 |
|
---|
| 119 | [Test]
|
---|
| 120 | public void TestShowLabelOnAxes() {
|
---|
| 121 | LineChartTestForm f = new LineChartTestForm(model);
|
---|
| 122 |
|
---|
| 123 | IDataRow row1 = new DataRow();
|
---|
| 124 | IDataRow row2 = new DataRow();
|
---|
| 125 |
|
---|
| 126 | model.XAxis.Label = "X-Axis";
|
---|
| 127 | model.XAxis.ShowLabel = true;
|
---|
| 128 |
|
---|
| 129 | row1.YAxis = model.DefaultYAxis;
|
---|
| 130 | row1.YAxis.Label = "Y-Axis row1";
|
---|
| 131 | row1.RowSettings.Color = Color.Blue;
|
---|
| 132 | row1.YAxis.ShowYAxisLabel = false;
|
---|
| 133 |
|
---|
| 134 | row2.YAxis = new YAxisDescriptor();
|
---|
| 135 | row2.YAxis.Label = "Y-Axis row2";
|
---|
| 136 | row2.RowSettings.Color = Color.Red;
|
---|
| 137 | row2.YAxis.ShowYAxisLabel = true;
|
---|
| 138 |
|
---|
| 139 | model.AddDataRow(row1);
|
---|
| 140 | model.AddDataRow(row2);
|
---|
| 141 |
|
---|
| 142 | row1.AddValue(0);
|
---|
| 143 | row1.AddValue(10);
|
---|
| 144 | row1.AddValue(15);
|
---|
| 145 | row1.AddValue(16);
|
---|
| 146 |
|
---|
| 147 | row2.AddValue(0);
|
---|
| 148 | row2.AddValue(20);
|
---|
| 149 | row2.AddValue(25);
|
---|
| 150 | row2.AddValue(26);
|
---|
| 151 |
|
---|
| 152 | f.ShowDialog();
|
---|
| 153 | }
|
---|
| 154 |
|
---|
| 155 | [Test]
|
---|
[983] | 156 | public void TestAxes() {
|
---|
[1038] | 157 | LineChartTestForm f = new LineChartTestForm(model);
|
---|
[983] | 158 |
|
---|
| 159 | IDataRow row1 = new DataRow();
|
---|
[1285] | 160 | IDataRow row2 = new DataRow();
|
---|
[1350] | 161 | IDataRow row3 = new DataRow();
|
---|
[983] | 162 |
|
---|
[1885] | 163 | model.XAxis.Label = "X Axis";
|
---|
| 164 | model.XAxis.ShowLabel = true;
|
---|
| 165 | model.XAxis.ShowGrid = true;
|
---|
| 166 | model.XAxis.GridColor = Color.Blue;
|
---|
| 167 |
|
---|
[1387] | 168 | YAxisDescriptor yaxis1 = model.DefaultYAxis;
|
---|
| 169 | YAxisDescriptor yaxis2 = new YAxisDescriptor();
|
---|
| 170 |
|
---|
| 171 | yaxis1.Label = "Y-Axis 1";
|
---|
[1462] | 172 | yaxis1.Position = AxisPosition.Left;
|
---|
| 173 |
|
---|
[1387] | 174 | yaxis2.Label = "Y-Axis 2";
|
---|
[1457] | 175 | yaxis2.Position = AxisPosition.Right;
|
---|
[1458] | 176 |
|
---|
[1962] | 177 | row1.RowSettings.Color = Color.Red;
|
---|
| 178 | row1.RowSettings.Label = "Die Rote";
|
---|
[983] | 179 |
|
---|
[1962] | 180 | row2.RowSettings.Color = Color.Green;
|
---|
| 181 | row2.RowSettings.Label = "Die Grüne";
|
---|
[1285] | 182 |
|
---|
[1962] | 183 | row3.RowSettings.Color = Color.Blue;
|
---|
| 184 | row3.RowSettings.Label = "Die Blaue";
|
---|
[1387] | 185 | row3.YAxis = yaxis2;
|
---|
[1350] | 186 |
|
---|
[1038] | 187 | model.AddDataRow(row1);
|
---|
[1285] | 188 | model.AddDataRow(row2);
|
---|
[1350] | 189 | model.AddDataRow(row3);
|
---|
[983] | 190 |
|
---|
[1285] | 191 | Random rand = new Random(42);
|
---|
[1350] | 192 |
|
---|
[1285] | 193 | for (int i = 0; i < 10; i++) {
|
---|
[1607] | 194 | row1.AddValue(rand.NextDouble() * 10);
|
---|
| 195 | row2.AddValue(rand.NextDouble() * 10);
|
---|
| 196 | row3.AddValue(rand.NextDouble() * 1);
|
---|
[1285] | 197 | }
|
---|
[983] | 198 |
|
---|
[1350] | 199 | f.AddValue += delegate {
|
---|
[1607] | 200 | row1.AddValue(rand.NextDouble() * 10);
|
---|
| 201 | row2.AddValue(rand.NextDouble() * 10);
|
---|
| 202 | row3.AddValue(rand.NextDouble() * 1);
|
---|
[1350] | 203 | };
|
---|
| 204 |
|
---|
[983] | 205 | f.ShowDialog();
|
---|
| 206 | }
|
---|
[1040] | 207 |
|
---|
| 208 | [Test]
|
---|
[1981] | 209 | public void TestDataRowWithOnlyOneValueShouldntCauseZoomLevelTooHighError() {
|
---|
| 210 | LineChartTestForm f = new LineChartTestForm(model);
|
---|
| 211 |
|
---|
| 212 | IDataRow row1 = new DataRow();
|
---|
| 213 | row1.AddValue(10);
|
---|
| 214 |
|
---|
| 215 | model.AddDataRow(row1);
|
---|
| 216 |
|
---|
| 217 | f.ShowDialog();
|
---|
| 218 | }
|
---|
| 219 |
|
---|
| 220 | [Test]
|
---|
[1987] | 221 | public void TestDataRowWithoutValuesShouldntCauseZoomLevelTooHighError() {
|
---|
| 222 | LineChartTestForm f = new LineChartTestForm(model);
|
---|
| 223 |
|
---|
| 224 | IDataRow row1 = new DataRow();
|
---|
| 225 |
|
---|
| 226 | model.AddDataRow(row1);
|
---|
| 227 |
|
---|
| 228 | f.ShowDialog();
|
---|
| 229 | }
|
---|
| 230 |
|
---|
| 231 | [Test]
|
---|
| 232 | public void TestModelWithoutDataRowsShouldntCauseZoomLevelTooHighError() {
|
---|
| 233 | LineChartTestForm f = new LineChartTestForm(model);
|
---|
| 234 |
|
---|
| 235 | f.ShowDialog();
|
---|
| 236 | }
|
---|
| 237 |
|
---|
| 238 | [Test]
|
---|
[1983] | 239 | public void TestAddValueToDataRow() {
|
---|
[1982] | 240 | LineChartTestForm f = new LineChartTestForm(model);
|
---|
| 241 |
|
---|
| 242 | IDataRow row = new DataRow();
|
---|
| 243 | row.AddValue(0);
|
---|
[1983] | 244 | row.AddValue(10);
|
---|
| 245 | row.AddValue(-5);
|
---|
| 246 |
|
---|
| 247 | model.AddDataRow(row);
|
---|
| 248 |
|
---|
| 249 | f.ShowDialog();
|
---|
| 250 | }
|
---|
| 251 |
|
---|
| 252 | [Test]
|
---|
| 253 | public void TestAddValuesToDataRow() {
|
---|
| 254 | LineChartTestForm f = new LineChartTestForm(model);
|
---|
| 255 |
|
---|
| 256 | IDataRow row = new DataRow();
|
---|
| 257 | row.AddValues(new double[] {0, 10, -5});
|
---|
| 258 |
|
---|
| 259 | model.AddDataRow(row);
|
---|
| 260 |
|
---|
| 261 | f.ShowDialog();
|
---|
| 262 | }
|
---|
| 263 |
|
---|
| 264 | [Test]
|
---|
| 265 | public void TestInsertValueInDataRow() {
|
---|
| 266 | LineChartTestForm f = new LineChartTestForm(model);
|
---|
| 267 |
|
---|
| 268 | IDataRow row = new DataRow();
|
---|
| 269 | row.AddValue(0);
|
---|
[1982] | 270 | row.AddValue(5);
|
---|
| 271 |
|
---|
| 272 | row.AddValue(10, 1);
|
---|
| 273 | row.AddValue(10, 2);
|
---|
| 274 |
|
---|
| 275 | model.AddDataRow(row);
|
---|
| 276 |
|
---|
| 277 | f.ShowDialog();
|
---|
| 278 | }
|
---|
| 279 |
|
---|
| 280 | [Test]
|
---|
[1983] | 281 | public void TestInsertValuesInDataRow() {
|
---|
| 282 | LineChartTestForm f = new LineChartTestForm(model);
|
---|
| 283 |
|
---|
| 284 | IDataRow row = new DataRow();
|
---|
| 285 | row.AddValue(0);
|
---|
| 286 | row.AddValue(5);
|
---|
| 287 |
|
---|
| 288 | row.AddValues(new double[] {10, 10}, 1);
|
---|
| 289 |
|
---|
| 290 | model.AddDataRow(row);
|
---|
| 291 |
|
---|
| 292 | f.ShowDialog();
|
---|
| 293 | }
|
---|
| 294 |
|
---|
| 295 | [Test]
|
---|
| 296 | public void TestModifyValueInDataRow() {
|
---|
| 297 | LineChartTestForm f = new LineChartTestForm(model);
|
---|
| 298 |
|
---|
| 299 | IDataRow row = new DataRow();
|
---|
| 300 | row.AddValue(0);
|
---|
| 301 | row.AddValue(100);
|
---|
| 302 | row.AddValue(0);
|
---|
| 303 |
|
---|
| 304 | row.ModifyValue(5, 1);
|
---|
| 305 |
|
---|
| 306 | model.AddDataRow(row);
|
---|
| 307 |
|
---|
| 308 | f.ShowDialog();
|
---|
| 309 | }
|
---|
| 310 |
|
---|
| 311 | [Test]
|
---|
| 312 | public void TestModifyValuesInDataRow() {
|
---|
| 313 | LineChartTestForm f = new LineChartTestForm(model);
|
---|
| 314 |
|
---|
| 315 | IDataRow row = new DataRow();
|
---|
| 316 | row.AddValue(0);
|
---|
| 317 | row.AddValue(100);
|
---|
| 318 | row.AddValue(100);
|
---|
| 319 | row.AddValue(0);
|
---|
| 320 |
|
---|
| 321 | row.ModifyValues(new double[] {5, 5}, 1);
|
---|
| 322 |
|
---|
| 323 | model.AddDataRow(row);
|
---|
| 324 |
|
---|
| 325 | f.ShowDialog();
|
---|
| 326 | }
|
---|
| 327 |
|
---|
| 328 | [Test]
|
---|
[1984] | 329 | public void TestRemoveValueFromDataRow() {
|
---|
| 330 | LineChartTestForm f = new LineChartTestForm(model);
|
---|
| 331 |
|
---|
| 332 | IDataRow row = new DataRow();
|
---|
| 333 | row.AddValue(0);
|
---|
| 334 | row.AddValue(20);
|
---|
| 335 | row.AddValue(100);
|
---|
| 336 | row.AddValue(50);
|
---|
| 337 |
|
---|
| 338 | row.RemoveValue(2);
|
---|
| 339 |
|
---|
| 340 | model.AddDataRow(row);
|
---|
| 341 |
|
---|
| 342 | f.ShowDialog();
|
---|
| 343 | }
|
---|
| 344 |
|
---|
| 345 | [Test]
|
---|
| 346 | public void TestRemoveValuesFromDataRow() {
|
---|
| 347 | LineChartTestForm f = new LineChartTestForm(model);
|
---|
| 348 |
|
---|
| 349 | IDataRow row = new DataRow();
|
---|
| 350 | row.AddValue(0);
|
---|
| 351 | row.AddValue(20);
|
---|
| 352 | row.AddValue(100);
|
---|
| 353 | row.AddValue(50);
|
---|
| 354 |
|
---|
| 355 | row.RemoveValues(1, 2);
|
---|
| 356 |
|
---|
| 357 | model.AddDataRow(row);
|
---|
| 358 |
|
---|
| 359 | f.ShowDialog();
|
---|
| 360 | }
|
---|
| 361 |
|
---|
| 362 | [Test]
|
---|
[1607] | 363 | public void SimpleTestAggregator() {
|
---|
[1326] | 364 | LineChartTestForm f = new LineChartTestForm(model);
|
---|
| 365 |
|
---|
[1962] | 366 | IDataRow row1 = new DataRow();
|
---|
| 367 | row1.RowSettings.Label = "row";
|
---|
| 368 | row1.RowSettings.Color = Color.Red;
|
---|
| 369 | row1.RowSettings.Thickness = 3;
|
---|
[1972] | 370 | row1.RowSettings.Style = DrawingStyle.Solid;
|
---|
[1326] | 371 |
|
---|
| 372 | model.AddDataRow(row1);
|
---|
| 373 |
|
---|
| 374 |
|
---|
[1962] | 375 | MaxAggregator aggregator = new MaxAggregator();
|
---|
| 376 | aggregator.RowSettings.Label = "MinAggregator";
|
---|
| 377 | aggregator.RowSettings.Color = Color.Pink;
|
---|
| 378 | aggregator.RowSettings.Thickness = 5;
|
---|
[1972] | 379 | aggregator.RowSettings.Style = DrawingStyle.Solid;
|
---|
| 380 | aggregator.RowSettings.LineType = DataRowType.SingleValue;
|
---|
[1326] | 381 | aggregator.AddWatch(row1);
|
---|
| 382 |
|
---|
| 383 | model.AddDataRow(aggregator);
|
---|
| 384 |
|
---|
| 385 | row1.AddValue(10);
|
---|
| 386 | row1.AddValue(5);
|
---|
| 387 | row1.AddValue(7);
|
---|
| 388 | row1.AddValue(3);
|
---|
| 389 | row1.AddValue(10);
|
---|
| 390 | row1.AddValue(2);
|
---|
| 391 |
|
---|
| 392 | f.ShowDialog();
|
---|
| 393 | }
|
---|
| 394 |
|
---|
| 395 |
|
---|
| 396 | public class Worker {
|
---|
| 397 | // This method will be called when the thread is started.
|
---|
[1607] | 398 | private readonly ChartDataRowsModel model;
|
---|
| 399 |
|
---|
[1326] | 400 | public Worker(ChartDataRowsModel model) {
|
---|
| 401 | this.model = model;
|
---|
| 402 | }
|
---|
[1607] | 403 |
|
---|
[1386] | 404 | public void DoWorkMultiLine() {
|
---|
[1962] | 405 | IDataRow row1 = new DataRow();
|
---|
| 406 | row1.RowSettings.Color = Color.Red;
|
---|
| 407 | row1.RowSettings.Thickness = 2;
|
---|
| 408 | row1.RowSettings.Label = "Sinus";
|
---|
[1972] | 409 | row1.RowSettings.Style = DrawingStyle.Solid;
|
---|
| 410 | row1.RowSettings.ShowMarkers = false;
|
---|
[1326] | 411 | model.AddDataRow(row1);
|
---|
| 412 |
|
---|
[1962] | 413 | IDataRow row2 = new DataRow();
|
---|
| 414 | row2.RowSettings.Color = Color.Red;
|
---|
| 415 | row2.RowSettings.Thickness = 3;
|
---|
| 416 | row2.RowSettings.Label = "Growing";
|
---|
[1972] | 417 | row2.RowSettings.Style = DrawingStyle.Solid;
|
---|
| 418 | row2.RowSettings.ShowMarkers = false;
|
---|
[1326] | 419 | model.AddDataRow(row2);
|
---|
| 420 |
|
---|
[1962] | 421 | AvgAggregator multiAvgAggregator = new AvgAggregator();
|
---|
| 422 | multiAvgAggregator.RowSettings.Label = "MultiAvgAggregator";
|
---|
| 423 | multiAvgAggregator.RowSettings.Color = Color.DarkOliveGreen;
|
---|
| 424 | multiAvgAggregator.RowSettings.Thickness = 3;
|
---|
[1972] | 425 | multiAvgAggregator.RowSettings.Style = DrawingStyle.Solid;
|
---|
| 426 | multiAvgAggregator.RowSettings.LineType = DataRowType.SingleValue;
|
---|
| 427 | multiAvgAggregator.RowSettings.ShowMarkers = false;
|
---|
[1326] | 428 | multiAvgAggregator.AddWatch(row1);
|
---|
| 429 | multiAvgAggregator.AddWatch(row2);
|
---|
| 430 | model.AddDataRow(multiAvgAggregator);
|
---|
| 431 |
|
---|
[1962] | 432 | MaxAggregator multiMaxAggregator = new MaxAggregator();
|
---|
| 433 | multiMaxAggregator.RowSettings.Label = "MultiMaxAggregator";
|
---|
| 434 | multiMaxAggregator.RowSettings.Color = Color.DarkKhaki;
|
---|
| 435 | multiMaxAggregator.RowSettings.Thickness = 3;
|
---|
[1972] | 436 | multiMaxAggregator.RowSettings.Style = DrawingStyle.Solid;
|
---|
| 437 | multiMaxAggregator.RowSettings.LineType = DataRowType.SingleValue;
|
---|
| 438 | multiMaxAggregator.RowSettings.ShowMarkers = false;
|
---|
[1326] | 439 | multiMaxAggregator.AddWatch(row1);
|
---|
| 440 | multiMaxAggregator.AddWatch(row2);
|
---|
| 441 | model.AddDataRow(multiMaxAggregator);
|
---|
| 442 |
|
---|
[1962] | 443 | MinAggregator multiMinAggregator = new MinAggregator();
|
---|
| 444 | multiMinAggregator.RowSettings.Label = "MultiMinAggregator";
|
---|
| 445 | multiMinAggregator.RowSettings.Color = Color.DarkRed;
|
---|
| 446 | multiMinAggregator.RowSettings.Thickness = 3;
|
---|
[1972] | 447 | multiMinAggregator.RowSettings.Style = DrawingStyle.Solid;
|
---|
| 448 | multiMinAggregator.RowSettings.LineType = DataRowType.SingleValue;
|
---|
| 449 | multiMinAggregator.RowSettings.ShowMarkers = false;
|
---|
[1326] | 450 | multiMinAggregator.AddWatch(row1);
|
---|
| 451 | multiMinAggregator.AddWatch(row2);
|
---|
| 452 | model.AddDataRow(multiMinAggregator);
|
---|
| 453 |
|
---|
[1607] | 454 | // AvgLineAggregator multiLineAvgAggregator = new AvgLineAggregator {
|
---|
| 455 | // Label = "MultiLineAvgAggregator",
|
---|
| 456 | // Color = Color.Red,
|
---|
| 457 | // Thickness = 4,
|
---|
| 458 | // Style = DrawingStyle.Solid,
|
---|
| 459 | // LineType = DataRowType.Normal,
|
---|
| 460 | // ShowMarkers = false
|
---|
| 461 | // };
|
---|
| 462 | // multiLineAvgAggregator.AddWatch(row1);
|
---|
| 463 | // multiLineAvgAggregator.AddWatch(row2);
|
---|
| 464 | // multiLineAvgAggregator.AddValue(0);
|
---|
| 465 | // model.AddDataRow(multiLineAvgAggregator);
|
---|
[1326] | 466 |
|
---|
| 467 | double i = 0;
|
---|
| 468 |
|
---|
[1607] | 469 |
|
---|
[1326] | 470 | while (!_shouldStop && i <= 24) {
|
---|
| 471 | i += 0.2;
|
---|
[1607] | 472 | double newY = Math.Sin(i);
|
---|
| 473 | Console.WriteLine("working");
|
---|
[1326] | 474 | //row1.AddValue(rand.NextDouble() * 10);
|
---|
| 475 | row1.AddValue(newY * 10);
|
---|
[1607] | 476 | row2.AddValue(i * 2 - 15);
|
---|
| 477 | Thread.Sleep(100);
|
---|
[1326] | 478 | }
|
---|
| 479 | Console.WriteLine("worker thread: terminating gracefully.");
|
---|
| 480 | }
|
---|
[1607] | 481 |
|
---|
[1386] | 482 | public void DoWorkSingleLine() {
|
---|
[1962] | 483 | IDataRow row1 = new DataRow();
|
---|
| 484 | row1.RowSettings.Color = Color.Red;
|
---|
| 485 | row1.RowSettings.Thickness = 2;
|
---|
| 486 | row1.RowSettings.Label = "Sinus";
|
---|
[1972] | 487 | row1.RowSettings.Style = DrawingStyle.Solid;
|
---|
| 488 | row1.RowSettings.ShowMarkers = false;
|
---|
[1386] | 489 | model.AddDataRow(row1);
|
---|
| 490 |
|
---|
[1962] | 491 | IDataRow row2 = new DataRow();
|
---|
| 492 | row2.RowSettings.Color = Color.Red;
|
---|
| 493 | row2.RowSettings.Thickness = 3;
|
---|
| 494 | row2.RowSettings.Label = "Growing";
|
---|
[1972] | 495 | row2.RowSettings.Style = DrawingStyle.Solid;
|
---|
| 496 | row2.RowSettings.ShowMarkers = false;
|
---|
[1386] | 497 | model.AddDataRow(row2);
|
---|
| 498 |
|
---|
[1962] | 499 | MinAggregator aggregator = new MinAggregator();
|
---|
| 500 | aggregator.RowSettings.Label = "MinAggregator";
|
---|
| 501 | aggregator.RowSettings.Color = Color.Pink;
|
---|
| 502 | aggregator.RowSettings.Thickness = 3;
|
---|
[1972] | 503 | aggregator.RowSettings.Style = DrawingStyle.Solid;
|
---|
| 504 | aggregator.RowSettings.LineType = DataRowType.SingleValue;
|
---|
[1386] | 505 | aggregator.AddWatch(row1);
|
---|
| 506 | model.AddDataRow(aggregator);
|
---|
| 507 |
|
---|
[1962] | 508 | MaxAggregator maxAggregator = new MaxAggregator();
|
---|
| 509 | maxAggregator.RowSettings.Label = "MaxAggregator";
|
---|
| 510 | maxAggregator.RowSettings.Color = Color.DeepSkyBlue;
|
---|
| 511 | maxAggregator.RowSettings.Thickness = 3;
|
---|
[1972] | 512 | maxAggregator.RowSettings.Style = DrawingStyle.Solid;
|
---|
| 513 | maxAggregator.RowSettings.LineType = DataRowType.SingleValue;
|
---|
[1386] | 514 | maxAggregator.AddWatch(row1);
|
---|
| 515 | model.AddDataRow(maxAggregator);
|
---|
| 516 |
|
---|
[1962] | 517 | AvgAggregator avgAggregator = new AvgAggregator();
|
---|
| 518 | avgAggregator.RowSettings.Label = "AvgAggregator";
|
---|
| 519 | avgAggregator.RowSettings.Color = Color.Violet;
|
---|
| 520 | avgAggregator.RowSettings.Thickness = 3;
|
---|
[1972] | 521 | avgAggregator.RowSettings.Style = DrawingStyle.Solid;
|
---|
| 522 | avgAggregator.RowSettings.LineType = DataRowType.SingleValue;
|
---|
[1386] | 523 | avgAggregator.AddWatch(row1);
|
---|
| 524 | model.AddDataRow(avgAggregator);
|
---|
| 525 |
|
---|
| 526 | double i = 0;
|
---|
| 527 |
|
---|
[1607] | 528 |
|
---|
| 529 | while (!_shouldStop && i <= 240) {
|
---|
[1386] | 530 | i += 0.2;
|
---|
[1607] | 531 | double newY = Math.Sin(i);
|
---|
| 532 | Console.WriteLine("working");
|
---|
[1386] | 533 | //row1.AddValue(rand.NextDouble() * 10);
|
---|
| 534 | row1.AddValue(newY * 10);
|
---|
| 535 | row2.AddValue(i * 2 - 15);
|
---|
[1607] | 536 | //System.Threading.Thread.Sleep(100);
|
---|
[1386] | 537 | }
|
---|
| 538 | Console.WriteLine("worker thread: terminating gracefully.");
|
---|
| 539 | }
|
---|
[1607] | 540 |
|
---|
[1386] | 541 | public void DoWorkAvgLine() {
|
---|
[1962] | 542 | IDataRow row1 = new DataRow();
|
---|
| 543 | row1.RowSettings.Color = Color.Red;
|
---|
| 544 | row1.RowSettings.Thickness = 2;
|
---|
| 545 | row1.RowSettings.Label = "Sinus";
|
---|
[1972] | 546 | row1.RowSettings.Style = DrawingStyle.Solid;
|
---|
| 547 | row1.RowSettings.ShowMarkers = false;
|
---|
[1386] | 548 | model.AddDataRow(row1);
|
---|
| 549 |
|
---|
[1962] | 550 | IDataRow row2 = new DataRow();
|
---|
| 551 | row2.RowSettings.Color = Color.Red;
|
---|
| 552 | row2.RowSettings.Thickness = 3;
|
---|
| 553 | row2.RowSettings.Label = "Growing";
|
---|
[1972] | 554 | row2.RowSettings.Style = DrawingStyle.Solid;
|
---|
| 555 | row2.RowSettings.ShowMarkers = false;
|
---|
[1386] | 556 | model.AddDataRow(row2);
|
---|
| 557 |
|
---|
[1962] | 558 | AvgLineAggregator avgLineAggregator = new AvgLineAggregator();
|
---|
| 559 | avgLineAggregator.RowSettings.Label = "AvgLineAggregator";
|
---|
| 560 | avgLineAggregator.RowSettings.Color = Color.Violet;
|
---|
| 561 | avgLineAggregator.RowSettings.Thickness = 3;
|
---|
[1972] | 562 | avgLineAggregator.RowSettings.Style = DrawingStyle.Solid;
|
---|
| 563 | avgLineAggregator.RowSettings.LineType = DataRowType.Normal;
|
---|
| 564 | avgLineAggregator.RowSettings.ShowMarkers = false;
|
---|
[1386] | 565 | avgLineAggregator.AddWatch(row1);
|
---|
| 566 | avgLineAggregator.AddWatch(row2);
|
---|
| 567 | model.AddDataRow(avgLineAggregator);
|
---|
| 568 |
|
---|
| 569 | double i = 0;
|
---|
| 570 |
|
---|
[1607] | 571 | while (!_shouldStop && i <= 240) {
|
---|
[1386] | 572 | i += 0.2;
|
---|
[1607] | 573 | double newY = Math.Sin(i);
|
---|
| 574 | Console.WriteLine("working");
|
---|
[1386] | 575 | //row1.AddValue(rand.NextDouble() * 10);
|
---|
| 576 | row1.AddValue(newY * 10);
|
---|
| 577 | row2.AddValue(i * 2 - 15);
|
---|
[1607] | 578 | //Thread.Sleep(100);
|
---|
[1386] | 579 | }
|
---|
| 580 | Console.WriteLine("worker thread: terminating gracefully.");
|
---|
| 581 | }
|
---|
[1607] | 582 |
|
---|
| 583 | public void DoWorkFloatingAvg() {
|
---|
[1962] | 584 | IDataRow row1 = new DataRow();
|
---|
| 585 | row1.RowSettings.Color = Color.Red;
|
---|
| 586 | row1.RowSettings.Thickness = 2;
|
---|
| 587 | row1.RowSettings.Label = "SinusHacked";
|
---|
[1972] | 588 | row1.RowSettings.Style = DrawingStyle.Solid;
|
---|
| 589 | row1.RowSettings.ShowMarkers = false;
|
---|
[1607] | 590 | model.AddDataRow(row1);
|
---|
| 591 |
|
---|
[1962] | 592 | IDataRow row2 = new DataRow();
|
---|
| 593 | row2.RowSettings.Color = Color.Red;
|
---|
| 594 | row2.RowSettings.Thickness = 3;
|
---|
| 595 | row2.RowSettings.Label = "GrowingHacked";
|
---|
[1972] | 596 | row2.RowSettings.Style = DrawingStyle.Solid;
|
---|
| 597 | row2.RowSettings.ShowMarkers = false;
|
---|
[1607] | 598 | model.AddDataRow(row2);
|
---|
| 599 |
|
---|
[1962] | 600 | FloatingAvgAggregator avgAggregator = new FloatingAvgAggregator();
|
---|
| 601 | avgAggregator.RowSettings.Thickness = 2;
|
---|
| 602 | avgAggregator.RowSettings.Label = "floatingAvg";
|
---|
| 603 | avgAggregator.RowSettings.Color = Color.Peru;
|
---|
[1972] | 604 | avgAggregator.RowSettings.ShowMarkers = false;
|
---|
| 605 | avgAggregator.RowSettings.Style = DrawingStyle.Solid;
|
---|
[1607] | 606 |
|
---|
[1818] | 607 | avgAggregator.AddWatch(row1);
|
---|
| 608 | model.AddDataRow(avgAggregator);
|
---|
[1607] | 609 |
|
---|
[1962] | 610 | FloatingAvgAggregator avgAggregator2 = new FloatingAvgAggregator();
|
---|
| 611 | avgAggregator2.RowSettings.Thickness = 2;
|
---|
| 612 | avgAggregator2.RowSettings.Label = "floatingAvg";
|
---|
| 613 | avgAggregator2.RowSettings.Color = Color.Aqua;
|
---|
[1972] | 614 | avgAggregator2.RowSettings.ShowMarkers = false;
|
---|
| 615 | avgAggregator2.RowSettings.Style = DrawingStyle.Solid;
|
---|
[1818] | 616 |
|
---|
| 617 | avgAggregator2.AddWatch(row2);
|
---|
| 618 | model.AddDataRow(avgAggregator2);
|
---|
| 619 |
|
---|
| 620 |
|
---|
[1607] | 621 | double i = 0;
|
---|
| 622 | Random rnd = new Random();
|
---|
| 623 |
|
---|
[1818] | 624 | while (!_shouldStop && i <= 100) {
|
---|
[1607] | 625 | i += 0.2;
|
---|
| 626 | double newY = Math.Sin(i);
|
---|
| 627 |
|
---|
| 628 | double hack = rnd.NextDouble() * i / 10;
|
---|
| 629 | row1.AddValue(newY * 10 + hack);
|
---|
| 630 |
|
---|
| 631 | hack = rnd.NextDouble() * i / 10;
|
---|
| 632 | row2.AddValue(i * 2 - 15 + hack);
|
---|
| 633 | //Thread.Sleep(100);
|
---|
| 634 | }
|
---|
| 635 | Console.WriteLine("worker thread: terminating gracefully.");
|
---|
| 636 | }
|
---|
| 637 |
|
---|
[1326] | 638 | public void RequestStop() {
|
---|
| 639 | _shouldStop = true;
|
---|
| 640 | }
|
---|
[1607] | 641 |
|
---|
[1326] | 642 | // Volatile is used as hint to the compiler that this data
|
---|
| 643 | // member will be accessed by multiple threads.
|
---|
| 644 | private volatile bool _shouldStop;
|
---|
| 645 | }
|
---|
| 646 |
|
---|
| 647 |
|
---|
| 648 | [Test]
|
---|
[1386] | 649 | public void TestAggregatorMultiLine() {
|
---|
[1326] | 650 | LineChartTestForm f = new LineChartTestForm(model);
|
---|
[1386] | 651 |
|
---|
| 652 | // Create the thread object. This does not start the thread.
|
---|
| 653 | Worker workerObject = new Worker(model);
|
---|
| 654 | Thread workerThread = new Thread(workerObject.DoWorkMultiLine);
|
---|
| 655 |
|
---|
| 656 | // Start the worker thread.
|
---|
| 657 | workerThread.Start();
|
---|
| 658 |
|
---|
| 659 | f.ShowDialog();
|
---|
| 660 | workerObject.RequestStop();
|
---|
| 661 | }
|
---|
| 662 |
|
---|
| 663 | [Test]
|
---|
| 664 | public void TestAggregatorSingleLine() {
|
---|
| 665 | LineChartTestForm f = new LineChartTestForm(model);
|
---|
[1607] | 666 | model.Title = "SingleLineAggregator Tests";
|
---|
| 667 |
|
---|
[1326] | 668 | // Create the thread object. This does not start the thread.
|
---|
| 669 | Worker workerObject = new Worker(model);
|
---|
[1386] | 670 | Thread workerThread = new Thread(workerObject.DoWorkSingleLine);
|
---|
[1326] | 671 |
|
---|
| 672 | // Start the worker thread.
|
---|
| 673 | workerThread.Start();
|
---|
| 674 |
|
---|
| 675 | f.ShowDialog();
|
---|
| 676 | workerObject.RequestStop();
|
---|
| 677 | }
|
---|
[1607] | 678 |
|
---|
[1386] | 679 | [Test]
|
---|
| 680 | public void TestAggregatorAvgLine() {
|
---|
| 681 | LineChartTestForm f = new LineChartTestForm(model);
|
---|
[1607] | 682 | model.Title = "AvgLineTest";
|
---|
[1326] | 683 |
|
---|
[1386] | 684 | // Create the thread object. This does not start the thread.
|
---|
| 685 | Worker workerObject = new Worker(model);
|
---|
| 686 | Thread workerThread = new Thread(workerObject.DoWorkAvgLine);
|
---|
| 687 |
|
---|
| 688 | // Start the worker thread.
|
---|
| 689 | workerThread.Start();
|
---|
| 690 |
|
---|
| 691 | f.ShowDialog();
|
---|
| 692 | workerObject.RequestStop();
|
---|
| 693 | }
|
---|
| 694 |
|
---|
[1607] | 695 | [Test]
|
---|
| 696 | public void TestFloatingAvg() {
|
---|
| 697 | LineChartTestForm f = new LineChartTestForm(model);
|
---|
| 698 | model.Title = "FloatingAvg Test";
|
---|
| 699 | model.ViewSettings.LegendPosition = Legend.LegendPosition.Top;
|
---|
[1326] | 700 |
|
---|
[1607] | 701 | // Create the thread object. This does not start the thread.
|
---|
| 702 | Worker workerObject = new Worker(model);
|
---|
| 703 | Thread workerThread = new Thread(workerObject.DoWorkFloatingAvg);
|
---|
| 704 |
|
---|
| 705 | // Start the worker thread.
|
---|
| 706 | workerThread.Start();
|
---|
| 707 |
|
---|
| 708 | f.ShowDialog();
|
---|
| 709 | workerObject.RequestStop();
|
---|
| 710 | }
|
---|
| 711 |
|
---|
| 712 |
|
---|
[1326] | 713 | [Test]
|
---|
[1040] | 714 | public void TestAutoZoomInConstructor() {
|
---|
[1962] | 715 | IDataRow row1 = new DataRow();
|
---|
| 716 | row1.RowSettings.Color = Color.Red;
|
---|
| 717 | row1.RowSettings.Thickness = 3;
|
---|
[1972] | 718 | row1.RowSettings.Style = DrawingStyle.Solid;
|
---|
[1040] | 719 |
|
---|
| 720 | model.AddDataRow(row1);
|
---|
| 721 |
|
---|
| 722 | row1.AddValue(10);
|
---|
| 723 | row1.AddValue(5);
|
---|
| 724 | row1.AddValue(7);
|
---|
| 725 | row1.AddValue(3);
|
---|
| 726 | row1.AddValue(10);
|
---|
| 727 | row1.AddValue(2);
|
---|
| 728 |
|
---|
| 729 | LineChartTestForm f = new LineChartTestForm(model);
|
---|
| 730 | f.ShowDialog();
|
---|
| 731 | }
|
---|
[1240] | 732 |
|
---|
[1243] | 733 |
|
---|
[1240] | 734 | [Test]
|
---|
[1243] | 735 | public void TestSingleValueDataRows() {
|
---|
| 736 | LineChartTestForm f = new LineChartTestForm(model);
|
---|
| 737 |
|
---|
| 738 | IDataRow row1 = new DataRow();
|
---|
| 739 | IDataRow row2 = new DataRow();
|
---|
| 740 | IDataRow row3 = new DataRow();
|
---|
| 741 |
|
---|
[1342] | 742 | IDataRow row4 = new DataRow();
|
---|
| 743 | IDataRow row5 = new DataRow();
|
---|
| 744 | IDataRow row6 = new DataRow();
|
---|
| 745 |
|
---|
[1962] | 746 | row1.RowSettings.Color = Color.Red;
|
---|
| 747 | row2.RowSettings.Color = Color.Green;
|
---|
| 748 | row3.RowSettings.Color = Color.Blue;
|
---|
[1243] | 749 |
|
---|
[1962] | 750 | row4.RowSettings.Color = Color.DeepPink;
|
---|
| 751 | row5.RowSettings.Color = Color.Firebrick;
|
---|
| 752 | row6.RowSettings.Color = Color.DarkSlateGray;
|
---|
[1342] | 753 |
|
---|
[1962] | 754 | row1.RowSettings.Thickness = 3;
|
---|
| 755 | row2.RowSettings.Thickness = 4;
|
---|
| 756 | row3.RowSettings.Thickness = 5;
|
---|
[1243] | 757 |
|
---|
[1962] | 758 | row4.RowSettings.Thickness = 3;
|
---|
| 759 | row5.RowSettings.Thickness = 4;
|
---|
| 760 | row6.RowSettings.Thickness = 5;
|
---|
[1342] | 761 |
|
---|
[1962] | 762 | row1.RowSettings.Label = "SingleValue";
|
---|
| 763 | row2.RowSettings.Label = "Gertschi";
|
---|
| 764 | row3.RowSettings.Label = "Maxi";
|
---|
[1243] | 765 |
|
---|
[1962] | 766 | row4.RowSettings.Label = "Simon";
|
---|
| 767 | row5.RowSettings.Label = "klausmuellerwesternhagenunddierasperies";
|
---|
| 768 | row6.RowSettings.Label = "anyways";
|
---|
[1342] | 769 |
|
---|
[1972] | 770 | row1.RowSettings.Style = DrawingStyle.Solid;
|
---|
| 771 | row2.RowSettings.Style = DrawingStyle.Solid;
|
---|
| 772 | row3.RowSettings.Style = DrawingStyle.Dashed;
|
---|
[1243] | 773 |
|
---|
[1972] | 774 | row4.RowSettings.Style = DrawingStyle.Solid;
|
---|
| 775 | row5.RowSettings.Style = DrawingStyle.Solid;
|
---|
| 776 | row6.RowSettings.Style = DrawingStyle.Dashed;
|
---|
[1342] | 777 |
|
---|
[1972] | 778 | row1.RowSettings.LineType = DataRowType.SingleValue;
|
---|
| 779 | row2.RowSettings.LineType = DataRowType.SingleValue;
|
---|
[1243] | 780 | row1.AddValue(12);
|
---|
| 781 |
|
---|
| 782 | row2.AddValue(5);
|
---|
| 783 |
|
---|
[1607] | 784 |
|
---|
[1243] | 785 | row3.AddValue(2);
|
---|
| 786 | row3.AddValue(5);
|
---|
| 787 | row3.AddValue(9);
|
---|
| 788 | row3.AddValue(1);
|
---|
| 789 | row3.AddValue(3);
|
---|
| 790 |
|
---|
| 791 |
|
---|
[1342] | 792 | row4.AddValue(10);
|
---|
| 793 | row5.AddValue(11);
|
---|
| 794 | row6.AddValue(11);
|
---|
[1243] | 795 |
|
---|
[1342] | 796 | model.AddDataRow(row1);
|
---|
| 797 | model.AddDataRow(row2);
|
---|
| 798 | model.AddDataRow(row3);
|
---|
| 799 | model.AddDataRow(row4);
|
---|
| 800 | model.AddDataRow(row5);
|
---|
| 801 | model.AddDataRow(row6);
|
---|
| 802 |
|
---|
[1243] | 803 | f.ShowDialog();
|
---|
| 804 | }
|
---|
| 805 |
|
---|
| 806 | [Test]
|
---|
[1240] | 807 | public void TestMainForm() {
|
---|
| 808 | MainForm f = new MainForm();
|
---|
| 809 | f.ShowDialog();
|
---|
| 810 | }
|
---|
[1884] | 811 |
|
---|
| 812 |
|
---|
| 813 | [Test]
|
---|
| 814 | public void TestPointLines() {
|
---|
[1962] | 815 | IDataRow row1 = new DataRow();
|
---|
| 816 | row1.RowSettings.Color = Color.Red;
|
---|
| 817 | row1.RowSettings.Thickness = 3;
|
---|
[1972] | 818 | row1.RowSettings.Style = DrawingStyle.Dashed;
|
---|
[1884] | 819 |
|
---|
[1972] | 820 | row1.RowSettings.LineType = DataRowType.Points;
|
---|
[1884] | 821 | model.AddDataRow(row1);
|
---|
| 822 |
|
---|
| 823 | row1.AddValue(10);
|
---|
| 824 | row1.AddValue(5);
|
---|
| 825 | row1.AddValue(7);
|
---|
| 826 | row1.AddValue(3);
|
---|
| 827 | row1.AddValue(10);
|
---|
| 828 | row1.AddValue(2);
|
---|
| 829 |
|
---|
| 830 | LineChartTestForm f = new LineChartTestForm(model);
|
---|
| 831 | f.ShowDialog();
|
---|
| 832 | }
|
---|
| 833 |
|
---|
| 834 |
|
---|
[861] | 835 | }
|
---|
[1607] | 836 | } |
---|