Series.FilterCriteria Property
Gets or sets the current filter criteria. This is a dependency property.
Namespace: DevExpress.Xpf.Charts
Assembly: DevExpress.Xpf.Charts.v21.2.dll
NuGet Package: DevExpress.Wpf.Charts
Declaration
Property Value
Type | Description |
---|---|
CriteriaOperator | The current filter criteria. |
Remarks
Use the FilterCriteria property to create 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 FilterCriteria to a new value.
Use CriteriaOperator‘s descendants to specify the FilterCriteria property. Refer to Criteria Operators for more information.
<dxc:ChartControl x:Name="chart" Width="640" Height="360">
<dxc:XYDiagram2D>
<dxc:BarSideBySideSeries2D x:Name="series"
DisplayName="Sales"
DataSource="{DXBinding 'new $local:DevAVSales().GetSalesByRegion()'}"
ArgumentDataMember="Region"
ValueDataMember="Sales">
</dxc:BarSideBySideSeries2D>
</dxc:XYDiagram2D>
</dxc:ChartControl>
Code-Behind:
using System.Data;
using System.Windows;
namespace FilterStringExample {
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
series.FilterCriteria = new BinaryOperator("ProductCategory", "Automation", BinaryOperatorType.Equal);
}
}
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;
}
}
}
Alternatively, you can use the Series.FilterString property to pass a filter expression. Note that the FilterString and FilterCriteria properties are dependent. If you update one property, it changes the other property. Refer to Criteria Language Syntax for more information on how to create filter expressions.
You can also use the CriteriaOperator.Parse method to convert a filter string to its CriteriaOperator equivalent as follows:
Example
Use the Series.FilterCriteria
property to filter series or chart data source using the Criteria Language.
Public Sub New()
InitializeComponent()
Dim dataStreamInfo As StreamResourceInfo = Application.GetResourceStream(New Uri("Data/GDPStatistic.xml", UriKind.RelativeOrAbsolute))
Dim valueProvider As New XmlGdpValueProvider(dataStreamInfo.Stream)
DataContext = New MainViewModel(valueProvider)
End Sub
Public Class MainViewModel
Private privateGdpValues As IEnumerable(Of GdpValue)
Public Property GdpValues() As IEnumerable(Of GdpValue)
Get
Return privateGdpValues
End Get
Private Set(ByVal value As IEnumerable(Of GdpValue))
privateGdpValues = value
End Set
End Property
'Filter parameters
Private privateMinGdpValue As Double
Public Property MinGdpValue() As Double
Get
Return privateMinGdpValue
End Get
Private Set(ByVal value As Double)
privateMinGdpValue = value
End Set
End Property
Private privateMaxGdpValue As Double
Public Property MaxGdpValue() As Double
Get
Return privateMaxGdpValue
End Get
Private Set(ByVal value As Double)
privateMaxGdpValue = value
End Set
End Property
Private privateStartYear As Integer
Public Property StartYear() As Integer
Get
Return privateStartYear
End Get
Private Set(ByVal value As Integer)
privateStartYear = value
End Set
End Property
Private privateEndYear As Integer
Public Property EndYear() As Integer
Get
Return privateEndYear
End Get
Private Set(ByVal value As Integer)
privateEndYear = value
End Set
End Property
Private privateCountryNames As IEnumerable(Of String)
Public Property CountryNames() As IEnumerable(Of String)
Get
Return privateCountryNames
End Get
Private Set(ByVal value As IEnumerable(Of String))
privateCountryNames = value
End Set
End Property
Private privateContinentNames As IEnumerable(Of String)
Public Property ContinentNames() As IEnumerable(Of String)
Get
Return privateContinentNames
End Get
Private Set(ByVal value As IEnumerable(Of String))
privateContinentNames = value
End Set
End Property
Public Sub New(ByVal valueProvider As XmlGdpValueProvider)
GdpValues = valueProvider.GetValues()
MinGdpValue = GdpValues.Min(Function(gdp) gdp.Value)
MaxGdpValue = GdpValues.Max(Function(gdp) gdp.Value)
StartYear = GdpValues.Min(Function(gdp) gdp.Year)
EndYear = GdpValues.Max(Function(gdp) gdp.Year)
CountryNames = GdpValues.Select(Function(gdp) gdp.CountryName)
ContinentNames = GdpValues.Select(Function(gdp) gdp.ContinentName)
End Sub
End Class
Public Class GdpValue
<FilterLookup(DataSourceMember := "ContinentNames", UseBlanks := False)> _
Public Property ContinentName() As String
<FilterLookup(DataSourceMember := "CountryNames", UseBlanks := False)> _
Public Property CountryName() As String
<FilterRange(MaximumMember := "MaxGdpValue", MinimumMember := "MinGdpValue")> _
Public Property Value() As Double
<FilterRange(MinimumMember := "StartYear", MaximumMember := "EndYear")> _
Public Property Year() As Integer
End Class