Esempio n. 1
0
 //Extract variable names from scatter plot and set them in content
 private void setVariablesInContentFromScatterPlot(ScatterPlotContent scatterContent, ScatterPlot scatterPlot)
 {
     // only one data row should be in scatter plot
     if (scatterPlot.Rows.Count == 1)
     {
         string[] variables = scatterPlot.Rows.ElementAt(0).Name.Split(new string[] { " - " }, StringSplitOptions.None); // extract variable names from string
         scatterContent.SelectedXVariable = variables[0];
         scatterContent.SelectedYVariable = variables[1];
     }
 }
Esempio n. 2
0
        //Open scatter plot in new tab with new content when double clicked
        private void ScatterPlotDoubleClick(object sender, EventArgs e)
        {
            PreprocessingScatterPlotView pspv           = (PreprocessingScatterPlotView)sender;
            ScatterPlotContent           scatterContent = new ScatterPlotContent(Content, new Cloner()); // create new content
            ScatterPlot scatterPlot = pspv.Content;

            setVariablesInContentFromScatterPlot(scatterContent, scatterPlot);

            MainFormManager.MainForm.ShowContent(scatterContent, typeof(ScatterPlotSingleView)); // open in new tab
        }
        private void UpdateScatterPlot()
        {
            if (comboBoxXVariable.SelectedItem != null && comboBoxYVariable.SelectedItem != null && comboBoxGroup.SelectedItem != null)
            {
                var xVariable     = (string)comboBoxXVariable.SelectedItem;
                var yVariable     = (string)comboBoxYVariable.SelectedItem;
                var groupVariable = (string)comboBoxGroup.SelectedItem;
                var legendOrder   = (PreprocessingChartContent.LegendOrder)orderComboBox.SelectedItem;

                ScatterPlot scatterPlot = ScatterPlotContent.CreateScatterPlot(Content.PreprocessingData, xVariable, yVariable, groupVariable, legendOrder);
                //rows are saved and removed to avoid firing of visual property changed events
                var rows = scatterPlot.Rows.ToList();
                scatterPlot.Rows.Clear();
                var regressionType = (RegressionType)regressionTypeComboBox.SelectedValue;
                int order          = (int)polynomialRegressionOrderNumericUpDown.Value;
                foreach (var row in rows)
                {
                    row.VisualProperties.PointSize = 6;
                    row.VisualProperties.IsRegressionVisibleInLegend = false;
                    row.VisualProperties.RegressionType            = regressionType;
                    row.VisualProperties.PolynomialRegressionOrder = order;
                    row.VisualProperties.IsVisibleInLegend         = !useGradientCheckBox.Checked;
                }
                scatterPlot.Rows.AddRange(rows);
                var vp = scatterPlot.VisualProperties;
                vp.Title      = string.Empty;
                vp.XAxisTitle = xVariable;
                vp.YAxisTitle = yVariable;

                scatterPlotView.Content = scatterPlot;

                //save selected x and y variable in content
                this.Content.SelectedXVariable = (string)comboBoxXVariable.SelectedItem;
                this.Content.SelectedYVariable = (string)comboBoxYVariable.SelectedItem;
                this.Content.GroupingVariable  = (string)comboBoxGroup.SelectedItem;
            }
        }
    //Extract variable names from scatter plot and set them in content
    private void setVariablesInContentFromScatterPlot(ScatterPlotContent scatterContent, ScatterPlot scatterPlot) {

      // only one data row should be in scatter plot
      if (scatterPlot.Rows.Count == 1) {
        string[] variables = scatterPlot.Rows.ElementAt(0).Name.Split(new string[] { " - " }, StringSplitOptions.None); // extract variable names from string
        scatterContent.SelectedXVariable = variables[0];
        scatterContent.SelectedYVariable = variables[1];
      }
    }
    //Open scatter plot in new tab with new content when double clicked
    private void ScatterPlotDoubleClick(object sender, EventArgs e) {
      PreprocessingScatterPlotView pspv = (PreprocessingScatterPlotView)sender;
      ScatterPlotContent scatterContent = new ScatterPlotContent(Content, new Cloner());  // create new content
      ScatterPlot scatterPlot = pspv.Content;
      setVariablesInContentFromScatterPlot(scatterContent, scatterPlot);

      MainFormManager.MainForm.ShowContent(scatterContent, typeof(ScatterPlotSingleView));  // open in new tab
    }
        private Control GetBody(string colVariable, string rowVariable)
        {
            var key = Tuple.Create(colVariable, rowVariable);

            if (!bodyCache.ContainsKey(key))
            {
                if (rowVariable == colVariable) // use historgram if x and y variable are equal
                {
                    var dataTable = HistogramContent.CreateHistogram(
                        Content.PreprocessingData,
                        rowVariable,
                        (string)groupingComboBox.SelectedItem,
                        (AggregationType)aggregationComboBox.SelectedItem,
                        (PreprocessingChartContent.LegendOrder)legendOrderComboBox.SelectedItem);
                    dataTable.VisualProperties.Title = string.Empty;
                    foreach (var dataRow in dataTable.Rows)
                    {
                        dataRow.VisualProperties.IsVisibleInLegend = legendCheckbox.Checked && groupingComboBox.SelectedIndex > 0;
                    }
                    var pcv = new DataTableView {
                        Name          = key.ToString(),
                        Content       = dataTable,
                        Dock          = DockStyle.Fill,
                        ShowChartOnly = true
                    };
                    //pcv.ChartDoubleClick += HistogramDoubleClick;  // ToDo: not working; double click is already handled by the chart
                    bodyCache.Add(key, pcv);
                }
                else //scatter plot
                {
                    var scatterPlot = ScatterPlotContent.CreateScatterPlot(Content.PreprocessingData,
                                                                           colVariable,
                                                                           rowVariable,
                                                                           (string)groupingComboBox.SelectedItem,
                                                                           (PreprocessingChartContent.LegendOrder)legendOrderComboBox.SelectedItem);
                    var regressionType = (RegressionType)regressionTypeComboBox.SelectedValue;
                    int order          = (int)polynomialRegressionOrderNumericUpDown.Value;
                    int i      = 0;
                    var colors = PreprocessingChartView.Colors;
                    foreach (var row in scatterPlot.Rows)
                    {
                        row.VisualProperties.PointSize = (int)pointSizeNumericUpDown.Value;
                        row.VisualProperties.Color     = Color.FromArgb((int)(pointOpacityNumericUpDown.Value * 255),
                                                                        row.VisualProperties.Color.IsEmpty ? colors[i++ % colors.Length] : row.VisualProperties.Color);
                        row.VisualProperties.IsVisibleInLegend           = legendCheckbox.Checked && groupingComboBox.SelectedIndex > 0;
                        row.VisualProperties.IsRegressionVisibleInLegend = false;
                        row.VisualProperties.RegressionType            = regressionType;
                        row.VisualProperties.PolynomialRegressionOrder = order;
                    }
                    scatterPlot.VisualProperties.Title = string.Empty;
                    var scatterPlotView = new ScatterPlotView {
                        Name     = key.ToString(),
                        Content  = scatterPlot,
                        Dock     = DockStyle.Fill,
                        ShowName = false
                                   //ShowLegend = false,
                                   //XAxisFormat = "G3"
                    };
                    //scatterPlotView.DoubleClick += ScatterPlotDoubleClick; // ToDo: not working; double click is already handled by the chart
                    bodyCache.Add(key, scatterPlotView);
                }
            }
            return(bodyCache[key]);
        }