Free cookie consent management tool by TermsFeed Policy Generator

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

Added coloring selection feature to line chart

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.