Changeset 15942 for branches/2922-DataCompletenessChartPerf/HeuristicLab.DataPreprocessing.Views/3.4/DataCompletenessView.cs
- Timestamp:
- 05/23/18 07:09:27 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2922-DataCompletenessChartPerf/HeuristicLab.DataPreprocessing.Views/3.4/DataCompletenessView.cs
r15583 r15942 35 35 private static readonly Color colorNonMissingValue = Color.CornflowerBlue; 36 36 private static readonly Color colorMissingValue = Color.Orange; 37 private bool[,] valueMissing; 37 38 38 39 public new DataCompletenessChartContent Content { … … 52 53 53 54 private void InitData() { 54 bool[,]valueMissing = new bool[Content.PreprocessingData.Rows, Content.PreprocessingData.Columns];55 valueMissing = new bool[Content.PreprocessingData.Rows, Content.PreprocessingData.Columns]; 55 56 for (int row = 0; row < Content.PreprocessingData.Rows; row++) { 56 57 for (int column = 0; column < Content.PreprocessingData.Columns; column++) … … 59 60 60 61 var yValuesPerColumn = ProcessMatrixForCharting(valueMissing); 61 PrepareChart();62 CreateSeries(yValuesPerColumn);63 62 } 64 63 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 label76 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 label83 chart.ChartAreas[0].AxisY.IsReversed = true;84 }85 64 86 private void CreateSeries(List<List<int>> yValuesPerColumn) {87 chart.Series.SuspendUpdates();88 //prepare series89 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 values96 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 }112 65 113 66 #region data_preparation_for_chartseries … … 142 95 } 143 96 #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 } 144 120 } 145 121 }
Note: See TracChangeset
for help on using the changeset viewer.