Changeset 14458
- Timestamp:
- 12/07/16 13:36:27 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Analysis.Views/3.3/DataTableControl.cs
r14457 r14458 542 542 543 543 int bins = histogramRows.Max(r => r.VisualProperties.Bins); 544 d ouble minValue =histogramRows.Min(r => r.Values.Min());545 d ouble maxValue =histogramRows.Max(r => r.Values.Max());546 d oubleintervalWidth = (maxValue - minValue) / bins;544 decimal minValue = (decimal)histogramRows.Min(r => r.Values.Min()); 545 decimal maxValue = (decimal)histogramRows.Max(r => r.Values.Max()); 546 decimal intervalWidth = (maxValue - minValue) / bins; 547 547 if (intervalWidth < 0) return; 548 548 if (intervalWidth == 0) { … … 552 552 553 553 if (!histogramRows.Any(r => r.VisualProperties.ExactBins)) { 554 intervalWidth = HumanRoundRange(intervalWidth);554 intervalWidth = (decimal)HumanRoundRange((double)intervalWidth); 555 555 minValue = Math.Floor(minValue / intervalWidth) * intervalWidth; 556 556 maxValue = Math.Ceiling(maxValue / intervalWidth) * intervalWidth; 557 557 } 558 558 559 d oubleintervalCenter = intervalWidth / 2;560 561 d ouble min = 0.0, max = 0.0;559 decimal intervalCenter = intervalWidth / 2; 560 561 decimal min = 0.0m, max = 0.0m; 562 562 if (!Double.IsNaN(Content.VisualProperties.XAxisMinimumFixedValue) && !Content.VisualProperties.XAxisMinimumAuto) 563 min = Content.VisualProperties.XAxisMinimumFixedValue;563 min = (decimal)Content.VisualProperties.XAxisMinimumFixedValue; 564 564 else min = minValue; 565 565 if (!Double.IsNaN(Content.VisualProperties.XAxisMaximumFixedValue) && !Content.VisualProperties.XAxisMaximumAuto) 566 max = Content.VisualProperties.XAxisMaximumFixedValue;566 max = (decimal)Content.VisualProperties.XAxisMaximumFixedValue; 567 567 else max = maxValue + intervalWidth; 568 568 569 double axisInterval = intervalWidth / row.VisualProperties.ScaleFactor;569 double axisInterval = (double)intervalWidth / row.VisualProperties.ScaleFactor; 570 570 571 571 var area = chart.ChartAreas[0]; … … 575 575 576 576 // get the range or intervals which define the grouping of the frequency values 577 var doubleRange = DoubleRange(min, max, intervalWidth).Skip(1).ToList();577 var range = Range(min, max, intervalWidth).Skip(1).ToList(); 578 578 579 579 // aggregate the row values by unique key and frequency value … … 585 585 586 586 // ensure that each column is displayed completely on the chart by adding two dummy datapoints on the upper and lower range 587 series.Points.Add(new DataPoint( min - intervalWidth, 0));588 series.Points.Add(new DataPoint( max + intervalWidth, 0));587 series.Points.Add(new DataPoint((double)(min - intervalWidth), 0)); 588 series.Points.Add(new DataPoint((double)(max + intervalWidth), 0)); 589 589 590 590 // add data points 591 591 int j = 0; 592 foreach (var d in doubleRange) {592 foreach (var d in range) { 593 593 double sum = 0.0; 594 594 // sum the frequency values that fall within the same interval 595 while (j < valueFrequencies.Count && valueFrequencies[j].Item1 < d) {595 while (j < valueFrequencies.Count && (decimal)valueFrequencies[j].Item1 < d) { 596 596 sum += valueFrequencies[j].Item2; 597 597 ++j; … … 603 603 ? "Y" 604 604 : Content.VisualProperties.YAxisTitle; 605 series.Points.Add(new DataPoint( d - intervalCenter, sum) {605 series.Points.Add(new DataPoint((double)(d - intervalCenter), sum) { 606 606 ToolTip = 607 607 xAxisTitle + ": [" + (d - intervalWidth) + "-" + d + ")" + Environment.NewLine + … … 612 612 613 613 #region Helpers 614 public static IEnumerable<d ouble> DoubleRange(double min, double max, doublestep) {615 d oublei;614 public static IEnumerable<decimal> Range(decimal min, decimal max, decimal step) { 615 decimal i; 616 616 for (i = min; i <= max; i += step) 617 617 yield return i;
Note: See TracChangeset
for help on using the changeset viewer.