Пример #1
0
        private string GetFormula(TrendLineTypeEnum tlt, double[] k)
        {
            string s = "";

            switch (tlt)
            {
            case TrendLineTypeEnum.Polynom:
                return(GetFormula(DataType.Poly2, k));

            case TrendLineTypeEnum.Exponent:
                return(GetFormula(DataType.Expo, k));

            case TrendLineTypeEnum.Logarithmic:
                return(GetFormula(DataType.Log, k));

            case TrendLineTypeEnum.Power:
                return(GetFormula(DataType.Pow, k));

            case TrendLineTypeEnum.Fourier:
                return(GetFormula(DataType.Fourier2, k));

            default:
                break;
            }

            return(s);
        }
Пример #2
0
        private void UpdateFormulaLabel()
        {
            C1.Win.C1Chart.Label lbl;

            if (c1Chart1.ChartLabels.LabelsCollection.Count < 2)
            {
                // create formula label
                lbl = c1Chart1.ChartLabels.LabelsCollection.AddNewLabel();
                lbl.AttachMethod              = AttachMethodEnum.Coordinate;
                lbl.AttachMethodData.X        = c1Chart1.ChartArea.PlotArea.Location.X + c1Chart1.ChartArea.PlotArea.Size.Width / 2;
                lbl.AttachMethodData.Y        = c1Chart1.ChartArea.PlotArea.Location.Y + 20;
                lbl.Style.BackColor           = Color.FromArgb(192, Color.LightBlue);
                lbl.Style.GradientStyle       = GradientStyleEnum.None;
                lbl.Style.Border.BorderStyle  = BorderStyleEnum.Solid;
                lbl.Style.Border.Color        = Color.DarkBlue;
                lbl.Style.Border.Rounding.All = 15;
                lbl.Style.VerticalAlignment   = AlignVertEnum.Center;
                lbl.Compass = LabelCompassEnum.North;
            }
            else
            {
                lbl = c1Chart1.ChartLabels[1];
            }

            TrendLine tl = null;

            if (c1Chart1.ChartGroups[0].ChartData.TrendsList.Count > 0)
            {
                tl = c1Chart1.ChartGroups[0].ChartData.TrendsList[0];
            }
            else
            {
                return;
            }

            RegressionStatistics rs = tl.RegressionStatistics;

            if (rs == null || rs.Coeffs == null || !cbViewFormula.Checked)
            {
                lbl.Visible = false;
                return;
            }

            TrendLineTypeEnum tlt = (TrendLineTypeEnum)cbTrendType.SelectedItem;

            string s_regr  = GetFormula(tlt, rs.Coeffs);
            string s_exact = GetFormula(dtLastGenerated, k);

            if (s_regr.Length > 0 && s_exact.Length > 0)
            {
                lbl.Visible = true;
                lbl.Text    = string.Format("Data formula: {0}\n\nRegression formula: {1}", s_exact, s_regr);
            }
            else if (s_regr.Length > 0)
            {
                lbl.Visible = true;
                lbl.Text    = string.Format("Regression formula: {1}", s_exact, s_regr);
            }
            else
            {
                lbl.Visible = false;
            }
        }