private void SetChartData(List<XYChartData> dataList, StatisticsRepository.LinearRegression.LinearRegressionResults regresResults, NumericDataValue maxValue, NumericDataValue minValue) { List<RegressionChartData> regressionDataList = new List<RegressionChartData>(); if (regresResults.variables != null) { decimal coefficient = Convert.ToDecimal(regresResults.variables[0].coefficient); decimal constant = Convert.ToDecimal(regresResults.variables[1].coefficient); NumericDataValue newMaxValue = new NumericDataValue(); newMaxValue.IndependentValue = maxValue.IndependentValue; newMaxValue.DependentValue = (coefficient * maxValue.IndependentValue) + constant; NumericDataValue newMinValue = new NumericDataValue(); newMinValue.IndependentValue = minValue.IndependentValue; newMinValue.DependentValue = (coefficient * minValue.IndependentValue) + constant; tblockEquation.Text = "Y = (" + Math.Round(coefficient, 4).ToString() + ")X + " + Math.Round(constant, 4).ToString(); List<NumericDataValue> regresValues = new List<NumericDataValue>(); regresValues.Add(newMinValue); regresValues.Add(newMaxValue); RegressionChartData rChartData = new RegressionChartData(); rChartData.X = (double)newMinValue.IndependentValue; rChartData.Z = (double)newMinValue.DependentValue; regressionDataList.Add(rChartData); rChartData = new RegressionChartData(); rChartData.X = (double)newMaxValue.IndependentValue; rChartData.Z = (double)newMaxValue.DependentValue; regressionDataList.Add(rChartData); //bool foundMin = false; //bool foundMax = false; //foreach (XYChartData chartData in dataList) //{ // if ((double)chartData.X == (double)newMaxValue.IndependentValue) // { // RegressionChartData rChartData = new RegressionChartData(); // rChartData.X = (double)newMaxValue.IndependentValue; // rChartData.Z = (double)newMaxValue.DependentValue; // regressionDataList.Add(rChartData); // //chartData.Z = (double)newMaxValue.DependentValue; // foundMax = true; // } // if ((double)chartData.X == (double)newMinValue.IndependentValue) // { // //chartData.Z = (double)newMinValue.DependentValue; // RegressionChartData rChartData = new RegressionChartData(); // rChartData.X = (double)newMaxValue.IndependentValue; // rChartData.Z = (double)newMinValue.DependentValue; // regressionDataList.Add(rChartData); // foundMin = true; // } //} //if (foundMax == false) //{ // XYChartData data = new XYChartData(); // data.X = (double)newMaxValue.IndependentValue; // //data.Z = (double)newMaxValue.DependentValue; // dataList.Add(data); // RegressionChartData rChartData = new RegressionChartData(); // rChartData.X = data.X; // rChartData.Z = (double)newMaxValue.DependentValue; // regressionDataList.Add(rChartData); // xAxis.MaxValue = data.X; //} //if (foundMin == false) //{ // XYChartData data = new XYChartData(); // data.X = (double)newMinValue.IndependentValue; // //data.Z = (double)newMinValue.DependentValue; // dataList.Add(data); // RegressionChartData rChartData = new RegressionChartData(); // rChartData.X = data.X; // rChartData.Z = (double)newMinValue.DependentValue; // regressionDataList.Add(rChartData); // xAxis.MinValue = data.X; //} } //xAxis.UseOnlyVisiblePointsToComputeRange = true; //xyChart.DataSource = dataList; series0.DataSource = dataList; series1.DataSource = regressionDataList; xyChart.Width = double.Parse(txtWidth.Text); xyChart.Height = double.Parse(txtHeight.Text); //xAxis.UseOnlyVisiblePointsToComputeRange = true; }
private void SetChartData(List<XYChartData> dataList, StatisticsRepository.LinearRegression.LinearRegressionResults regresResults, NumericDataValue maxValue, NumericDataValue minValue) { List<RegressionChartData> regressionDataList = new List<RegressionChartData>(); ScatterChartParameters chtParameters = (ScatterChartParameters)Parameters; if (regresResults.variables != null) { decimal coefficient = Convert.ToDecimal(regresResults.variables[0].coefficient); decimal constant = Convert.ToDecimal(regresResults.variables[1].coefficient); NumericDataValue newMaxValue = new NumericDataValue(); newMaxValue.IndependentValue = maxValue.IndependentValue; newMaxValue.DependentValue = (coefficient * maxValue.IndependentValue) + constant; NumericDataValue newMinValue = new NumericDataValue(); newMinValue.IndependentValue = minValue.IndependentValue; newMinValue.DependentValue = (coefficient * minValue.IndependentValue) + constant; tblockEquation.Text = "Y = (" + Math.Round(coefficient, 4).ToString() + ")X + " + Math.Round(constant, 4).ToString(); List<NumericDataValue> regresValues = new List<NumericDataValue>(); regresValues.Add(newMinValue); regresValues.Add(newMaxValue); RegressionChartData rChartData = new RegressionChartData(); rChartData.X = (double)newMinValue.IndependentValue; rChartData.Z = (double)newMinValue.DependentValue; regressionDataList.Add(rChartData); rChartData = new RegressionChartData(); rChartData.X = (double)newMaxValue.IndependentValue; rChartData.Z = (double)newMaxValue.DependentValue; regressionDataList.Add(rChartData); } //xAxis.UseOnlyVisiblePointsToComputeRange = true; series0.DataSource = dataList; series1.DataSource = regressionDataList; xyChart.Width = chtParameters.ChartWidth; xyChart.Height = chtParameters.ChartHeight; //xAxis.UseOnlyVisiblePointsToComputeRange = true; }