[14902] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
| 3 | * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
| 4 | *
|
---|
| 5 | * This file is part of HeuristicLab.
|
---|
| 6 | *
|
---|
| 7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
| 20 | #endregion
|
---|
| 21 |
|
---|
| 22 | using System;
|
---|
[10882] | 23 | using System.Collections.Generic;
|
---|
| 24 | using System.Drawing;
|
---|
| 25 | using System.Linq;
|
---|
| 26 | using System.Windows.Forms;
|
---|
| 27 | using HeuristicLab.Analysis;
|
---|
[14446] | 28 | using HeuristicLab.Analysis.Views;
|
---|
[14381] | 29 | using HeuristicLab.Collections;
|
---|
| 30 | using HeuristicLab.Data;
|
---|
[10882] | 31 | using HeuristicLab.MainForm;
|
---|
[14381] | 32 | using HeuristicLab.MainForm.WindowsForms;
|
---|
[14975] | 33 | using AggregationType = HeuristicLab.Analysis.DataRowVisualProperties.DataRowHistogramAggregation;
|
---|
[14514] | 34 | using RegressionType = HeuristicLab.Analysis.ScatterPlotDataRowVisualProperties.ScatterPlotDataRowRegressionType;
|
---|
[10882] | 35 |
|
---|
| 36 | namespace HeuristicLab.DataPreprocessing.Views {
|
---|
[10987] | 37 | [View("Scatter Plot Multi View")]
|
---|
[14462] | 38 | [Content(typeof(MultiScatterPlotContent), true)]
|
---|
[14381] | 39 | public partial class ScatterPlotMultiView : PreprocessingCheckedVariablesView {
|
---|
[14580] | 40 | private readonly IDictionary<string, Label> columnHeaderCache = new Dictionary<string, Label>();
|
---|
| 41 | private readonly IDictionary<string, VerticalLabel> rowHeaderCache = new Dictionary<string, VerticalLabel>();
|
---|
| 42 | private readonly IDictionary<Tuple<string/*col*/, string/*row*/>, Control> bodyCache = new Dictionary<Tuple<string, string>, Control>();
|
---|
[14384] | 43 |
|
---|
[14996] | 44 | public new MultiScatterPlotContent Content {
|
---|
| 45 | get { return (MultiScatterPlotContent)base.Content; }
|
---|
| 46 | set { base.Content = value; }
|
---|
| 47 | }
|
---|
| 48 |
|
---|
[10987] | 49 | public ScatterPlotMultiView() {
|
---|
[10882] | 50 | InitializeComponent();
|
---|
[14381] | 51 |
|
---|
[14917] | 52 | oldWidth = (int)widthNumericUpDown.Value;
|
---|
| 53 | oldHeight = (int)heightNumericUpDown.Value;
|
---|
| 54 |
|
---|
[14514] | 55 | regressionTypeComboBox.DataSource = Enum.GetValues(typeof(RegressionType));
|
---|
| 56 | regressionTypeComboBox.SelectedItem = RegressionType.None;
|
---|
| 57 |
|
---|
[14975] | 58 | aggregationComboBox.DataSource = Enum.GetValues(typeof(AggregationType));
|
---|
| 59 | aggregationComboBox.SelectedItem = AggregationType.Overlapping;
|
---|
| 60 |
|
---|
[14993] | 61 | legendOrderComboBox.DataSource = Enum.GetValues(typeof(PreprocessingChartContent.LegendOrder));
|
---|
| 62 | legendOrderComboBox.SelectedItem = PreprocessingChartContent.LegendOrder.Appearance;
|
---|
| 63 |
|
---|
[14388] | 64 | #region Initialize Scrollbars
|
---|
[14384] | 65 | columnHeaderScrollPanel.HorizontalScroll.Enabled = true;
|
---|
| 66 | columnHeaderScrollPanel.VerticalScroll.Enabled = false;
|
---|
| 67 | columnHeaderScrollPanel.HorizontalScroll.Visible = false;
|
---|
| 68 | columnHeaderScrollPanel.VerticalScroll.Visible = false;
|
---|
[14381] | 69 |
|
---|
[14384] | 70 | rowHeaderScrollPanel.HorizontalScroll.Enabled = false;
|
---|
| 71 | rowHeaderScrollPanel.VerticalScroll.Enabled = true;
|
---|
| 72 | rowHeaderScrollPanel.HorizontalScroll.Visible = false;
|
---|
| 73 | rowHeaderScrollPanel.VerticalScroll.Visible = false;
|
---|
[14381] | 74 |
|
---|
[14384] | 75 | bodyScrollPanel.HorizontalScroll.Enabled = true;
|
---|
| 76 | bodyScrollPanel.VerticalScroll.Enabled = true;
|
---|
| 77 | bodyScrollPanel.HorizontalScroll.Visible = true;
|
---|
| 78 | bodyScrollPanel.VerticalScroll.Visible = true;
|
---|
| 79 | bodyScrollPanel.AutoScroll = true;
|
---|
[14388] | 80 | #endregion
|
---|
[14381] | 81 |
|
---|
[14384] | 82 | bodyScrollPanel.MouseWheel += bodyScrollPanel_MouseWheel;
|
---|
[10882] | 83 | }
|
---|
| 84 |
|
---|
| 85 | protected override void OnContentChanged() {
|
---|
| 86 | base.OnContentChanged();
|
---|
| 87 | if (Content != null) {
|
---|
[14996] | 88 | groupingComboBox.Items.Add(string.Empty);
|
---|
[14725] | 89 | foreach (string var in PreprocessingChartContent.GetVariableNamesForGrouping(Content.PreprocessingData)) {
|
---|
| 90 | groupingComboBox.Items.Add(var);
|
---|
| 91 | }
|
---|
[14996] | 92 | groupingComboBox.SelectedItem = Content.GroupingVariable ?? string.Empty;
|
---|
[14725] | 93 |
|
---|
[14975] | 94 | // uncheck variables that max 20 vars are selected initially
|
---|
| 95 | var list = Content.VariableItemList;
|
---|
| 96 | int numChecked = list.CheckedItems.Count();
|
---|
| 97 | if (numChecked > 20) {
|
---|
[15021] | 98 | string message = string.Format("Displaying {0} variables ({1} charts) can slown down HeuristicLab. " +
|
---|
[14975] | 99 | "Should the number of initially checked variables be reduced to 20?",
|
---|
| 100 | numChecked, numChecked * numChecked);
|
---|
| 101 | if (MessageBox.Show(this, message, "Reduce befor continue?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) {
|
---|
[14996] | 102 | SuppressCheckedChangedUpdate = true;
|
---|
[14975] | 103 | foreach (var var in list.CheckedItems.Reverse().Take(numChecked - 20)) {
|
---|
| 104 | Content.VariableItemList.SetItemCheckedState(var.Value, false);
|
---|
| 105 | }
|
---|
[14996] | 106 | SuppressCheckedChangedUpdate = false;
|
---|
[14975] | 107 | }
|
---|
| 108 | }
|
---|
[14953] | 109 | GenerateCharts(true);
|
---|
[10882] | 110 | }
|
---|
| 111 | }
|
---|
| 112 |
|
---|
[14514] | 113 | protected override void SetEnabledStateOfControls() {
|
---|
| 114 | base.SetEnabledStateOfControls();
|
---|
| 115 | var regressionType = (RegressionType)regressionTypeComboBox.SelectedValue;
|
---|
| 116 | polynomialRegressionOrderNumericUpDown.Enabled = regressionType == RegressionType.Polynomial;
|
---|
[14975] | 117 | sizeGroupBox.Enabled = Content != null;
|
---|
| 118 | pointsGroupBox.Enabled = Content != null;
|
---|
| 119 | groupingComboBox.Enabled = Content != null;
|
---|
| 120 | regressionGroupBox.Enabled = Content != null;
|
---|
[14514] | 121 | }
|
---|
| 122 |
|
---|
[14381] | 123 | protected override void CheckedItemsChanged(object sender, CollectionItemsChangedEventArgs<IndexedItem<StringValue>> checkedItems) {
|
---|
| 124 | base.CheckedItemsChanged(sender, checkedItems);
|
---|
[14996] | 125 | if (SuppressCheckedChangedUpdate) return;
|
---|
[14975] | 126 |
|
---|
| 127 | foreach (var variable in checkedItems.Items) {
|
---|
| 128 | if (Content.VariableItemList.ItemChecked(variable.Value))
|
---|
| 129 | ShowChartOnTable(variable.Value.Value, variable.Index);
|
---|
[14384] | 130 | else
|
---|
[14975] | 131 | HideChartFromTable(variable.Value.Value, variable.Index);
|
---|
[14384] | 132 | }
|
---|
| 133 | }
|
---|
[10952] | 134 |
|
---|
[14975] | 135 | #region Show and Hide charts
|
---|
| 136 | private void ShowChartOnTable(string variable, int idx) {
|
---|
| 137 | frameTableLayoutPanel.SuspendLayout();
|
---|
| 138 |
|
---|
| 139 | // show column header
|
---|
| 140 | var colH = columnHeaderTableLayoutPanel;
|
---|
| 141 | colH.ColumnStyles[idx].Width = GetColumnWidth();
|
---|
| 142 | if (colH.GetControlFromPosition(idx, 0) == null)
|
---|
| 143 | colH.Controls.Add(GetColumnHeader(variable), idx, 0);
|
---|
| 144 | else
|
---|
| 145 | colH.GetControlFromPosition(idx, 0).Visible = true;
|
---|
| 146 |
|
---|
| 147 | // show row header
|
---|
| 148 | var rowH = rowHeaderTableLayoutPanel;
|
---|
| 149 | rowH.RowStyles[idx].Height = GetRowHeight();
|
---|
| 150 | if (rowH.GetControlFromPosition(0, idx) == null)
|
---|
| 151 | rowH.Controls.Add(GetRowHeader(variable), 0, idx);
|
---|
| 152 | else
|
---|
| 153 | rowH.GetControlFromPosition(0, idx).Visible = true;
|
---|
| 154 |
|
---|
| 155 | // show body
|
---|
| 156 | var body = bodyTableLayoutPanel;
|
---|
| 157 | ShowColumnHelper(body, idx, r => GetBody(variable, Content.VariableItemList[r].Value));
|
---|
| 158 | ShowRowHelper(body, idx, c => GetBody(Content.VariableItemList[c].Value, variable));
|
---|
| 159 |
|
---|
| 160 | frameTableLayoutPanel.ResumeLayout(true);
|
---|
| 161 | }
|
---|
| 162 | private void ShowColumnHelper(TableLayoutPanel tlp, int idx, Func<int, Control> creatorFunc) {
|
---|
| 163 | tlp.ColumnStyles[idx].Width = GetColumnWidth();
|
---|
| 164 | for (int r = 0; r < tlp.RowCount; r++) {
|
---|
| 165 | if (Content.VariableItemList.ItemChecked(Content.VariableItemList[r])) {
|
---|
| 166 | var control = tlp.GetControlFromPosition(idx, r);
|
---|
| 167 | if (control == null)
|
---|
| 168 | tlp.Controls.Add(creatorFunc(r), idx, r);
|
---|
| 169 | else
|
---|
| 170 | control.Visible = true;
|
---|
| 171 | }
|
---|
| 172 | }
|
---|
| 173 | }
|
---|
| 174 | private void ShowRowHelper(TableLayoutPanel tlp, int idx, Func<int, Control> creatorFunc) {
|
---|
| 175 | tlp.RowStyles[idx].Height = GetRowHeight();
|
---|
| 176 | for (int c = 0; c < tlp.ColumnCount; c++) {
|
---|
| 177 | if (Content.VariableItemList.ItemChecked(Content.VariableItemList[c])) {
|
---|
| 178 | var control = tlp.GetControlFromPosition(c, idx);
|
---|
| 179 | if (control == null)
|
---|
| 180 | tlp.Controls.Add(creatorFunc(c), c, idx);
|
---|
| 181 | else
|
---|
| 182 | tlp.GetControlFromPosition(c, idx).Visible = true;
|
---|
| 183 | }
|
---|
| 184 | }
|
---|
| 185 | }
|
---|
| 186 |
|
---|
| 187 | private void HideChartFromTable(string variable, int idx) {
|
---|
| 188 | frameTableLayoutPanel.SuspendLayout();
|
---|
| 189 |
|
---|
| 190 | // hide column header
|
---|
| 191 | var colH = columnHeaderTableLayoutPanel;
|
---|
| 192 | HideColumnHelper(colH, idx);
|
---|
| 193 |
|
---|
| 194 | // hide row header
|
---|
| 195 | var rowH = rowHeaderTableLayoutPanel;
|
---|
| 196 | HideRowHelper(rowH, idx);
|
---|
| 197 |
|
---|
| 198 | // hide from body
|
---|
| 199 | var body = bodyTableLayoutPanel;
|
---|
| 200 | HideColumnHelper(body, idx);
|
---|
| 201 | HideRowHelper(body, idx);
|
---|
| 202 |
|
---|
| 203 | frameTableLayoutPanel.ResumeLayout(true);
|
---|
| 204 | }
|
---|
| 205 | private void HideColumnHelper(TableLayoutPanel tlp, int idx) {
|
---|
| 206 | tlp.ColumnStyles[idx].Width = 0;
|
---|
| 207 | // hide controls
|
---|
| 208 | for (int r = 0; r < tlp.RowCount; r++) {
|
---|
| 209 | var control = tlp.GetControlFromPosition(idx, r);
|
---|
| 210 | if (control != null)
|
---|
| 211 | control.Visible = false;
|
---|
| 212 | }
|
---|
| 213 | }
|
---|
| 214 | private void HideRowHelper(TableLayoutPanel tlp, int idx) {
|
---|
| 215 | tlp.RowStyles[idx].Height = 0;
|
---|
| 216 | // hide controls
|
---|
| 217 | for (int c = 0; c < tlp.ColumnCount; c++) {
|
---|
| 218 | var control = tlp.GetControlFromPosition(c, idx);
|
---|
| 219 | if (control != null)
|
---|
| 220 | control.Visible = false;
|
---|
| 221 | }
|
---|
| 222 | }
|
---|
| 223 | #endregion
|
---|
| 224 |
|
---|
| 225 | #region Add/Remove/Update Variable
|
---|
| 226 | protected override void AddVariable(string name) {
|
---|
| 227 | base.AddVariable(name);
|
---|
| 228 | if (IsVariableChecked(name))
|
---|
| 229 | AddChartToTable(name);
|
---|
| 230 | }
|
---|
| 231 | protected override void RemoveVariable(string name) {
|
---|
| 232 | base.RemoveVariable(name);
|
---|
| 233 |
|
---|
| 234 | if (IsVariableChecked(name)) {
|
---|
| 235 | RemoveChartFromTable(name);
|
---|
| 236 | }
|
---|
| 237 |
|
---|
| 238 | // clear caches
|
---|
| 239 | columnHeaderCache[name].Dispose();
|
---|
| 240 | columnHeaderCache.Remove(name);
|
---|
| 241 | rowHeaderCache[name].Dispose();
|
---|
| 242 | rowHeaderCache.Remove(name);
|
---|
| 243 | var keys = bodyCache.Keys.Where(t => t.Item1 == name || t.Item2 == name).ToList();
|
---|
| 244 | foreach (var key in keys) {
|
---|
| 245 | bodyCache[key].Dispose();
|
---|
| 246 | bodyCache.Remove(key);
|
---|
| 247 | }
|
---|
| 248 | }
|
---|
| 249 | protected override void UpdateVariable(string name) {
|
---|
| 250 | base.UpdateVariable(name);
|
---|
| 251 | RemoveVariable(name);
|
---|
| 252 | AddVariable(name);
|
---|
| 253 | }
|
---|
| 254 | protected override void ResetAllVariables() {
|
---|
| 255 | GenerateCharts(true);
|
---|
| 256 | }
|
---|
| 257 |
|
---|
[14384] | 258 | private void AddChartToTable(string variable) {
|
---|
[14388] | 259 | frameTableLayoutPanel.SuspendLayout();
|
---|
[14384] | 260 |
|
---|
[14388] | 261 | // find index to insert
|
---|
[14511] | 262 | var variables = Content.VariableItemList.Select(v => v.Value).ToList();
|
---|
[14388] | 263 | int idx = variables // all variables
|
---|
| 264 | .TakeWhile(t => t != variable) // ... until the variable that was checked
|
---|
| 265 | .Count(IsVariableChecked); // ... how many checked variables
|
---|
| 266 |
|
---|
| 267 | // add column header
|
---|
| 268 | var colH = columnHeaderTableLayoutPanel;
|
---|
| 269 | AddColumnHelper(colH, idx, _ => GetColumnHeader(variable));
|
---|
| 270 |
|
---|
| 271 | // add row header
|
---|
| 272 | var rowH = rowHeaderTableLayoutPanel;
|
---|
| 273 | AddRowHelper(rowH, idx, _ => GetRowHeader(variable));
|
---|
| 274 |
|
---|
| 275 | // add body
|
---|
| 276 | var body = bodyTableLayoutPanel;
|
---|
| 277 | var vars = GetCheckedVariables();
|
---|
| 278 | var varsMinus = vars.Except(new[] { variable }).ToList();
|
---|
| 279 | AddColumnHelper(body, idx, r => GetBody(variable, varsMinus[r])); // exclude "variable" because the row for it does not exist yet
|
---|
| 280 | AddRowHelper(body, idx, c => GetBody(vars[c], variable));
|
---|
| 281 |
|
---|
| 282 | frameTableLayoutPanel.ResumeLayout(true);
|
---|
[14381] | 283 | }
|
---|
[14388] | 284 | private void AddColumnHelper(TableLayoutPanel tlp, int idx, Func<int, Control> creatorFunc) {
|
---|
| 285 | // add column
|
---|
| 286 | tlp.ColumnCount++;
|
---|
| 287 | tlp.ColumnStyles.Insert(idx, new ColumnStyle(SizeType.Absolute, GetColumnWidth()));
|
---|
| 288 | // shift right
|
---|
[14580] | 289 | for (int c = tlp.ColumnCount; c > idx - 1; c--) {
|
---|
[14388] | 290 | for (int r = 0; r < tlp.RowCount; r++) {
|
---|
| 291 | var control = tlp.GetControlFromPosition(c, r);
|
---|
| 292 | if (control != null) {
|
---|
| 293 | tlp.SetColumn(control, c + 1);
|
---|
| 294 | }
|
---|
| 295 | }
|
---|
| 296 | }
|
---|
| 297 | // add controls
|
---|
| 298 | for (int r = 0; r < tlp.RowCount; r++) {
|
---|
| 299 | if (tlp.GetControlFromPosition(idx, r) == null)
|
---|
| 300 | tlp.Controls.Add(creatorFunc(r), idx, r);
|
---|
| 301 | }
|
---|
| 302 |
|
---|
| 303 | }
|
---|
| 304 | private void AddRowHelper(TableLayoutPanel tlp, int idx, Func<int, Control> creatorFunc) {
|
---|
| 305 | // add row
|
---|
| 306 | tlp.RowCount++;
|
---|
| 307 | tlp.RowStyles.Insert(idx, new RowStyle(SizeType.Absolute, GetRowHeight()));
|
---|
| 308 | // shift right
|
---|
| 309 | for (int r = tlp.RowCount; r > idx - 1; r--) {
|
---|
| 310 | for (int c = 0; c < tlp.ColumnCount; c++) {
|
---|
| 311 | var control = tlp.GetControlFromPosition(c, r);
|
---|
| 312 | if (control != null) {
|
---|
| 313 | tlp.SetRow(control, r + 1);
|
---|
| 314 | }
|
---|
| 315 | }
|
---|
| 316 | }
|
---|
| 317 | // add controls
|
---|
| 318 | for (int c = 0; c < tlp.ColumnCount; c++)
|
---|
| 319 | if (tlp.GetControlFromPosition(c, idx) == null)
|
---|
| 320 | tlp.Controls.Add(creatorFunc(c), c, idx);
|
---|
| 321 | }
|
---|
| 322 |
|
---|
[14384] | 323 | private void RemoveChartFromTable(string variable) {
|
---|
| 324 | frameTableLayoutPanel.SuspendLayout();
|
---|
[10987] | 325 |
|
---|
[14384] | 326 | // remove column header
|
---|
| 327 | var colH = columnHeaderTableLayoutPanel;
|
---|
| 328 | int colIdx = colH.GetColumn(colH.Controls[variable]);
|
---|
| 329 | RemoveColumnHelper(colH, colIdx);
|
---|
| 330 |
|
---|
| 331 | // remove row header
|
---|
| 332 | var rowH = rowHeaderTableLayoutPanel;
|
---|
| 333 | int rowIdx = rowH.GetRow(rowH.Controls[variable]);
|
---|
| 334 | RemoveRowHelper(rowH, rowIdx);
|
---|
| 335 |
|
---|
| 336 | // remove from body
|
---|
| 337 | var body = bodyTableLayoutPanel;
|
---|
| 338 | RemoveColumnHelper(body, colIdx);
|
---|
| 339 | RemoveRowHelper(body, rowIdx);
|
---|
| 340 |
|
---|
| 341 | frameTableLayoutPanel.ResumeLayout(true);
|
---|
| 342 | }
|
---|
| 343 | private void RemoveColumnHelper(TableLayoutPanel tlp, int idx) {
|
---|
[14388] | 344 | // remove controls
|
---|
[14384] | 345 | for (int r = 0; r < tlp.RowCount; r++)
|
---|
| 346 | tlp.Controls.Remove(tlp.GetControlFromPosition(idx, r));
|
---|
[14388] | 347 | // shift left
|
---|
[14384] | 348 | for (int c = idx + 1; c < tlp.ColumnCount; c++) {
|
---|
| 349 | for (int r = 0; r < tlp.RowCount; r++) {
|
---|
| 350 | var control = tlp.GetControlFromPosition(c, r);
|
---|
| 351 | if (control != null) {
|
---|
| 352 | tlp.SetColumn(control, c - 1);
|
---|
| 353 | }
|
---|
| 354 | }
|
---|
| 355 | }
|
---|
[14388] | 356 | // delete column
|
---|
[14384] | 357 | tlp.ColumnStyles.RemoveAt(tlp.ColumnCount - 1);
|
---|
| 358 | tlp.ColumnCount--;
|
---|
| 359 | }
|
---|
| 360 | private void RemoveRowHelper(TableLayoutPanel tlp, int idx) {
|
---|
[14388] | 361 | // remove controls
|
---|
[14384] | 362 | for (int c = 0; c < tlp.ColumnCount; c++)
|
---|
| 363 | tlp.Controls.Remove(tlp.GetControlFromPosition(c, idx));
|
---|
[14388] | 364 | // shift left
|
---|
[14384] | 365 | for (int r = idx + 1; r < tlp.RowCount; r++) {
|
---|
| 366 | for (int c = 0; c < tlp.ColumnCount; c++) {
|
---|
| 367 | var control = tlp.GetControlFromPosition(c, r);
|
---|
| 368 | if (control != null) {
|
---|
| 369 | tlp.SetRow(control, r - 1);
|
---|
| 370 | }
|
---|
| 371 | }
|
---|
| 372 | }
|
---|
[14388] | 373 | // delete rows
|
---|
[14384] | 374 | tlp.RowStyles.RemoveAt(tlp.RowCount - 1);
|
---|
| 375 | tlp.RowCount--;
|
---|
| 376 | }
|
---|
[14388] | 377 | #endregion
|
---|
[14384] | 378 |
|
---|
[14580] | 379 | #region Creating Headers and Body
|
---|
[14384] | 380 | private Label GetColumnHeader(string variable) {
|
---|
| 381 | if (!columnHeaderCache.ContainsKey(variable)) {
|
---|
| 382 | columnHeaderCache.Add(variable, new Label() {
|
---|
| 383 | Text = variable,
|
---|
| 384 | TextAlign = ContentAlignment.MiddleCenter,
|
---|
| 385 | Name = variable,
|
---|
| 386 | Height = columnHeaderTableLayoutPanel.Height,
|
---|
| 387 | Dock = DockStyle.Fill,
|
---|
| 388 | Margin = new Padding(3)
|
---|
| 389 | });
|
---|
| 390 | }
|
---|
| 391 | return columnHeaderCache[variable];
|
---|
| 392 | }
|
---|
| 393 | private Label GetRowHeader(string variable) {
|
---|
| 394 | if (!rowHeaderCache.ContainsKey(variable)) {
|
---|
[14514] | 395 | rowHeaderCache.Add(variable, new VerticalLabel() {
|
---|
[14384] | 396 | Text = variable,
|
---|
| 397 | TextAlign = ContentAlignment.MiddleCenter,
|
---|
| 398 | Name = variable,
|
---|
| 399 | Width = rowHeaderTableLayoutPanel.Width,
|
---|
[14514] | 400 | Height = columnHeaderScrollPanel.Width,
|
---|
[14384] | 401 | Dock = DockStyle.Fill,
|
---|
| 402 | Margin = new Padding(3)
|
---|
| 403 | });
|
---|
| 404 | }
|
---|
| 405 | return rowHeaderCache[variable];
|
---|
| 406 | }
|
---|
[14446] | 407 | private Control GetBody(string colVariable, string rowVariable) {
|
---|
[14384] | 408 | var key = Tuple.Create(colVariable, rowVariable);
|
---|
| 409 | if (!bodyCache.ContainsKey(key)) {
|
---|
| 410 | if (rowVariable == colVariable) { // use historgram if x and y variable are equal
|
---|
[14975] | 411 | var dataTable = HistogramContent.CreateHistogram(
|
---|
| 412 | Content.PreprocessingData,
|
---|
| 413 | rowVariable,
|
---|
| 414 | (string)groupingComboBox.SelectedItem,
|
---|
[14993] | 415 | (AggregationType)aggregationComboBox.SelectedItem,
|
---|
| 416 | (PreprocessingChartContent.LegendOrder)legendOrderComboBox.SelectedItem);
|
---|
[14975] | 417 | dataTable.VisualProperties.Title = string.Empty;
|
---|
[14993] | 418 | foreach (var dataRow in dataTable.Rows) {
|
---|
| 419 | dataRow.VisualProperties.IsVisibleInLegend = legendCheckbox.Checked && groupingComboBox.SelectedIndex > 0;
|
---|
| 420 | }
|
---|
[14983] | 421 | var pcv = new DataTableView {
|
---|
[14384] | 422 | Name = key.ToString(),
|
---|
| 423 | Content = dataTable,
|
---|
| 424 | Dock = DockStyle.Fill,
|
---|
[14983] | 425 | ShowName = false
|
---|
[14384] | 426 | };
|
---|
[14996] | 427 | //pcv.ChartDoubleClick += HistogramDoubleClick; // ToDo: not working; double click is already handled by the chart
|
---|
[14384] | 428 | bodyCache.Add(key, pcv);
|
---|
| 429 | } else { //scatter plot
|
---|
[14975] | 430 | var scatterPlot = ScatterPlotContent.CreateScatterPlot(Content.PreprocessingData,
|
---|
| 431 | colVariable,
|
---|
| 432 | rowVariable,
|
---|
[14993] | 433 | (string)groupingComboBox.SelectedItem,
|
---|
| 434 | (PreprocessingChartContent.LegendOrder)legendOrderComboBox.SelectedItem);
|
---|
[14514] | 435 | var regressionType = (RegressionType)regressionTypeComboBox.SelectedValue;
|
---|
| 436 | int order = (int)polynomialRegressionOrderNumericUpDown.Value;
|
---|
[14975] | 437 | int i = 0;
|
---|
| 438 | var colors = PreprocessingChartView.Colors;
|
---|
[14514] | 439 | foreach (var row in scatterPlot.Rows) {
|
---|
[14975] | 440 | row.VisualProperties.PointSize = (int)pointSizeNumericUpDown.Value;
|
---|
| 441 | row.VisualProperties.Color = Color.FromArgb((int)(pointOpacityNumericUpDown.Value * 255),
|
---|
| 442 | row.VisualProperties.Color.IsEmpty ? colors[i++ % colors.Length] : row.VisualProperties.Color);
|
---|
[14993] | 443 | row.VisualProperties.IsVisibleInLegend = legendCheckbox.Checked && groupingComboBox.SelectedIndex > 0;
|
---|
[14514] | 444 | row.VisualProperties.IsRegressionVisibleInLegend = false;
|
---|
| 445 | row.VisualProperties.RegressionType = regressionType;
|
---|
| 446 | row.VisualProperties.PolynomialRegressionOrder = order;
|
---|
| 447 | }
|
---|
[14446] | 448 | scatterPlot.VisualProperties.Title = string.Empty;
|
---|
[14983] | 449 | var scatterPlotView = new ScatterPlotView {
|
---|
[14384] | 450 | Name = key.ToString(),
|
---|
| 451 | Content = scatterPlot,
|
---|
| 452 | Dock = DockStyle.Fill,
|
---|
[14983] | 453 | ShowName = false
|
---|
[14446] | 454 | //ShowLegend = false,
|
---|
| 455 | //XAxisFormat = "G3"
|
---|
[14384] | 456 | };
|
---|
[14983] | 457 | //scatterPlotView.DoubleClick += ScatterPlotDoubleClick; // ToDo: not working; double click is already handled by the chart
|
---|
| 458 | bodyCache.Add(key, scatterPlotView);
|
---|
[14384] | 459 | }
|
---|
| 460 | }
|
---|
| 461 | return bodyCache[key];
|
---|
| 462 | }
|
---|
| 463 | #endregion
|
---|
| 464 |
|
---|
[14511] | 465 | protected override void CheckedChangedUpdate() {
|
---|
[14953] | 466 | GenerateCharts(false); // only checked-changes -> reuse cached values
|
---|
[14511] | 467 | }
|
---|
| 468 |
|
---|
[14381] | 469 | #region Generate Charts
|
---|
[14953] | 470 | private void GenerateCharts(bool clearCache) {
|
---|
[14996] | 471 | if (Content == null || SuppressCheckedChangedUpdate) return;
|
---|
[14511] | 472 |
|
---|
[14384] | 473 | // Clear old layouts and cache
|
---|
| 474 | foreach (var tableLayoutPanel in new[] { columnHeaderTableLayoutPanel, rowHeaderTableLayoutPanel, bodyTableLayoutPanel }) {
|
---|
| 475 | tableLayoutPanel.Controls.Clear();
|
---|
| 476 | tableLayoutPanel.ColumnStyles.Clear();
|
---|
| 477 | tableLayoutPanel.RowStyles.Clear();
|
---|
[14381] | 478 | }
|
---|
[10882] | 479 |
|
---|
[14953] | 480 | if (clearCache) {
|
---|
[14993] | 481 | foreach (var control in bodyCache.Values.Concat(columnHeaderCache.Values).Concat(rowHeaderCache.Values)) {
|
---|
[14953] | 482 | control.Dispose();
|
---|
| 483 | }
|
---|
| 484 | columnHeaderCache.Clear();
|
---|
| 485 | rowHeaderCache.Clear();
|
---|
| 486 | bodyCache.Clear();
|
---|
| 487 | }
|
---|
| 488 |
|
---|
[14975] | 489 | var variables = Content.VariableItemList.Select(x => x.Value).ToList();
|
---|
| 490 |
|
---|
[14381] | 491 | // Set row and column count
|
---|
[14384] | 492 | columnHeaderTableLayoutPanel.ColumnCount = variables.Count;
|
---|
| 493 | rowHeaderTableLayoutPanel.RowCount = variables.Count;
|
---|
[14381] | 494 | bodyTableLayoutPanel.ColumnCount = variables.Count;
|
---|
| 495 | bodyTableLayoutPanel.RowCount = variables.Count;
|
---|
[10915] | 496 |
|
---|
[14381] | 497 | // Set column and row layout
|
---|
| 498 | for (int i = 0; i < variables.Count; i++) {
|
---|
[14975] | 499 | bool @checked = Content.VariableItemList.ItemChecked(Content.VariableItemList[i]);
|
---|
| 500 | columnHeaderTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, @checked ? GetColumnWidth() : 0));
|
---|
| 501 | rowHeaderTableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, @checked ? GetRowHeight() : 0));
|
---|
| 502 | bodyTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, @checked ? GetColumnWidth() : 0));
|
---|
| 503 | bodyTableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, @checked ? GetRowHeight() : 0));
|
---|
[10882] | 504 | }
|
---|
[10915] | 505 |
|
---|
[14384] | 506 | frameTableLayoutPanel.SuspendLayout();
|
---|
[14381] | 507 | AddHeaderToTableLayoutPanels();
|
---|
| 508 | AddChartsToTableLayoutPanel();
|
---|
[14384] | 509 | UpdateHeaderMargin();
|
---|
| 510 | frameTableLayoutPanel.ResumeLayout(true);
|
---|
[10952] | 511 | }
|
---|
[10915] | 512 |
|
---|
[14381] | 513 | private void AddHeaderToTableLayoutPanels() {
|
---|
[14975] | 514 | for (int i = 0; i < Content.VariableItemList.Count; i++) {
|
---|
| 515 | var variable = Content.VariableItemList[i];
|
---|
| 516 | if (Content.VariableItemList.ItemChecked(variable)) {
|
---|
| 517 | columnHeaderTableLayoutPanel.Controls.Add(GetColumnHeader(variable.Value), i, 0);
|
---|
| 518 | rowHeaderTableLayoutPanel.Controls.Add(GetRowHeader(variable.Value), 0, i);
|
---|
| 519 | }
|
---|
[14381] | 520 | }
|
---|
| 521 | }
|
---|
| 522 | private void AddChartsToTableLayoutPanel() {
|
---|
[14975] | 523 | for (int c = 0; c < Content.VariableItemList.Count; c++) {
|
---|
| 524 | var colVar = Content.VariableItemList[c].Value;
|
---|
[14384] | 525 | if (!IsVariableChecked(colVar)) continue;
|
---|
[14975] | 526 | for (int r = 0; r < Content.VariableItemList.Count; r++) {
|
---|
| 527 | var rowVar = Content.VariableItemList[r].Value;
|
---|
[14384] | 528 | if (!IsVariableChecked(rowVar)) continue;
|
---|
| 529 | bodyTableLayoutPanel.Controls.Add(GetBody(colVar, rowVar), c, r);
|
---|
[10915] | 530 | }
|
---|
| 531 | }
|
---|
[14514] | 532 | UpdateRegressionLine();
|
---|
[10882] | 533 | }
|
---|
| 534 |
|
---|
[14381] | 535 | #endregion
|
---|
| 536 |
|
---|
| 537 | #region DoubleClick Events
|
---|
[10952] | 538 | //Open scatter plot in new tab with new content when double clicked
|
---|
| 539 | private void ScatterPlotDoubleClick(object sender, EventArgs e) {
|
---|
[14983] | 540 | var scatterPlotView = (ScatterPlotView)sender;
|
---|
[14467] | 541 | var scatterContent = new SingleScatterPlotContent(Content.PreprocessingData);
|
---|
[14983] | 542 | ScatterPlot scatterPlot = scatterPlotView.Content;
|
---|
[10915] | 543 |
|
---|
[14381] | 544 | //Extract variable names from scatter plot and set them in content
|
---|
[10952] | 545 | if (scatterPlot.Rows.Count == 1) {
|
---|
[10992] | 546 | string[] variables = scatterPlot.Rows.ElementAt(0).Name.Split(new string[] { " - " }, StringSplitOptions.None); // extract variable names from string
|
---|
[10952] | 547 | scatterContent.SelectedXVariable = variables[0];
|
---|
| 548 | scatterContent.SelectedYVariable = variables[1];
|
---|
| 549 | }
|
---|
[14381] | 550 |
|
---|
[14993] | 551 | MainFormManager.MainForm.ShowContent(scatterContent, typeof(ScatterPlotSingleView)); // open in new tab
|
---|
[10915] | 552 | }
|
---|
[10952] | 553 |
|
---|
[14381] | 554 | //open histogram in new tab with new content when double clicked
|
---|
| 555 | private void HistogramDoubleClick(object sender, EventArgs e) {
|
---|
[14983] | 556 | DataTableView pcv = (DataTableView)sender;
|
---|
[14381] | 557 | HistogramContent histoContent = new HistogramContent(Content.PreprocessingData); // create new content
|
---|
[14975] | 558 | //ToDo: histoContent.VariableItemList = Content.CreateVariableItemList();
|
---|
[14459] | 559 | var dataTable = pcv.Content;
|
---|
[10952] | 560 |
|
---|
[14381] | 561 | //Set variable item list from with variable from data table
|
---|
| 562 | if (dataTable.Rows.Count == 1) { // only one data row should be in data table
|
---|
[10952] | 563 | string variableName = dataTable.Rows.ElementAt(0).Name;
|
---|
| 564 |
|
---|
| 565 | // set only variable name checked
|
---|
[10992] | 566 | foreach (var checkedItem in histoContent.VariableItemList) {
|
---|
[14381] | 567 | histoContent.VariableItemList.SetItemCheckedState(checkedItem, checkedItem.Value == variableName);
|
---|
[10952] | 568 | }
|
---|
| 569 | }
|
---|
[14993] | 570 | MainFormManager.MainForm.ShowContent(histoContent, typeof(HistogramView)); // open in new tab
|
---|
[10952] | 571 | }
|
---|
[14381] | 572 | #endregion
|
---|
[10952] | 573 |
|
---|
[14388] | 574 | #region Scrolling
|
---|
[14384] | 575 | private void bodyScrollPanel_Scroll(object sender, ScrollEventArgs e) {
|
---|
[14381] | 576 | SyncScroll();
|
---|
[10952] | 577 |
|
---|
[14384] | 578 | UpdateHeaderMargin();
|
---|
[10952] | 579 | }
|
---|
[14384] | 580 | private void bodyScrollPanel_MouseWheel(object sender, MouseEventArgs e) {
|
---|
[14381] | 581 | // Scrolling with the mouse wheel is not captured in the Scoll event
|
---|
| 582 | SyncScroll();
|
---|
| 583 | }
|
---|
| 584 | private void SyncScroll() {
|
---|
| 585 | frameTableLayoutPanel.SuspendRepaint();
|
---|
[10992] | 586 |
|
---|
[14384] | 587 | columnHeaderScrollPanel.HorizontalScroll.Minimum = bodyScrollPanel.HorizontalScroll.Minimum;
|
---|
| 588 | columnHeaderScrollPanel.HorizontalScroll.Maximum = bodyScrollPanel.HorizontalScroll.Maximum;
|
---|
| 589 | rowHeaderScrollPanel.VerticalScroll.Minimum = bodyScrollPanel.VerticalScroll.Minimum;
|
---|
| 590 | rowHeaderScrollPanel.VerticalScroll.Maximum = bodyScrollPanel.VerticalScroll.Maximum;
|
---|
[10882] | 591 |
|
---|
[14384] | 592 | columnHeaderScrollPanel.HorizontalScroll.Value = Math.Max(bodyScrollPanel.HorizontalScroll.Value, 1);
|
---|
| 593 | rowHeaderScrollPanel.VerticalScroll.Value = Math.Max(bodyScrollPanel.VerticalScroll.Value, 1);
|
---|
[14381] | 594 | // minimum 1 is nececary because of two factors:
|
---|
| 595 | // - setting the Value-property of Horizontal/VerticalScroll updates the internal state but the Value-property stays 0
|
---|
| 596 | // - setting the same number of the Value-property has no effect
|
---|
| 597 | // since the Value-property is always 0, setting it to 0 would have no effect; so it is set to 1 instead
|
---|
[10992] | 598 |
|
---|
[14381] | 599 | frameTableLayoutPanel.ResumeRepaint(true);
|
---|
| 600 | }
|
---|
[14384] | 601 | // add a margin to the header table layouts if the scollbar is visible to account for the width/height of the scrollbar
|
---|
| 602 | private void UpdateHeaderMargin() {
|
---|
| 603 | columnHeaderScrollPanel.Margin = new Padding(0, 0, bodyScrollPanel.VerticalScroll.Visible ? SystemInformation.VerticalScrollBarWidth : 0, 0);
|
---|
| 604 | rowHeaderScrollPanel.Margin = new Padding(0, 0, 0, bodyScrollPanel.HorizontalScroll.Visible ? SystemInformation.HorizontalScrollBarHeight : 0);
|
---|
| 605 | }
|
---|
[14388] | 606 | #endregion
|
---|
| 607 |
|
---|
| 608 | #region Sizing of Charts
|
---|
[14917] | 609 | private int oldWidth;
|
---|
| 610 | private int oldHeight;
|
---|
| 611 | private float AspectRatio {
|
---|
| 612 | get {
|
---|
| 613 | if (oldWidth == 0 || oldHeight == 0) return 1;
|
---|
| 614 | return (float)oldWidth / oldHeight;
|
---|
| 615 | }
|
---|
| 616 | }
|
---|
| 617 | private bool lockChange = false;
|
---|
[14902] | 618 |
|
---|
| 619 | private int GetColumnWidth() { return (int)widthNumericUpDown.Value; }
|
---|
| 620 | private int GetRowHeight() { return (int)heightNumericUpDown.Value; }
|
---|
[14917] | 621 |
|
---|
[14902] | 622 | private void widthNumericUpDown_ValueChanged(object sender, EventArgs e) {
|
---|
[14388] | 623 | frameTableLayoutPanel.SuspendRepaint();
|
---|
[14917] | 624 | if (lockAspectCheckBox.Checked && !lockChange) {
|
---|
| 625 | lockChange = true;
|
---|
| 626 | heightNumericUpDown.Value = (int)((double)widthNumericUpDown.Value / AspectRatio);
|
---|
| 627 | lockChange = false;
|
---|
| 628 | }
|
---|
[14388] | 629 | for (int i = 0; i < columnHeaderTableLayoutPanel.ColumnCount; i++) {
|
---|
[14975] | 630 | if (Content.VariableItemList.ItemChecked(Content.VariableItemList[i])) {
|
---|
| 631 | columnHeaderTableLayoutPanel.ColumnStyles[i].Width = GetColumnWidth();
|
---|
| 632 | bodyTableLayoutPanel.ColumnStyles[i].Width = GetColumnWidth();
|
---|
| 633 | }
|
---|
[14388] | 634 | }
|
---|
[14917] | 635 | oldWidth = GetColumnWidth();
|
---|
| 636 | oldHeight = GetRowHeight();
|
---|
[14388] | 637 | frameTableLayoutPanel.ResumeRepaint(true);
|
---|
| 638 | }
|
---|
[14902] | 639 | private void heightNumericUpDown_ValueChanged(object sender, EventArgs e) {
|
---|
[14388] | 640 | frameTableLayoutPanel.SuspendRepaint();
|
---|
[14917] | 641 | if (lockAspectCheckBox.Checked && !lockChange) {
|
---|
| 642 | lockChange = true;
|
---|
| 643 | widthNumericUpDown.Value = (int)((double)heightNumericUpDown.Value * AspectRatio);
|
---|
| 644 | lockChange = false;
|
---|
| 645 | }
|
---|
[14388] | 646 | for (int i = 0; i < rowHeaderTableLayoutPanel.RowCount; i++) {
|
---|
[14975] | 647 | if (Content.VariableItemList.ItemChecked(Content.VariableItemList[i])) {
|
---|
| 648 | rowHeaderTableLayoutPanel.RowStyles[i].Height = GetRowHeight();
|
---|
| 649 | bodyTableLayoutPanel.RowStyles[i].Height = GetRowHeight();
|
---|
| 650 | }
|
---|
[14388] | 651 | }
|
---|
[14917] | 652 | oldWidth = GetColumnWidth();
|
---|
| 653 | oldHeight = GetRowHeight();
|
---|
[14388] | 654 | frameTableLayoutPanel.ResumeRepaint(true);
|
---|
| 655 | }
|
---|
[14975] | 656 | private void pointSizeNumericUpDown_ValueChanged(object sender, EventArgs e) {
|
---|
| 657 | int pointSize = (int)pointSizeNumericUpDown.Value;
|
---|
| 658 | foreach (var control in bodyCache.ToList()) {
|
---|
[14983] | 659 | var scatterPlotView = control.Value as ScatterPlotView;
|
---|
| 660 | if (scatterPlotView != null) {
|
---|
| 661 | foreach (var row in scatterPlotView.Content.Rows) {
|
---|
[14975] | 662 | row.VisualProperties.PointSize = pointSize;
|
---|
| 663 | }
|
---|
| 664 | }
|
---|
| 665 | }
|
---|
| 666 | }
|
---|
| 667 | private void pointOpacityNumericUpDown_ValueChanged(object sender, EventArgs e) {
|
---|
| 668 | float opacity = (float)pointOpacityNumericUpDown.Value;
|
---|
| 669 | foreach (var control in bodyCache.ToList()) {
|
---|
[14983] | 670 | var scatterPlotView = control.Value as ScatterPlotView;
|
---|
| 671 | if (scatterPlotView != null) {
|
---|
| 672 | foreach (var row in scatterPlotView.Content.Rows) {
|
---|
[14975] | 673 | var color = row.VisualProperties.Color;
|
---|
| 674 | if (color.IsEmpty)
|
---|
| 675 | color = PreprocessingChartView.Colors.First();
|
---|
| 676 | row.VisualProperties.Color = Color.FromArgb((int)(opacity * 255), color);
|
---|
| 677 | }
|
---|
| 678 | }
|
---|
| 679 | }
|
---|
| 680 | }
|
---|
[14388] | 681 | #endregion
|
---|
[14514] | 682 |
|
---|
| 683 | #region Regression Line
|
---|
| 684 | private void regressionTypeComboBox_SelectedValueChanged(object sender, EventArgs e) {
|
---|
| 685 | var regressionType = (RegressionType)regressionTypeComboBox.SelectedValue;
|
---|
| 686 | polynomialRegressionOrderNumericUpDown.Enabled = regressionType == RegressionType.Polynomial;
|
---|
| 687 | UpdateRegressionLine();
|
---|
| 688 | }
|
---|
| 689 |
|
---|
| 690 | private void polynomialRegressionOrderNumericUpDown_ValueChanged(object sender, EventArgs e) {
|
---|
| 691 | UpdateRegressionLine();
|
---|
| 692 | }
|
---|
| 693 |
|
---|
| 694 | private void UpdateRegressionLine() {
|
---|
| 695 | var regressionType = (RegressionType)regressionTypeComboBox.SelectedValue;
|
---|
| 696 | int order = (int)polynomialRegressionOrderNumericUpDown.Value;
|
---|
| 697 |
|
---|
[14975] | 698 | foreach (var control in bodyCache.ToList()) {
|
---|
| 699 | // hidden chart => reset cache
|
---|
| 700 | if (!bodyTableLayoutPanel.Controls.Contains(control.Value)) {
|
---|
| 701 | bodyCache.Remove(control.Key);
|
---|
| 702 | }
|
---|
| 703 |
|
---|
[14983] | 704 | var scatterPlotView = control.Value as ScatterPlotView;
|
---|
| 705 | if (scatterPlotView != null) {
|
---|
| 706 | foreach (var row in scatterPlotView.Content.Rows) {
|
---|
[14514] | 707 | row.VisualProperties.IsRegressionVisibleInLegend = false;
|
---|
| 708 | row.VisualProperties.RegressionType = regressionType;
|
---|
| 709 | row.VisualProperties.PolynomialRegressionOrder = order;
|
---|
| 710 | }
|
---|
| 711 | }
|
---|
| 712 | }
|
---|
| 713 | }
|
---|
| 714 | #endregion
|
---|
[14725] | 715 |
|
---|
[14975] | 716 | #region Grouping
|
---|
[14725] | 717 | private void groupingComboBox_SelectedIndexChanged(object sender, EventArgs e) {
|
---|
[14993] | 718 | aggregationLabel.Enabled = groupingComboBox.SelectedIndex > 0;
|
---|
[14975] | 719 | aggregationComboBox.Enabled = groupingComboBox.SelectedIndex > 0;
|
---|
[14993] | 720 | legendGroupBox.Enabled = groupingComboBox.SelectedIndex > 0;
|
---|
[14953] | 721 | GenerateCharts(true); // new series within charts -> clear cache
|
---|
[14725] | 722 | }
|
---|
[14975] | 723 |
|
---|
| 724 | private void aggregationComboBox_SelectedIndexChanged(object sender, EventArgs e) {
|
---|
| 725 | var aggregation = (AggregationType)aggregationComboBox.SelectedValue;
|
---|
| 726 | foreach (var control in bodyCache.ToList()) {
|
---|
| 727 | // hidden chart => reset cache
|
---|
| 728 | if (!bodyTableLayoutPanel.Controls.Contains(control.Value)) {
|
---|
| 729 | bodyCache.Remove(control.Key);
|
---|
| 730 | }
|
---|
| 731 |
|
---|
[14983] | 732 | var histogramControl = control.Value as DataTableView;
|
---|
[14975] | 733 | if (histogramControl != null) {
|
---|
| 734 | foreach (var row in histogramControl.Content.Rows) {
|
---|
| 735 | row.VisualProperties.Aggregation = aggregation;
|
---|
| 736 | }
|
---|
| 737 | }
|
---|
| 738 | }
|
---|
| 739 | }
|
---|
[14993] | 740 |
|
---|
| 741 | private void legendCheckbox_CheckedChanged(object sender, EventArgs e) {
|
---|
| 742 | foreach (var control in bodyCache.ToList()) {
|
---|
| 743 | var histogramControl = control.Value as DataTableView;
|
---|
| 744 | if (histogramControl != null) {
|
---|
| 745 | foreach (var row in histogramControl.Content.Rows) {
|
---|
| 746 | row.VisualProperties.IsVisibleInLegend = legendCheckbox.Checked && groupingComboBox.SelectedIndex > 0;
|
---|
| 747 | }
|
---|
| 748 | }
|
---|
| 749 | var scatterplotControl = control.Value as ScatterPlotView;
|
---|
| 750 | if (scatterplotControl != null) {
|
---|
| 751 | foreach (var row in scatterplotControl.Content.Rows) {
|
---|
| 752 | row.VisualProperties.IsVisibleInLegend = legendCheckbox.Checked && groupingComboBox.SelectedIndex > 0;
|
---|
| 753 | }
|
---|
| 754 | }
|
---|
| 755 | }
|
---|
| 756 | }
|
---|
| 757 |
|
---|
| 758 | private void legendOrderComboBox_SelectedIndexChanged(object sender, EventArgs e) {
|
---|
| 759 | GenerateCharts(true);
|
---|
| 760 | }
|
---|
[14975] | 761 | #endregion
|
---|
[14381] | 762 | }
|
---|
[10882] | 763 | }
|
---|
[14514] | 764 |
|
---|