Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/14/14 13:37:28 (10 years ago)
Author:
aesterer
Message:

Added coloring feature for line chart

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/ChartLogic.cs

    r10811 r10847  
    2222using System;
    2323using System.Collections.Generic;
     24using System.Drawing;
    2425using HeuristicLab.Analysis;
    2526using HeuristicLab.Core;
     
    3536      this.preprocessingData = preprocessingData;
    3637    }
     38
     39    #region IChartLogic Members
    3740
    3841    public DataRow CreateDataRow(string variableName, DataRowVisualProperties.DataRowChartType chartType) {
     
    9295    }
    9396
     97    public event EventHandler SelectionChanged {
     98      add { preprocessingData.SelectionChanged += value; }
     99      remove { preprocessingData.SelectionChanged -= value; }
     100    }
     101
    94102    public string GetVariableNameByIndex(int index) {
    95103      return preprocessingData.GetVariableName(index);
     
    104112    }
    105113
     114    public List<DataRow> CreateAllSelectedDataRows(DataRowVisualProperties.DataRowChartType chartType) {
     115      List<DataRow> dataRows = new List<DataRow>();
     116      foreach (var name in GetVariableNames()) {
     117        DataRow row = CreateSelectedDataRow(name, chartType);
     118        if(row != null)
     119          dataRows.Add(row);
     120      }
     121      return dataRows;
     122    }
     123
     124    public DataRow CreateSelectedDataRow(string variableName, DataRowVisualProperties.DataRowChartType chartType) {
     125     
     126      IDictionary<int,IList<int>> selection = preprocessingData.GetSelection();
     127      int variableIndex = preprocessingData.GetColumnIndex(variableName);
     128
     129      if (selection.Keys.Contains(variableIndex))
     130      {
     131        List<int> selectedIndices = new List<int>(selection[variableIndex]);
     132        //need selection with more than 1 value
     133        if(selectedIndices.Count < 2)
     134          return null;
     135
     136        int end = selectedIndices[0];      // indices are provided in reverse order
     137        int start = selectedIndices[selectedIndices.Count-1];
     138
     139        DataRow rowSelect = CreateDataRowRange(variableName, start, end, chartType);
     140        rowSelect.VisualProperties.Color = Color.Green;
     141        return rowSelect;
     142      }
     143      else
     144       return null;
     145    }
     146
     147    #endregion
    106148  }
    107149}
Note: See TracChangeset for help on using the changeset viewer.