Changeset 14457
- Timestamp:
- 12/07/16 13:19:31 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Analysis.Views/3.3/DataTableControl.cs
r14439 r14457 181 181 break; 182 182 case DataRowVisualProperties.DataRowChartType.Histogram: 183 series.ChartType = SeriesChartType. Column;183 series.ChartType = SeriesChartType.StackedColumn; 184 184 series.SetCustomProperty("PointWidth", "1"); 185 185 if (!series.Color.IsEmpty && series.Color.GetBrightness() < 0.25) … … 500 500 switch (row.VisualProperties.ChartType) { 501 501 case DataRowVisualProperties.DataRowChartType.Histogram: 502 CalculateHistogram(series, row); 502 // when a single histogram is updated, all histograms must be updated. otherwise the value ranges and bin sizes may not be equal. 503 var histograms = Content.Rows 504 .Where(r => r.VisualProperties.ChartType == DataRowVisualProperties.DataRowChartType.Histogram) 505 .ToList(); 506 CalculateHistogram(series, row, histograms); 507 foreach (var h in from r in histograms 508 where r != row 509 let s = chart.Series.FindByName(r.Name) 510 where s != null 511 where !invisibleSeries.Contains(s) 512 select new { row = r, series = s }) { 513 h.series.Points.Clear(); 514 CalculateHistogram(h.series, h.row, histograms); 515 } 503 516 break; 504 517 default: { … … 524 537 } 525 538 526 protected virtual void CalculateHistogram(Series series, DataRow row ) {539 protected virtual void CalculateHistogram(Series series, DataRow row, IEnumerable<DataRow> histogramRows) { 527 540 series.Points.Clear(); 528 541 if (!row.Values.Any()) return; 529 int bins = row.VisualProperties.Bins; 530 531 double minValue = row.Values.Min();532 double maxValue = row.Values.Max();542 543 int bins = histogramRows.Max(r => r.VisualProperties.Bins); 544 double minValue = histogramRows.Min(r => r.Values.Min()); 545 double maxValue = histogramRows.Max(r => r.Values.Max()); 533 546 double intervalWidth = (maxValue - minValue) / bins; 534 547 if (intervalWidth < 0) return; … … 538 551 } 539 552 540 if (! row.VisualProperties.ExactBins) {553 if (!histogramRows.Any(r => r.VisualProperties.ExactBins)) { 541 554 intervalWidth = HumanRoundRange(intervalWidth); 542 555 minValue = Math.Floor(minValue / intervalWidth) * intervalWidth; … … 571 584 select new Tuple<double, double>(g.First(), g.Count())).ToList(); 572 585 573 // shift the chart to the left so the bars are placed on the intervals574 if (valueFrequencies.First().Item1 < doubleRange.First())575 series.Points.Add(new DataPoint(min -intervalWidth, 0));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)); 576 589 577 590 // add data points
Note: See TracChangeset
for help on using the changeset viewer.