Asp.net饼图如何在图例和yvaluemember中显示不同的值

时间:2012-10-22 07:25:23

标签: c# asp.net charts pie-chart

以下是代码: 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();

我的问题是我想在图例中显示不同的值,并在实际的饼图区域标签中显示不同的值。我该怎么做?

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

Education包含我想要在图表区域中显示的整数值。

请帮助。

1 个答案:

答案 0 :(得分:4)

Series属性设置为IsValueShownAsLabel="true"

相关问题