1、条形图

界面放置一个dev的控件:chartcontrol,然后设置它的series,如果一个横坐标,比如说:任务ID,对应的三种状态:待验收、已验收、驳回。那么就有三个series,同时先设置好配色,选个漂亮的,对应其他窗体的颜色。剩下就是代码的完成了:

Series s1 = this.chartControl1.Series[0];
s1.DataSource = dt;
            s1.ArgumentDataMember = ConstColumnName.COLUMN_XNAME;
            s1.ValueDataMembers[0] = ConstColumnName.COLUMN_STAYNAME;
            s1.LegendText = ConstColumnName.COLUMN_STAYNAME;

            Series s2 = this.chartControl1.Series[1];
            s2.DataSource = dt;
            s2.ArgumentDataMember = ConstColumnName.COLUMN_XNAME;
            s2.ValueDataMembers[0] = ConstColumnName.COLUMN_ALREADYNAME;
            s2.LegendText = ConstColumnName.COLUMN_ALREADYNAME;

            Series s3 = this.chartControl1.Series[2];
            s3.DataSource = dt;
            s3.ArgumentDataMember = ConstColumnName.COLUMN_XNAME;
            s3.ValueDataMembers[0] = ConstColumnName.COLUMN_REJECTNAME;
            s3.LegendText = ConstColumnName.COLUMN_REJECTNAME;
            ChartTitle _title = new ChartTitle();
            _title.Text = "产品验收近一周统计";
            chartControl1.Titles.Add(_title);

public class ConstColumnName
    {
        //public const string SUM_COLUMN_NAME = "总任务数";
        public const int SUM_COLUMN_NAME = 0;
        public const string IP_COLUMN_NAME = "日期";

        public const string COLUMN_STAYNAME = "待验收";
        public const string COLUMN_ALREADYNAME = "已验收";
        public const string COLUMN_REJECTNAME = "驳回";
        public const string COLUMN_XNAME = "日期";
        //public const string COLUMN_YNAME = "产品数量";
        public const int COLUMN_YNAME = 0;

        public const string PIE_STAYNAME = "待验收";
        public const string PIE_ALREADYNAME = "已验收";
        public const string PIE_REJECTNAME = "驳回";
        //public const string PIE_YNAME = "数量";
        public const int PIE_YNAME=0;
        public const string PIE_XNAME = "状态";
    }
最后显示图

(等到后面再补上)


2、扇形图

设置和条形图都差不多,所以直接上代码了:

 ChartTitle pChartTitle = new ChartTitle();
            pChartTitle.Alignment = StringAlignment.Center;
            pChartTitle.Text = string.Format("产品验收统计({0})", toDate);
            chartControl2.Titles.Add(pChartTitle);
            if (flag == true)
            {
                Series Serices1 = new Series("饼状图", DevExpress.XtraCharts.ViewType.Pie3D);
                chartControl2.Series.Add(Serices1);
                //设置series样式
                Serices1.ArgumentScaleType = ScaleType.Qualitative;//定性的
                Serices1.ValueScaleType = ScaleType.Numerical;//数字类型
                Serices1.PointOptions.PointView = PointView.ArgumentAndValues;//显示表示的信息和数据
                Serices1.PointOptions.ValueNumericOptions.Format = NumericFormat.Percent;//用百分比表示
                Serices1.PointOptions.ValueNumericOptions.Precision = 2;
                Serices1.DataSource = PIEdt;
                Serices1.ArgumentDataMember = ConstColumnName.PIE_XNAME;
                Serices1.ValueDataMembers[0] = "Value";
                
            }

最后显示图

(待补)