2

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

客户服务代码

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();

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

我尝试了各种组合,但没有通过我想要的是图例应该包含来自一列的值和来自另一列的饼图值。这是我想要的图片 在此处输入图像描述

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

请帮助。

4

1 回答 1

5

Series属性设置为IsValueShownAsLabel="true"

于 2012-10-22T11:50:30.450 回答