ComponentOne Expression Editor for UWP
Working with Expression Editor / Integration with FlexChart / Filtering in FlexChart
In This Topic
    Filtering in FlexChart
    In This Topic

    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 C1CollectionView. 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(Of Object)(AddressOf Contains)
      
      View.Filter = new Predicate<object>(Contains);
      
    3. Define the method for delegate, as shown in the following code snippet.
      Private Function Contains(obj As Object) As Boolean
          editor.DataSource = TryCast(obj, DataItem)
          Dim value As Object = editor.Evaluate()
          Dim ret As Object = True
          If value IsNot Nothing Then
              [Boolean].TryParse(value.ToString(), ret)
          End If
          Return ret
      End Function
      
      private bool Contains(object obj)
      {
          editor.DataSource = obj as DataItem;
          var value = editor.Evaluate();
          var ret = true;
          if (value != null)
              Boolean.TryParse(value.ToString(), out ret);
          return ret;
      }
      

    Back to Top