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

标签 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

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

请帮忙。

最佳答案

Series 属性设置为 IsValueShownAsLabel="true"

关于c# - Asp.net饼图如何在图例和yvaluemember中显示不同的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13006730/

相关文章:

c# - 编写一个可以等待的异步进程

c# - 字符串未被识别为有效的日期时间,当它出现时?

c# - 捆绑 - 应用程序路径错误

reporting-services - 有没有办法在运行时更改 sql 报告图表类型和子类型?

笛卡尔坐标系中的 JavaScript/JSF2 数据(矩形)可视化

c# - 为什么 "async Task"方法的返回值不是任务

c# - 解析方法重载时有优先级吗?

c# - 如何获得方法参数的名称?

asp.net - 如何在 LINQ 中使用 IN 运算符

javascript - 设置 ChartJs 中所有图表通用的通用标签和背景颜色