Changeset 14710 for branches/HeuristicLab.DatastreamAnalysis/HeuristicLab.DatastreamAnalysis.Views/3.4/DataBarSetView.cs
- Timestamp:
- 03/02/17 14:10:57 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.DatastreamAnalysis/HeuristicLab.DatastreamAnalysis.Views/3.4/DataBarSetView.cs
r14588 r14710 119 119 120 120 chart.Series.Clear(); 121 121 122 Series series = chart.Series.Add(seriesName); 122 123 series.IsVisibleInLegend = false; … … 124 125 int i = 0; 125 126 foreach (var bar in Content.Bars) { 126 series.Points.Add(new DataPoint(i, bar.Value) { AxisLabel = bar.Name, Color = bar.BarColor }); 127 var dp = new DataPoint(i, bar.Value) { 128 AxisLabel = bar.Name, 129 ToolTip = bar.Name, 130 Color = bar.BarColor, 131 BorderWidth = 5 132 }; 133 series.Points.Add(dp); 127 134 i++; 128 135 } … … 154 161 for (int i = 0; i < bars.Count; i++) { 155 162 chart.Series[seriesName].Points.ElementAt(i).SetValueY(bars[i].Value); 163 chart.Series[seriesName].Points.ElementAt(i).ToolTip = bars[i].Name + " = " + bars[i].Value; 156 164 } 157 165 … … 163 171 } 164 172 173 public static Color DefaultColor = Color.FromArgb(65, 140, 240); 174 public static Color HighlightColor1 = Color.FromArgb(37, 105, 175); 175 public static Color HighlightColor2 = Color.FromArgb(247, 150, 70); 176 public static Color HighlightColor3 = Color.FromArgb(228, 108, 10); 177 //public static Color HighlightColor1 = Color.FromArgb(45, 120, 200); 178 //public static Color HighlightColor2 = Color.FromArgb(15, 90, 160); 179 //public static Color HighlightColor3 = Color.FromArgb(10, 60, 110); 165 180 private void CheckThresholds() { 166 181 var bars = Content.Bars.ToList(); 182 var winner = 183 !bars.Any() ? -1 : 184 bars 185 .Select((value, index) => new {Value = value, Index = index}) 186 .Aggregate((a, b) => ((a.Value.Value - a.Value.ThresholdUpperBound) > (b.Value.Value - b.Value.ThresholdUpperBound)) ? a : b) 187 .Index; 188 189 // color bars depending on the threshold boundaries they exceed 167 190 for (int i = 0; i < bars.Count; i++) { 168 191 var bar = bars[i]; 169 if (bar.Value > bar.Threshold) { 170 chart.Series[seriesName].Points[i].Color = Color.Orange; 192 if (bar.Value > bar.ThresholdUpperBound) { 193 chart.Series[seriesName].Points[i].Color = HighlightColor2; 194 chart.Series[seriesName].Points[i].BorderColor = HighlightColor2; 195 } else if (bar.Value > bar.ThresholdLowerBound) { 196 chart.Series[seriesName].Points[i].Color = HighlightColor1; 197 chart.Series[seriesName].Points[i].BorderColor = HighlightColor1; 171 198 } else { 172 199 chart.Series[seriesName].Points[i].Color = bar.BarColor; 200 chart.Series[seriesName].Points[i].BorderColor = bar.BarColor; 173 201 } 174 202 } 175 } 176 203 204 // color the winner's border 205 if (winner != -1 && bars[winner].Value > bars[winner].ThresholdUpperBound) { 206 chart.Series[seriesName].Points[winner].BorderColor = HighlightColor3; 207 } 208 } 209 210 211 212 private void AddThresholds() { 213 Series series = chart.Series.Add("Thresholds"); 214 series.IsVisibleInLegend = false; 215 series.ChartType = SeriesChartType.ErrorBar; 216 217 int i = 0; 218 foreach (var bar in Content.Bars) { 219 string desc = string.Format("{0} - Threshold [{1},{2}]", bar.Name, bar.ThresholdLowerBound,bar.ThresholdUpperBound); 220 var threshold = new DataPoint(i, new[] 221 {(bar.ThresholdLowerBound + bar.ThresholdUpperBound)/2, bar.ThresholdLowerBound, bar.ThresholdUpperBound}) { 222 AxisLabel = desc, 223 ToolTip = desc, 224 Color = bar.ThresholdColor, 225 BorderWidth = 1 226 }; 227 series.Points.Add(threshold); 228 i++; 229 } 230 } 177 231 private void AddThresholdsOld() { 178 232 Series series = chart.Series.Add("Thresholds"); … … 183 237 foreach (var bar in Content.Bars) { 184 238 //series.Points.Add(new DataPoint(i, new [] { bar.Threshold, bar.Threshold + 0.05 }) { AxisLabel = bar.Name, Color = Color.Transparent, BorderWidth = 2, BorderColor = bar.ThresholdColor}); 185 series.Points.Add(new DataPoint(i, new[] { bar.Threshold , bar.Threshold + 0.05}) { AxisLabel = bar.Name, Color = bar.ThresholdColor });239 series.Points.Add(new DataPoint(i, new[] { bar.ThresholdLowerBound, bar.ThresholdUpperBound }) { AxisLabel = bar.Name, Color = bar.ThresholdColor }); 186 240 i++; 187 241 } 188 242 } 189 190 private void AddThresholds() { 243 private void AddThresholdsOld2() { 191 244 chart.Annotations.Clear(); 192 245 … … 202 255 annotation.AxisX = chart.ChartAreas[0].AxisX; 203 256 annotation.AxisY = chart.ChartAreas[0].AxisY; 204 annotation.Y = bars[i].Threshold ;257 annotation.Y = bars[i].ThresholdLowerBound; 205 258 206 259 annotation.Alignment = ContentAlignment.MiddleCenter; … … 208 261 209 262 annotation.X = i - 0.4; 210 annotation.Width = 52.0/ bars.Count;263 annotation.Width = (46 - bars.Count) / bars.Count; 211 264 annotation.Name = bars[i].Name; 212 265 annotation.Tag = bars[i].Name;
Note: See TracChangeset
for help on using the changeset viewer.