protected
void
Page_Load(object
sender, EventArgs e)
{
DataTable dt = default(DataTable);
dt = CreateDataTable();
//
设置图表的数据源
Chart1.DataSource = dt;
//
设置图表
Y
轴对应项
Chart1.Series[0].YValueMembers = "Volume1";
Chart1.Series[1].YValueMembers = "Volume2";
//
设置图表
X
轴对应项
Chart1.Series[0].XValueMember = "Date";
//
绑定数据
Chart1.DataBind();
}
private
DataTable CreateDataTable()
{
//Create a DataTable as the data source of
the Chart control
DataTable dt = new
DataTable();
//Add three columns to the DataTable
dt.Columns.Add("Date");
dt.Columns.Add("Volume1");
dt.Columns.Add("Volume2");
DataRow dr;
//Add rows to the table which contains some
random data for demonstration
dr = dt.NewRow();
dr["Date"] = "Jan";
dr["Volume1"] = 3731;
dr["Volume2"] = 4101;
dt.Rows.Add(dr);
dr = dt.NewRow();
dr["Date"] = "Feb";
dr["Volume1"] = 6024;
dr["Volume2"] = 4324;
dt.Rows.Add(dr);
dr = dt.NewRow();
dr["Date"] = "Mar";