private void printChart(InputData[] data, int lambda, string[] dataDescriptions)
        {

            DataTable table;


            this.Text = "Lambda" + lambda + " comparison";
            this.chartLambda.Series.RemoveAt(0);
            for (int i = 0; i < 4; i++)
            {
                if (data.Length >= i + 1)
                {
                    if (data[i] != null)
                    {
                        table = data[i].getLagrangeDatatable();
           
                        this.chartLambda.Series.Add(dataDescriptions[i] + "values").ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.BoxPlot;
                        this.chartLambda.Series[dataDescriptions[i] + "values"].Points.DataBindY((table.Rows[lambda]).ItemArray);

                        this.chartLambda.Series.Add(dataDescriptions[i]).ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.BoxPlot;
                        this.chartLambda.Series[dataDescriptions[i]]["BoxPlotSeries"] = dataDescriptions[i] + "values";
                        this.chartLambda.Series[dataDescriptions[i]]["BoxPlotWhiskerPercentile"] = "15";
                        this.chartLambda.Series[dataDescriptions[i]]["BoxPlotShowAverage"] = "true";
                        this.chartLambda.Series[dataDescriptions[i]]["BoxPlotShowMedian"] = "true";
                        this.chartLambda.Series[dataDescriptions[i]]["BoxPlotShowUnusualValues"] = "true";

                        this.chartLambda.Series[dataDescriptions[i] + "values"].Enabled = false;
                        addColorToBoxPlot(i,dataDescriptions[i]);
                    }
                }
            } 
        }
 public BoxPlotComp(InputData[] data, int lambda, string[] dataDescriptions)
 {
     InitializeComponent();
     m_data = data;
     m_dataDescriptions = dataDescriptions;
     m_lambda = lambda;
     PerformComparison();
 }
        public SVDValueComp(InputData[] data, int lambda, string[] dataDescriptions)
        {
            metaData = new GraphMetaData[dataDescriptions.Length];
            InitializeComponent();
            m_Lambda = lambda;
            m_Data = data;
            m_DataDescriptions = dataDescriptions;
            activeLines = new Boolean[] { false, false, false, false };
            locateButtuns(data.Length, dataDescriptions);
            printChart(data, lambda, dataDescriptions);


        }
 private void cmdBrowse_Click(object sender, EventArgs e)
 {
     if (numOfActiveData == Consts.OPTIONAL_DATA_INSERT)
     {
         MessageBox.Show("No space for more data...");
         return;
     }
     dialog = new OpenFileDialog();
     dialog.Filter = "Text files | *.csv"; // file types, that will be allowed to upload
     dialog.Multiselect = false; // allow/deny user to upload more than one file at a time
     if (dialog.ShowDialog() == DialogResult.OK) // if user clicked OK
     {
         showPath(dialog.FileName);
         txtUploadCSV1.Text = dialog.FileName; // get name of file
         FileStream fs = new FileStream(dialog.FileName, FileMode.OpenOrCreate);
         inputData[numOfActiveData] = new InputData(fs);
         numOfActiveData++;
     }
 }
        private void printChart(InputData[] data, int lambda, string[] dataDescriptions)
        {

            DataTable table1, table2, table3, table4;


            this.Text = "Lambda" + lambda + " comparison";
            if (data.Length >= 1)
            {
                if (data[0] != null && activeLines[0])
                {
                    
                    table1 = data[0].getLagrangeDatatable();
                    double[] array = new double[table1.Rows.Count]; 
                    this.chartLambda.Series.Add(dataDescriptions[0]).ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
                    this.chartLambda.Series[dataDescriptions[0]].Color = Color.Blue;
                    for (int i = 0; i < table1.Rows.Count; i++)
                    {
                        if (table1.Rows.Count > lambda)
                        {
                            this.chartLambda.Series[dataDescriptions[0]].Points.AddXY(i, table1.Rows[lambda][i]);
                            array[i] = (double)table1.Rows[lambda][i];
                        }
                    }
                    metaData[0] = new GraphMetaData 
                    {
                        Average = array.Average(),
                        StandardDeviation = getStandardDeviation(array.ToList<double>())
                    };
                }
                
            }
            if (data.Length >= 2)
            {
                if (data[1] != null && activeLines[1])
                {
                    
                    table2 = data[1].getLagrangeDatatable();
                    double[] array = new double[table2.Rows.Count]; 
                    this.chartLambda.Series.Add(dataDescriptions[1]).ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
                    this.chartLambda.Series[dataDescriptions[1]].Color = Color.Red;
                    for (int i = 0; i < table2.Rows.Count; i++)
                    {
                        if (table2.Rows.Count > lambda)
                        {
                            this.chartLambda.Series[dataDescriptions[1]].Points.AddXY(i, table2.Rows[lambda][i]);
                            array[i] = (double)table2.Rows[lambda][i];
                        }
                    }
                    metaData[1] = new GraphMetaData 
                    {
                        Average = array.Average(),
                        StandardDeviation = getStandardDeviation(array.ToList<double>())
                    };
                }
            }
            if (data.Length >= 3)
            {
                if (data[2] != null && activeLines[2])
                {
                     
                    table3 = data[2].getLagrangeDatatable();
                    double[] array = new double[table3.Rows.Count];
                    this.chartLambda.Series.Add(dataDescriptions[2]).ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
                    this.chartLambda.Series[dataDescriptions[2]].Color = Color.Green;
                    for (int i = 0; i < table3.Rows.Count; i++)
                    {
                        if (table3.Rows.Count > lambda)
                        {
                            this.chartLambda.Series[dataDescriptions[2]].Points.AddXY(i, table3.Rows[lambda][i]);
                            array[i] = (double)table3.Rows[lambda][i];
                        }
                    }
                    metaData[2] = new GraphMetaData 
                    {
                        Average = array.Average(),
                        StandardDeviation = getStandardDeviation(array.ToList<double>())
                    };
                }
            }
            if (data.Length >= 4)
            {
                if (data[3] != null && activeLines[3])
                {
                    table4 = data[3].getLagrangeDatatable();
                    double[] array = new double[table4.Rows.Count];
                    this.chartLambda.Series.Add(dataDescriptions[3]).ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
                    this.chartLambda.Series[dataDescriptions[3]].Color = Color.Orange;
                    for (int i = 0; i < table4.Rows.Count; i++)
                    {
                        if (table4.Rows.Count > lambda)
                        {
                            this.chartLambda.Series[dataDescriptions[3]].Points.AddXY(i, table4.Rows[lambda][i]);
                            array[i] = (double)table4.Rows[lambda][i];
                        }
                    }
                    metaData[3] = new GraphMetaData 
                    {
                        Average = array.Average(),
                        StandardDeviation = getStandardDeviation(array.ToList<double>())
                    };
                }
            
            }
        }
        private void generateGraphs()
        {
            string[] filePaths = Directory.GetDirectories(resultsPath);
            InputData[] subGroups = new InputData[4];
            string[] descriptions = new string[]{"","","",""};
            int i = 0;
            foreach (string filePath in filePaths)
            {
                subGroups[i] = new InputData(new FileStream(filePath + "\\outPut.csv",FileMode.OpenOrCreate));
                descriptions[i] = Regex.Match(filePath, @"(.*)\\([^\\]*)").Groups[2].Value;
                i++;
            }

            for (int j = 0; j < 10; j++)
            {
                new CSA.SVDValueComp(subGroups, j, descriptions).Show();
            }
          
        }