DataFilter(String, String, DataFilterCondition, Object) Constructor
Initializes a new instance of the DataFilter class with the specified column name and data type name, condition and filter value.
Namespace: DevExpress.XtraCharts
Assembly: DevExpress.XtraCharts.v24.2.dll
Declaration
public DataFilter(
string columnName,
string dataTypeName,
DataFilterCondition condition,
object val
)
Parameters
Name | Type | Description |
---|---|---|
columnName | String | A String which specifies the name of the data column whose values are to be filtered according to the data filter condition. This value is assigned to the DataFilter.ColumnName property. |
dataTypeName | String | A String which specifies the type name of the data stored in the columnName data column. This value is assigned to the DataFilter.DataType property. |
condition | DataFilterCondition | A DataFilterCondition enumeration value which specifies the condition used for data filtering. This value is assigned to the DataFilter.Condition property. |
val | Object | An Object which specifies the value which will be used for data filtering. Note that the type of the filtering value should correspond to the type specified via the dataTypeName parameter. This value is assigned to the DataFilter.Value 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});