Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/23/18 07:09:27 (6 years ago)
Author:
gkronber
Message:

#2922 changed DataCompletenessView to use a simple bitmap instead of the ChartControl.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2922-DataCompletenessChartPerf/HeuristicLab.DataPreprocessing.Views/3.4/DataCompletenessView.cs

    r15583 r15942  
    3535    private static readonly Color colorNonMissingValue = Color.CornflowerBlue;
    3636    private static readonly Color colorMissingValue = Color.Orange;
     37    private bool[,] valueMissing;
    3738
    3839    public new DataCompletenessChartContent Content {
     
    5253
    5354    private void InitData() {
    54       bool[,] valueMissing = new bool[Content.PreprocessingData.Rows, Content.PreprocessingData.Columns];
     55      valueMissing = new bool[Content.PreprocessingData.Rows, Content.PreprocessingData.Columns];
    5556      for (int row = 0; row < Content.PreprocessingData.Rows; row++) {
    5657        for (int column = 0; column < Content.PreprocessingData.Columns; column++)
     
    5960
    6061      var yValuesPerColumn = ProcessMatrixForCharting(valueMissing);
    61       PrepareChart();
    62       CreateSeries(yValuesPerColumn);
    6362    }
    6463
    65     private void PrepareChart() {
    66       chart.EnableDoubleClickResetsZoom = true;
    67       chart.ChartAreas[0].AxisX.MajorGrid.LineWidth = 0;
    68       chart.ChartAreas[0].AxisY.MajorGrid.LineWidth = 0;
    69       chart.ChartAreas[0].AxisX.IsMarginVisible = false;
    70       chart.ChartAreas[0].AxisY.IsMarginVisible = false;
    71       chart.ChartAreas[0].CursorX.IsUserEnabled = true;
    72       chart.ChartAreas[0].CursorX.IsUserSelectionEnabled = true;
    73       chart.ChartAreas[0].CursorY.IsUserEnabled = true;
    74       chart.ChartAreas[0].CursorY.IsUserSelectionEnabled = true;
    75       //custom x axis label
    76       double from = 0.5;
    77       foreach (String columnName in Content.PreprocessingData.VariableNames) {
    78         double to = from + 1;
    79         chart.ChartAreas[0].AxisX.CustomLabels.Add(from, to, columnName);
    80         from = to;
    81       }
    82       //custom y axis label
    83       chart.ChartAreas[0].AxisY.IsReversed = true;
    84     }
    8564
    86     private void CreateSeries(List<List<int>> yValuesPerColumn) {
    87       chart.Series.SuspendUpdates();
    88       //prepare series
    89       int seriesCount = DetermineSeriesCount(yValuesPerColumn);
    90       for (int i = 0; i < seriesCount; i++) {
    91         Series series = new Series(CreateSeriesName(i));
    92         series.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.StackedColumn;
    93         series.IsVisibleInLegend = false;
    94         series["PointWidth"] = "1.0";
    95         series.IsVisibleInLegend = i < 2; //only first two series are visible, non-missing and missing values
    96         series.Color = i % 2 == 0 ? colorNonMissingValue : colorMissingValue;
    97 
    98         var values = yValuesPerColumn.Select(y => i < y.Count ? y[i] : 0).ToArray();
    99         series.Points.DataBindY(values);
    100         chart.Series.Add(series);
    101       }
    102       chart.Series.ResumeUpdates();
    103     }
    104 
    105     private String CreateSeriesName(int index) {
    106       if (index == 0)
    107         return "non-missing value";
    108       else if (index == 1)
    109         return "missing value";
    110       return "series" + index;
    111     }
    11265
    11366    #region data_preparation_for_chartseries
     
    14295    }
    14396    #endregion
     97
     98    private void pictureBox_Paint(object sender, System.Windows.Forms.PaintEventArgs e) {
     99      var m = valueMissing;
     100      var g = e.Graphics;
     101      g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
     102      g.Clear(colorNonMissingValue);
     103      // TODO consider cliprectangle
     104      using (var bm = new Bitmap(m.GetLength(0), m.GetLength(1))) {
     105        for (int r = 0; r < m.GetLength(0); r++)
     106          for (int c = 0; c < m.GetLength(1); c++) {
     107            if (m[r, c]) bm.SetPixel(r, c, colorMissingValue);
     108          }
     109        g.DrawImage(bm, 0, 0, pictureBox.Width, pictureBox.Height);
     110      }
     111    }
     112
     113    private void toolStrip2_ItemClicked(object sender, System.Windows.Forms.ToolStripItemClickedEventArgs e) {
     114
     115    }
     116
     117    private void pictureBox_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) {
     118      toolTip.SetToolTip(pictureBox, "TODO: show variable")
     119    }
    144120  }
    145121}
Note: See TracChangeset for help on using the changeset viewer.