Free cookie consent management tool by TermsFeed Policy Generator

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

Added coloring selection feature to line chart

Location:
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3
Files:
2 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;
Note: See TracChangeset for help on using the changeset viewer.