Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10803


Ignore:
Timestamp:
05/07/14 10:44:11 (11 years ago)
Author:
aesterer
Message:

Added coloring selection feature to line chart

Location:
branches/DataPreprocessing
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/PreprocessingChartView.cs

    r10771 r10803  
    3030using HeuristicLab.Core.Views;
    3131using HeuristicLab.Data;
     32using HeuristicLab.DataPreprocessing.Implementations;
    3233using HeuristicLab.MainForm;
    3334
     
    3940
    4041    private IChartLogic logic;
    41     private DataTable dataTable;
    42     private List<DataTable> dataTablePerVariable;
     42    private PreprocessingDataTable dataTable;
     43    private List<PreprocessingDataTable> dataTablePerVariable;
    4344    private ICheckedItemList<StringValue> variableItemList;
    4445    private List<DataRow> dataRows;
     
    6768          DataRow row = GetDataRow(variableName);
    6869          dataTable.Rows.Add(row);
    69           DataTable d = new DataTable(variableName);
     70          PreprocessingDataTable d = new PreprocessingDataTable(variableName);
    7071          d.Rows.Add(row);
    7172          dataTablePerVariable.Add(d);
     
    109110
    110111      // init data table
    111       dataTable = new DataTable(chartTitle);
     112      dataTable = new PreprocessingDataTable(chartTitle);
    112113      dataTable.Rows.AddRange(dataRows);
     114     
    113115
    114116      // init data table per variable
    115       dataTablePerVariable = new List<DataTable>();
     117      dataTablePerVariable = new List<PreprocessingDataTable>();
    116118      foreach(var checkedItem in variableItemList.CheckedItems)  {
    117119        string variableName = variableItemList[checkedItem.Index].Value;
    118         DataTable d = new DataTable(variableName);
     120        PreprocessingDataTable d = new PreprocessingDataTable(variableName);
    119121        DataRow row = GetDataRow(variableName);
     122        //DataRow rowSelect = logic.CreateDataRowRange(variableName, 200, 400, chartType);
     123        //rowSelect.Name = variableName + "(Selected)";
     124        //rowSelect.VisualProperties.Color = Color.Green;
     125       
    120126        d.Rows.Add(row);
     127        //d.SelectedRows.Add(rowSelect);
     128       
    121129        dataTablePerVariable.Add(d);
    122       }
    123 
     130
     131      }
    124132    }
    125133
     
    179187      DataRow row = logic.CreateDataRow(name, chartType);
    180188      dataTable.Rows.Add(row);
    181       DataTable d = new DataTable(name);
     189      PreprocessingDataTable d = new PreprocessingDataTable(name);
    182190      d.Rows.Add(row);
    183191      dataTablePerVariable.Add(d);
     
    264272      tableLayoutPanel.RowCount = rows;
    265273
    266       List<DataTable>.Enumerator enumerator = dataTablePerVariable.GetEnumerator();
     274      List<PreprocessingDataTable>.Enumerator enumerator = dataTablePerVariable.GetEnumerator();
    267275      for (int x = 0; x < columns; x++) {
    268276       
     
    284292          PreprocessingDataTableView dataView = new PreprocessingDataTableView();
    285293          enumerator.MoveNext();
    286           DataTable d = enumerator.Current;
     294          PreprocessingDataTable d = enumerator.Current;
    287295          if (d == null) {
    288296            // dummy panel for empty field
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/PreprocessingDataTableView.cs

    r10771 r10803  
    2929using System.Windows.Forms;
    3030using System.Windows.Forms.DataVisualization.Charting;
     31using HeuristicLab.DataPreprocessing.Implementations;
    3132
    3233namespace HeuristicLab.Analysis.Views {
    3334  [View("Preprocessing DataTable View")]
    34   [Content(typeof(DataTable), false)]
     35  [Content(typeof(PreprocessingDataTable), false)]
    3536  public partial class PreprocessingDataTableView : ItemView, IConfigureableView {
    3637    protected List<Series> invisibleSeries;
    3738    protected Dictionary<IObservableList<double>, DataRow> valuesRowsTable;
    3839
    39     public new DataTable Content {
    40       get { return (DataTable)base.Content; }
     40    public new PreprocessingDataTable Content {
     41      get { return (PreprocessingDataTable)base.Content; }
    4142      set { base.Content = value; }
    4243    }
     
    103104        //chart.Titles[0].Text = Content.Name;
    104105        AddDataRows(Content.Rows);
     106        AddSelectedDataRows(Content.SelectedRows);
    105107        ConfigureChartArea(chart.ChartAreas[0]);
    106108        RecalculateAxesScale(chart.ChartAreas[0]);
     
    130132        chart.Series.Add(series);
    131133      }
     134
    132135      ConfigureChartArea(chart.ChartAreas[0]);
    133136      RecalculateAxesScale(chart.ChartAreas[0]);
    134137      UpdateYCursorInterval();
     138    }
     139
     140    protected virtual void AddSelectedDataRows(IEnumerable<DataRow> rows) {
     141      foreach (var row in rows) {
     142        if (row.VisualProperties.ChartType == DataRowVisualProperties.DataRowChartType.Line) {
     143          //RegisterDataRowEvents(row);
     144          row.VisualProperties.IsVisibleInLegend = false;
     145          var series = new Series(row.Name);
     146          ConfigureSeries(series, row);
     147          FillSeriesWithRowValues(series, row);
     148          chart.Series.Add(series);
     149        }
     150      }
    135151    }
    136152
     
    156172      else series.Color = Color.Empty;
    157173      series.IsVisibleInLegend = row.VisualProperties.IsVisibleInLegend;
    158 
     174     
    159175      switch (row.VisualProperties.ChartType) {
    160176        case DataRowVisualProperties.DataRowChartType.Line:
     
    518534    }
    519535
     536    // get minimum ignores nan values
     537    private double GetMinimum(IEnumerable<double> values)
     538    {
     539      double min = Double.MaxValue;
     540
     541      foreach (double value in values) {
     542        if (!Double.IsNaN(value) && value < min)
     543          min = value;     
     544      }
     545      return min;
     546    }
     547
     548    //get maximium ignores nan values
     549    private double GetMaximum(IEnumerable<double> values) {
     550      double max = Double.MinValue;
     551
     552      foreach (double value in values) {
     553        if (!Double.IsNaN(value) && value > max)
     554          max = value;
     555      }
     556      return max;
     557    }
     558
    520559    protected virtual void CalculateHistogram(Series series, DataRow row) {
    521560      series.Points.Clear();
     
    523562      int bins = row.VisualProperties.Bins;
    524563
    525       double minValue = row.Values.Min();
    526       double maxValue = row.Values.Max();
     564      double minValue = GetMinimum(row.Values);
     565      double maxValue = GetMaximum(row.Values);
    527566      double intervalWidth = (maxValue - minValue) / bins;
    528567      if (intervalWidth < 0) return;
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/HeuristicLab.DataPreprocessing-3.3.csproj

    r10786 r10803  
    7777    <Compile Include="Implementations\PreprocessingData.cs" />
    7878    <Compile Include="Implementations\DataGridLogic.cs" />
     79    <Compile Include="Implementations\PreprocessingDataTable.cs" />
    7980    <Compile Include="Interfaces\IFilteredPreprocessingData.cs" />
    8081    <Compile Include="PreprocessingTransformator.cs" />
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/ChartLogic.cs

    r10736 r10803  
    3838    public DataRow CreateDataRow(string variableName, DataRowVisualProperties.DataRowChartType chartType) {
    3939      IList<double> values = preprocessingData.GetValues<double>(variableName);
    40 
    41       //TODO: handle NAN values correctly
    42       // CalculateHistogram in DataTableView fails with NAN values ( Min(), Max() returns NAN)
    43       ReplayNANwithZero(values);
    4440      DataRow row = new DataRow(variableName, "", values);
    4541      row.VisualProperties.ChartType = chartType;
     
    4743    }
    4844
    49     private void ReplayNANwithZero(IList<double> values) {
     45    public DataRow CreateDataRowRange(string variableName,int start, int end, DataRowVisualProperties.DataRowChartType chartType) {
     46      IList<double> values = preprocessingData.GetValues<double>(variableName);
     47      IList<double> valuesRange = new List<double>();
     48      for (int i = 0; i < values.Count; i++) {
     49        if (i >= start && i <= end)
     50          valuesRange.Add(values[i]);
     51        else
     52          valuesRange.Add(Double.NaN);
     53      }
     54
     55      DataRow row = new DataRow(variableName, "", valuesRange);
     56      row.VisualProperties.ChartType = chartType;
     57      return row;
     58    }
     59
     60    private void ReplaceNANwithZero(IList<double> values) {
    5061      for (int i = 0; i < values.Count; i++) {
    5162        if (Double.IsNaN(values[i]))
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Interfaces/IChartLogic.cs

    r10733 r10803  
    3636    DataRow CreateDataRow(string variableName,DataRowVisualProperties.DataRowChartType chartType);
    3737
     38    DataRow CreateDataRowRange(string variableName, int start, int end, DataRowVisualProperties.DataRowChartType chartType);
     39
    3840    string GetVariableNameByIndex(int index);
    3941  }
Note: See TracChangeset for help on using the changeset viewer.