Skip to main content

SeriesBase.FilterCriteria Property

Gets or sets the current filter criteria.

Namespace: DevExpress.XtraCharts

Assembly: DevExpress.XtraCharts.v24.2.dll

Declaration

[XtraChartsLocalizableCategory(XtraChartsCategory.Data)]
public CriteriaOperator FilterCriteria { get; set; }

Property Value

Type Description
CriteriaOperator

The current filter criteria.

Remarks

Use the FilterCriteria property to create a filter expression that consists of multiple conditions applied to multiple data columns, and apply it to the series’ data. Setting the FilterCriteria property to a new value clears any filters that have been previously applied.

Note that the FilterCriteria and SeriesBase.FilterString properties are dependent. If you update one of them, the other changes as well.

Use a CriteriaOperator descendants to specify the FilterCriteria property. Refer to Criteria Operators for more information.

Series series = chartControl1.Series[0];
series.FilterCriteria = new BinaryOperator("CategoryID", 1, BinaryOperatorType.Equal) |
                        new BinaryOperator("CategoryID", 3, BinaryOperatorType.Equal) |
                        new BinaryOperator("CategoryID", 7, BinaryOperatorType.Equal);

Alternatively, you can use the SeriesBase.FilterString property to pass a filter expression. Refer to Criteria Language Syntax for more information.

Series series = chartControl1.Series[0];
series.FilterString = "CategoryID = 1 Or CategoryID = 3 Or CategoryID = 7";

You can also use the CriteriaOperator.Parse method to convert a filter string to its CriteriaOperator equivalent as follows:

Series series = chartControl1.Series[0];
series.FilterCriteria = CriteriaOperator.Parse("CategoryID = 1 Or CategoryID = 3 Or CategoryID = 7");

Example

To filter a data series using a criteria that FilterControl provides, assign the FilterControl.FilterCriteria property value to the SeriesBase.FilterCriteria property.

private void Form1_Load(object sender, EventArgs e) {
    filterControl.SourceControl = Products;
    filterControl.FilterString = "Contains([CategoryName], 'Condiments')";

    ProductSeries.DataSource = Products;
    ProductSeries.ArgumentDataMember = "ProductName";
    ProductSeries.ValueDataMembers.AddRange("UnitPrice");
    ProductSeries.FilterCriteria = filterControl.FilterCriteria;
}

private void filterControl1_FilterChanged(object sender, DevExpress.XtraEditors.FilterChangedEventArgs e) {
    // Because of Filter Control recreates its FilterCriteria, 
    // the criteria should be reassigned to the SeriesBase.FilterCriteria property.
    ProductSeries.FilterCriteria = filterControl.FilterCriteria;
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the FilterCriteria property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also