ComponentOne Expression Editor for WPF
Filtering in FlexChart
Working with Expression Editor > Integration with FlexChart > Filtering in FlexChart

Expression Editor, when integrated with FlexChart, enables filtering of its data items using expressions.

To filter the data items of FlexChart based on expressions entered in Expression Editor, you can use Filter predicate of ICollectionView. Note that, C1Expression Editor's data source should be same as the FlexChart's data source. 

The following image exhibits FlexChart control, demonstrating filtering using expression entered in Expression Editor control.


 

The following code demonstrates filtering the FlexChart's view through expression entered in Expression Editor control.

  1. Bind the FlexChart control with Expression Editor control, as discussed in Integration with FlexChart.
  2. Instantiate the Filter delegate, as shown in the following code snippet.  
    View.Filter = new Predicate<object>(Contains);
    
  3. Define the method for delegate, as shown in the following code snippet.
    private bool Contains(object obj)
    {
        C1ExpressionEditor _editor = new C1ExpressionEditor();
        _editor.Expression = FlexExpEditor.editor.FlexExpressionEditor.Expression;
        _editor.DataSource = View.CurrentItem;
        var value = _editor.Evaluate();
        var ret = true;
        if (value != null)
            Boolean.TryParse(value.ToString(), out ret);
        return ret;
    }
    

Back to Top