Series.FilterString Property

Gets or sets the series's filter expression. This is a dependency property.

Namespace: DevExpress.Xpf.Charts

Assembly: DevExpress.Xpf.Charts.v20.1.dll

Declaration

public string FilterString { get; set; }
Public Property FilterString As String

Property Value

Type Description
String

The current filter expression.

Remarks

Use the FilterString property to specify a filter expression that consists of different conditions applied to multiple data columns, and apply it to the series data. All existing filters are reset after you change the FilterString to a new value.

Use Criteria Language Syntax to create a filter expression. Then, assign the expression to the FilterString property:

<dxc:ChartControl x:Name="chart">
    <dxc:XYDiagram2D>
        <dxc:BarSideBySideSeries2D DisplayName="Sales" 
                                   x:Name="series"
                                   DataSource="{DXBinding 'new $local:DevAVSales().GetSalesByRegion()'}"
                                   ArgumentDataMember="Region"
                                   ValueDataMember="Sales" 
                                   FilterString="[ProductCategory]='Automation'" 
                                   LabelsVisibility="True"/>
        <dxc:XYDiagram2D.AxisX>
            <dxc:AxisX2D TickmarksMinorVisible="False">
                <dxc:AxisX2D.QualitativeScaleOptions>
                    <dxc:QualitativeScaleOptions GridLayoutMode="GridShiftedLabelCentered"/>
                </dxc:AxisX2D.QualitativeScaleOptions>
            </dxc:AxisX2D>
        </dxc:XYDiagram2D.AxisX>
    </dxc:XYDiagram2D>
</dxc:ChartControl>

Code-Behind:

Show code
using System.Data;
using System.Windows;
namespace FilterStringExample {
    public partial class MainWindow : Window {
        public MainWindow() {
            InitializeComponent();
        }
    }
    public class DevAVSales {
        public DataTable GetSalesByRegion() {
            DataTable table = new DataTable();
            table.Columns.AddRange(new DataColumn[] { new DataColumn("ProductCategory", typeof(string)),
                                          new DataColumn("Region", typeof(string)), 
                                          new DataColumn("Sales", typeof(decimal)) });
            table.Rows.Add("Video players", "Asia", 853D);
            table.Rows.Add("Video players", "Australia", 321D);
            table.Rows.Add("Video players", "Europe", 655D);
            table.Rows.Add("Video players", "North America", 1325D);
            table.Rows.Add("Video players", "South America", 653D);
            table.Rows.Add("Automation", "Asia", 172D);
            table.Rows.Add("Automation", "Australia", 255D);
            table.Rows.Add("Automation", "Europe", 981D);
            table.Rows.Add("Automation", "North America", 963D);
            table.Rows.Add("Automation", "South America", 123D);
            table.Rows.Add("Monitors", "Asia", 1011D);
            table.Rows.Add("Monitors", "Australia", 359D);
            table.Rows.Add("Monitors", "Europe", 721D);
            table.Rows.Add("Monitors", "North America", 565D);
            table.Rows.Add("Monitors", "South America", 532D);
            table.Rows.Add("Projectors", "Asia", 998D);
            table.Rows.Add("Projectors", "Australia", 222D);
            table.Rows.Add("Projectors", "Europe", 865D);
            table.Rows.Add("Projectors", "North America", 787D);
            table.Rows.Add("Projectors", "South America", 332D);
            table.Rows.Add("Televisions", "Asia", 1356D);
            table.Rows.Add("Televisions", "Australia", 232D);
            table.Rows.Add("Televisions", "Europe", 1323D);
            table.Rows.Add("Televisions", "North America", 1125D);
            table.Rows.Add("Televisions", "South America", 865D);
            return table;
        }
    }
}

You can use the following code to set the FilterString property at runtime:

series.FilterString = "[ProductCategory]='Automation'";

Result:

a chart with an applied filter expression

Alternatively, you can use the FilterCriteria property to set the filter expression. See Criteria Operators for information on supported syntax. Note that the FilterString and FilterCriteria properties are dependent. If you update one property, it changes the other property.

series.FilterCriteria = new BinaryOperator("ProductCategory", "Automation", BinaryOperatorType.Equal);

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

series.FilterCriteria = CriteriaOperator.Parse("[ProductCategory] = 'Automation'");
See Also