Changeset 12598
- Timestamp:
- 07/06/15 13:42:53 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/BubbleChart/HeuristicLab.Optimization.BubbleChart/3.3/BubbleChartView.cs
r12595 r12598 56 56 public BubbleChartView() { 57 57 InitializeComponent(); 58 59 chart.CustomizeAllChartAreas(); 60 chart.ChartAreas[0].CursorX.Interval = 1; 61 chart.ChartAreas[0].CursorY.Interval = 1; 62 chart.ChartAreas[0].AxisX.ScaleView.Zoomable = true; 63 chart.ChartAreas[0].AxisY.ScaleView.Zoomable = true; 58 64 } 59 65 … … 190 196 var ys = GetValues(item, YAxisValue).ToList(); 191 197 var ss = GetValues(item, SizeAxisValue).ToList(); 192 if (xs.Count > 0 && ys.Count > 0 && ss.Count == 1) { 193 var s = ss[0]; 198 if (xs.Count > 0 && ys.Count > 0 && (ss.Count == 1 || ss.Count == xs.Count || ss.Count == ys.Count)) { 199 var sEnum = ss.Count > 1 ? ss.GetEnumerator() : Enumerable.Repeat(ss[0], xs.Count * ys.Count).GetEnumerator(); 200 sEnum.MoveNext(); 194 201 if (xs.Count > 1 && ys.Count > 1) { // index matching 195 202 for (int i = 0; i < Math.Min(xs.Count, ys.Count); i++) 196 series.Points.Add(new DataPoint(xs[i], new[] { ys[i], s }));203 series.Points.Add(new DataPoint(xs[i], new[] { ys[i], sEnum.Current })); 197 204 } else { 198 foreach (var x in xs) 199 foreach (var y in ys) 200 series.Points.Add(new DataPoint(x, new[] { y, s })); 205 foreach (var x in xs) { 206 foreach (var y in ys) { 207 series.Points.Add(new DataPoint(x, new[] { y, sEnum.Current })); 208 sEnum.MoveNext(); 209 } 210 } 201 211 } 202 212 } 203 213 } 214 UpdateMarkerSizes(); 204 215 } 205 216 } … … 349 360 } 350 361 } 362 363 private void UpdateMarkerSizes() { 364 var series = chart.Series[0]; 365 if (series.Points.Count <= 0) return; 366 367 var sizeValues = series.Points.Select(p => p.YValues[1]); 368 double minSizeValue = sizeValues.Min(); 369 double maxSizeValue = sizeValues.Max(); 370 double sizeRange = maxSizeValue - minSizeValue; 371 372 const int smallestBubbleSize = 7; 373 374 foreach (DataPoint point in series.Points) { 375 //calculates the relative size of the data point 0 <= relativeSize <= 1 376 double relativeSize = (point.YValues[1] - minSizeValue); 377 if (sizeRange > double.Epsilon) { 378 relativeSize /= sizeRange; 379 380 //invert bubble sizes if the value of the trackbar is negative 381 //if (sizeTrackBar.Value < 0) relativeSize = Math.Abs(relativeSize - 1); 382 } else relativeSize = 1; 383 384 double sizeChange = /*Math.Abs(sizeTrackBar.Value)*/ 10 * relativeSize; 385 //double sizeChange = 0; 386 point.MarkerSize = (int)Math.Round(sizeChange + smallestBubbleSize); 387 } 388 } 351 389 #endregion 352 390
Note: See TracChangeset
for help on using the changeset viewer.