Jump to content
Software FX Community

Pie / Bar chart legend values


Mick
 Share

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...