vbscript ms owc 封裝代码
作者 佚名
来源 ASP编程
浏览
发布时间 2013-07-09
复制代码 代码如下: ''''owc.vbs class owc private o ''传入物件 public property set set_obj(o_id) set o=o_id end property ''画图矩形图 ''chart_bgcolor_图表的背景颜色 ''chartCaption_图表的标题 ''chartCaption_fontColor_图表标题颜色 ''Interior_Color_矩形内的填充颜色 ''Caption_名称 ''categories_名称数组 ''values_值数组串 public sub bar(chart_bgcolor_,chartCaption_,chartCaption_fontColor_,Interior_Color_,Caption_,categories_,values_) o.Clear set cht = o.Charts.Add set c = o.Constants cht.Type = c.chChartTypeColumnClustered ''设背景色或是填充 o.Charts(0).PlotArea.Interior.SetSolid chart_bgcolor_ ''加上图表的标题 o.HasChartSpaceTitle = True set cst=o.ChartSpaceTitle cst.Caption = chartCaption_ cst.Font.Color = chartCaption_fontColor_ cst.Font.Italic = False cst.Font.Name = "Arial" cst.Font.Size = 12 cst.Font.Underline = c.owcUnderlineStyleSingle ''添加数据 cht.SetData c.chDimCategories, c.chDataLiteral, categories_ cht.SeriesCollection(0).SetData c.chDimValues, c.chDataLiteral, values_ ''直条的背景色进行设定 set sc=o.Charts(0).SeriesCollection(0) sc.Interior.Color=Interior_Color_ ''直条上的显示设置 sc.Caption=Caption_ set dl = cht.SeriesCollection(0).DataLabelsCollection.Add dl.HasValue = True dl.HasPercentage = False dl.Font.Size = 9 dl.Font.Color = "red" dl.Position = c.chLegendPositionRight dl.NumberFormat = "00.00%" ''左边百分比的属性设置 Set cta = cht.Axes(c.chAxisPositionLeft) cta.Font.Size = 9 cta.NumberFormat = "0.0%" cta.MajorUnit = 0.1 end sub ''多系列矩形图 ''chart_bgColor_图表的背景颜色 ''chartCaption_图表的标题 ''chartCaption_fontColor_图表标题颜色 ''color_颜色数组 ''caption_名称数组 ''categories_名称数组 ''values_值数组 public sub serBar(chart_bgColor_,chartCaption_,chartCaption_fontColor_,color_,caption_,categories_,values_) o.Clear o.Charts.Add Set c = o.Constants ''图表的类型 o.Charts(0).type=c.chChartTypeColumnClustered ''给绘图区加背景色 o.Charts(0).PlotArea.Interior.SetSolid chart_bgColor_ ''''加上图表的标题 o.HasChartSpaceTitle = True o.ChartSpaceTitle.Caption = chartCaption_ ''标题的属性 o.ChartSpaceTitle.Font.Color = chartCaption_fontColor_ o.ChartSpaceTitle.Font.Italic = False o.ChartSpaceTitle.Font.Name = "Arial" o.ChartSpaceTitle.Font.Size = 12 o.ChartSpaceTitle.Font.Underline = c.owcUnderlineStyleSingle ''用循环来新增SeriesCollection以及里面的内容 for i=0 to ubound(caption_) valuetemp="" for j = i*(ubound(categories_)+1) to (i+1)*(ubound(categories_)+1)-1 valuetemp = valuetemp & "," & values_(j) next valuearr = split(mid(valuetemp,2),",") o.Charts(0).SeriesCollection.Add o.Charts(0).SeriesCollection(i).Caption = caption_(i) o.Charts(0).SeriesCollection(i).Interior.Color = color_(i) o.Charts(0).SeriesCollection(i).SetData c.chDimCategories, c.chDataLiteral, categories_ o.Charts(0).SeriesCollection(i).SetData c.chDimValues, c.chDataLiteral, valuearr set dl = o.Charts(0).SeriesCollection(i).DataLabelsCollection.Add dl.HasValue = True dl.HasPercentage = False dl.Font.Size = 9 dl.Font.Color = "red" dl.Position = c.chLegendPositionRight dl.NumberFormat = "00.00%" next ''''图例的设定 o.Charts(0).HasLegend = True o.Charts(0).Legend.Font.Size = 9 o.Charts(0).Legend.Position = c.chLegendPositionBottom ''''左边百分比的属性设置 Set cta = o.Charts(0).Axes(c.chAxisPositionLeft) cta.Font.Size = 9 cta.NumberFormat = "0.00%" cta.MajorUnit = 0.1 end sub ''画圆饼图 ''chart_bgColor_绘图区加背景色 ''chartCaption_图表的标题 ''chartCaption_fontColor_图表标题颜色 public sub Pie(chart_bgColor_,chartCaption_,chartCaption_fontColor_,Caption_,categories_,values_) o.Clear Set cht = o.Charts.Add Set c = o.Constants cht.Type = c.chChartTypePie3d ''给绘图区加背景色 o.Charts(0).PlotArea.Interior.SetSolid chart_bgColor_ cht.ExtrudeAngle = 90 cht.ChartDepth = 169 cht.AspectRatio = 120 cht.Rotation =180 cht.Inclination=70 o.HasChartSpaceTitle = True o.ChartSpaceTitle.Caption = chartCaption_ o.ChartSpaceTitle.Font.Color = chartCaption_fontColor_ o.ChartSpaceTitle.Font.Name = "Arial" o.ChartSpaceTitle.Font.Size = 12 o.ChartSpaceTitle.Font.Underline = c.owcUnderlineStyleSingle cht.HasLegend = True cht.Legend.Font.Size = 9 cht.Legend.Position = c.chLegendPositionBottom cht.SetData c.chDimCategories, c.chDataLiteral, categories_ cht.SeriesCollection(0).SetData c.chDimValues, c.chDataLiteral, values_ set sc=o.Charts(0).SeriesCollection(0) sc.Caption=Caption_ Set dl = cht.SeriesCollection(0).DataLabelsCollection.Add dl.Separator = ":" dl.HasValue = false dl.HasSeriesName = false dl.HasCategoryName=true dl.HasPercentage = true dl.Font.Size = 9 dl.Font.Color = "red" dl.NumberFormat = "00.00%" end sub ''拆线图 ''chart_bgColor_绘图区加背景色 ''chartCaption_图表的标题 ''chartCaption_fontColor_图表标题颜色 public sub line(chart_bgColor_,chartCaption_,chartCaption_fontColor_,Caption_,categories_,values_) o.Clear Set cht = o.Charts.Add Set c = o.Constants cht.Type = c.chChartTypeLineMarkers ''给绘图区加背景色 o.Charts(0).PlotArea.Interior.SetSolid chart_bgColor_ o.HasChartSpaceTitle = True o.ChartSpaceTitle.Caption = chartCaption_ o.ChartSpaceTitle.Font.Color = chartCaption_fontColor_ o.ChartSpaceTitle.Font.Name = "Arial" o.ChartSpaceTitle.Font.Size = 12 o.ChartSpaceTitle.Font.Underline = c.owcUnderlineStyleSingle cht.SetData c.chDimCategories, c.chDataLiteral, categories_ cht.SeriesCollection(0).SetData c.chDimValues, c.chDataLiteral, values_ set sc=o.Charts(0).SeriesCollection(0) sc.Caption=Caption_ Set dl = cht.SeriesCollection(0).DataLabelsCollection.Add dl.HasValue = True dl.HasPercentage = False dl.Font.Size = 9 dl.Font.Color = "red" Set categoryAxis = cht.Axes(c.chAxisPositionBottom) categoryAxis.Font.Size = 9 Set categoryAxis = cht.Axes(c.chAxisPositionLeft) categoryAxis.Font.Size = 9 end sub ''多系列拆线图 ''chart_bgColor_图表的背景颜色 ''chartCaption_图表的标题 ''chartCaption_fontColor_图表标题颜色 ''color_颜色数组 ''caption_名称数组 ''categories_名称数组 ''values_值数组 public sub serLine(chart_bgColor_,chartCaption_,chartCaption_fontColor_,color_,SeriesNames_,categories_,values_) o.Clear Set cht = o.Charts.Add Set c = o.Constants ''设置图表类型 cht.Type = c.chChartTypeLineMarkers ''给绘图区加背景色 o.Charts(0).PlotArea.Interior.Color=chart_bgColor_ ''加上标题 o.HasChartSpaceTitle = True o.ChartSpaceTitle.Caption = chartCaption_ o.ChartSpaceTitle.Font.Color = chartCaption_fontColor_ o.ChartSpaceTitle.Font.Name = "Arial" o.ChartSpaceTitle.Font.Size = 12 ''''添加数据 cht.SetData c.chDimSeriesNames, c.chDataLiteral, SeriesNames_ cht.SetData c.chDimCategories, c.chDataLiteral, Categories_ set categoryAxis = cht.Axes(c.chAxisPositionBottom) categoryAxis.Font.Size = 9 Set categoryAxis = cht.Axes(c.chAxisPositionLeft) categoryAxis.Font.Size = 9 for i = 0 to ubound(SeriesNames_) valuetemp = "" for j = i*(ubound(Categories_)+1) to (i+1)*(ubound(Categories_)+1)-1 valuetemp = valuetemp & "," & values_(j) next valuearr = split(mid(valuetemp,2),",") cht.SeriesCollection(i).SetData c.chDimValues, c.chDataLiteral, valuearr cht.SeriesCollection(i).Line.Color = color_(i) cht.SeriesCollection(i).Line.Weight = c.owcLineWeightThin cht.SeriesCollection(i).Marker.Style = c.chMarkerStyleDiamond cht.SeriesCollection(i).Interior.Color = color_(i) Set dl = cht.SeriesCollection(i).DataLabelsCollection.Add dl.HasValue = true dl.HasPercentage = false dl.Font.Size = 9 dl.font.color="red" next end sub ''清除图型 public sub clear() o.Clear end sub end class 使 |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
关于vbscript ms owc 封裝代码的所有评论