Mick Posted March 24, 2009 Report Share Posted March 24, 2009 How do I set the name of the points in a given series for a pie / bar chart? I have the following code that generates a very simple 10 slice pie chart: public Chart PieChart(){ Chart chart = new Chart(); chart.Gallery = Gallery.Pie; SeriesAttributes series = new SeriesAttributes(); series.Gallery = Gallery.Pie; chart.Series.Add(series); for (int i = 1; i <= 10; i++) chart.Data[0, i-1] = new DataUnit(i); return chart;} How do I make the legend display values of my choosing for the slice names rather than "Point 1," "Point 2," "Point 3" etc ... ? For example, I want the legend to display "A," "B," and "C" instead. Thank you, Mick Quote Link to comment Share on other sites More sharing options...
JuanC Posted March 24, 2009 Report Share Posted March 24, 2009 In a pie chart we use the collection of X axis labels, please also note that DataUnit has implicit converters for doubles and dates so you do not need to manually create them. LabelCollection axisLabels = chart.AxisX.Labels.Items;for (int i = 1; i <= 10; i++) { chart.Data[0, i - 1] = i; axisLabels[i - 1] = "P" + i.ToString();} Regards, JuanC Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.