• 在C#中使用owc11 画折线图 .


    1.引入owc对象

        可 通过两种途径使C#支持OWC

        A.安装Fontpage2003

       B.从microsoft网站上下载OWC

         http://www.microsoft.com/downloads/details.aspx?familyid=7287252C-402E-4F72-97A5-E0FD290D4B76&displaylang=zh-cn

      在ASP.NET项目的“引入”中的“COM”项中选择“office web Components 11”就可以引入owc对象了。

    2.引用OWC对象

       using Microsoft.Office.Interop.Owc11;

    3.新建 OWC对象

      注:本例用的是一个交叉数据,如下表

    缺陷完成数 缺陷未完成数 缺陷新建数   日期

     20               30                       10                2008-01-01

     50               10                       10                2008-01-02

     20               30                       10                2008-01-01

    本例中要显示每天缺陷完成数、未完数、新建数情况

             ChartSpace mychartSpace = new ChartSpace();
            ChartSpace myspace = new ChartSpace();
            //在图表空间内添加一个图表对象
            ChChart mychart = mychartSpace.Charts.Add(0);
            //设置图表类型,本例使用柱形
            mychart.Type = ChartChartTypeEnum.chChartTypeColumnClustered;
            //设置图表的一些属性
            //是否需要图例
            mychart.HasLegend = true;
            //是否需要主题
            mychart.HasTitle = true;
            //主题内容
            mychart.Title.Caption = "缺陷报告";
            //设置x,y坐标
            mychart.Axes[0].HasTitle = true;
            mychart.Axes[0].Title.Caption = "X轴:天";
            mychart.Axes[1].HasTitle = true;
            mychart.Axes[1].Title.Caption = "Y轴:缺陷数";
            //新建三个系列(相当于数据库交叉的行记录)
            mychart.SeriesCollection.Add(0);mychart.SeriesCollection.Add(0);mychart.SeriesCollection.Add(0);
            mychart.SeriesCollection[0].Caption = "未完成数";
           
            mychart.SeriesCollection[1].Caption = "完成数";
           
            mychart.SeriesCollection[2].Caption = "新建数";
            //设置图表块的属性
            //标题
            string strDate = "";
            string strCreateBugCount = "";
            string strFinishBugCount = "";
            string strUnFinishBugCount = "";
            foreach(var P in "记录集")
            {
                //X坐标的值属性
                strCreateBugCount += P.CreateBugCount.ToString()+"/t";
                strFinishBugCount += P.FinishBugCount.ToString() +"/t";
                strUnFinishBugCount += P.UnFinishBugCount.ToString()+"/t";
                strDate += P.dDate.ToString().Substring(0, 9) + "/t";
            }


            mychart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimCategories, (int)ChartSpecialDataSourcesEnum.chDataLiteral, strDate);
            //y坐标的值属性
            mychart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimValues, (int)ChartSpecialDataSourcesEnum.chDataLiteral, strUnFinishBugCount);
            mychart.SeriesCollection[1].SetData(ChartDimensionsEnum.chDimValues, (int)ChartSpecialDataSourcesEnum.chDataLiteral, strFinishBugCount);
            mychart.SeriesCollection[2].SetData(ChartDimensionsEnum.chDimValues, (int)ChartSpecialDataSourcesEnum.chDataLiteral, strCreateBugCount);
            //Y轴数据
            //生成图片
          mychartSpace.ExportPicture(Server.MapPath(".") + @"/test.jpg", "jpg", 500, 350);
          //加载图片
          Image1.ImageUrl = Server.MapPath(".") + @"/test.jpg";

  • 相关阅读:
    Android Packaging Problem
    Dedecms中{dede:type}标签支持调用父级栏目名称
    DeDecms远程写入漏洞webshell (dedecms漏洞)
    Dedecms 目标仿站的学习视频
    关于前端JS走马灯(marquee)总结
    浏览器端如何使用VConsole.js调试代码?
    Firefox中input元素,不能重新获取焦点函数focus()
    Centos7 systemctl添加自定义系统开机服务
    织梦cms 内容模型 option下拉框 value 分离
    wdcp如何添加反向代理功能
  • 原文地址:https://www.cnblogs.com/superfeeling/p/2936755.html
Copyright © 2020-2023  润新知