Changeset 362 for trunk/sources/HeuristicLab.Logging
- Timestamp:
- 07/04/08 15:20:17 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Logging/LinechartView.cs
r2 r362 34 34 namespace HeuristicLab.Logging { 35 35 public partial class LinechartView : ViewBase { 36 private static int[] colors = new int[] { 37 182,182,255, 38 218,255,182, 39 255,182,218, 40 182,255,255, 41 218,182,255, 42 255,182,255, 43 255,182,182, 44 255,218,182, 45 255,255,182, 46 182,255,182, 47 182,255,218, 48 182,218,255 49 }; 50 36 51 public Linechart Linechart { 37 52 get { return (Linechart)base.Item; } … … 49 64 50 65 protected override void RemoveItemEvents() { 51 if 66 if(Linechart != null) { 52 67 Linechart.Values.ItemAdded -= new EventHandler<ItemIndexEventArgs>(Values_ItemAdded); 53 68 Linechart.Values.ItemRemoved -= new EventHandler<ItemIndexEventArgs>(Values_ItemRemoved); … … 57 72 protected override void AddItemEvents() { 58 73 base.AddItemEvents(); 59 if 74 if(Linechart != null) { 60 75 Linechart.Values.ItemAdded += new EventHandler<ItemIndexEventArgs>(Values_ItemAdded); 61 76 Linechart.Values.ItemRemoved += new EventHandler<ItemIndexEventArgs>(Values_ItemRemoved); … … 71 86 datachart.Group.Clear(); 72 87 datachart.Group.Add(new Axis(datachart, 0, 0, AxisType.Both)); 73 if (Linechart != null) { 88 double maxY = double.MinValue, minY = double.MaxValue; 89 if(Linechart != null) { 74 90 datachart.UpdateEnabled = false; 75 for (int i = 0; i < Linechart.NumberOfLines; i++) 76 datachart.AddDataRow(DataRowType.Lines, Pens.Black, Brushes.Blue); 91 for(int i = 0; i < Linechart.NumberOfLines; i++) { 92 int colorIndex = (i % 12)*3; 93 Color curCol = Color.FromArgb(colors[colorIndex],colors[colorIndex + 1], colors[colorIndex + 2]); 94 Pen p = new Pen(curCol); 95 SolidBrush b = new SolidBrush(curCol); 96 datachart.AddDataRow(DataRowType.Lines, p, b); 97 } 77 98 78 for 99 for(int i = 0; i < Linechart.Values.Count; i++) { 79 100 ItemList list = (ItemList)Linechart.Values[i]; 80 for (int j = 0; j < list.Count; j++) 81 datachart.AddDataPoint(j, i, ((DoubleData)list[j]).Data); 101 for(int j = 0; j < list.Count; j++) { 102 double value = ((DoubleData)list[j]).Data; 103 if(!double.IsInfinity(value) && !double.IsNaN(value)) { 104 if(value < minY) minY = value; 105 if(value > maxY) maxY = value; 106 datachart.AddDataPoint(j, i, value); 107 } 108 } 82 109 } 110 datachart.ZoomIn(-Linechart.Values.Count * 0.05, minY - (minY * 0.1), Linechart.Values.Count * 1.05, maxY * 1.05); 83 111 datachart.UpdateEnabled = true; 84 112 datachart.EnforceUpdate(); … … 89 117 private delegate void ItemIndexDelegate(object sender, ItemIndexEventArgs e); 90 118 private void Values_ItemRemoved(object sender, ItemIndexEventArgs e) { 91 if 119 if(InvokeRequired) { 92 120 Invoke(new ItemIndexDelegate(Values_ItemRemoved), sender, e); 93 121 } else { … … 96 124 } 97 125 private void Values_ItemAdded(object sender, ItemIndexEventArgs e) { 98 if 126 if(InvokeRequired) { 99 127 Invoke(new ItemIndexDelegate(Values_ItemAdded), sender, e); 100 128 } else { … … 102 130 ItemList list = (ItemList)e.Item; 103 131 datachart.UpdateEnabled = false; 104 for 132 for(int i = 0; i < list.Count; i++) 105 133 datachart.AddDataPoint(i, e.Index, ((DoubleData)list[i]).Data); 106 134 datachart.UpdateEnabled = true;
Note: See TracChangeset
for help on using the changeset viewer.