Free cookie consent management tool by TermsFeed Policy Generator

Changeset 15942 for branches


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

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

Location:
branches/2922-DataCompletenessChartPerf/HeuristicLab.DataPreprocessing.Views/3.4
Files:
2 edited

Legend:

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

    r15583 r15942  
    4646    private void InitializeComponent() {
    4747      this.components = new System.ComponentModel.Container();
    48       System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
    49       System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend();
    50       this.chart = new HeuristicLab.Visualization.ChartControlsExtensions.EnhancedChart();
    51       ((System.ComponentModel.ISupportInitialize)(this.chart)).BeginInit();
     48      this.nonMissingLabel = new System.Windows.Forms.Label();
     49      this.missingLabel = new System.Windows.Forms.Label();
     50      this.nonMissingColorPanel = new System.Windows.Forms.Panel();
     51      this.missingColorPanel = new System.Windows.Forms.Panel();
     52      this.legendPanel = new System.Windows.Forms.Panel();
     53      this.pictureBox = new System.Windows.Forms.PictureBox();
     54      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
     55      this.legendPanel.SuspendLayout();
     56      ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
    5257      this.SuspendLayout();
    5358      //
    54       // chart
     59      // nonMissingLabel
    5560      //
    56       this.chart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     61      this.nonMissingLabel.AutoSize = true;
     62      this.nonMissingLabel.ForeColor = System.Drawing.Color.Black;
     63      this.nonMissingLabel.Location = new System.Drawing.Point(159, 3);
     64      this.nonMissingLabel.Name = "nonMissingLabel";
     65      this.nonMissingLabel.Size = new System.Drawing.Size(91, 13);
     66      this.nonMissingLabel.TabIndex = 1;
     67      this.nonMissingLabel.Text = "non-missing value";
     68      //
     69      // missingLabel
     70      //
     71      this.missingLabel.AutoSize = true;
     72      this.missingLabel.Location = new System.Drawing.Point(297, 3);
     73      this.missingLabel.Name = "missingLabel";
     74      this.missingLabel.Size = new System.Drawing.Size(70, 13);
     75      this.missingLabel.TabIndex = 2;
     76      this.missingLabel.Text = "missing value";
     77      //
     78      // nonMissingColorPanel
     79      //
     80      this.nonMissingColorPanel.BackColor = System.Drawing.Color.CornflowerBlue;
     81      this.nonMissingColorPanel.Location = new System.Drawing.Point(118, 3);
     82      this.nonMissingColorPanel.Name = "nonMissingColorPanel";
     83      this.nonMissingColorPanel.Size = new System.Drawing.Size(35, 13);
     84      this.nonMissingColorPanel.TabIndex = 3;
     85      //
     86      // missingColorPanel
     87      //
     88      this.missingColorPanel.BackColor = System.Drawing.Color.Orange;
     89      this.missingColorPanel.Location = new System.Drawing.Point(256, 3);
     90      this.missingColorPanel.Name = "missingColorPanel";
     91      this.missingColorPanel.Size = new System.Drawing.Size(35, 13);
     92      this.missingColorPanel.TabIndex = 4;
     93      //
     94      // legendPanel
     95      //
     96      this.legendPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     97            | System.Windows.Forms.AnchorStyles.Right)));
     98      this.legendPanel.Controls.Add(this.nonMissingColorPanel);
     99      this.legendPanel.Controls.Add(this.missingLabel);
     100      this.legendPanel.Controls.Add(this.missingColorPanel);
     101      this.legendPanel.Controls.Add(this.nonMissingLabel);
     102      this.legendPanel.Location = new System.Drawing.Point(3, 3);
     103      this.legendPanel.Name = "legendPanel";
     104      this.legendPanel.Size = new System.Drawing.Size(487, 23);
     105      this.legendPanel.TabIndex = 0;
     106      //
     107      // pictureBox
     108      //
     109      this.pictureBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    57110            | System.Windows.Forms.AnchorStyles.Left)
    58111            | System.Windows.Forms.AnchorStyles.Right)));
    59       chartArea1.Name = "ChartArea1";
    60       this.chart.ChartAreas.Add(chartArea1);
    61       legend1.Alignment = System.Drawing.StringAlignment.Center;
    62       legend1.Docking = System.Windows.Forms.DataVisualization.Charting.Docking.Top;
    63       legend1.Name = "Legend1";
    64       this.chart.Legends.Add(legend1);
    65       this.chart.Location = new System.Drawing.Point(4, 4);
    66       this.chart.Name = "chart";
    67       this.chart.Size = new System.Drawing.Size(486, 337);
    68       this.chart.TabIndex = 0;
    69       this.chart.Text = "enhancedChart1";
     112      this.pictureBox.Location = new System.Drawing.Point(3, 32);
     113      this.pictureBox.Name = "pictureBox";
     114      this.pictureBox.Size = new System.Drawing.Size(487, 309);
     115      this.pictureBox.TabIndex = 1;
     116      this.pictureBox.TabStop = false;
     117      this.pictureBox.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBox_Paint);
     118      this.pictureBox.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pictureBox_MouseMove);
     119      //
     120      // toolTip
     121      //
     122      this.toolTip.AutomaticDelay = 0;
     123      this.toolTip.ShowAlways = true;
     124      this.toolTip.UseAnimation = false;
     125      this.toolTip.UseFading = false;
    70126      //
    71127      // DataCompletenessView
    72128      //
    73       this.Controls.Add(this.chart);
     129      this.Controls.Add(this.pictureBox);
     130      this.Controls.Add(this.legendPanel);
    74131      this.Name = "DataCompletenessView";
    75132      this.Size = new System.Drawing.Size(493, 344);
    76       ((System.ComponentModel.ISupportInitialize)(this.chart)).EndInit();
     133      this.legendPanel.ResumeLayout(false);
     134      this.legendPanel.PerformLayout();
     135      ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
    77136      this.ResumeLayout(false);
    78137
    79138    }
    80139
     140
    81141    #endregion
    82 
    83     private Visualization.ChartControlsExtensions.EnhancedChart chart;
    84 
    85 
     142    private System.Windows.Forms.Label nonMissingLabel;
     143    private System.Windows.Forms.Label missingLabel;
     144    private System.Windows.Forms.Panel nonMissingColorPanel;
     145    private System.Windows.Forms.Panel missingColorPanel;
     146    private System.Windows.Forms.Panel legendPanel;
     147    private System.Windows.Forms.PictureBox pictureBox;
     148    private System.Windows.Forms.ToolTip toolTip;
    86149  }
    87150}
  • 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.