代码如下: ASPX代码
<asp:Chart ID="Chart1" runat="server" Width="414px" Height="396px" BackColor="Transparent"
Palette="SeaGreen">
<Series>
<asp:Series Name="Education" XValueMember="State" YValueMembers="Education" IsVisibleInLegend="true"
ChartType="Pie" Color="255, 255, 128">
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1" Area3DStyle-Enable3D="true">
<AxisX LineColor="DarkGray">
<MajorGrid LineColor="LightGray" />
</AxisX>
<AxisY LineColor="DarkGray">
<MajorGrid LineColor="LightGray" />
</AxisY>
<Area3DStyle Enable3D="True" WallWidth="5" LightStyle="Realistic"></Area3DStyle>
</asp:ChartArea>
</ChartAreas>
<Legends>
<asp:Legend>
</asp:Legend>
</Legends>
</asp:Chart>
CS代码
var table = new DataTable();
table.Columns.Add("State", typeof(string));
table.Columns.Add("Education", typeof(long));
table.Columns.Add("Lbl");
var row = table.NewRow();
row["State"] = "Gujarat";
row["Education"] = 791;
table.Rows.Add(row);
row = table.NewRow();
row["State"] = "Delhi";
row["Education"] = 978;
table.Rows.Add(row);
row = table.NewRow();
row["State"] = "Panjab";
row["Education"] = 1650;
table.Rows.Add(row);
Chart1.DataSource = table;
Chart1.DataBind();
我的问题是我想在图例中显示不同的值,在实际的饼图区域标签中显示不同的值。我该怎么做?
我尝试了各种组合,但没有得到我想要的结果,即图例应该包含一列中的值和另一列中的饼图值。这是我想要的图片
列教育
包含我想要在图表区域中显示的整数值。
请帮忙。
最佳答案
将 Series
属性设置为 IsValueShownAsLabel="true"
关于c# - Asp.net饼图如何在图例和yvaluemember中显示不同的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13006730/