private void InitializeComponent(GenericDataset myds, int width, int height) { this.Dataset = myds; var DS = new UnivariateDataset <double>() as IUnivariateDataset; var col = new AlphanumericDataset(); col.Name = "Default X"; col.ListOfObservations = new List <string>(); //Console.WriteLine(col.DataType); foreach (var i in Enumerable.Range(1, Dataset.GetVariableCount(Dataset.Labels[0]))) { col.ListOfObservations.Add(i.ToString()); } //DS.isNumeric = true; DS.Init(col); if (!Dataset.UnivariateDatasets.ContainsKey(DS.Name)) { Dataset.UnivariateDatasets.Add(DS.Name, DS); } else { DS.Name = DS.Name + "1"; Dataset.UnivariateDatasets.Add(DS.Name, DS); } Dataset.Labels.Add(DS.Name); Dataset.Log(); Console.WriteLine("Added {0}", DS.Name); this.Width = width; int sidebarWidth = (int)(this.Width * 0.3); this.PointSettings = new System.Windows.Forms.GroupBox(); this.SelectLabel = new System.Windows.Forms.ComboBox(); this.PickPointColor = new System.Windows.Forms.Button(); this.DisplayPointColor = new System.Windows.Forms.RichTextBox(); this.DisplayLabel = new System.Windows.Forms.CheckBox(); this.PickLabelColor = new System.Windows.Forms.Button(); this.DisplayLabelColor = new System.Windows.Forms.RichTextBox(); this.DisplayLabel.CheckedChanged += new System.EventHandler(this.onDisplayLabelChange); MyPlotDataView view = new MyPlotDataView(); //this.Height = view.PointSettings(0, 0, sidebarWidth, PointSettings, SelectLabel, PickPointColor, DisplayPointColor, DisplayLabel, PickLabelColor, DisplayLabelColor); this.VarXSettings = new System.Windows.Forms.GroupBox(); this.SelectVarX = new System.Windows.Forms.ComboBox(); this.PickXColor = new System.Windows.Forms.Button(); this.DisplayXColor = new System.Windows.Forms.RichTextBox(); this.IntervalX = new System.Windows.Forms.NumericUpDown(); this.SelectVarX.SelectedIndexChanged += new System.EventHandler(this.onVarXChange); this.IntervalX.Value = 10; this.Height = view.VariableSettings("X", 0, 0, sidebarWidth, VarXSettings, SelectVarX, IntervalX); this.VarYSettings = new System.Windows.Forms.GroupBox(); this.SelectVarY = new System.Windows.Forms.ComboBox(); this.PickYColor = new System.Windows.Forms.Button(); this.DisplayYColor = new System.Windows.Forms.RichTextBox(); this.IntervalY = new System.Windows.Forms.NumericUpDown(); this.SelectVarY.SelectedIndexChanged += new System.EventHandler(this.onVarYChange); this.IntervalY.Value = 10; this.Height += view.VariableSettings("Y", 0, this.Height, sidebarWidth, VarYSettings, SelectVarY, IntervalY); this.ClearChartButton = new System.Windows.Forms.Button(); this.StatisticsGroupBox = new System.Windows.Forms.GroupBox(); this.ContingencyTableButton = new System.Windows.Forms.Button(); this.PlotDataButton = new System.Windows.Forms.Button(); this.ClearChartButton.Click += new System.EventHandler(this.onClearClick); this.PlotDataButton.Click += new System.EventHandler(this.onPlotClick); this.ContingencyTableButton.Click += new System.EventHandler(this.onCTClick); this.Height += view.StatisticsControls(0, this.Height, sidebarWidth, StatisticsGroupBox, PlotDataButton, ContingencyTableButton); this.PlotDataButton.Text = "Refresh Chart"; // // ClearChartButton Button // ClearChartButton.Text = "Clear Chart"; ClearChartButton.Name = "ClearChartButton"; int ClearChartButtonX = view.marginX; int ClearChartButtonY = this.StatisticsGroupBox.Height; ClearChartButton.Location = new System.Drawing.Point(ClearChartButtonX, ClearChartButtonY); ClearChartButton.Height = view.stdButtonHeight; ClearChartButton.Width = this.StatisticsGroupBox.Width - 2 * view.marginX; StatisticsGroupBox.Height += ClearChartButton.Height + 2 * view.marginY; this.Height += ClearChartButton.Height + 2 * view.marginY; StatisticsGroupBox.Controls.Add(ClearChartButton); this.DisplayDataSettings = new System.Windows.Forms.GroupBox(); this.DataTable = new System.Windows.Forms.ListView(); this.DataTable.View = View.Details; MyImportCSV ctr = new MyImportCSV(); this.Height += ctr.DisplayData(0, this.Height, sidebarWidth, 0, this.DisplayDataSettings, this.DataTable); DisplayDataSettings.Text = "Calculated Statistics"; this.DisplayDataSettings.Anchor = ( (System.Windows.Forms.AnchorStyles)( (System.Windows.Forms.AnchorStyles.Top) | (System.Windows.Forms.AnchorStyles.Bottom) | (System.Windows.Forms.AnchorStyles.Left) )); this.DataTable.Anchor = ( (System.Windows.Forms.AnchorStyles)( (System.Windows.Forms.AnchorStyles.Top) | (System.Windows.Forms.AnchorStyles.Bottom) | (System.Windows.Forms.AnchorStyles.Left) )); this.ChartGroupBox = new System.Windows.Forms.GroupBox(); this.Chart = new System.Windows.Forms.PictureBox(); int temp = view.ChartView(sidebarWidth, 0, width - sidebarWidth, 0, this.ChartGroupBox, this.Chart); if (temp > this.Height) { this.Height = temp; } else { this.ChartGroupBox.Height = this.Height - 30; } this.Controls.Add(this.ChartGroupBox); this.Controls.Add(this.DisplayDataSettings); this.Controls.Add(this.StatisticsGroupBox); this.Controls.Add(this.VarYSettings); this.Controls.Add(this.VarXSettings); //this.Controls.Add(this.PointSettings); this.ClientSize = new System.Drawing.Size(this.Width, this.Height); this.Text = "Plot Data"; InitializeGraphics(); InitializeLabels(); InitializeListView(); InitializeVariables(); }
//---------------------------------------------------------------------------------------------------// // // // private void GenerateDataPoints() { updateParameters(); // var AN_jumps = new AlphanumericDataset(); // AN_jumps.Name = "Distance Of Individual Jumps"; // AN_jumps.ListOfObservations = new List<string>(); // var AN_cons = new AlphanumericDataset(); // AN_cons.Name = "Distance Of Consecutive Jumps"; // AN_cons.ListOfObservations = new List<string>(); // var prev_val = new double[m]; // var AN_Walkers = new AlphanumericDataset(); // AN_Walkers.Name = "Poisson Walkers"; // AN_Walkers.ListOfObservations = new List<string>(); var f = new double[m]; for (int k = 0; k < m; k++) { f[k] = (NumericStart.Value > 0? (double)NumericStart.Value * 0.01 : getInitialValue()); //f[k] = (double) (NumericStart.Value); raw_paths.Add(new AlphanumericDataset()); raw_paths[k].Name = (k).ToString(); raw_paths[k].ListOfObservations = new List <string>(); MyPen.Add(new Pen(Color.FromArgb(150, rand.Next(256), rand.Next(256), rand.Next(256)), 1)); prev_X.Add(Viewport.Left); prev_Y.Add(Viewport.Bottom - Viewport.Height / 2); } AlphanumericDataset DistSamples; for (int i = 0; i < n; i++) { double index = (double)(i + 1); // if(i == n-1) // { // DistSamples = new AlphanumericDataset(); // DistSamples.ListOfObservations = new List<string>(); // DistSamples.Name = i.ToString(); // } for (int k = 0; k < m; k++) { double val = updateVal(n, p, lambda, sigma, A, B, L, f[k], index); // Console.WriteLine("{0} updated", k); f[k] = f[k] + val; raw_paths[k].ListOfObservations.Add((f[k]).ToString()); if (i == n - 1) { // store all paths in dataset var DS = new UnivariateDataset <double>() as IUnivariateDataset; DS.Init(raw_paths[k]); // calculate statistics // sample max if (double.Parse(DS.M) > max) { max = double.Parse(DS.M); } //sample min if (double.Parse(DS.m) < min) { min = double.Parse(DS.m); } //sample range range = max - min; //sample mean ? //mean += (double.Parse(DS.AM) - mean)/(k+1); // expected value? //variance? myds.UnivariateDatasets.Add(DS.Name, DS); myds.Labels.Add(DS.Name); //distribution samples // DistSamples.ListOfObservations.Add((f[k]).ToString()); } } } // var DS = new UnivariateDataset<double>() as IUnivariateDataset; // DS.Init(DistSamples); // myds.UnivariateDatasets.Add(DS.Name, DS); // myds.Labels.Add(DS.Name); //var ordered = ListOfRects.OrderBy(rect => -rect.Top); // int x_index = 0; // foreach(var rect in ListOfRects) // { // var new_rect = new Rectangle(rect.Left, (int) (Viewport.Bottom - Viewport.Height/2 - (Viewport.Height/2)*rect.Top/1000), rect.Width, (int)(size*Viewport.Height/2)); // g.FillRectangle(new SolidBrush(Color.FromArgb(200, 0, 0, 0)), new_rect ); // g.DrawRectangle(new Pen(Color.FromArgb( 255, 255, 255)), new_rect ); // x_index+=1; // } // var myds = new GenericDataset(); // var DS = new UnivariateDataset<int>(); // DS.isNumeric = true; // DS.Init(AN_jumps); // myds.IntDictionary.Add(DS.Name, DS); // myds.Labels.Add(DS.Name); // DS = new UnivariateDataset<int>(); // DS.isNumeric = true; // DS.Init(AN_cons); // myds.IntDictionary.Add(DS.Name, DS); // myds.Labels.Add(DS.Name); // var DDS = new UnivariateDataset<double>(); // DDS.isNumeric = true; // DDS.Init(AN_Walkers); // myds.DoubleDictionary.Add(DDS.Name, DDS); // myds.Labels.Add(DDS.Name); // myds.Log(); // FormUA UA = new FormUA(myds); // UA.Show(); }
// // Confirm Click // private void Confirm() { Console.WriteLine("confirm"); if (Columns == null) { return; } myds = new GenericDataset(); foreach (var col in Columns) { var v2 = col.GetType().GetProperty("DataType").GetValue(col, null); //Console.WriteLine(v2); if (col.DataType == typeof(int)) { var DS = new UnivariateDataset <int>() as IUnivariateDataset; DS.Init(col); if (!myds.UnivariateDatasets.ContainsKey(DS.Name)) { myds.UnivariateDatasets.Add(DS.Name, DS); } else { DS.Name = DS.Name + "1"; myds.UnivariateDatasets.Add(DS.Name, DS); } myds.Labels.Add(DS.Name); } else if (col.DataType == typeof(double)) { var DS = new UnivariateDataset <double>() as IUnivariateDataset; DS.Init(col); if (!myds.UnivariateDatasets.ContainsKey(DS.Name)) { myds.UnivariateDatasets.Add(DS.Name, DS); } else { DS.Name = DS.Name + "1"; myds.UnivariateDatasets.Add(DS.Name, DS); } myds.Labels.Add(DS.Name); } else if (col.DataType == typeof(DateTime)) { var DS = new UnivariateDataset <DateTime>() as IUnivariateDataset; DS.Init(col); if (!myds.UnivariateDatasets.ContainsKey(DS.Name)) { myds.UnivariateDatasets.Add(DS.Name, DS); } else { DS.Name = DS.Name + "1"; myds.UnivariateDatasets.Add(DS.Name, DS); } myds.Labels.Add(DS.Name); } else if (col.DataType == typeof(string)) { var DS = new UnivariateDataset <string>() as IUnivariateDataset; DS.Name = col.Name; DS.Init(col); //DS.Log(); if (!myds.UnivariateDatasets.ContainsKey(DS.Name)) { myds.UnivariateDatasets.Add(DS.Name, DS); } else { DS.Name = DS.Name + "1"; myds.UnivariateDatasets.Add(DS.Name, DS); } myds.Labels.Add(DS.Name); } } //myds.Log(); //StatApp parent = (StatApp)this.Owner; //parent.Confirm(myds); //this.Close(); }