public void SetChartTitle(ChartFX.WebForms.Chart chart, string title) { if (chart == null) { return; } if (string.IsNullOrEmpty(title) == true) { return; } chart.Titles.Clear(); List <TitleDockable> listTitle = new List <TitleDockable>(); System.Drawing.Font font = new System.Drawing.Font("Arial", 10, System.Drawing.FontStyle.Bold); int start = 0; for (; ;) { int len = 75; if (start + len < title.Length) { if (title[start + len].Equals('_') == false || title[start + len].Equals(',') == false) { for (int i = start + len; i > start + len - 20; i--) { if (title[i] == '_' || title[i] == ',') { len = i - start; break; } } } TitleDockable td = new TitleDockable(title.Substring(start, len + 1)); td.Font = font; listTitle.Add(td); } else { TitleDockable td = new TitleDockable(title.Substring(start)); td.Font = font; listTitle.Add(td); break; } start = start + len + 1; } chart.LegendBox.Titles.Clear(); chart.LegendBox.AutoSize = true; for (int i = 0; i < listTitle.Count; i++) { chart.LegendBox.Titles.Add(listTitle[i]); } chart.LegendBox.ContentLayout = ContentLayout.Spread; chart.LegendBox.Border = DockBorder.None; chart.LegendBox.SizeToFit(); }
public void setchartfxStyle(ChartFX.WebForms.Chart FX, ChartFX.WebForms.Gallery ChartGallery, string title, int AxisX_Step, int X_ScaleUnit, int Y_ScaleUnit, bool showTargetLine, int TargetQty) { //FX.Height = Unit.Pixel(180); //FX.Width = Unit.Pixel(210); //FX.EnableViewState = false; FX.Gallery = ChartGallery; FX.AllSeries.FillMode = FillMode.Gradient; GradientBackground myGradient = new GradientBackground(GradientType.Radial); //myGradient.ColorFrom = Color.Black; //myGradient.ColorTo = Color.Black; myGradient.Angle = 45; SimpleBorder myBorder = new SimpleBorder(SimpleBorderType.Etched); //myBorder.Color = Color.Gray; myBorder.InternalOpposite = false; FX.Background = myGradient; FX.Border = myBorder; FX.LegendBox.Visible = false; FX.RenderFormat = "Image"; //FX.AllSeries.Border.Color = Color.Black; TitleDockable oTitle = new TitleDockable(); oTitle.Text = title; oTitle.TextColor = Color.Red; FX.Titles.Add(oTitle); FX.AxisX.ForceZero = true; FX.AxisX.ScrollPosition = 200; FX.AxisY2.Grids.Major.Visible = false; FX.AxisX.Grids.Major.Visible = false; //FX.ForeColor = Color.Yellow; //FX.ChartAreaRectangle.Location. FX.PlotAreaMargin.Top = 20; FX.PlotAreaMargin.Left = 10; FX.PlotAreaMargin.Bottom = 10; FX.PlotAreaMargin.Right = 10; if (AxisX_Step > 0) { FX.AxisX.Step = double.Parse(AxisX_Step.ToString()); } if (showTargetLine == true) { ShowTagLine_FX(FX, TargetQty); } if (X_ScaleUnit > 0) { FX.AxisX.ScaleUnit = double.Parse(X_ScaleUnit.ToString()); } if (Y_ScaleUnit > 0) { FX.AxisY.ScaleUnit = double.Parse(Y_ScaleUnit.ToString()); } FX.ToolBar.Visible = false; }
/// <summary> /// Sub Chart 표시 /// </summary> /// <param name="ds"></param> private void UpdateSubChart(DataSet ds) { InitChart(); uiChart_Pareto.Titles.Clear(); if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { return; } int nPoints = 0; double minY = double.MaxValue; double maxY = double.MinValue; int col = 1; for (int row = 0; row < ds.Tables[0].Rows.Count; ++row) { double val = 0; //double stdVal = 0; nPoints = uiChart_Pareto.Data.Points++; uiChart_Pareto.AxesX[0].Labels[nPoints] = ds.Tables[0].Rows[row][0].ToString(); if (double.TryParse(ds.Tables[0].Rows[row][col].ToString(), out val) == true) { uiChart_Pareto.Data[0, nPoints] = val; maxY = Math.Max(maxY, val); minY = Math.Min(minY, val); } } //chart1.AxisY.Min = minY * 0.5; uiChart_Pareto.AxisY.Min = 0; uiChart_Pareto.AxisY.Max = maxY * 1.5; //chart1.AxisY.Min = 0; //chart1.AxisY.Max = 100; //chart1.AxisY.Step = 10; uiChart_Pareto.AxisY.LabelsFormat.Decimals = 1; uiLab_ChartTitle.Text = string.Format("Materials Information Chart"); //차트 Title 설정 TitleDockable td = new TitleDockable(); td.Font = new Font("Arial", 11, FontStyle.Bold); td.TextColor = Color.DarkBlue; td.Text = "Pareto Chart"; uiChart_Pareto.Titles.Add(td); }
/// <summary> /// 서브 차트 데이터 바인딩 /// </summary> /// <param name="ds"></param> private void UpdateSubChart(DataSet ds, string materials) { uiChart_Trend.Titles.Clear(); if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { return; } int nPoints = 0; double minY = double.MaxValue; double maxY = double.MinValue; int col = uiChk_GapValue.Checked ? 7 : 6; for (int row = 0; row < ds.Tables[0].Rows.Count; ++row) { double val = 0; double stdVal = 0; nPoints = uiChart_Trend.Data.Points++; if (double.TryParse(ds.Tables[0].Rows[row][col].ToString(), out val) == true) { uiChart_Trend.Data[0, nPoints] = val; maxY = Math.Max(maxY, val); minY = Math.Min(minY, val); } if (double.TryParse(ds.Tables[0].Rows[row][5].ToString(), out stdVal) == true) { uiChart_Trend.Data[1, nPoints] = stdVal; } } uiChart_Trend.AxisY.Min = minY - 20; uiChart_Trend.AxisY.Max = maxY + 20; uiChart_Trend.AxisY.LabelsFormat.Decimals = 1; //차트 Title 설정 TitleDockable td = new TitleDockable(); td.Font = new Font("Arial", 11, FontStyle.Bold); td.TextColor = Color.DarkBlue; td.Text = $"'{materials}' - Trend Chart"; uiChart_Trend.Titles.Add(td); }
public void setchartfx(DataTable dt, ChartFX.WebForms.Chart chart, string title) { TitleDockable newTitle = new TitleDockable(); chart.DataSource = dt; chart.DataBind(); chart.Zoom = true; newTitle.Text = title; chart.Titles.Add(newTitle); newTitle.Font = new Font(newTitle.Font, FontStyle.Bold); newTitle.Dock = DockArea.Top; chart.LegendBox.Visible = false; chart.Width = 300; chart.Height = 200; chart.RenderFormat = "Image"; //Link to Chart Link seriesLink = chart.Series[0].Link; seriesLink.OnMouseOver = "DisplayTooltip('<IMG SRC=../ChartReport_Detail.aspx>');"; seriesLink.OnMouseOut = "DisplayTooltip('');"; }
public void MakeGraph(BLRetention retention) { //DataSet ds = null; if (this.Page is PageBaseWI) { // ds = ((PageBaseWI)this.Page).DataSet; } // graph1.DataSourceSettings.Fields.Add(new FieldMap(ds.v_RetentionWWoDisEconELPSchoolDistState.Retention_RateColumn.ColumnName, FieldUsage.Value)); // graph1.DataSourceSettings.Fields.Add(new FieldMap(ds.v_RetentionWWoDisEconELPSchoolDistState.yearColumn.ColumnName, FieldUsage.Label)); // graph1.DataSourceSettings.DataSource = ds.v_RetentionWWoDisEconELPSchoolDistState; //test above lines graph1.Gallery = ChartFX.WebForms.Gallery.Bar; graph1.AxisY.DataFormat.Decimals = 0; graph1.Width = 460; graph1.Height = 370; graph1.AxisY.Title.Text = "Retention Rate"; // a function 2b done here graph1.LegendBox.Dock = ChartFX.WebForms.DockArea.Bottom; m_numseries = numseries(retention); m_numpoints = numpoints(retention); graph1.Data.Points = m_numpoints; graph1.Data.Series = m_numseries; /* series for school years */ graphPointsLabel(retention); if (retention.ViewBy.Key == GroupKeys.All) { databind_AllStudentsFAY(retention); } if (retention.ViewBy.Key == GroupKeys.Gender) { databind_Gender(retention); } if (retention.ViewBy.Key == GroupKeys.Disability) { databind_Disability(retention); } if (retention.ViewBy.Key == GroupKeys.Race) { //databind_Ethnicity(retention); } if (retention.ViewBy.Key == GroupKeys.Grade) { //databind_Grade(retention); } seriescolors(); findAxisYMin(); findAxisYMax(); graph1.AxisY.Min = m_axisYMin; graph1.AxisY.Max = m_axisYMax; graph1.AxisY.LabelsFormat.Format = AxisFormat.Percentage; graph1.LegendBox.Border = 0; graph1.LegendBox.AutoSize = false; graph1.LegendBox.Height = 60; graph1.LegendBox.Width = 600; graph1.LegendBox.MarginX = 38; graph1.LegendBox.ContentLayout = ContentLayout.Near; graph1.LegendBox.PlotAreaOnly = false; TitleDockable graph1Title; graph1Title = new TitleDockable(); /*To do a function or class for title */ graph1Title.Text = "Retention Rate" + "\n" + " DePeres " + "\n" + zYear + " Compared To Prior Years"; graph1.Titles.Add(graph1Title); graph1Title.Font.Bold.Equals(true); graph1Title.Dock = DockArea.Top; graph1.Visible = true; }
/// <summary> /// 서브 차트 데이터 바인딩 /// </summary> /// <param name="ds"></param> private void UpdateOpeningChart(DataSet ds, string opening, string materials) { uiChart_Histogram.Titles.Clear(); if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { return; } int nPoints = 0; double minY = double.MaxValue; double maxY = double.MinValue; int col = uiChk_GapValue.Checked ? 6 : 5; for (int row = 0; row < ds.Tables[0].Rows.Count; ++row) { double val = 0; nPoints = uiChart_Histogram.Data.Points++; if (double.TryParse(ds.Tables[0].Rows[row][col].ToString(), out val) == true) { uiChart_Histogram.Data[0, nPoints] = val; maxY = Math.Max(maxY, val); minY = Math.Min(minY, val); } } //Histogram uiChart_Histogram.Extensions.Clear(); ChartFX.WinForms.Statistical.Statistics st = new ChartFX.WinForms.Statistical.Statistics(); st.Chart = uiChart_Histogram; uiChart_Histogram.GalleryAttributes = st.Gallery.Histogram; //chart1.DataGrid.TextColorData = Color.Blue; uiChart_Histogram.ToolTipFormat = "%L\nPoint Value : %v"; //null 값 처리 되어 입력 된 값이 없을 경우... if (uiChart_Histogram.Data.Series == 0) { return; } double range = (maxY + 25) - (minY - 25); st.Gallery.Histogram.AxisX.Step = range / 10; //차트 막대바 두께 설정 st.Chart.AllSeries.Volume = 90; //차트 X축 라벨 기울기 각도 설정 st.Gallery.Histogram.AxisX.LabelAngle = 0; st.Gallery.Histogram.DataMax = (double)(maxY + 25); st.Gallery.Histogram.DataMin = (double)(minY - 25); st.Gallery.Histogram.AxisX.LabelsFormat.Decimals = 1; st.Studies.Clear(); st.Studies.AddTitle("\n\n"); st.Studies.Add(AnalysisMulti.SampleSize); st.Studies.Add(Analysis.LowerQuartile); st.Studies.Add(Analysis.UpperQuartile); st.Studies.Add(Analysis.Mean); st.Studies.Add(Analysis.Lsl); st.Studies.Add(Analysis.Usl); st.Studies.Add(Analysis.Cp); st.Studies.Add(Analysis.Cpk); for (int i = 0; i < st.Studies.Count; ++i) { st.Studies[i].Decimals = 2; } st.Studies[1].Text = "Total Size"; st.Studies[2].Text = "25%(L)"; st.Studies[3].Text = "25%(U)"; st.Calculators[0].Lsl = minY; st.Calculators[0].Usl = maxY; st.LegendBox.Visible = true; st.LegendBox.Dock = ChartFX.WinForms.DockArea.Right; st.LegendBox.AutoSize = false; st.LegendBox.Width = 135; st.LegendBox.Height = 300; st.Gallery.Histogram.ShowLimits = true; uiChart_Histogram.Series[0].Text = "Width"; st.LegendBox.Visible = true; //차트 Title 설정 TitleDockable td = new TitleDockable(); td.Font = new Font("Arial", 11, FontStyle.Bold); td.TextColor = Color.DarkBlue; td.Text = $"'{materials}'_'{opening}' - Capability Analysis"; uiChart_Histogram.Titles.Add(td); }
/// <summary> /// Opening 차트 데이터 바인딩 /// </summary> /// <param name="ds"></param> private void UpdateOpeningChart(DataSet ds, string opening, string materials) { uiChart_Yield.Titles.Clear(); if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { return; } int nPoints = 0; double totatCnt = 0; double okTotalCnt = 0; double ngTotalCnt = 0; double minY = double.MaxValue; double maxY = double.MinValue; int col = (int)MAIN_COLUMNS.YIELD; //Total 양품률, 불량률 구하기 okTotalCnt = Convert.ToInt32(ds.Tables[0].Rows[0][(int)MAIN_COLUMNS.OK_TOTAL_CNT].ToString()); ngTotalCnt = Convert.ToInt32(ds.Tables[0].Rows[0][(int)MAIN_COLUMNS.NG_TOTAL_CNT].ToString()); //Total Count 계산 totatCnt = okTotalCnt + ngTotalCnt; nPoints = uiChart_Yield.Data.Points++; uiChart_Yield.AxesX[0].Labels[nPoints] = "TOTAL"; if (opt.JUDGE.Contains("OK")) { uiChart_Yield.Data[0, nPoints] = Math.Round((okTotalCnt / totatCnt) * 100); } else { uiChart_Yield.Data[0, nPoints] = Math.Round((ngTotalCnt / totatCnt) * 100); } for (int row = 0; row < ds.Tables[0].Rows.Count; ++row) { double val = 0; //double stdVal = 0; nPoints = uiChart_Yield.Data.Points++; uiChart_Yield.AxesX[0].Labels[nPoints] = ds.Tables[0].Rows[row][(int)MAIN_COLUMNS.MATERIAS].ToString(); if (double.TryParse(ds.Tables[0].Rows[row][col].ToString(), out val) == true) { uiChart_Yield.Data[0, nPoints] = val; maxY = Math.Max(maxY, val); minY = Math.Min(minY, val); } } uiChart_Yield.AxisY.Min = 0; uiChart_Yield.AxisY.Max = 100; uiChart_Yield.AxisY.Step = 10; uiChart_Yield.AxisY.LabelsFormat.Decimals = 0; uiLab_ChartTitle.Text = string.Format("Yield Information Chart"); //차트 Title 설정 TitleDockable td = new TitleDockable(); td.Font = new Font("Arial", 11, FontStyle.Bold); if (opt.JUDGE.Contains("OK")) { uiChart_Yield.Series[0].Color = System.Drawing.ColorTranslator.FromHtml("#C8C8FF"); td.Text = $"'{materials}'_'{opening}' - OK Yield Chart"; td.TextColor = Color.DarkBlue; } else { uiChart_Yield.Series[0].Color = System.Drawing.ColorTranslator.FromHtml("#FF607F"); td.Text = $"'{materials}'_'{opening}' - NG Yield Chart"; td.TextColor = Color.Red; } uiChart_Yield.Titles.Add(td); }
/// <summary> /// Sub Chart 표시 /// </summary> /// <param name="ds"></param> private void UpdateOpeningChart(DataSet ds, string materials, string opening) { InitChart(); uiChart_BarLine.Titles.Clear(); if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { return; } int nPoints = 0; double minY = double.MaxValue; double maxY = double.MinValue; double sum = 0.0; int resultValue = 1; int share = 3; for (int row = 0; row < ds.Tables[0].Rows.Count; ++row) { double val = 0; double stdVal = 0; nPoints = uiChart_BarLine.Data.Points++; uiChart_BarLine.AxesX[0].Labels[nPoints] = ds.Tables[0].Rows[row][0].ToString(); uiChart_BarLine.Points[nPoints].Tag = ds.Tables[0].Rows[row][0].ToString(); uiChart_BarLine.Series[(int)Type.LINES].Color = System.Drawing.ColorTranslator.FromHtml("#FF007F"); uiChart_BarLine.Series[(int)Type.LINES].AxisY = uiChart_BarLine.AxisY2; if (double.TryParse(ds.Tables[0].Rows[row][resultValue].ToString(), out val) == true) { uiChart_BarLine.Data[(int)Type.BAR, nPoints] = val; maxY = Math.Max(maxY, val); minY = Math.Min(minY, val); } if (double.TryParse(ds.Tables[0].Rows[row][share].ToString(), out stdVal) == true) { sum += Math.Round(stdVal / 100, 4); uiChart_BarLine.Data[(int)Type.LINES, nPoints] = sum; //항상 마지막 점유율의 총 합은 100이다 if (row == ds.Tables[0].Rows.Count - 1) { sum = Math.Round(100.0 / 100, 4);; uiChart_BarLine.Data[(int)Type.LINES, nPoints] = sum; } } } uiChart_BarLine.AxisY.Min = 0; uiChart_BarLine.AxisY.Max = maxY * 1.5; uiChart_BarLine.AxisY.LabelsFormat.Decimals = 0; uiChart_BarLine.AxisY2.DataFormat.Format = ChartFX.WinForms.AxisFormat.Percentage; uiChart_BarLine.AxisY2.LabelsFormat.Format = ChartFX.WinForms.AxisFormat.Percentage; uiChart_BarLine.AxisY2.Min = 0; uiChart_BarLine.AxisY2.Max = 1; uiChart_BarLine.AxisY2.LabelsFormat.Decimals = 0; uiLab_ChartTitle.Text = string.Format("Materials Information Chart"); //차트 Title 설정 TitleDockable td = new TitleDockable(); td.Font = new Font("Arial", 11, FontStyle.Bold); td.TextColor = Color.DarkBlue; td.Text = $"'{material}'_'{opening}' Pareto Chart"; uiChart_BarLine.Titles.Add(td); }
/// <summary> /// Opening 차트 데이터 바인딩 /// </summary> /// <param name="ds"></param> private void UpdateOpeningChart(DataSet ds, string opening, string materials) { uiChart_XBar.Titles.Clear(); if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { return; } double avg = Math.Ceiling(Math.Round(count / Convert.ToDouble(opt.TOPN), 2)); uiChart_XBar.Data.Series = avg > Convert.ToInt32(opt.TOPN) ? Convert.ToInt32(opt.TOPN) : Convert.ToInt32(avg); int nPoints = 0; double minY = double.MaxValue; double maxY = double.MinValue; int col = uiChk_GapValue.Checked ? 7 : 6; int k = 0; List <double> resultList = new List <double>(); List <double> avgList = new List <double>(); for (int idx = 0; idx < uiChart_XBar.Data.Series; idx++) { resultList.Clear(); for (int row = 0; row < ds.Tables[0].Rows.Count; ++row) { if ((uiChart_XBar.Data.Series != 1 && row != 0 && row % uiChart_XBar.Data.Series == 0) || k == ds.Tables[0].Rows.Count) { break; } nPoints = 0; double val = 0; nPoints = uiChart_XBar.Data.Points++; string date = ds.Tables[0].Rows[k][1].ToString(); uiChart_XBar.Series[idx].Text = date.Substring(date.Length - 6, 6).ToString(); uiChart_XBar.AxisX.LabelAngle = 45; if (double.TryParse(ds.Tables[0].Rows[k][col].ToString(), out val) == true) { uiChart_XBar.Data[idx, nPoints] = val; resultList.Add(val); maxY = Math.Max(maxY, val); minY = Math.Min(minY, val); } k++; } double avgValue = resultList.Average(); avgList.Add(Math.Round(avgValue, 2)); } double minValue = 0.0; double maxValue = 0.0; double gap = 0.0; if (uiChart_XBar.Data.Series == 1) { minValue = resultList.Min(); maxValue = resultList.Max(); gap = Math.Round(maxValue - minValue, 2); } else { minValue = avgList.Min(); maxValue = avgList.Max(); gap = Math.Round(maxValue - minValue, 2); } // X Chart uiChart_XBar.Extensions.Clear(); ChartFX.WinForms.Statistical.Statistics st = new ChartFX.WinForms.Statistical.Statistics(); st.Chart = uiChart_XBar; uiChart_XBar.GalleryAttributes = st.Gallery.XChart; st.Studies.Add(StudyGroup.Spc); if (gap < 5) { uiChart_XBar.AxisY.Min = minValue - gap; uiChart_XBar.AxisY.Max = maxValue + gap; uiChart_XBar.AxisY.LabelsFormat.Decimals = 1; } else { uiChart_XBar.AxisY.Min = minValue - (gap / 5); uiChart_XBar.AxisY.Max = maxValue + (gap / 5); uiChart_XBar.AxisY.LabelsFormat.Decimals = 1; } //차트 Title 설정 TitleDockable td = new TitleDockable(); td.Font = new Font("Arial", 11, FontStyle.Bold); td.TextColor = Color.DarkBlue; td.Text = $"'{materials}'_'{opening}' - X̄ (X bar) Chart"; uiChart_XBar.Titles.Add(td); }