zoukankan      html  css  js  c++  java
  • DevExpress中chartControl中实现统计图功能

     public partial class Form1 : DevExpress.XtraEditors.XtraForm
        {
            public Form1()
            {
                InitializeComponent();
                LoadAll();
            }
            public void LoadAll()
            {   //Series  对象表示数据系列,并且存储在 SeriesCollection 类中。
                Series s1 = this.chartControl1.Series[0];//新建一个series类并给控件赋值
                s1.DataSource = ServiceData.GetClassCount();//设置实例对象s1的数据源
                s1.ArgumentDataMember = "class";//绑定图表的横坐标
                s1.ValueDataMembers[0] = "count"; //绑定图表的纵坐标坐标
                s1.LegendText = "人数";//设置图例文字 就是右上方的小框框               
            }
            private void textEdit1_SelectedIndexChanged(object sender, EventArgs e)
            {
                if (this.textEdit1.Text == "--请选择图表类型--")return;
    
                if (this.textEdit1.Text == "漏斗图")
                {
                    DevExpress.XtraCharts.FunnelSeriesView funnelSeriesView1 = new DevExpress.XtraCharts.FunnelSeriesView();
                    this.chartControl1.Series[0].View = funnelSeriesView1;
                }
                if (this.textEdit1.Text == "折线图")
                {
                    DevExpress.XtraCharts.LineSeriesView lineSeriesView1 = new DevExpress.XtraCharts.LineSeriesView();
                    this.chartControl1.Series[0].View = lineSeriesView1;
                }
                if (this.textEdit1.Text == "饼状图")
                {
                    DevExpress.XtraCharts.PieSeriesView pieSeriesView1 = new DevExpress.XtraCharts.PieSeriesView();
                    this.chartControl1.Series[0].View = pieSeriesView1;
                }
                if (this.textEdit1.Text == "柱形图")
                {
                    DevExpress.XtraCharts.StackedBarSeriesView stackedBarSeriesView1 = new DevExpress.XtraCharts.StackedBarSeriesView();
                    this.chartControl1.Series[0].View = stackedBarSeriesView1;
                } 
            }
        }
        //创建测试数据表
        public static class ServiceData
       {
            public static DataTable GetClassCount()
             {
                DataTable dt = new DataTable();
                dt.Columns.Add("class", typeof(string));//年级
                dt.Columns.Add("count", typeof(int));   //人数
                dt.Rows.Add("一年级", 120);
                dt.Rows.Add("二年级", 180);
                dt.Rows.Add("三年级", 890);
                dt.Rows.Add("四年级", 108);
                dt.Rows.Add("五年级", 280);
                dt.Rows.Add("六年级", 320);
                dt.Rows.Add("七年级", 450);
                dt.Rows.Add("八年级", 410);
                dt.Rows.Add("九年级", 230);
                return dt; 
            }
        }

    源文: http://blog.csdn.net/l1158513573/article/details/46728721  DevExpress中chartControl中实现统计图功能

  • 相关阅读:
    docker 实践七:docker-machine
    docker 实践六:dockerfile 详解
    docker 实践五:端口映射和容器互联
    docker 实践四:数据管理
    利用onerror将页面异常图片替换成随即图
    checkbox绑定v-for的数据
    iphone在jsp显示时间会NAN解决办法
    html5文本超过指定行数隐藏显示省略号
    使用vue做移动端瀑布流分页
    java导入Excel表格数据
  • 原文地址:https://www.cnblogs.com/shy1766IT/p/7568539.html
Copyright © 2011-2022 走看看