OWC11绘制双轴图表

private object showPic()
    {
        ChartSpace chartSpace = new ChartSpaceClass();

        //是否显示图例
        chartSpace.HasChartSpaceLegend = true;
        chartSpace.ChartSpaceLegend.Position = ChartLegendPositionEnum.chLegendPositionBottom;
        chartSpace.ChartSpaceLegend.Font.Color = "blue";
        chartSpace.ChartSpaceLegend.Font.Size = 10;

        chartSpace.Border.Color = "white";

        //chartSpace.Interior.

        //chartSpace.Interior.SetPresetGradient(ChartGradientStyleEnum.chGradientHorizontal,
        // ChartGradientVariantEnum.chGradientVariantStart, ChartPresetGradientTypeEnum.chGradientParchment);

        chartSpace.Interior.SetOneColorGradient(ChartGradientStyleEnum.chGradientHorizontal,
                  ChartGradientVariantEnum.chGradientVariantEnd, 0.95, "LightGreen");
        /*設置背景  objChart.SeriesCollection[0].Points[0].Interior.SetTextured("\\images\\add.gif",
                  ChartTextureFormatEnum.chTile,
                  1,
                 ChartTexturePlacementEnum.chFrontSides);
                單色漸變
                 objChart.SeriesCollection[0].Points[1].Interior.SetOneColorGradient(ChartGradientStyleEnum.chGradientFromCenter,
                  ChartGradientVariantEnum.chGradientVariantStart,0.3,"Blue");
                紋理
         * objChart.SeriesCollection[0].Points[3].Interior.SetPatterned(OWC11.ChartPatternTypeEnum.chPatternDiagonalBrick,
             "Red","LightGreen");

         */
        //在ChartSpace对象中添加图表,Add方法返回Chart对象chGradientDaybreak chGradientParchment chGradientSilver
        ChChart chChart = chartSpace.Charts.Add(0);

        //點區域背景
        chChart.PlotArea.Interior.Color = "LightGoldenrodYellow";


        //给定标题
        chChart.HasTitle = true;
        chChart.Title.Caption = "By Day 燒錄產出、嫁動率趨勢";
        chChart.Title.Font.Size = 10;
        chChart.Title.Font.Color = "blue";

        //给定x,y轴的图示说明

        //chChart.Axes[0].HasTitle = true;
        //chChart.Axes[0].Title.Caption = "By Day 燒錄產出、嫁動率趨勢";
        //chChart.Axes[0].Title.Font.Size = 10;
        //chChart.Axes[0].Title.Font.Color = "blue";

        // 刻度數值間隔
        chChart.Axes[1].MajorUnit = 10000;
        chChart.Axes[0].Font.Size = 10;

        chChart.Axes[1].HasTitle = true;
        chChart.Axes[1].Title.Caption = "燒錄需求/實際產出";
        chChart.Axes[1].Title.Font.Size = 10;
        chChart.Axes[1].Title.Font.Color = "blue";
        chChart.Axes[1].HasMajorGridlines = false; // 不顯示格線
        chChart.Axes[1].Font.Size = 10;

 

        //设定图表类型
        chChart.SeriesCollection.Add(0);
        //chChart.Interior.Color = "LightGoldenrodYellow";
        chChart.SeriesCollection[0].Border.Color = "gray";
        chChart.SeriesCollection[0].Type = ChartChartTypeEnum.chChartTypeColumnClustered;  /*柱形并行图*/
        //  chChart.SeriesCollection[0].Type = ChartChartTypeEnum.chChartTypeLineMarkers;

        //系列PG1
        //给定系列的名字

        chChart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimSeriesNames,
            +(int)ChartSpecialDataSourcesEnum.chDataLiteral, "燒錄需求");

        //给定分类
        chChart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimCategories,
            +(int)ChartSpecialDataSourcesEnum.chDataLiteral, "2013/01/01\t2013/01/02\t2013/01/03\t2013/01/04\t");

        //给定系列的值
        chChart.SeriesCollection[0].SetData
            (ChartDimensionsEnum.chDimValues,
            (int)ChartSpecialDataSourcesEnum.chDataLiteral, "40000\t35000\t38000\t42000\t");

 

        //系列PD1
        //给定系列的名字
        chChart.SeriesCollection.Add(1);

        chChart.SeriesCollection[1].Border.Color = "gray";
        chChart.SeriesCollection[1].SetData(ChartDimensionsEnum.chDimSeriesNames,
             (int)ChartSpecialDataSourcesEnum.chDataLiteral, "實際產出");

        //给定分类
        chChart.SeriesCollection[1].SetData(ChartDimensionsEnum.chDimCategories,
              (int)ChartSpecialDataSourcesEnum.chDataLiteral, "2013/01/01\t2013/01/02\t2013/01/03\t2013/01/04\t");


        //给定系列的值
        chChart.SeriesCollection[1].SetData
            (ChartDimensionsEnum.chDimValues,
             (int)ChartSpecialDataSourcesEnum.chDataLiteral, "38000\t34500\t40000\t32000\t");

        //節點數值格式、是否顯示
        chChart.SeriesCollection[0].DataLabelsCollection.Add();
        chChart.SeriesCollection[1].DataLabelsCollection.Add();
        chChart.SeriesCollection[0].DataLabelsCollection[0].HasValue = true;
        chChart.SeriesCollection[1].DataLabelsCollection[0].HasValue = true;
        chChart.SeriesCollection[0].DataLabelsCollection[0].NumberFormat = "#,###";
        chChart.SeriesCollection[1].DataLabelsCollection[0].NumberFormat = "#,###";
        chChart.SeriesCollection[0].DataLabelsCollection[0].Font.Size = 10;
        chChart.SeriesCollection[1].DataLabelsCollection[0].Font.Size = 10;


        /*折线图*/
        //再增加一个系列Y(右)
        ChSeries chSeries = chChart.SeriesCollection.Add(2);

        //指定图表类型
        chSeries.Type = ChartChartTypeEnum.chChartTypeLineMarkers;
        chSeries.Ungroup(true);

        ChAxis chAxis = chChart.Axes.Add(chSeries.get_Scalings(ChartDimensionsEnum.chDimValues));
        chAxis.Position = ChartAxisPositionEnum.chAxisPositionRight;
        chAxis.NumberFormat = "0.00%";
        chAxis.HasMajorGridlines = false;
        chAxis.HasTitle = true;
        chAxis.Title.Caption = "達成率";
        chAxis.Title.Font.Size = 10;
        chAxis.Title.Font.Color = "blue";
        chAxis.Title.Font.Name = "Arial";
        chAxis.Font.Size = 10;
        chAxis.MajorUnit = 0.2;
        chSeries.Marker.Style = ChartMarkerStyleEnum.chMarkerStyleCircle;


        chSeries.DataLabelsCollection.Add();
        chSeries.DataLabelsCollection[0].NumberFormat = "0.00%";
        chSeries.DataLabelsCollection[0].Font.Size = 10;
        chSeries.Line.Color = "red";

        chSeries.Line.DashStyle = ChartLineDashStyleEnum.chLineSolid;

        chSeries.SetData(ChartDimensionsEnum.chDimSeriesNames,
            +(int)ChartSpecialDataSourcesEnum.chDataLiteral, "達成率");

        //给定系列的值
        chSeries.SetData
            (ChartDimensionsEnum.chDimValues,
            (int)ChartSpecialDataSourcesEnum.chDataLiteral, "0.9\t0.998\t1.5\t1.22\t");

        //输出成GIF文件.
        string strAbsolutePath = (Server.MapPath(".")) + "/test.jpg";

        Response.Write(strAbsolutePath);
        chartSpace.ExportPicture(strAbsolutePath, "GIF", 190 * 4, 450);

        //Response.Write(strAbsolutePath);
        //创建GIF文件的相对路径.
        string strRelativePath = "./test.jpg";

        //加载图片
        dd.ImageUrl = strRelativePath;

        return chartSpace.GetPicture("gif", 190 * 4, 450);

    }

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、付费专栏及课程。

余额充值