Skip to main content
A newer version of this page is available. .

DataFilter Class

Defines specific filter conditions of a particular series.

Namespace: DevExpress.XtraCharts

Assembly: DevExpress.XtraCharts.v19.1.dll

Declaration

public class DataFilter :
    ChartElement,
    IDataFilter,
    IObjectValueTypeProvider

The following members return DataFilter objects:

Remarks

The DataFilter class contains settings that define specific filter conditions to be applied to the corresponding series.

A series maintains instances of the DataFilter class in its SeriesBase.DataFilters collection which is represented by an object of the DataFilterCollection type. A particular DataFilter object can be accessed within the collection using indexer notation (see the DataFilterCollection.Item property and the ChartCollectionBase.GetElementByIndex method).

When one or more data filter objects are created for a series, the series will be represented within a chart control’s diagram only by the data points that meet the filter conditions defined. Filter conditions of several data filter objects are combined using either the AND or OR conjunction operator which is specified by the DataFilterCollection.ConjunctionMode property of the SeriesBase.DataFilters collection (or by a series’ SeriesBase.DataFiltersConjunctionMode property).

Example

The following example demonstrates how to create DataFilter objects, and apply their conditions to a series at runtime. For more information, refer to Filtering Data.

For this example to work correctly, a chart should contain at least one series, which is bound to the “Categories” data table in the Northwind Traders database (nwind.mdb file shipped with the XtraCharts demo). Please refer to the following tutorial to see how to bind a series to data: How to: Bind Individual Chart Series to Data (Runtime Sample).

The code below creates and applies the following filter to series data: “CategoryID = 1 or CategoryID = 4 or CategoryID = 7”

using DevExpress.XtraCharts;
// ...

// Create new data filters and specify conditions for them.
DataFilter dataFilter1 = new DataFilter("CategoryID", "System.Int32", DataFilterCondition.Equal, 1);
DataFilter dataFilter2 = new DataFilter("CategoryID", "System.Int32", DataFilterCondition.Equal, 4);
DataFilter dataFilter3 = new DataFilter("CategoryID", "System.Int32", DataFilterCondition.Equal, 7);

// Obtain the first series of the chart.
Series series1 = chartControl1.Series[0];

// Set the logical operator used to combine individual data filter conditions for this series.
series1.DataFiltersConjunctionMode = ConjunctionTypes.Or;

// Remove all other filters.
series1.DataFilters.Clear();

// Add new filters to apply to the series data.
series1.DataFilters.AddRange(new DataFilter[] {dataFilter1, dataFilter2, dataFilter3});

Inheritance

See Also