当我在堆积柱状图中将数据与多个系列绑定时,仅显示第一个系列,
而其他系列未显示数据。我遍历系列并动态添加点到系列,但问题仍然存在。我还将 isshowedaslabel
属性设置为 true 但问题不解决请帮助我。
asp 代码:
XValueMember="qno" YValueMembers="option3" ></asp:Series>
<asp:Series Name="Series2" ChartType="StackedColumn"
XValueMember="description" YValueMembers="option3"></asp:Series>
<asp:Series Name="Series3" ChartType="StackedColumn"
XValueMember="option1" YValueMembers="option3"></asp:Series>
<asp:Series Name="Series4" ChartType="StackedColumn"
XValueMember="description" YValueMembers="option3">
</asp:Series>
</Series
>
<ChartAreas>
<asp:ChartArea Name="ChartArea1">
</asp:ChartArea>
</ChartAreas>
</asp:Chart>
**.aspx.cs**
assessdal d = new assessdal();
SqlConnection con = dbconnect.GetConnection();
SqlCommand cmd = new SqlCommand("select assessid, qno ,description,
option1,option2,option3,option4 from assessmenttest", con);
SqlDataReader reder = cmd.ExecuteReader();
Chart2.DataSource = d.showop1();
Chart2.DataBind();
Chart2.Series["Series1"].IsValueShownAsLabel = true;
Chart2.Series["Series2"].IsValueShownAsLabel = true;
Chart2.Series["Series3"].IsValueShownAsLabel = true;
Chart2.Series["Series4"].IsValueShownAsLabel = true;
while (reder.Read())
{
if (reder.HasRows)
{
//Chart2.Series["Series1"].Points.DataBindY(reder, "option3");
//Chart2.Series["Series2"].Points.DataBindY(reder, "option3");
//Chart2.Series["Series3"].Points.DataBindY(reder, "option3");
//Chart2.Series["Series4"].Points.DataBindY(reder, "option3");
}
foreach (Series s in Chart2.Series)
{
s.Points.DataBindY(reder,"option3");
}
}