public RegressionGraphPane(RegressionGraphData graphData) { _graphData = graphData; Title.Text = graphData.Title; XAxis.Title.Text = graphData.LabelX; YAxis.Title.Text = graphData.LabelY; Border.IsVisible = false; Title.IsVisible = true; Chart.Border.IsVisible = false; XAxis.Scale.MaxAuto = true; XAxis.Scale.MinAuto = true; YAxis.Scale.MaxAuto = true; YAxis.Scale.MinAuto = true; Y2Axis.IsVisible = false; X2Axis.IsVisible = false; XAxis.MajorTic.IsOpposite = false; YAxis.MajorTic.IsOpposite = false; XAxis.MinorTic.IsOpposite = false; YAxis.MinorTic.IsOpposite = false; IsFontsScaled = false; YAxis.Scale.MaxGrace = 0.1; // Legend.FontSpec.Size = 12; var curve = AddCurve(Resources.RegressionGraphPane_RegressionGraphPane_Values, graphData.XValues, graphData.YValues, Color.Black, SymbolType.Diamond); curve.Line.IsVisible = false; curve.Symbol.Border.IsVisible = false; curve.Symbol.Fill = new Fill(COLOR_REGRESSION); // Find maximum points for drawing the regression line var lineX = new[] { double.MaxValue, double.MinValue }; var lineY = new[] { double.MaxValue, double.MinValue }; for (int i = 0; i < graphData.XValues.Length; i++) { double xValue = graphData.XValues[i]; double yValue = graphData.YValues[i]; if (xValue < lineX[0]) { lineX[0] = xValue; lineY[0] = yValue; } if (xValue > lineX[1]) { lineX[1] = xValue; lineY[1] = yValue; } } if (graphData.RegressionLine != null) { // Recalculate the y values based on the maximum x values // and the regression. lineY[0] = graphData.RegressionLine.GetY(lineX[0]); lineY[1] = graphData.RegressionLine.GetY(lineX[1]); curve = AddCurve(Resources.RegressionGraphPane_RegressionGraphPane_Regression, lineX, lineY, COLOR_LINE_REGRESSION); curve.Line.IsAntiAlias = true; curve.Line.IsOptimizedDraw = true; Statistics statsX = new Statistics(_graphData.XValues); Statistics statsY = new Statistics(_graphData.YValues); double slope = statsY.Slope(statsX); double intercept = statsY.Intercept(statsX); _labelRegression = string.Format("{0} = {1:F04}, {2} = {3:F04}\n" + "r = {4:F02}", // Not L10N Resources.Regression_slope, slope, Resources.Regression_intercept, intercept, statsY.R(statsX)); } var regressionLineCurrent = graphData.RegressionLineCurrent; if (regressionLineCurrent != null) { lineY[0] = regressionLineCurrent.GetY(lineX[0]); lineY[1] = regressionLineCurrent.GetY(lineX[1]); curve = AddCurve(Resources.RegressionGraphPane_RegressionGraphPane_Current, lineX, lineY, COLOR_LINE_REGRESSION_CURRENT); curve.Line.IsAntiAlias = true; curve.Line.IsOptimizedDraw = true; curve.Line.Style = DashStyle.Dash; _labelRegressionCurrent = string.Format("{0} = {1:F04}, {2} = {3:F04}", // Not L10N Resources.Regression_slope, regressionLineCurrent.Slope, Resources.Regression_intercept, regressionLineCurrent.Intercept); } }
public RegressionGraphPane(RegressionGraphData graphData) { _graphData = graphData; Title.Text = graphData.Title; XAxis.Title.Text = graphData.LabelX; YAxis.Title.Text = graphData.LabelY; Border.IsVisible = false; Title.IsVisible = true; Chart.Border.IsVisible = false; XAxis.Scale.MaxAuto = true; XAxis.Scale.MinAuto = true; YAxis.Scale.MaxAuto = true; YAxis.Scale.MinAuto = true; Y2Axis.IsVisible = false; X2Axis.IsVisible = false; XAxis.MajorTic.IsOpposite = false; YAxis.MajorTic.IsOpposite = false; XAxis.MinorTic.IsOpposite = false; YAxis.MinorTic.IsOpposite = false; IsFontsScaled = false; YAxis.Scale.MaxGrace = 0.1; // Legend.FontSpec.Size = 12; var curve = AddCurve(Resources.RegressionGraphPane_RegressionGraphPane_Values, graphData.RegularPoints, Color.Black, SymbolType.Diamond); curve.Line.IsVisible = false; curve.Symbol.Border.IsVisible = false; curve.Symbol.Fill = new Fill(COLOR_REGRESSION); if (graphData.MissingPoints.Any()) { var curveMissing = AddCurve(Resources.RegressionGraphPane_RegressionGraphPane_Missing, graphData.MissingPoints, COLOR_MISSING, SymbolType.Diamond); curveMissing.Line.IsVisible = false; curveMissing.Symbol.Border.IsVisible = false; curveMissing.Symbol.Fill = new Fill(COLOR_MISSING); curveMissing.Symbol.Size = 12; } if (graphData.OutlierPoints.Any()) { var curveOutliers = AddCurve(Resources.RegressionGraphPane_RegressionGraphPane_Outliers, graphData.OutlierPoints, COLOR_OUTLIERS, SymbolType.Diamond); curveOutliers.Line.IsVisible = false; curveOutliers.Symbol.Border.IsVisible = false; curveOutliers.Symbol.Fill = new Fill(COLOR_OUTLIERS); } var regressionLine = graphData.RegressionLine; if (graphData.RegressionLine != null) { graphData.GetCurvePoints(true, regressionLine is RegressionLine ? 2 : 1000, out var lineX, out var lineY); curve = AddCurve( !string.IsNullOrEmpty(graphData.RegressionName) ? graphData.RegressionName : Resources.RegressionGraphPane_RegressionGraphPane_Regression, lineX, lineY, COLOR_LINE_REGRESSION, SymbolType.None); curve.Line.IsAntiAlias = true; curve.Line.IsOptimizedDraw = true; if (!Equals(regressionLine.DisplayEquation, Resources.DisplayEquation_N_A)) { _labelRegression = regressionLine.DisplayEquation + Environment.NewLine; } _labelRegression += string.Format(@"r = {0:F03}", graphData.R); if (graphData.R < graphData.MinCorrelation) { _labelRegression += string.Format(@" < {0:F03}", graphData.MinCorrelation); if (graphData.MinPoints.HasValue) { _labelRegression = string.Format(Resources.RegressionGraphPane_RegressionGraphPane__0___at__1__points_minimum_, _labelRegression, graphData.MinPoints.Value); } } } var regressionLineCurrent = graphData.RegressionLineCurrent; if (regressionLineCurrent != null) { graphData.GetCurvePoints(false, regressionLineCurrent is RegressionLine ? 2 : 1000, out var lineX, out var lineY); curve = AddCurve(Resources.RegressionGraphPane_RegressionGraphPane_Current, lineX, lineY, COLOR_LINE_REGRESSION_CURRENT, SymbolType.None); curve.Line.IsAntiAlias = true; curve.Line.IsOptimizedDraw = true; curve.Line.Style = DashStyle.Dash; if (!ReferenceEquals(regressionLineCurrent.DisplayEquation, Resources.DisplayEquation_N_A)) { _labelRegressionCurrent = regressionLineCurrent.DisplayEquation + Environment.NewLine; } if (graphData.ShowCurrentCorrelation) { _labelRegressionCurrent += string.Format(@"r = {0:F03}", graphData.RCurrent); } } }
public RegressionGraphPane(RegressionGraphData graphData) { _graphData = graphData; Title.Text = graphData.Title; XAxis.Title.Text = graphData.LabelX; YAxis.Title.Text = graphData.LabelY; Border.IsVisible = false; Title.IsVisible = true; Chart.Border.IsVisible = false; XAxis.Scale.MaxAuto = true; XAxis.Scale.MinAuto = true; YAxis.Scale.MaxAuto = true; YAxis.Scale.MinAuto = true; Y2Axis.IsVisible = false; X2Axis.IsVisible = false; XAxis.MajorTic.IsOpposite = false; YAxis.MajorTic.IsOpposite = false; XAxis.MinorTic.IsOpposite = false; YAxis.MinorTic.IsOpposite = false; IsFontsScaled = false; YAxis.Scale.MaxGrace = 0.1; // Legend.FontSpec.Size = 12; var curve = AddCurve(Resources.RegressionGraphPane_RegressionGraphPane_Values, graphData.RegularPoints, Color.Black, SymbolType.Diamond); curve.Line.IsVisible = false; curve.Symbol.Border.IsVisible = false; curve.Symbol.Fill = new Fill(COLOR_REGRESSION); if (graphData.MissingPoints.Any()) { var curveMissing = AddCurve(Resources.RegressionGraphPane_RegressionGraphPane_Missing, graphData.MissingPoints, COLOR_MISSING, SymbolType.Diamond); curveMissing.Line.IsVisible = false; curveMissing.Symbol.Border.IsVisible = false; curveMissing.Symbol.Fill = new Fill(COLOR_MISSING); curveMissing.Symbol.Size = 12; } if (graphData.OutlierPoints.Any()) { var curveOutliers = AddCurve(Resources.RegressionGraphPane_RegressionGraphPane_Outliers, graphData.OutlierPoints, COLOR_OUTLIERS, SymbolType.Diamond); curveOutliers.Line.IsVisible = false; curveOutliers.Symbol.Border.IsVisible = false; curveOutliers.Symbol.Fill = new Fill(COLOR_OUTLIERS); } // Find maximum points for drawing the regression line var lineX = new[] { double.MaxValue, double.MinValue }; var lineXCurrent = new[] { double.MaxValue, double.MinValue }; var lineY = new[] { 0d, 0d }; foreach (var point in graphData.RegularPoints) { if (point.X < lineX[0]) { lineX[0] = lineXCurrent[0] = point.X; } if (point.X > lineX[1]) { lineX[1] = lineXCurrent[1] = point.X; } } foreach (var point in graphData.OutlierPoints) { if (point.X < lineXCurrent[0]) { lineXCurrent[0] = point.X; } if (point.X > lineXCurrent[1]) { lineXCurrent[1] = point.X; } } var regressionLine = graphData.RegressionLine; if (graphData.RegressionLine != null) { // Recalculate the y values based on the maximum x values // and the regression. lineY[0] = regressionLine.GetY(lineX[0]); lineY[1] = regressionLine.GetY(lineX[1]); curve = AddCurve(!string.IsNullOrEmpty(graphData.RegressionName) ? graphData.RegressionName : Resources.RegressionGraphPane_RegressionGraphPane_Regression, lineX, lineY, COLOR_LINE_REGRESSION); curve.Line.IsAntiAlias = true; curve.Line.IsOptimizedDraw = true; _labelRegression = string.Format("{0} = {1:F04}, {2} = {3:F04}\n" + "r = {4:F03}", // Not L10N Resources.Regression_slope, regressionLine.Slope, Resources.Regression_intercept, regressionLine.Intercept, graphData.R); if (graphData.R < graphData.MinR) { _labelRegression += string.Format(" < {0:F03}", graphData.MinR); // Not L10N if (graphData.MinPoints.HasValue) { _labelRegression = string.Format(Resources.RegressionGraphPane_RegressionGraphPane__0___at__1__points_minimum_, _labelRegression, graphData.MinPoints.Value); } } } var regressionLineCurrent = graphData.RegressionLineCurrent; if (regressionLineCurrent != null) { lineY[0] = regressionLineCurrent.GetY(lineXCurrent[0]); lineY[1] = regressionLineCurrent.GetY(lineXCurrent[1]); curve = AddCurve(Resources.RegressionGraphPane_RegressionGraphPane_Current, lineXCurrent, lineY, COLOR_LINE_REGRESSION_CURRENT); curve.Line.IsAntiAlias = true; curve.Line.IsOptimizedDraw = true; curve.Line.Style = DashStyle.Dash; _labelRegressionCurrent = string.Format("{0} = {1:F04}, {2} = {3:F04}", // Not L10N Resources.Regression_slope, regressionLineCurrent.Slope, Resources.Regression_intercept, regressionLineCurrent.Intercept); if (graphData.ShowCurrentR) { _labelRegressionCurrent += string.Format("\n" + "r = {0:F03}", graphData.CurrentR); // Not L10N } } }
public RegressionGraphPane(RegressionGraphData graphData) { _graphData = graphData; Title.Text = graphData.Title; XAxis.Title.Text = graphData.LabelX; YAxis.Title.Text = graphData.LabelY; Border.IsVisible = false; Title.IsVisible = true; Chart.Border.IsVisible = false; XAxis.Scale.MaxAuto = true; XAxis.Scale.MinAuto = true; YAxis.Scale.MaxAuto = true; YAxis.Scale.MinAuto = true; Y2Axis.IsVisible = false; X2Axis.IsVisible = false; XAxis.MajorTic.IsOpposite = false; YAxis.MajorTic.IsOpposite = false; XAxis.MinorTic.IsOpposite = false; YAxis.MinorTic.IsOpposite = false; IsFontsScaled = false; YAxis.Scale.MaxGrace = 0.1; // Legend.FontSpec.Size = 12; var curve = AddCurve(Resources.RegressionGraphPane_RegressionGraphPane_Values, graphData.XValues, graphData.YValues, Color.Black, SymbolType.Diamond); curve.Line.IsVisible = false; curve.Symbol.Border.IsVisible = false; curve.Symbol.Fill = new Fill(COLOR_REGRESSION); // Find maximum points for drawing the regression line var lineX = new[] { double.MaxValue, double.MinValue }; var lineY = new[] { double.MaxValue, double.MinValue }; for (int i = 0; i < graphData.XValues.Length; i++) { double xValue = graphData.XValues[i]; double yValue = graphData.YValues[i]; if (xValue < lineX[0]) { lineX[0] = xValue; lineY[0] = yValue; } if (xValue > lineX[1]) { lineX[1] = xValue; lineY[1] = yValue; } } if (graphData.RegressionLine != null) { // Recalculate the y values based on the maximum x values // and the regression. lineY[0] = graphData.RegressionLine.GetY(lineX[0]); lineY[1] = graphData.RegressionLine.GetY(lineX[1]); curve = AddCurve(Resources.RegressionGraphPane_RegressionGraphPane_Regression, lineX, lineY, COLOR_LINE_REGRESSION); curve.Line.IsAntiAlias = true; curve.Line.IsOptimizedDraw = true; Statistics statsX = new Statistics(_graphData.XValues); Statistics statsY = new Statistics(_graphData.YValues); double slope = statsY.Slope(statsX); double intercept = statsY.Intercept(statsX); _labelRegression = string.Format("{0} = {1:F04}, {2} = {3:F04}\n" + "r = {4:F02}", // Not L10N Resources.Regression_slope, slope, Resources.Regression_intercept, intercept, statsY.R(statsX)); } var regressionLineCurrent = graphData.RegressionLineCurrent; if (regressionLineCurrent != null) { lineY[0] = regressionLineCurrent.GetY(lineX[0]); lineY[1] = regressionLineCurrent.GetY(lineX[1]); curve = AddCurve(Resources.RegressionGraphPane_RegressionGraphPane_Current, lineX, lineY, COLOR_LINE_REGRESSION_CURRENT); curve.Line.IsAntiAlias = true; curve.Line.IsOptimizedDraw = true; curve.Line.Style = DashStyle.Dash; _labelRegressionCurrent = string.Format("{0} = {1:F04}, {2} = {3:F04}", // Not L10N Resources.Regression_slope, regressionLineCurrent.Slope, Resources.Regression_intercept, regressionLineCurrent.Intercept); } }