惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LINUX DO - 最新话题
G
Google Developers Blog
J
Java Code Geeks
The GitHub Blog
The GitHub Blog
F
Full Disclosure
H
Help Net Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Vercel News
Vercel News
酷 壳 – CoolShell
酷 壳 – CoolShell
Recent Announcements
Recent Announcements
Help Net Security
Help Net Security
The Hacker News
The Hacker News
IT之家
IT之家
Y
Y Combinator Blog
Martin Fowler
Martin Fowler
L
Lohrmann on Cybersecurity
C
CERT Recently Published Vulnerability Notes
V
Visual Studio Blog
博客园 - 聂微东
Hacker News: Ask HN
Hacker News: Ask HN
H
Hacker News: Front Page
Know Your Adversary
Know Your Adversary
Security Latest
Security Latest
Security Archives - TechRepublic
Security Archives - TechRepublic
Simon Willison's Weblog
Simon Willison's Weblog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
T
Troy Hunt's Blog
Last Week in AI
Last Week in AI
Schneier on Security
Schneier on Security
N
News and Events Feed by Topic
博客园 - 【当耐特】
有赞技术团队
有赞技术团队
AWS News Blog
AWS News Blog
Blog — PlanetScale
Blog — PlanetScale
博客园_首页
Google DeepMind News
Google DeepMind News
Cloudbric
Cloudbric
N
News | PayPal Newsroom
A
About on SuperTechFans
S
Schneier on Security
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Hugging Face - Blog
Hugging Face - Blog
M
MIT News - Artificial intelligence
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
雷峰网
雷峰网
T
The Exploit Database - CXSecurity.com
罗磊的独立博客
K
Kaspersky official blog
The Cloudflare Blog
I
Intezer

博客园 - asheng

JavaScript UI选型及Jquery EasyUI使用经验谈 云计算风险识别 五年之痒 敏捷软件开发 嫁给程序员吧!!! Cute Editor for .NET v6.4 Java与.NET的WebServices相互调用 用户体验5大要素 【转】LINQ To XML 入门(3) 【转】LINQ To XML 入门(2) 【转】LINQ To XML 入门(1) 学写Windows Service 微软发布ASP.NET MVC框架1.0正式版 Web定时任务 CSS分类编写方法 JS中错误处理(2) JS中错误处理(1) Log4Net 好员工为什么会变坏
OWC画图表 - asheng - 博客园
asheng · 2008-04-24 · via 博客园 - asheng

由于需要用,自己查一些资料,写的一个OWC画图表的方法,希望有用

/// <summary>
    
/// 生成图表
    
/// </summary>
    
/// <param name="strSeriesName">图表名称</param>
    
/// <param name="strCategory">类型</param>
    
/// <param name="strValue"></param>
    
/// <param name="Caption">图标标题</param>
    
/// <param name="Type">类型</param>
    
/// <param name="Longth">图片长</param>
    
/// <param name="Width">图片宽</param>

    public string GengerateChart(string strSeriesName, string strCategory, string strValue, string Caption, string Type, int Longth, int Width)
    
{
        
string chartSeriesName = strSeriesName;
        
string chartCategory = strCategory;
        
string chartValue = strValue;
        
string chartCaption = Caption;
        
string chartType = Type;
        
int chartLongth = Longth;
        
int chartWidth = Width;

        
//创建ChartSpace对象来放置图表
        ChartSpace laySpace = new ChartSpaceClass();

        
//在ChartSpace对象中添加图表
        ChChart InsertChart = laySpace.Charts.Add(0);
        
switch (chartType)
        
{
            
case "Pie"://饼状图
                {
                    InsertChart.Type 
= ChartChartTypeEnum.chChartTypePie;
                    InsertChart.HasLegend 
= true;
                    InsertChart.HasTitle 
= true;//为图表添加标题
                    InsertChart.Title.Caption = chartCaption;//标题名称
                    InsertChart.Title.Font.Color = "Blue";
                    InsertChart.Title.Font.Name 
= "黑体";
                    
//指定图表是否需要图例标注
                    InsertChart.HasLegend = true;


                }

                
break;

            
case "Line"://折线图
                {
                    InsertChart.Type 
= ChartChartTypeEnum.chChartTypeLine;
                    
//指定图表是否需要图例标注
                    InsertChart.HasLegend = true;

                    InsertChart.HasTitle 
= true;//为图表添加标题
                    InsertChart.Title.Caption = chartCaption;//标题名称
                    InsertChart.Title.Font.Color = "Blue";
                    InsertChart.Title.Font.Name 
= "黑体";
                }

                
break;
            
case "BarClustered"://条形图
                {
                    InsertChart.Type 
= ChartChartTypeEnum.chChartTypeBarClustered;
                    
//指定图表是否需要图例标注
                    InsertChart.HasLegend = true;

                    InsertChart.HasTitle 
= true;//为图表添加标题
                    InsertChart.Title.Caption = chartCaption;//标题名称
                    InsertChart.Title.Font.Color = "Blue";
                    InsertChart.Title.Font.Name 
= "黑体";
                }

                
break;
            
case "Area"://面积图
                {
                    InsertChart.Type 
= ChartChartTypeEnum.chChartTypeArea;
                    
//指定图表是否需要图例标注
                    InsertChart.HasLegend = true;
                    InsertChart.HasTitle 
= true;//为图表添加标题
                    InsertChart.Title.Caption = chartCaption;//标题名称
                    InsertChart.Title.Font.Color = "Blue";
                    InsertChart.Title.Font.Name 
= "黑体";
                }

                
break;
        }


        
//添加一个series系列
        InsertChart.SeriesCollection.Add(0);

        
//给定series系列的名字
        InsertChart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimSeriesNames, +(int)ChartSpecialDataSourcesEnum.chDataLiteral, chartSeriesName);

        
//给定分类
        InsertChart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimCategories, +(int)ChartSpecialDataSourcesEnum.chDataLiteral, chartCategory);

        
//给定值
        InsertChart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimValues, (int)ChartSpecialDataSourcesEnum.chDataLiteral, chartValue);

        
if (chartType == "Pie")
        
{
            
//增加数据值标签
            InsertChart.SeriesCollection[0].DataLabelsCollection.Add();

            InsertChart.SeriesCollection[
0].DataLabelsCollection[0].HasValue = true;
            InsertChart.SeriesCollection[
0].DataLabelsCollection[0].HasPercentage = true;
        }


        
//输出文件.
        string imageName = System.DateTime.Now.ToShortDateString().Replace("-""").Trim() + System.DateTime.Now.ToLongTimeString().Replace(":""").Trim();
        imageName 
= imageName + System.DateTime.Now.Millisecond + "Chart.gif";
        
string strAbsolutePath = (Server.MapPath(".")) + "\\" + imageName;
        laySpace.ExportPicture(strAbsolutePath, 
"GIF", chartLongth, chartWidth);

        
//创建GIF文件的相对路径.
        string strRelativePath = "./" + imageName;

        
//把图片添加到placeholder中,并在页面上显示
        string strImageTag = "<IMG SRC='" + strRelativePath + "'/>";
        
//this.PlaceHolder1.Controls.Add(new LiteralControl(strImageTag));
        return strRelativePath;


    }

效果图如下:

//****************************************
  by: Amen cnblogs博客  转载请注明出处
//****************************************