图表从数据表中添加了3个系列的多个系列

时间:2018-02-22 07:36:14

标签: c# sql winforms charts

  SqlDataAdapter da = new SqlDataAdapter("select p.mn as dta,p.quan as 
    quan,i.quan,iss.quan from purchase p join inward i on p.mn=i.nm join issue iss on p.mn = iss.nm where p.pid = 4 and i.pid = 4 and iss.pid = 4", con);
    DataTable dt = new DataTable();
    da.Fill(dt);
    chart1.DataSource = dt;           
    chart1.Series["Purchase"].XValueMember = "mn";
  chart1.Series["Purchase"].YValueMembers ="quan";

我试了但是没有生成图表

enter image description here

1 个答案:

答案 0 :(得分:0)

设置DataSource后,您还需要绑定:

chart1.DataBind();

您还需要为所有其他XValueMember设置YValueMemberSeries

只要添加或更改了数据点,就应该致电DataBind()