namespace SPC.WebUI { using System; using System.Data; using System.Drawing; using System.Drawing.Imaging; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Xml; using SPC.SystemFrameworks; using ASPNet_Drawing; /// /// DrawPicture 的摘要说明。 /// public class DrawPicture { private Graph obGraph = null; /// /// 趋势图 /// public Bitmap DrawTrendChart(DataTable[] mytable,String[] trendName,out Unit height,out Unit width) { try { obGraph = new Spc_Trend_Graph2D(); obGraph.HasXAxisLabel = true; obGraph.HasYAxisLabel = true; obGraph.XAxisLabel = "数 据 组"; obGraph.YAxisLabel = "参 考 值"; obGraph.LoadAndSetGraph(); height = obGraph.Height; width = obGraph.Width; StatisticalFunction myStatisticalFunction = new StatisticalFunction( mytable, 2 ,trendName); XmlDataDocument mydocument_Trend; myStatisticalFunction.SPC_Trend(out mydocument_Trend); obGraph.HasLegends = true; obGraph.SetGraphData (mydocument_Trend); obGraph.DrawGraph(ImageFormat.Jpeg); return obGraph.m_obBitmap; } catch(Exception err) { ApplicationLog.WriteLog(err,"趋势图"); height = 0; width = 0; return null; } } /// /// 不合格品数控制图 /// public Bitmap DrawNPChart(DataTable newTable,out Unit height,out Unit width) { try { obGraph = new Spc_NP_Graph2D(); obGraph.HasXAxisLabel = true; obGraph.HasYAxisLabel = true; obGraph.XAxisLabel = "数 据 组"; obGraph.YAxisLabel = "不合格品数"; obGraph.LoadAndSetGraph(); height = obGraph.Height; width = obGraph.Width; StatisticalFunction myStatisticalFunction = new StatisticalFunction( newTable, 1 ); XmlDataDocument mydocument_NP ; myStatisticalFunction.SPC_NP(out mydocument_NP); //下面的代码用于生成图形 obGraph.SetGraphData (mydocument_NP); obGraph.DrawGraph(ImageFormat.Jpeg); return obGraph.m_obBitmap; } catch(Exception err) { ApplicationLog.WriteLog(err,"趋势图"); height = 0; width = 0; return null; } } /// /// 不合格品率控制图 /// public Bitmap DrawPChart(DataTable newTable,out Unit height,out Unit width) { try { obGraph = new Spc_P_Graph2D(); obGraph.HasXAxisLabel = true; obGraph.HasYAxisLabel = true; obGraph.XAxisLabel = "数 据 组"; obGraph.YAxisLabel = "不合格品率"; obGraph.LoadAndSetGraph(); height = obGraph.Height; width = obGraph.Width; StatisticalFunction myStatisticalFunction = new StatisticalFunction( newTable, 1 ); XmlDataDocument mydocument_P ; myStatisticalFunction.SPC_P(out mydocument_P); obGraph.SetGraphData (mydocument_P); obGraph.DrawGraph(ImageFormat.Jpeg); return obGraph.m_obBitmap; } catch(Exception err) { ApplicationLog.WriteLog(err,"趋势图"); height = 0; width = 0; return null; } } /// /// 水平分析图 /// public Bitmap DrawXZChart(DataTable newTable,out Unit height,out Unit width) { try { obGraph = new Spc_XZ_Graph2D(); obGraph.HasXAxisLabel = true; obGraph.HasYAxisLabel = true; obGraph.XAxisLabel = "数 据 组"; obGraph.YAxisLabel = "参 考 值"; obGraph.LoadAndSetGraph(); height = obGraph.Height; width = obGraph.Width; StatisticalFunction myStatisticalFunction = new StatisticalFunction( newTable, 2 ); XmlDataDocument mydocument_H ; myStatisticalFunction.SPC_H(out mydocument_H); obGraph.SetGraphData (mydocument_H); obGraph.DrawGraph(ImageFormat.Jpeg); return obGraph.m_obBitmap; } catch(Exception err) { ApplicationLog.WriteLog(err,"趋势图"); height = 0; width = 0; return null; } } /// /// 水平分析图 /// public Bitmap DrawXZChart(DataTable newTable,string columnName,out Unit height,out Unit width) { try { obGraph = new Spc_XZ_Graph2D(); obGraph.HasXAxisLabel = true; obGraph.HasYAxisLabel = true; obGraph.XAxisLabel = "数 据 组"; obGraph.YAxisLabel = "参 考 值"; obGraph.LoadAndSetGraph(); height = obGraph.Height; width = obGraph.Width; StatisticalFunction myStatisticalFunction = new StatisticalFunction( newTable, columnName ); XmlDataDocument mydocument_H ; myStatisticalFunction.SPC_H(out mydocument_H); obGraph.SetGraphData (mydocument_H); obGraph.DrawGraph(ImageFormat.Jpeg); return obGraph.m_obBitmap; } catch(Exception err) { ApplicationLog.WriteLog(err,"趋势图"); height = 0; width = 0; return null; } } /// /// 直方图 /// public Bitmap DrawBARChart(DataTable newTable,out Unit height,out Unit width,out XmlDataDocument xmlDocument) { try { obGraph = new Spc_Bar_Graph2D(); obGraph.HasXAxisLabel = true; obGraph.HasYAxisLabel = true; obGraph.XAxisLabel = "数据分组情况"; obGraph.YAxisLabel = "数据的频数分布"; obGraph.LoadAndSetGraph(); height = obGraph.Height; width = obGraph.Width; StatisticalFunction myStatisticalFunction = new StatisticalFunction( newTable, 1 ); myStatisticalFunction.SPC_Bar(out xmlDocument); obGraph.SetGraphData (xmlDocument); obGraph.DrawGraph(ImageFormat.Jpeg); return obGraph.m_obBitmap; } catch(Exception err) { ApplicationLog.WriteLog(err,"直方图"); xmlDocument = null; height = 0; width = 0; return null; } } /// /// 直方图无返回值 /// public Bitmap DrawBARChart(DataTable newTable,out Unit height,out Unit width) { try { XmlDataDocument xmlDocument; obGraph = new Spc_Bar_Graph2D(); obGraph.HasXAxisLabel = true; obGraph.HasYAxisLabel = true; obGraph.XAxisLabel = "数据分组情况"; obGraph.YAxisLabel = "数据的频数分布"; obGraph.LoadAndSetGraph(); height = obGraph.Height; width = obGraph.Width; StatisticalFunction myStatisticalFunction = new StatisticalFunction( newTable, 1 ); myStatisticalFunction.SPC_Bar(out xmlDocument); obGraph.SetGraphData (xmlDocument); obGraph.DrawGraph(ImageFormat.Jpeg); return obGraph.m_obBitmap; } catch(Exception err) { ApplicationLog.WriteLog(err,"直方图无返回值"); height = 0; width = 0; return null; } } /// /// 均值-极差控制图 /// public Bitmap DrawXRChart(DataTable newTable,int Spc_GroupCount,out Unit height,out Unit width,out XmlDataDocument xmlDocument_X,out XmlDataDocument xmlDocument_R) { try { obGraph = new Spc_XR_Graph2D(); StatisticalFunction myStatisticalFunction = new StatisticalFunction( newTable, 1 ); Spc_XR_Graph2D obGraphXR = new Spc_XR_Graph2D(); obGraphXR.HasXAxisLabel = true; obGraphXR.HasYAxisLabel = true; obGraphXR.XAxisLabel = "数 据 组"; obGraphXR.YAxisLabel = "均 值"; //设置控件的高度,使之与XML文件中一致 obGraphXR.LoadAndSetGraph(); myStatisticalFunction.SPC_XR(Spc_GroupCount,obGraphXR.Spc_XR_X_Digits,obGraphXR.Spc_XR_R_Digits ,out xmlDocument_X,out xmlDocument_R); height = obGraphXR.Height; width = obGraphXR.Width; obGraphXR.Width = obGraphXR.Width; obGraphXR.Height = obGraphXR.Height/2; obGraphXR.SetGraphData (xmlDocument_X); obGraphXR.Title = "均值控制图"; obGraphXR.DrawGraph(ImageFormat.Jpeg); Bitmap m_obBitmap1 = obGraphXR.m_obBitmap; obGraphXR = new Spc_XR_Graph2D(); obGraphXR.HasXAxisLabel = true; obGraphXR.HasYAxisLabel = true; obGraphXR.XAxisLabel = "数 据 组"; obGraphXR.YAxisLabel = "极 差"; obGraphXR.LoadAndSetGraph(); obGraphXR.Width = obGraphXR.Width; obGraphXR.Height = obGraphXR.Height/2; obGraphXR.SetGraphData (xmlDocument_R); obGraphXR.Title = "极差控制图"; obGraphXR.DrawGraph(ImageFormat.Jpeg); Bitmap m_obBitmap2 = obGraphXR.m_obBitmap; //完成图形的粘贴,再生成图形时只需要单独构造再合成就可以了 Bitmap mybBitmap = new Bitmap(obGraphXR.Width, obGraphXR.Height * 2); Graphics mybGraphics = Graphics.FromImage(mybBitmap); mybGraphics.DrawImage(m_obBitmap1,0,0,obGraphXR.Width,obGraphXR.Height); mybGraphics.DrawImage(m_obBitmap2,0,obGraphXR.Height,obGraphXR.Width,obGraphXR.Height); obGraph.m_obBitmap = mybBitmap; if( m_obBitmap1 != null ) m_obBitmap1.Dispose(); if( m_obBitmap2 != null ) m_obBitmap2.Dispose(); return obGraph.m_obBitmap; } catch(Exception err) { ApplicationLog.WriteLog(err," 均值-极差控制图"); xmlDocument_X = null; xmlDocument_R= null; height = 0; width = 0; return null; } } /// /// 均值-极差控制图无返回值 /// public Bitmap DrawXRChart(DataTable newTable,out Unit height,out Unit width) { try { XmlDataDocument xmlDocument_X,xmlDocument_R; int Spc_GroupCount = 5; obGraph = new Spc_XR_Graph2D(); StatisticalFunction myStatisticalFunction = new StatisticalFunction( newTable, 1 ); Spc_XR_Graph2D obGraphXR = new Spc_XR_Graph2D(); obGraphXR.HasXAxisLabel = true; obGraphXR.HasYAxisLabel = true; obGraphXR.XAxisLabel = "数 据 组"; obGraphXR.YAxisLabel = "均 值"; //设置控件的高度,使之与XML文件中一致 obGraphXR.LoadAndSetGraph(); myStatisticalFunction.SPC_XR(Spc_GroupCount,obGraphXR.Spc_XR_X_Digits,obGraphXR.Spc_XR_R_Digits ,out xmlDocument_X,out xmlDocument_R); height = obGraphXR.Height; width = obGraphXR.Width; obGraphXR.Width = obGraphXR.Width; obGraphXR.Height = obGraphXR.Height/2; obGraphXR.SetGraphData (xmlDocument_X); obGraphXR.Title = "均值控制图"; obGraphXR.DrawGraph(ImageFormat.Jpeg); Bitmap m_obBitmap1 = obGraphXR.m_obBitmap; obGraphXR = new Spc_XR_Graph2D(); obGraphXR.HasXAxisLabel = true; obGraphXR.HasYAxisLabel = true; obGraphXR.XAxisLabel = "数 据 组"; obGraphXR.YAxisLabel = "极 差"; obGraphXR.LoadAndSetGraph(); obGraphXR.Width = obGraphXR.Width; obGraphXR.Height = obGraphXR.Height/2; obGraphXR.SetGraphData (xmlDocument_R); obGraphXR.Title = "极差控制图"; obGraphXR.DrawGraph(ImageFormat.Jpeg); Bitmap m_obBitmap2 = obGraphXR.m_obBitmap; //完成图形的粘贴,再生成图形时只需要单独构造再合成就可以了 Bitmap mybBitmap = new Bitmap(obGraphXR.Width, obGraphXR.Height * 2); Graphics mybGraphics = Graphics.FromImage(mybBitmap); mybGraphics.DrawImage(m_obBitmap1,0,0,obGraphXR.Width,obGraphXR.Height); mybGraphics.DrawImage(m_obBitmap2,0,obGraphXR.Height,obGraphXR.Width,obGraphXR.Height); obGraph.m_obBitmap = mybBitmap; if( m_obBitmap1 != null ) m_obBitmap1.Dispose(); if( m_obBitmap2 != null ) m_obBitmap2.Dispose(); return obGraph.m_obBitmap; } catch(Exception err) { ApplicationLog.WriteLog(err,"均值-极差控制图无返回值"); height = 0; width = 0; return null; } } /// /// 均值-偏差控制图 /// public Bitmap DrawXSChart(DataTable newTable,int Spc_GroupCount,out Unit height,out Unit width,out XmlDataDocument xmlDocument_X,out XmlDataDocument xmlDocument_S) { try { obGraph = new Spc_XR_Graph2D(); StatisticalFunction myStatisticalFunction = new StatisticalFunction( newTable, 1 ); //下面的代码用于生成图形 Spc_XS_Graph2D obGraphXR = new Spc_XS_Graph2D(); obGraphXR.HasXAxisLabel = true; obGraphXR.HasYAxisLabel = true; obGraphXR.XAxisLabel = "数 据 组"; obGraphXR.YAxisLabel = "均 值"; obGraphXR.LoadAndSetGraph(); myStatisticalFunction.SPC_XS(Spc_GroupCount,obGraphXR.Spc_XS_X_Digits,obGraphXR.Spc_XS_S_Digits,out xmlDocument_X,out xmlDocument_S); height = obGraphXR.Height; width = obGraphXR.Width; obGraphXR.Width = obGraphXR.Width; obGraphXR.Height = obGraphXR.Height/2; obGraphXR.SetGraphData (xmlDocument_X); obGraphXR.Title = "均值控制图"; obGraphXR.DrawGraph(ImageFormat.Jpeg); Bitmap m_obBitmap1 = obGraphXR.m_obBitmap; obGraphXR = new Spc_XS_Graph2D(); obGraphXR.HasXAxisLabel = true; obGraphXR.HasYAxisLabel = true; obGraphXR.XAxisLabel = "数 据 组"; obGraphXR.YAxisLabel = "偏 值"; obGraphXR.LoadAndSetGraph(); obGraphXR.Width = obGraphXR.Width; obGraphXR.Height = obGraphXR.Height/2; obGraphXR.SetGraphData (xmlDocument_S); obGraphXR.Title = "偏差控制图"; obGraphXR.DrawGraph(ImageFormat.Jpeg); Bitmap m_obBitmap2 = obGraphXR.m_obBitmap; //完成图形的粘贴,再生成图形时只需要单独构造再合成就可以了 Bitmap mybBitmap = new Bitmap(obGraphXR.Width, obGraphXR.Height * 2); Graphics mybGraphics = Graphics.FromImage(mybBitmap); mybGraphics.DrawImage(m_obBitmap1,0,0,obGraphXR.Width,obGraphXR.Height); mybGraphics.DrawImage(m_obBitmap2,0,obGraphXR.Height,obGraphXR.Width,obGraphXR.Height); obGraph.m_obBitmap = mybBitmap; if( m_obBitmap1 != null ) m_obBitmap1.Dispose(); if( m_obBitmap2 != null ) m_obBitmap2.Dispose(); return obGraph.m_obBitmap; } catch(Exception err) { ApplicationLog.WriteLog(err,"均值-偏差控制图"); xmlDocument_X = null; xmlDocument_S = null; height = 0; width = 0; return null; } } /// /// 均值-偏差控制图无返回值 /// public Bitmap DrawXSChart(DataTable newTable,out Unit height,out Unit width) { try { XmlDataDocument xmlDocument_X,xmlDocument_S; int Spc_GroupCount = 5; obGraph = new Spc_XR_Graph2D(); StatisticalFunction myStatisticalFunction = new StatisticalFunction( newTable, 1 ); //下面的代码用于生成图形 Spc_XS_Graph2D obGraphXR = new Spc_XS_Graph2D(); obGraphXR.HasXAxisLabel = true; obGraphXR.HasYAxisLabel = true; obGraphXR.XAxisLabel = "数 据 组"; obGraphXR.YAxisLabel = "均 值"; obGraphXR.LoadAndSetGraph(); myStatisticalFunction.SPC_XS(Spc_GroupCount,obGraphXR.Spc_XS_X_Digits,obGraphXR.Spc_XS_S_Digits,out xmlDocument_X,out xmlDocument_S); height = obGraphXR.Height; width = obGraphXR.Width; obGraphXR.Width = obGraphXR.Width; obGraphXR.Height = obGraphXR.Height/2; obGraphXR.SetGraphData (xmlDocument_X); obGraphXR.Title = "均值控制图"; obGraphXR.DrawGraph(ImageFormat.Jpeg); Bitmap m_obBitmap1 = obGraphXR.m_obBitmap; obGraphXR = new Spc_XS_Graph2D(); obGraphXR.HasXAxisLabel = true; obGraphXR.HasYAxisLabel = true; obGraphXR.XAxisLabel = "数 据 组"; obGraphXR.YAxisLabel = "偏 值"; obGraphXR.LoadAndSetGraph(); obGraphXR.Width = obGraphXR.Width; obGraphXR.Height = obGraphXR.Height/2; obGraphXR.SetGraphData (xmlDocument_S); obGraphXR.Title = "偏差控制图"; obGraphXR.DrawGraph(ImageFormat.Jpeg); Bitmap m_obBitmap2 = obGraphXR.m_obBitmap; //完成图形的粘贴,再生成图形时只需要单独构造再合成就可以了 Bitmap mybBitmap = new Bitmap(obGraphXR.Width, obGraphXR.Height * 2); Graphics mybGraphics = Graphics.FromImage(mybBitmap); mybGraphics.DrawImage(m_obBitmap1,0,0,obGraphXR.Width,obGraphXR.Height); mybGraphics.DrawImage(m_obBitmap2,0,obGraphXR.Height,obGraphXR.Width,obGraphXR.Height); obGraph.m_obBitmap = mybBitmap; if( m_obBitmap1 != null ) m_obBitmap1.Dispose(); if( m_obBitmap2 != null ) m_obBitmap2.Dispose(); return obGraph.m_obBitmap; } catch(Exception err) { ApplicationLog.WriteLog(err,"均值-偏差控制图无返回值"); height = 0; width = 0; return null; } } /// /// 排列图 /// public Bitmap DrawPLChart(DataTable newTable,out Unit height,out Unit width) { try { obGraph = new Spc_PL_Graph2D(); obGraph.HasXAxisLabel = true; obGraph.HasYAxisLabel = false; obGraph.XAxisLabel = "数 据 组"; obGraph.LoadAndSetGraph(); height = obGraph.Height; width = obGraph.Width; StatisticalFunction myStatisticalFunction = new StatisticalFunction( newTable, 2 ); XmlDataDocument mydocument_PL ; myStatisticalFunction.SPC_PL(out mydocument_PL); obGraph.SetGraphData (mydocument_PL); obGraph.DrawGraph(ImageFormat.Jpeg); return obGraph.m_obBitmap; } catch(Exception err) { ApplicationLog.WriteLog(err,"排列图"); height = 0; width = 0; return null; } } /// /// 饼图 /// /// public Bitmap DrawPIEChart(DataTable newTable,out Unit height,out Unit width) { try { obGraph = new Spc_Pie_Graph2D(); obGraph.LoadAndSetGraph(); height = obGraph.Height; width = obGraph.Width; StatisticalFunction myStatisticalFunction = new StatisticalFunction( newTable, 2 ); XmlDataDocument mydocument_Pie ;//= new XmlDataDocument(); myStatisticalFunction.SPC_Pie(out mydocument_Pie); obGraph.SetGraphData (mydocument_Pie); obGraph.DrawGraph(ImageFormat.Jpeg); return obGraph.m_obBitmap; } catch(Exception err) { ApplicationLog.WriteLog(err,"饼图"); height = 0; width = 0; return null; } } /// /// 工序能力分析 /// public Bitmap DrawGXNL(DataTable newTable,out Unit height,out Unit width,double m_GXNL_UpParam,double m_GXNL_DownParam, out XmlDataDocument xmlDocument,out string[] m_Spc_GXNL_Param) { try { obGraph = new Spc_GXNL_Graph2D(); Spc_GXNL_Graph2D obGraph_GXNL = new Spc_GXNL_Graph2D(); obGraph_GXNL.HasXAxisLabel = true; obGraph_GXNL.HasYAxisLabel = false; obGraph_GXNL.XAxisLabel = "数据分组情况"; StatisticalFunction myStatisticalFunction = new StatisticalFunction( newTable, 1 ); obGraph_GXNL.LoadAndSetGraph(); myStatisticalFunction.GXNL_Analysis( m_GXNL_UpParam,m_GXNL_DownParam,obGraph_GXNL.Spc_GXNL_ParamDigits, out xmlDocument,out m_Spc_GXNL_Param); //加载完相关参数后再确定图像的大小 height = obGraph_GXNL.Height; width = obGraph_GXNL.Width; obGraph_GXNL.SetGraphData (xmlDocument); obGraph_GXNL.DrawGraph(ImageFormat.Jpeg); obGraph.m_obBitmap = obGraph_GXNL.m_obBitmap; return obGraph.m_obBitmap; } catch(Exception err) { ApplicationLog.WriteLog(err,"工序能力分析"); xmlDocument = null; m_Spc_GXNL_Param = null; height = 0; width = 0; return null; } } /// /// 工序能力分析 /// /// 数据表 /// 包含数据的列名 /// 高度 /// 宽度 /// 上限 /// 下限 /// 包含数据的文档 /// 参数列表 /// public Bitmap DrawGXNL(DataTable newTable,string columnName,out Unit height,out Unit width,double m_GXNL_UpParam,double m_GXNL_DownParam, out XmlDataDocument xmlDocument,out string[] m_Spc_GXNL_Param) { try { obGraph = new Spc_GXNL_Graph2D(); Spc_GXNL_Graph2D obGraph_GXNL = new Spc_GXNL_Graph2D(); obGraph_GXNL.HasXAxisLabel = true; obGraph_GXNL.HasYAxisLabel = false; obGraph_GXNL.XAxisLabel = "数据分组情况"; StatisticalFunction myStatisticalFunction = new StatisticalFunction( newTable, columnName ); obGraph_GXNL.LoadAndSetGraph(); if(myStatisticalFunction.GXNL_Analysis( m_GXNL_UpParam,m_GXNL_DownParam,obGraph_GXNL.Spc_GXNL_ParamDigits, out xmlDocument,out m_Spc_GXNL_Param)) { //加载完相关参数后再确定图像的大小 height = obGraph_GXNL.Height; width = obGraph_GXNL.Width; obGraph_GXNL.SetGraphData (xmlDocument); obGraph_GXNL.DrawGraph(ImageFormat.Jpeg); obGraph.m_obBitmap = obGraph_GXNL.m_obBitmap; return obGraph.m_obBitmap; } else { height = 0; width = 0; m_Spc_GXNL_Param = null; return null; } } catch(Exception err) { ApplicationLog.WriteLog(err,"工序能力分析"); xmlDocument = null; m_Spc_GXNL_Param = null; height = 0; width = 0; return null; } } /// /// 工序能力分析无返回值 /// public Bitmap DrawGXNL(DataTable newTable,out Unit height,out Unit width,double m_GXNL_UpParam,double m_GXNL_DownParam) { try { XmlDataDocument xmlDocument; string[] m_Spc_GXNL_Param; obGraph = new Spc_GXNL_Graph2D(); Spc_GXNL_Graph2D obGraph_GXNL = new Spc_GXNL_Graph2D(); obGraph_GXNL.HasXAxisLabel = true; obGraph_GXNL.HasYAxisLabel = false; obGraph_GXNL.XAxisLabel = "数据分组情况"; StatisticalFunction myStatisticalFunction = new StatisticalFunction( newTable, 1 ); obGraph_GXNL.LoadAndSetGraph(); myStatisticalFunction.GXNL_Analysis( m_GXNL_UpParam,m_GXNL_DownParam,obGraph_GXNL.Spc_GXNL_ParamDigits, out xmlDocument,out m_Spc_GXNL_Param); //加载完相关参数后再确定图像的大小 height = obGraph_GXNL.Height; width = obGraph_GXNL.Width; obGraph_GXNL.SetGraphData (xmlDocument); obGraph_GXNL.DrawGraph(ImageFormat.Jpeg); obGraph.m_obBitmap = obGraph_GXNL.m_obBitmap; return obGraph.m_obBitmap; } catch(Exception err) { ApplicationLog.WriteLog(err,"工序能力分析无返回值"); height = 0; width = 0; return null; } } /// /// 绘制成组条形图 /// /// public Bitmap DrawGroupBarChart(DataTable newTable,out Unit height,out Unit width) { try { obGraph = new Spc_GroupBarGraph2D(); obGraph.Title = "全局设备效率统计"; obGraph.HasGridLines = false; obGraph.HasLegends = true; ((Spc_GroupBarGraph2D)obGraph).GraphAlignment = Alignment.Vertical; obGraph.LoadAndSetGraph(); height = obGraph.Height; width = obGraph.Width; StatisticalFunction myStatisticalFunction = new StatisticalFunction( newTable, 1 ); XmlDataDocument mydocument_GroupBar ; myStatisticalFunction.SPC_GroupBar(out mydocument_GroupBar); obGraph.SetGraphData (mydocument_GroupBar); obGraph.DrawGraph(ImageFormat.Jpeg); return obGraph.m_obBitmap; } catch(Exception err) { ApplicationLog.WriteLog(err,"绘制成组条形图"); height = 0; width = 0; return null; } } /// /// 典型数据的条形图:用于输出xml文件 /// /// 数据表 /// 数据列 /// 高度 /// 宽度 /// 典型数据的xml文件 /// static public Bitmap DrawCustomBarChart(DataTable newTable,string textColumnName,string dataColumnName,out Unit height,out Unit width,out XmlDataDocument mydocument_CustomBar) { try { obGraph = new Spc_CustomBar_Graph2D(); obGraph.HasXAxisLabel = true; obGraph.HasYAxisLabel = false; obGraph.XAxisLabel = "数 据 组"; obGraph.LoadAndSetGraph(); height = obGraph.Height; width = obGraph.Width; StatisticalFunction myStatisticalFunction = new StatisticalFunction( newTable,textColumnName,dataColumnName ); myStatisticalFunction.SPC_CustomBar(out mydocument_CustomBar); obGraph.SetGraphData (mydocument_CustomBar); obGraph.DrawGraph(ImageFormat.Jpeg); return obGraph.m_obBitmap; } catch(Exception err) { ApplicationLog.WriteLog(err,"典型数据的条形图:用于输出xml文件"); mydocument_CustomBar = null; height = 0; width = 0; return null; } } /// /// 典型数据的条形图 /// /// 数据表 /// 数据列 /// 高度 /// 宽度 /// public Bitmap DrawCustomBarChart(DataTable newTable,string textColumnName,string dataColumnName,out Unit height,out Unit width) { try { obGraph = new Spc_CustomBar_Graph2D(); obGraph.HasXAxisLabel = true; obGraph.HasYAxisLabel = false; obGraph.XAxisLabel = "数 据 组"; obGraph.LoadAndSetGraph(); height = obGraph.Height; width = obGraph.Width; XmlDataDocument mydocument_CustomBar; StatisticalFunction myStatisticalFunction = new StatisticalFunction( newTable,textColumnName,dataColumnName ); myStatisticalFunction.SPC_CustomBar(out mydocument_CustomBar); obGraph.SetGraphData (mydocument_CustomBar); obGraph.DrawGraph(ImageFormat.Jpeg); return obGraph.m_obBitmap; } catch(Exception err) { ApplicationLog.WriteLog(err,"典型数据的条形图"); height = 0; width = 0; return null; } } /// /// 典型数据的直线图:用于输出xml文档 /// /// 实际数据 /// 包含数据的列名 /// 控制上限 /// 控制下限 /// 高度 /// 宽度 /// public Bitmap DrawCustomLineChart(DataTable newTable,string columnName,float UCL_Value,float LCL_Value,out Unit height,out Unit width,out XmlDataDocument xmlDocument) { try { Spc_CustomLine_Graph2D obGraph = new Spc_CustomLine_Graph2D(); obGraph.Spc_CustomLine_UCL_Value = UCL_Value; obGraph.Spc_CustomLine_LCL_Value= LCL_Value; StatisticalFunction myStatisticalFunction = new StatisticalFunction( newTable, columnName ); obGraph.HasXAxisLabel = true; obGraph.HasYAxisLabel = false; obGraph.XAxisLabel = "数 据 组"; obGraph.YAxisLabel = "数 值"; obGraph.LoadAndSetGraph(); obGraph.Spc_CustomLine_UCL_Value = UCL_Value; obGraph.Spc_CustomLine_LCL_Value = LCL_Value; myStatisticalFunction.UCL_Value = UCL_Value; myStatisticalFunction.LCL_Value = LCL_Value; height = obGraph.Height; width = obGraph.Width; myStatisticalFunction.SPC_CustomLine( out xmlDocument ); height = obGraph.Height; width = obGraph.Width; obGraph.SetGraphData (xmlDocument); obGraph.Title = "控 制 图"; obGraph.DrawGraph(ImageFormat.Jpeg); return obGraph.m_obBitmap; } catch(Exception err) { ApplicationLog.WriteLog(err,"典型数据的直线图:用于输出xml文档"); xmlDocument = null; height = 0; width = 0; return null; } } /// /// 典型数据的直线图 /// /// 实际数据 /// 控制上限 /// 控制下限 /// 高度 /// 宽度 /// public Bitmap DrawCustomLineChart(DataTable newTable,float UCL_Value,float LCL_Value,out Unit height,out Unit width) { try { Spc_CustomLine_Graph2D obGraph = new Spc_CustomLine_Graph2D(); StatisticalFunction myStatisticalFunction = new StatisticalFunction( newTable, 5 ); obGraph.HasXAxisLabel = true; obGraph.HasYAxisLabel = false; obGraph.XAxisLabel = "数 据 组"; obGraph.YAxisLabel = "数 值"; obGraph.LoadAndSetGraph(); height = obGraph.Height; width = obGraph.Width; XmlDataDocument mydocument_CustomLine; myStatisticalFunction.SPC_CustomLine( out mydocument_CustomLine ); height = obGraph.Height; width = obGraph.Width; obGraph.SetGraphData (mydocument_CustomLine); obGraph.Title = "控 制 图"; obGraph.Spc_CustomLine_LCL_Value= LCL_Value; obGraph.Spc_CustomLine_UCL_Value = UCL_Value; obGraph.DrawGraph(ImageFormat.Jpeg); return obGraph.m_obBitmap; } catch(Exception err) { ApplicationLog.WriteLog(err,"典型数据的直线图"); height = 0; width = 0; return null; } } /// /// 典型数据的直线图:增加了一个参数 /// /// 数据表 /// 包含数据的列名 /// 上限 /// 下限 /// 高度 /// 宽度 /// public Bitmap DrawCustomLineChart(DataTable newTable,string columnName,float UCL_Value,float LCL_Value,out Unit height,out Unit width) { try { Spc_CustomLine_Graph2D obGraph = new Spc_CustomLine_Graph2D(); StatisticalFunction myStatisticalFunction = new StatisticalFunction( newTable, 5 ); obGraph.HasXAxisLabel = true; obGraph.HasYAxisLabel = false; obGraph.XAxisLabel = "数 据 组"; obGraph.YAxisLabel = "数 值"; obGraph.LoadAndSetGraph(); height = obGraph.Height; width = obGraph.Width; XmlDataDocument mydocument_CustomLine; myStatisticalFunction.SPC_CustomLine( out mydocument_CustomLine ); height = obGraph.Height; width = obGraph.Width; obGraph.SetGraphData (mydocument_CustomLine); obGraph.Title = "控 制 图"; obGraph.Spc_CustomLine_LCL_Value= LCL_Value; obGraph.Spc_CustomLine_UCL_Value = UCL_Value; obGraph.DrawGraph(ImageFormat.Jpeg); return obGraph.m_obBitmap; } catch(Exception err) { ApplicationLog.WriteLog(err,"典型数据的直线图:增加了一个参数"); height = 0; width = 0; return null; } } /// /// 典型数据的直线图:用来图形相关属性的设置 /// /// 实际数据 /// 实际数据列 /// 高度 /// 宽度 /// public Bitmap DrawCustomLineChart(DataTable newTable,string columnName,out Unit height,out Unit width) { try { Spc_CustomLine_Graph2D obGraph = new Spc_CustomLine_Graph2D(); StatisticalFunction myStatisticalFunction = new StatisticalFunction( newTable, columnName ); obGraph.HasXAxisLabel = true; obGraph.HasYAxisLabel = false; obGraph.XAxisLabel = "数 据 组"; obGraph.YAxisLabel = "数 值"; obGraph.LoadAndSetGraph(); height = obGraph.Height; width = obGraph.Width; XmlDataDocument mydocument_CustomLine; myStatisticalFunction.SPC_CustomLine( out mydocument_CustomLine ); height = obGraph.Height; width = obGraph.Width; obGraph.SetGraphData (mydocument_CustomLine); obGraph.Title = "控 制 图"; // obGraph.Spc_CustomLine_LCL_Value= LCL_Value; // obGraph.Spc_CustomLine_UCL_Value = UCL_Value; obGraph.DrawGraph(ImageFormat.Jpeg); return obGraph.m_obBitmap; } catch(Exception err) { ApplicationLog.WriteLog(err,"典型数据的直线图:用来图形相关属性的设置"); height = 0; width = 0; return null; } } /// /// 绘制成组条形图 /// /// static public Bitmap DrawOEEChart(DataTable newTable,out Unit height,out Unit width) { try { obGraph = new Spc_OEEGraph2D(); obGraph.Title = "全局设备效率统计"; obGraph.HasGridLines = false; obGraph.HasLegends = false; ((Spc_OEEGraph2D)obGraph).GraphAlignment = Alignment.Vertical; obGraph.LoadAndSetGraph(); height = obGraph.Height; width = obGraph.Width; StatisticalFunction myStatisticalFunction = new StatisticalFunction( newTable, 1 ); XmlDataDocument mydocument_GroupBar ; myStatisticalFunction.SPC_GroupBar(out mydocument_GroupBar); obGraph.SetGraphData (mydocument_GroupBar); obGraph.DrawGraph(ImageFormat.Jpeg); return obGraph.m_obBitmap; } catch(Exception err) { ApplicationLog.WriteLog(err,"绘制成组条形图"); height = 0; width = 0; return null; } } /// /// 绘制层叠条形图 /// /// public Bitmap DrawStackBarChart(DataTable[] newTable,string[] trendName,out Unit height,out Unit width) { try { Spc_StackBar_Graph2D obGraph = new Spc_StackBar_Graph2D(); obGraph.Title = "设备历史状态统计"; obGraph.HasGridLines = false; obGraph.HasLegends = true; ((Spc_StackBar_Graph2D)obGraph).GraphAlignment = Alignment.Horizontal; obGraph.LoadAndSetGraph(); height = obGraph.Height; width = obGraph.Width; StatisticalFunction myStatisticalFunction = new StatisticalFunction( newTable, 2 ,trendName); XmlDataDocument mydocument_StackBar ; myStatisticalFunction.SPC_Trend(out mydocument_StackBar); obGraph.SetGraphData (mydocument_StackBar); obGraph.DrawGraph(ImageFormat.Jpeg); return obGraph.m_obBitmap; } catch(Exception err) { ApplicationLog.WriteLog(err,"绘制层叠条形图"); height = 0; width = 0; return null; } } } }