我正在尝试使用饼图,我希望在上面显示 2 个区域。但是对于我下面的代码,只显示了最后一个。
Code behind:
protected void Page_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add("status");
dt.Columns.Add("count");
DataRow dr = dt.NewRow();
dr["status"] = "safe";
dr["count"] = loadChart("safe");
dt.Rows.Add(dr);
dr["status"] = "unsafe";
dr["count"] = loadChart("unsafe");
dr = dt.NewRow();
dt.Rows.Add(dr);
Chart1.DataSource = dt;
Chart1.Series[0].XValueMember = "status";
Chart1.Series[0].YValueMembers = "count";
Chart1.DataBind();
}
标记:
<asp:Chart ID="Chart1" runat="server">
<series>
<asp:Series ChartType="Pie" Name="Series1">
</asp:Series>
</series>
<chartareas>
<asp:ChartArea Name="ChartArea1">
</asp:ChartArea>
</chartareas>
</asp:Chart>
输出:
我也想看看安全的部分。我有它的价值。如何解决这个问题?