首先添加引用:
using DevExpress.XtraCharts;
具体代码如下:
DataTable dt = new DataTable();
dt.Columns.Add("week", typeof(string));
dt.Columns.Add("money", typeof(decimal));
dt.Rows.Add("周一", 1);
dt.Rows.Add("周二", 2);
dt.Rows.Add("周三", 3);
dt.Rows.Add("周四", 4);
dt.Rows.Add("周五", 5);
dt.Rows.Add("周六", 6);
dt.Rows.Add("周日", 7);
Series SI = new Series("money", ViewType.Bar);
for (int i = 0; i < dt.Rows.Count; i++)
{
SeriesPoint point = new SeriesPoint(dt.Rows[i]["week"].ToString(), Convert.ToDouble(dt.Rows[i]["money"].ToString()));
SI.Points.Add(point);
}
this.chartControl1.Series.Add(SI);