Asp.net pie chart how to display different values in legends and yvaluemember
asp.net, c#, charts, pie-chart
Solution
Set the `Series` property to `IsValueShownAsLabel="true"`
Problem
The following is the code: ASPX code ``` <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 code ``` 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 `Education` contains integer values which i want to display in the chart area. kindly help.