C#Winform中运用DevExpress提供的ChartControl控件绘制饼状图

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/kanhuadeng/article/details/50783650

首先添加引用:

using DevExpress.XtraCharts;

 

具体代码如下:

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);
            //_pieSeries.ValueDataMembers[0] = "Value";
            //_pieSeries.ArgumentDataMember = "Name";
            SeriesPoint point;
            for (int i = 0; i < table.Rows.Count; i++)
            {
                point = new SeriesPoint(table.Rows[i]["Name"].ToString(), Convert.ToDouble(table.Rows[i]["Value"].ToString()));
                _pieSeries.Points.Add(point);
            }

            _pieSeries.LegendPointOptions.PointView = PointView.ArgumentAndValues;
            _pieSeries.Label.Font = new Font("宋体", 8);
            _pieSeries.Label.LineLength = 50;

            _pieSeries.DataSource = table;
            chartControl1.Series.Add(_pieSeries);


 

展开阅读全文

没有更多推荐了,返回首页