Esempio n. 1
0
        //Расчет новых параметров регрессии и построение нового графика продаж вместе с линией тренда
        private void displaySalesGraph_Click(object sender, EventArgs e)
        {
            try
            {
                try
                {
                    chart1.Series[0].Points.Clear();
                    chart1.Series[0].Points.Dispose();
                    chart1.Series[1].Points.Clear();
                    chart1.Series[1].Points.Dispose();
                    chart1.Series[2].Points.Clear();
                    chart1.Series[2].Points.Dispose();
                }
                catch { }
                DBConnection.GetSellingsByYear(salesYears.Text);
                x.Clear();
                y.Clear();
                foreach (DataRow row in DBConnection.dtSellingsByYear.AsEnumerable())
                {
                    x.Add(Convert.ToSingle(row[0]));
                    y.Add(Convert.ToSingle(row[1]));
                }
                sales_chart(x, y);

                LinearRegression.calculate_regression(x, y);

                label20.Text = LinearRegression.mean_x.ToString("0.##");
                label21.Text = LinearRegression.mean_y.ToString("0.##");
                label22.Text = LinearRegression.std_deviation_x.ToString("0.##");
                label23.Text = LinearRegression.std_deviation_y.ToString("0.##");
                label2.Text  = LinearRegression.covariation.ToString("0.##");
                label4.Text  = LinearRegression.correlation.ToString("0.##");

                int end_x = Convert.ToInt32(x.Max()); //конечная точка линии тренда
                trend_line(LinearRegression.intercept, LinearRegression.slope, end_x);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }