OWC11 实例

项目中的工程模块需要用到图表来显示数据,后来选中了“OWC11”,效果如下:

owc11.gif

CS代码:
None.gif      void  ToPrint( string  categoryStr,  string [] valueArr,  string [] titleArr,  string [] colorArr)
ExpandedBlockStart.gifContractedBlock.gif    
dot.gif {
InBlock.gif        
// 新建一个绘图空间
InBlock.gif
        ChartSpace objCSpace = new ChartSpace();
InBlock.gif
InBlock.gif
InBlock.gif        
// 在绘图空间中新建一个图表
InBlock.gif
        ChChart objChart = objCSpace.Charts.Add(0);
InBlock.gif        
//objChart.Type = ChartChartTypeEnum.chChartTypeColumnClustered3D; // 指定图表的类型为3D柱状
InBlock.gif
        objChart.Type = ChartChartTypeEnum.chChartTypeColumnClustered; // 平面柱状
InBlock.gif
        objChart.HasLegend = true// 指定图表是否需要图例
InBlock.gif
InBlock.gif        
// 标题
InBlock.gif
        objChart.HasTitle = true;
InBlock.gif        objChart.Title.Caption 
= "年度水量消耗统计";
InBlock.gif        objChart.Title.Font.Size 
= 9;
InBlock.gif        objChart.Title.Font.Name 
= "宋体";
InBlock.gif        objChart.Title.Font.Bold 
= true;
InBlock.gif
InBlock.gif        objChart.PlotArea.Interior.Color 
= "#C0C0C0"// 绘图区的背景颜色
InBlock.gif
        objChart.PlotArea.Floor.Interior.Color = "#888888"// 绘图区的底色
InBlock.gif

InBlock.gif        objChart.Legend.Font.Size 
= 9// 图例的字体
InBlock.gif
InBlock.gif
InBlock.gif
InBlock.gif
InBlock.gif        
// X, Y 轴的图示属性
InBlock.gif        
//objChart.Axes[0].HasTitle = true;
InBlock.gif        
//objChart.Axes[0].Title.Caption = "X:月";
InBlock.gif        
//objChart.Axes[0].Title.Font.Size = 9;
InBlock.gif        
//objChart.Axes[1].HasTitle = true;
InBlock.gif        
//objChart.Axes[1].Title.Caption = "Y:量";
InBlock.gif        
//objChart.Axes[1].Title.Font.Size = 9;
InBlock.gif

InBlock.gif
InBlock.gif        
for (int i = 0; i < valueArr.Length; i++)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
// 在图表中添加一个数据系列
InBlock.gif
            ChSeries objSeries = objChart.SeriesCollection.Add(i);
InBlock.gif            objSeries.SetData(ChartDimensionsEnum.chDimSeriesNames, ChartSpecialDataSourcesEnum.chDataLiteral.GetHashCode(), titleArr[i]);
InBlock.gif            objSeries.SetData(ChartDimensionsEnum.chDimCategories, ChartSpecialDataSourcesEnum.chDataLiteral.GetHashCode(), categoryStr);
InBlock.gif            objSeries.SetData(ChartDimensionsEnum.chDimValues, ChartSpecialDataSourcesEnum.chDataLiteral.GetHashCode(), valueArr[i]);
InBlock.gif            objSeries.Interior.Color 
= colorArr[i]; // 柱子内部的颜色
InBlock.gif
            objSeries.GapWidth = 300// 柱子之间的间隙
InBlock.gif

InBlock.gif            ChDataLabels objDataLabels 
= objChart.SeriesCollection[i].DataLabelsCollection.Add();
InBlock.gif            objDataLabels.HasValue 
= false// 柱子上面的数字是否显示
InBlock.gif
            objDataLabels.Font.Color = "Black"// 柱子上面的数字颜色是黑色的
ExpandedSubBlockEnd.gif
        }

InBlock.gif
InBlock.gif        
object objPic = objCSpace.GetPicture("GIF"700300);
InBlock.gif
InBlock.gif        Response.Buffer 
= true;
InBlock.gif        Response.ContentType 
= "image/gif";
InBlock.gif        Response.BinaryWrite((
byte[])objPic);
InBlock.gif        Response.End();
ExpandedBlockEnd.gif    }

None.gif


调用:

ExpandedBlockStart.gif ContractedBlock.gif          string [] categoryArr  =   new   string []  dot.gif "1月份""2月份""3月份""4月份""5月份""6月份" } ;
None.gif        
string  categoryStr  =   string .Join( " \t " , categoryArr);
None.gif
ExpandedBlockStart.gifContractedBlock.gif        
string [] valueArr1  =   new   string []  dot.gif "3832""3167""3575""3816""2651""3494" } ;
ExpandedBlockStart.gifContractedBlock.gif        
string [] valueArr2  =   new   string []  dot.gif "17627.2""14568.2""12194.6""16445""17553.6""16072.4" } ;
ExpandedBlockStart.gifContractedBlock.gif        
string [] valueArr3  =   new   string []  dot.gif "5748""4750.5""3976.5""5362.5""5724""5241" } ;
ExpandedBlockStart.gifContractedBlock.gif        
string [] valueArr4  =   new   string []  dot.gif "23375.2""19318.7""16171.1""21807.5""23277.6""21313.4" } ;
None.gif        
string  valueStr1  =   string .Join( " \t " , valueArr1);
None.gif        
string  valueStr2  =   string .Join( " \t " , valueArr2);
None.gif        
string  valueStr3  =   string .Join( " \t " , valueArr3);
None.gif        
string  valueStr4  =   string .Join( " \t " , valueArr4);
ExpandedBlockStart.gifContractedBlock.gif        
string [] valueArr  =   new   string []  dot.gif { valueStr1, valueStr2, valueStr3, valueStr4 } ;
None.gif
ExpandedBlockStart.gifContractedBlock.gif        
string [] titleArr  =   new   string []  dot.gif "消耗量m3""水费(元)""污水费(元)""合计(元)" } ;
None.gif
ExpandedBlockStart.gifContractedBlock.gif        
string [] colorArr  =   new   string []  dot.gif "#9999FF""#993366""#FFFFCC""#CCFFFF" } ;
None.gif
None.gif        ToPrint(categoryStr, valueArr, titleArr, colorArr);
None.gif

转载于:https://www.cnblogs.com/jeky/archive/2007/02/11/647638.html

Retrieving the COM class factory for component with CLSID {0002E55D-0000-0000-C000-000000000046} failed due to the following error: 80040154. 收藏 Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID {0002E55D-0000-0000-C000-000000000046} failed due to the following error: 80040154. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [COMException (0x80040154): Retrieving the COM class factory for component with CLSID {0002E55D-0000-0000-C000-000000000046} failed due to the following error: 80040154.] GraphPage.Page_Load(Object sender, EventArgs e) +1097 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35 System.Web.UI.Control.OnLoad(EventArgs e) +99 System.Web.UI.Control.LoadRecursive() +50 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627 -------------------------------------------------------------------------------- Version Information: Microsoft .NET Framework Version:2.0.50727.3082; ASP.NET Version:2.0.50727.3082 请大家帮忙 谢谢 Server Error in '/' Application. -------------------------------------------------------------------------------- Retrieving the COM class factory for component with CLSID {0002E55D-0000-0000-C000-000000000046} failed due to the following error: 80040154.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值