zoukankan      html  css  js  c++  java
  • Dev 饼图

    // 添加引用命名空间
    using DevExpress.XtraCharts;
    
    /*
     *具体步骤:(1)先构建饼图对象的数据源DataTable
     *            (2)再设置饼图对象的相关参数
     *            (3)饼图空间添加创建的饼图对象
     *
     *  总体结构:dataTable ->  SeriesPoint ->  Series -> chartControl
     *  参考网址:http://blog.csdn.net/kanhuadeng/article/details/50783650
     */
    
     // 代码:
     
     // 构建饼图对象的数据源table
     DataTable table = new DataTable("Table1"); 
    
                // 先构建列
                table.Columns.Add("Name", typeof(String));  
                table.Columns.Add("Value", typeof(Int32)); 
    
                // 利用行填充每一列
                table.Rows.Add(new object[] { "", 1});  
                table.Rows.Add(new object[] { "", 2});  
                table.Rows.Add(new object[] { "", 3});  
                table.Rows.Add(new object[] { "", 4});  
                table.Rows.Add(new object[] { "", 5});  
                table.Rows.Add(new object[] { "", 6});  
                table.Rows.Add(new object[] { "", 7});  
                table.Rows.Add(new object[] { "", 8});
    
    // 实例化饼图对象
    Series pieSeries = new Series("测试", ViewType.Pie);
    
    
    SeriesPoint pSeriesPoint;
    
    // 遍历DataTable,将每一个行对象绑定到pSeriesPoint上
    for(int i = 0; i < table.Rows.Cout;i++)
    {
        // 找到DT中Name字段和Vlaue的数据
        string name = table.Rows[i]["Name"].ToString();
        double value = Convert.ToDouble(table.Rows[i]["Value"].ToString();
        
        // 利用pSeriesPoint组织好数据
        pSeriesPoint = new SeriesPoint(name, value);
        
        pieSeries.Points.add(pSeriesPoint);
    }
    
    // 设置新建的饼图对象
    pieSeries.LegendPointOptions.PointView = PointView.ArgumentAndValues;  
    pieSeries.Label.Font = new Font("宋体", 8);  
    pieSeries.Label.LineLength = 50;  
    
    //设置数据源
    pieSeries.DataSource = table; 
    
    // 饼图空间添加 新建的饼图对象
    chartControl1.Series.Add(pieSeries);
  • 相关阅读:
    socket
    IPv4 IPv6
    2变量与基本类型之const限定符
    15面向对象程序设计
    深度探索C++对象模型之第三章:数据语义学
    线段树(成段更新) 之 poj 3468 A Simple Problem with Integers
    USACO 之 Section 1.1 Ad Hoc Problems (已解决)
    构造字符串 之 hdu 4850 Wow! Such String!
    模拟 + 最短路 之 hdu 4849 Wow! Such City!
    简单题(需要注意一个细节) 之 hdu 4847 Wow! Such Doge!
  • 原文地址:https://www.cnblogs.com/MaFeng0213/p/5946618.html
Copyright © 2011-2022 走看看