Mick Posted January 27, 2010 Report Share Posted January 27, 2010 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: After: 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 Quote Link to comment Share on other sites More sharing options...
JuanC Posted January 28, 2010 Report Share Posted January 28, 2010 The blog post in question is here. Note that OtherTransform will group small slices into the other category, this class is in the ChartFX.WPF.Data namespace and exposes a MinPercentage property as well as a Text property. JuanC Quote Link to comment Share on other sites More sharing options...
Mick Posted January 28, 2010 Author Report Share Posted January 28, 2010 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 Quote Link to comment Share on other sites More sharing options...
JuanC Posted January 29, 2010 Report Share Posted January 29, 2010 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 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.