我正在尝试基于“名称”的多系列条形图,但它抛出了一个错误
图表区域包含不兼容的图表类型。例如,条形图和柱形图不能存在于同一图表区域中。
这是我的代码:
Chart1.Series["Series1"].ChartType = SeriesChartType.Bar;
Chart1.Series["Series1"]["DrawingStyle"] = "Emboss";
Chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = false;
Chart1.Series["Series1"].IsValueShownAsLabel = true;
DataTable dt = new DataTable();
DataColumn dc;
dc = new DataColumn();
dc.ColumnName = "Name";
dt.Columns.Add(dc);
dc = new DataColumn();
dc.ColumnName = "Question";
dt.Columns.Add(dc);
dc = new DataColumn();
dc.ColumnName = "Marks";
dt.Columns.Add(dc);
DataRow dr;
dr = dt.NewRow();
dr["Name"] = "Fred";
dr["Question"] = "2D";
dr["Marks"] = "54";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr["Name"] = "Bill";
dr["Question"] = "3D";
dr["Marks"] = "66";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr["Name"] = "Rhona";
dr["Question"] = "4D";
dr["Marks"] = "32";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr["Name"] = "Peter";
dr["Question"] = "5D";
dr["Marks"] = "46";
dt.Rows.Add(dr);
var IEtable = (dt as System.ComponentModel.IListSource).GetList();
Chart1.DataBindTable(IEtable, "Name");
标记是,
<asp:Chart ID="Chart1" runat="server" Width="850px" Height="500px" >
<Series>
<asp:series Name="Series1" ChartArea="ChartArea1"></asp:series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1">
</asp:ChartArea>
</ChartAreas>
</asp:Chart>
我正在寻找类似的输出,
其中彩条代表“名称”