We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How do I filter particular set of data points in the chart series?

 

Data is filtered on a series-by-series basis, and when a series data points are filtered they can be either removed from the series Points collection or marked as empty.

We can filter a particular set of data points using the Grouping Engine and data changes are reflected in chart.

Using the group engine we can set the main data source for the whole engine. The TableDescriptor will pick up the ItemProperties from the SourceList and table will be intialized at run-time with records from the list. Using RecordFilterDescriptor class we can filter the chart point values by comparing it against a given constant value. The filtered points added with series.

C#

// Generating Series

ChartSeries series =this.chartControl1 .Model.NewSeries ("Filter Series",ChartSeriesType.Column );

series.Text=series.Name;

list.Clear();

for(int i=0;i<10;i++)

{

a[i]=r.Next(300,500);

series.Points.Add(i,a[i]);

list.Add(new Data(i, a[i]));

}

this.chartControl1.Series.Add(series);

// Bind it to the model

Engine group=new Engine();

group.SetSourceList (list);

ExpressionFieldDescriptor exp = new ExpressionFieldDescriptor();

exp.Expression = "[Y] > "+this.textBox1.Text.ToString();

RecordFilterDescriptor rfd = new RecordFilterDescriptor(exp.Expression);

group.TableDescriptor.RecordFilters.Add (rfd);

System.Diagnostics.Trace.WriteLine("Filtered Record Count:" + group.Table.FilteredRecords.Count);

System.Diagnostics.Trace.WriteLine("Values greater than 30:");

// Filtering Data

this.chartControl1.Series[0].Points.Clear();

int j = 0;

foreach(Record rec in group.Table.FilteredRecords)

{

string b=rec.GetData().ToString();

System.Diagnostics.Trace.WriteLine(b);

this.chartControl1.Series[0].Points.Add(j,Convert.ToDouble(b));

j++;

}

this.label2.Text = "Number of Filtered points: "+group.Table.FilteredRecords.Count.ToString();

VB

' Generating Series

Dim series As ChartSeries =Me.chartControl1.Model.NewSeries ("Filter Series",ChartSeriesType.Column)

series.Text=series.Name

list.Clear()

For i As Integer = 0 To 9

a(i)=r.Next(300,500)

series.Points.Add(i,a(i))

list.Add(New Data(i, a(i)))

Next i

Me.chartControl1.Series.Add(series)

' Bind it to the model

Dim group As Engine = New Engine()

group.SetSourceList (list)

Dim exp As ExpressionFieldDescriptor = New ExpressionFieldDescriptor()

exp.Expression = "[Y] > " & Me.textBox1.Text.ToString()

Dim rfd As RecordFilterDescriptor = New RecordFilterDescriptor(exp.Expression)

group.TableDescriptor.RecordFilters.Add (rfd)

System.Diagnostics.Trace.WriteLine("Filtered Record Count:" & group.Table.FilteredRecords.Count)

System.Diagnostics.Trace.WriteLine("Values greater than 30:")

' Filtering Data

Me.chartControl1.Series(0).Points.Clear()

Dim j As Integer = 0

For Each rec As Record In group.Table.FilteredRecords

Dim b As String=rec.GetData().ToString()

System.Diagnostics.Trace.WriteLine(b)

Me.chartControl1.Series(0).Points.Add(j,Convert.ToDouble(b))

j += 1

Next rec

Me.label2.Text = "Number of Filtered points: " & group.Table.FilteredRecords.Count.ToString()

Article ID: Published Date: Last Revised Date: Platform: Control:
89 04/30/2011 07/10/2014 Windows Forms Chart
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.