Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Visualization/YAxisDescriptor.cs @ 1350

Last change on this file since 1350 was 1350, checked in by mstoeger, 15 years ago

Implemented multiple Y-Axes. A LineChart has several Y-Axes and each Y-Axis has several data rows. The same clipping area is set for all data rows belonging to a Y-Axis. (#433)

File size: 1.9 KB
Line 
1using System;
2using System.Collections.Generic;
3using HeuristicLab.Visualization.LabelProvider;
4
5namespace HeuristicLab.Visualization {
6  public delegate void YAxisDescriptorChangedHandler(YAxisDescriptor sender);
7
8  public class YAxisDescriptor {
9    private ILabelProvider yAxisLabelProvider = new ContinuousLabelProvider("0.##");
10    private readonly List<IDataRow> dataRows = new List<IDataRow>();
11    private bool showYAxis = true;
12    private string label = "";
13
14    public event YAxisDescriptorChangedHandler YAxisDescriptorChanged;
15
16    private void OnYAxisDescriptorChanged() {
17      if (YAxisDescriptorChanged != null) {
18        YAxisDescriptorChanged(this);
19      }
20    }
21
22    public List<IDataRow> DataRows {
23      get { return dataRows; }
24    }
25
26    public bool ShowYAxis {
27      get { return showYAxis; }
28      set {
29        showYAxis = value;
30        OnYAxisDescriptorChanged();
31      }
32    }
33
34    public ILabelProvider YAxisLabelProvider {
35      get { return yAxisLabelProvider; }
36      set {
37        yAxisLabelProvider = value;
38        OnYAxisDescriptorChanged();
39      }
40    }
41
42    public double MinValue {
43      get {
44        double min = double.MaxValue;
45
46        foreach (IDataRow row in dataRows) {
47          min = Math.Min(min, row.MinValue);
48        }
49
50        return min;
51      }
52    }
53
54    public double MaxValue {
55      get {
56        double max = double.MinValue;
57
58        foreach (IDataRow row in dataRows) {
59          max = Math.Max(max, row.MaxValue);
60        }
61
62        return max;
63      }
64    }
65
66    public string Label {
67      get { return label; }
68      set {
69        label = value;
70        OnYAxisDescriptorChanged();
71      }
72    }
73
74    public void AddDataRow(IDataRow row) {
75      if (row.YAxis != null) {
76        row.YAxis.DataRows.Remove(row);
77      }
78      this.DataRows.Add(row);
79      OnYAxisDescriptorChanged();
80    }
81  }
82}
Note: See TracBrowser for help on using the repository browser.