Free cookie consent management tool by TermsFeed Policy Generator

Changeset 14457


Ignore:
Timestamp:
12/07/16 13:19:31 (7 years ago)
Author:
pfleck
Message:

#2715

  • Histograms are now displayed as stacked column chart.
  • The value range and bin sizes are now calculated based on all histogram-rows of the DataTable.
  • When a single histogram is updated, all histograms must be updated in order to keep the value range and bin sizes the same for all histograms.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Analysis.Views/3.3/DataTableControl.cs

    r14439 r14457  
    181181          break;
    182182        case DataRowVisualProperties.DataRowChartType.Histogram:
    183           series.ChartType = SeriesChartType.Column;
     183          series.ChartType = SeriesChartType.StackedColumn;
    184184          series.SetCustomProperty("PointWidth", "1");
    185185          if (!series.Color.IsEmpty && series.Color.GetBrightness() < 0.25)
     
    500500      switch (row.VisualProperties.ChartType) {
    501501        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          }
    503516          break;
    504517        default: {
     
    524537    }
    525538
    526     protected virtual void CalculateHistogram(Series series, DataRow row) {
     539    protected virtual void CalculateHistogram(Series series, DataRow row, IEnumerable<DataRow> histogramRows) {
    527540      series.Points.Clear();
    528541      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());
    533546      double intervalWidth = (maxValue - minValue) / bins;
    534547      if (intervalWidth < 0) return;
     
    538551      }
    539552
    540       if (!row.VisualProperties.ExactBins) {
     553      if (!histogramRows.Any(r => r.VisualProperties.ExactBins)) {
    541554        intervalWidth = HumanRoundRange(intervalWidth);
    542555        minValue = Math.Floor(minValue / intervalWidth) * intervalWidth;
     
    571584                              select new Tuple<double, double>(g.First(), g.Count())).ToList();
    572585
    573       // shift the chart to the left so the bars are placed on the intervals
    574       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));
    576589
    577590      // add data points
Note: See TracChangeset for help on using the changeset viewer.