This is a migrated thread and some comments may be shown as answers.

Can I include/exclude certain points from a SeriesMapping Itemsource from being drawn

2 Answers 21 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Rob
Top achievements
Rank 1
Rob asked on 19 Nov 2013, 02:12 PM
Suppose I have a the following class

public class DataRow
{
    public int X { get; set; }
    public int Y { get; set; }
 
    public bool Exclude;
}

I want to plot this on a RadChart using a seriesmapping, which I do like this.

ObservableCollection<DataRow> SeriesSource = new ObservableCollection<DataRow>();
SeriesMapping series = new SeriesMapping();
series.ItemsSource = source;
series.ItemMappings.Add(new ItemMapping("X", DataPointMember.XValue));
series.ItemMappings.Add(new ItemMapping("Y", DataPointMember.YValue));

Is there any way that I can include/exclude data points being plotted based on the value of 'Exclude'? I wish to be able to include/exclude certain points from the plotted line.

The only other solution I can think of is to scan through the collection and create a second collection just containing members which aren't excluded. This doesn't seem very efficient though.

2 Answers, 1 is accepted

Sort by
0
Rob
Top achievements
Rank 1
answered on 20 Nov 2013, 09:45 AM
I've found the feature I need, I'm adding a ChartFilterDescriptor to the series like this....

ChartFilterDescriptor filter = new ChartFilterDescriptor();
filter.Member = "Excluded";
filter.Operator = FilterOperator.IsEqualTo;
filter.Value = false;
 
series.FilterDescriptors.Add(filter);

This works, but only when the series is originally drawn. If I change the value of Exclude (calling NotifyPropertyChanged etc) this isn't reflected in the chart, the plots change correctly when I change the X & Y values though.

Is there something I'm missing to will I have to recreate the series each time the value of Exclude changes?
0
Petar Marchev
Telerik team
answered on 22 Nov 2013, 08:33 AM
Hello Craig,

I suggest you go with your original idea about creating a second items source collection that you update when needed. It will not be more efficient if you use a filter descriptor.

On a side note - if you have not integrated the old RadChart into your project, I suggest you consider using the new ChartView which has a higher performance rate and generally it is more flexible.

Regards,
Petar Marchev
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
Chart
Asked by
Rob
Top achievements
Rank 1
Answers by
Rob
Top achievements
Rank 1
Petar Marchev
Telerik team
Share this question
or