C# Asp.net饼图如何在图例和yvaluemember中显示不同的值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13006730/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Asp.net pie chart how to display different values in legends and yvaluemember
提问by Ishan
The following is the code: ASPXcode
以下是代码: 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>
CScode
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();
My issue is i want to display different values in legends and different in the actual piechart area labels. How can i do it?
我的问题是我想在图例中显示不同的值,在实际的饼图区域标签中显示不同的值。我该怎么做?
I tried various combinations, but did not get through al i want is the legends should contain values from one column and pie chart values from another column. Here is a picture of what exactly i want

我尝试了各种组合,但没有通过我想要的是图例应该包含来自一列的值和来自另一列的饼图值。这是我想要的照片

Column Educationcontains integer values which i want to display in the chart area.
列Education包含我想在图表区域显示的整数值。
kindly help.
请帮助。
采纳答案by Ishan
Set the Seriesproperty to IsValueShownAsLabel="true"
将Series属性设置为IsValueShownAsLabel="true"

