Jump to content
Software FX Community

"Other" category


Mick

Recommended Posts

Is it possible to group data from separate points/series into an "other" category automatically?

Example:

  • I have I pie with 5slices. I want it to have 3 instead - the top 2 values will be in their own slices, but the last 3 would be grouped into a single slice.

Before:

Posted Image

After:

Posted Image

I seem to remember reading in a developer blog post that this feature was available, but I don't know what to search on in the help/online to find out how to use it.

Thank you,

Mick


Link to comment
Share on other sites

Thank you for pointing me in the right direction,

I looked up the help in the Samples and Resource center and coped the code into a test project. However, it throws an error when starting.

...

  chart1.Gallery = Gallery.Pie;

  chart1.Series.Clear();
  chart1.Series.Add(new SeriesAttributes());
  IList<int> source = new List<int>() { 1, 2, 3, 4, 5 };
  chart1.ItemsSource = source;
  chart1.AxisX.Labels.Items[0] = "A";
  chart1.AxisX.Labels.Items[1] = "B";
  chart1.AxisX.Labels.Items[2] = "C";
  chart1.AxisX.Labels.Items[3] = "D";
  chart1.AxisX.Labels.Items[4] = "E";

// Copied from Samples and Resource Center
  OtherTransform ot = new OtherTransform();
  ot.MinPercentage = 10;
  ot.Text = "Other Countries";
  chart1.DataTransforms.Add(ot);

...

I included a  reference to the ChartFX.WPF.Data dll just in case there was some internal reference to it (because the ChartFX.WPF.Data namespace exists in the ChartFX dll and the ChartFX.WPF.Data dll), but it didn't help.

I'm using version 8.0.3581.26941.

Thank you,

Michael

Link to comment
Share on other sites

Because the DataTransforms work at the binding label we will not pickup your labels if passed manually. Also there is a small bug (will be fixed in future builds) where an exception is thrown if you a pass a collection of numbers instead of passing a collection of objects.

class DataItem

{

  public double Value { get; set; }

  public string Label { get; set; }

}

 

chart1.Gallery = Gallery.Pie;

chart1.Series.Clear();

chart1.Series.Add(new SeriesAttributes("Value"));

chart1.AxisX.Labels.BindingPath = "Label";

List<DataItem> items = new List<DataItem>();

items.Add(new DataItem() { Value = 1, Label = "A" });

items.Add(new DataItem() { Value = 2, Label = "B" });

items.Add(new DataItem() { Value = 3, Label = "C" });

items.Add(new DataItem() { Value = 4, Label = "D" });

items.Add(new DataItem() { Value = 5, Label = "E" });

items.Add(new DataItem() { Value = 1.2, Label = "F" });

items.Add(new DataItem() { Value = 1.1, Label = "G" });

OtherTransform ot = new OtherTransform();

ot.MinPercentage = 10;

ot.Text = "Other Countries";

chart1.DataTransforms.Add(ot);

chart1.ItemsSource = items;

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.

×
×
  • Create New...