Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/17/17 13:22:51 (8 years ago)
Author:
pfleck
Message:

#2709

  • Added Legend order when grouping for histogram and (single and multi)scatterplot.
  • Removed the limitation of distinct values for the singlescatterplot (for the color gradient).
  • Added a legend-visible checkbox for the multi-scatterplot.
Location:
branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/Content
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/Content/HistogramContent.cs

    r14725 r14993  
    3939    public bool ExactBins { get; set; }
    4040
     41    public LegendOrder Order { get; set; }
     42
    4143    public HistogramContent(IFilteredPreprocessingData preprocessingData)
    4244      : base(preprocessingData) {
     
    5254    }
    5355
    54     public static DataTable CreateHistogram(IFilteredPreprocessingData preprocessingData, string variableName, string groupingVariableName, DataRowVisualProperties.DataRowHistogramAggregation aggregation) {
    55       {
    56         var dataTable = new DataTable();
     56    public static DataTable CreateHistogram(IFilteredPreprocessingData preprocessingData, string variableName, string groupingVariableName, DataRowVisualProperties.DataRowHistogramAggregation aggregation, LegendOrder legendOrder = LegendOrder.Appearance) {
     57      var dataTable = new DataTable();
    5758
    58         if (string.IsNullOrEmpty(groupingVariableName)) {
    59           var row = PreprocessingChartContent.CreateDataRow(preprocessingData, variableName, DataRowVisualProperties.DataRowChartType.Histogram);
    60           dataTable.Rows.Add(row);
    61           return dataTable;
    62         }
    63 
    64         dataTable.VisualProperties.Title = variableName;
    65 
    66         int variableIndex = preprocessingData.GetColumnIndex(variableName);
    67         var variableValues = preprocessingData.GetValues<double>(variableIndex);
    68         int groupVariableIndex = preprocessingData.GetColumnIndex(groupingVariableName);
    69         var groupingValues = Enumerable.Empty<string>();
    70 
    71         if (preprocessingData.VariableHasType<double>(groupVariableIndex)) {
    72           groupingValues = preprocessingData.GetValues<double>(groupVariableIndex).Select(x => x.ToString());
    73         } else if (preprocessingData.VariableHasType<string>(groupVariableIndex)) {
    74           groupingValues = preprocessingData.GetValues<string>(groupVariableIndex);
    75         } else if (preprocessingData.VariableHasType<DateTime>(groupVariableIndex)) {
    76           groupingValues = preprocessingData.GetValues<DateTime>(groupVariableIndex).Select(x => x.ToString());
    77         }
    78 
    79         var groups = groupingValues.Zip(variableValues, Tuple.Create).GroupBy(t => t.Item1, t => t.Item2);
    80 
    81         foreach (var group in groups) {
    82           var classRow = new DataRow();
    83           classRow.Name = group.Key;
    84           classRow.VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Histogram;
    85           classRow.VisualProperties.Aggregation = aggregation;
    86           classRow.Values.AddRange(group);
    87           dataTable.Rows.Add(classRow);
    88         }
     59      if (string.IsNullOrEmpty(groupingVariableName)) {
     60        var row = PreprocessingChartContent.CreateDataRow(preprocessingData, variableName, DataRowVisualProperties.DataRowChartType.Histogram);
     61        dataTable.Rows.Add(row);
    8962        return dataTable;
    9063      }
     64
     65      dataTable.VisualProperties.Title = variableName;
     66
     67      int variableIndex = preprocessingData.GetColumnIndex(variableName);
     68      var variableValues = preprocessingData.GetValues<double>(variableIndex);
     69      int groupVariableIndex = preprocessingData.GetColumnIndex(groupingVariableName);
     70      var groupingValues = Enumerable.Empty<string>();
     71
     72      if (preprocessingData.VariableHasType<double>(groupVariableIndex)) {
     73        groupingValues = preprocessingData.GetValues<double>(groupVariableIndex).Select(x => x.ToString());
     74      } else if (preprocessingData.VariableHasType<string>(groupVariableIndex)) {
     75        groupingValues = preprocessingData.GetValues<string>(groupVariableIndex);
     76      } else if (preprocessingData.VariableHasType<DateTime>(groupVariableIndex)) {
     77        groupingValues = preprocessingData.GetValues<DateTime>(groupVariableIndex).Select(x => x.ToString());
     78      }
     79
     80      var groups = groupingValues.Zip(variableValues, Tuple.Create).GroupBy(t => t.Item1, t => t.Item2);
     81
     82      if (legendOrder == LegendOrder.Alphabetically)
     83        groups = groups.OrderBy(x => x.Key, new NaturalStringComparer());
     84
     85      foreach (var group in groups) {
     86        var classRow = new DataRow {
     87          Name = group.Key,
     88          VisualProperties = {
     89              ChartType = DataRowVisualProperties.DataRowChartType.Histogram,
     90              Aggregation = aggregation
     91            }
     92        };
     93        classRow.Values.AddRange(group);
     94        dataTable.Rows.Add(classRow);
     95      }
     96      return dataTable;
    9197    }
    92 
    93 
    9498  }
    9599}
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/Content/PreprocessingChartContent.cs

    r14725 r14993  
    3333  [Item("PreprocessingChart", "Represents a preprocessing chart.")]
    3434  public class PreprocessingChartContent : Item, IViewShortcut {
     35
     36    public enum LegendOrder {
     37      Appearance,
     38      Alphabetically
     39    }
     40
    3541    public static new Image StaticItemImage {
    3642      get { return VSImageLibrary.PieChart; }
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/Content/ScatterPlotContent.cs

    r14725 r14993  
    4040    }
    4141
    42     public static ScatterPlot CreateScatterPlot(IFilteredPreprocessingData preprocessingData, string variableNameX, string variableNameY, string variableNameGroup = "-") {
     42    public static ScatterPlot CreateScatterPlot(IFilteredPreprocessingData preprocessingData, string variableNameX, string variableNameY, string variableNameGroup = "-", LegendOrder legendOrder = LegendOrder.Appearance) {
    4343      ScatterPlot scatterPlot = new ScatterPlot();
    4444
     
    5656          scatterPlot.VisualProperties.XAxisMinimumFixedValue = axisMin;
    5757          scatterPlot.VisualProperties.XAxisMaximumFixedValue = axisMax;
    58         }
    59         catch (ArgumentOutOfRangeException) { } // error during CalculateOptimalAxisInterval
     58        } catch (ArgumentOutOfRangeException) { } // error during CalculateOptimalAxisInterval
    6059        try {
    6160          double axisMin, axisMax, axisInterval;
     
    6564          scatterPlot.VisualProperties.YAxisMinimumFixedValue = axisMin;
    6665          scatterPlot.VisualProperties.YAxisMaximumFixedValue = axisMax;
    67         }
    68         catch (ArgumentOutOfRangeException) { } // error during CalculateOptimalAxisInterval
     66        } catch (ArgumentOutOfRangeException) { } // error during CalculateOptimalAxisInterval
    6967      }
    7068
     
    9189      var groups = groupingValues.Zip(validPoints, Tuple.Create).GroupBy(t => t.Item1, t => t.Item2);
    9290
     91      if (legendOrder == LegendOrder.Alphabetically)
     92        groups = groups.OrderBy(x => x.Key, new NaturalStringComparer());
     93
    9394      foreach (var group in groups) {
    94         var scdr = new ScatterPlotDataRow();
    95         scdr.Name = group.Key;
    96         scdr.VisualProperties.IsVisibleInLegend = true;
    97         scdr.VisualProperties.PointSize = 6;
     95        var scdr = new ScatterPlotDataRow {
     96          Name = group.Key,
     97          VisualProperties = {
     98            IsVisibleInLegend = true,
     99            PointSize = 6
     100          }
     101        };
    98102        scdr.Points.AddRange(group);
    99103        scatterPlot.Rows.Add(scdr);
Note: See TracChangeset for help on using the changeset viewer.