private void AddStackedColumnSeries(frmCSDesign pfrmCSDesign, string strSeriesName, System.Drawing.Color FillColor, double[,] adblValues, int intStats, int intNfeatures) { try { var pSeries = new System.Windows.Forms.DataVisualization.Charting.Series { Name = strSeriesName, Color = FillColor, BorderColor = Color.Black, IsVisibleInLegend = false, ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.StackedColumn, }; pfrmCSDesign.pChart.Series.Add(pSeries); for (int j = 0; j < intNfeatures; j++) { pSeries.Points.AddXY(j, adblValues[j, intStats]); } } catch (Exception ex) { MessageBox.Show(this.Handle.ToString() + " Error:" + ex.Message); return; } }
private void AddVerticalLineSeries(frmCSDesign pfrmCSDesign, string strSeriesName, System.Drawing.Color FillColor, double dblX, double dblYMin, double dblYMax) { try { var pSeries = new System.Windows.Forms.DataVisualization.Charting.Series { Name = strSeriesName, Color = FillColor, BorderColor = Color.Black, BorderWidth = 2, IsVisibleInLegend = false, ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line, }; pfrmCSDesign.pChart.Series.Add(pSeries); pSeries.Points.AddXY(dblX, dblYMin); pSeries.Points.AddXY(dblX, dblYMax); } catch (Exception ex) { MessageBox.Show(this.Handle.ToString() + " Error:" + ex.Message); return; } }
private void btnGraph_Click(object sender, EventArgs e) { frmCSDesign pfrmCSDesign = new frmCSDesign(); int intNfeature = arrEst.Length; double[,] adblValues = new double[intNfeature, 3]; System.Web.UI.DataVisualization.Charting.Chart pChart = new System.Web.UI.DataVisualization.Charting.Chart(); pfrmCSDesign.nudConfidenceLevel.Value = 99; double dblConfidenceValue = Convert.ToDouble(pfrmCSDesign.nudConfidenceLevel.Value); double dblConInstance = pChart.DataManipulator.Statistics.InverseNormalDistribution(dblConfidenceValue / 100); for (int i = 0; i < intNfeature; i++) { double dblValue = arrEst[i]; double dblUncern = dblConInstance * arrVar[i]; if (dblValue < dblUncern) { adblValues[i, 0] = 0; adblValues[i, 1] = dblValue; adblValues[i, 2] = dblUncern; } else { adblValues[i, 0] = dblValue - dblUncern; adblValues[i, 1] = dblUncern; adblValues[i, 2] = dblUncern; } } AddStackedColumnSeries(pfrmCSDesign, "Low", Color.White, adblValues, 0, intNfeature); AddStackedColumnSeries(pfrmCSDesign, "Mean", Color.Gray, adblValues, 1, intNfeature); AddStackedColumnSeries(pfrmCSDesign, "High", Color.Gray, adblValues, 2, intNfeature); double dblMin = 0; double dblMax = arrEst.Max() + (3 * arrVar.Max()); int[,] arrSepVerColors = RedToBlueColorRamps(); int intSepLineIdx = 0; System.Drawing.Color pColor = new Color(); for (int j = 0; j < intResultIdx.Length; j++) { intSepLineIdx = Convert.ToInt32(Math.Floor(dblpValue[j] * 10)); pColor = new Color(); pColor = Color.FromArgb(arrSepVerColors[intSepLineIdx, 0], arrSepVerColors[intSepLineIdx, 1], arrSepVerColors[intSepLineIdx, 2]); AddVerticalLineSeries(pfrmCSDesign, "ver_" + j.ToString(), pColor, intResultIdx[j] + 0.5, dblMin, dblMax); } pfrmCSDesign.pChart.ChartAreas[0].AxisX.IsStartedFromZero = true; pfrmCSDesign.pChart.ChartAreas[0].AxisY.Title = cboValueField.Text; pfrmCSDesign.nudConfidenceLevel.Value = 99; pfrmCSDesign.arrEst = arrEst; pfrmCSDesign.arrVar = arrVar; pfrmCSDesign.intResultIdx = intResultIdx; pfrmCSDesign.cb = cb; pfrmCSDesign.nudGCNClasses.Value = nudGCNClasses.Value; pfrmCSDesign.arrResults = arrResults; pfrmCSDesign.dblpValue = dblpValue; //pfrmClassfiGraph.pModel = pModel; //pfrmClassfiGraph.pDecVar = pDecVar; //pfrmClassfiGraph.pTotalStepsConst = pTotalStepsConst; pfrmCSDesign.lblMethod.Text = strClassificationMethod; //pfrmClassfiGraph.txtObjValue.Text = txtObjValue.Text; pfrmCSDesign.strValueFldName = cboValueField.Text; pfrmCSDesign.strUncernFldName = cboUncernFld.Text; pfrmCSDesign.mForm = mForm; pfrmCSDesign.pActiveView = pActiveView; pfrmCSDesign.pFLayer = pFLayer; pfrmCSDesign.Show(); }