echarts icon indicating copy to clipboard operation
echarts copied to clipboard

[Feature] Add "in" Operator to FilterTransform for Array Membership Filtering

Open mrwunderbar666 opened this issue 7 months ago • 1 comments

What problem does this feature solve?

Currently, the FilterTransform in Apache ECharts supports a rich set of conditional expressions including relational and logical operators (lt, gt, eq, reg, and, or, not, etc.). However, it does not support a mechanism to check whether a data value exists within a specified list—commonly known as an "in" operation.

Please add support for an in operator in RelationalExpressionOption, allowing developers to filter values based on membership in a list or array. This would greatly enhance the expressiveness and efficiency of data filtering within ECharts.

  • Many filtering scenarios require selecting rows where a field matches one of several known values.
  • Current alternatives require verbose or expressions, which are harder to write, maintain, and optimize.
  • The in operator is standard in SQL and many query DSLs, and users naturally expect this functionality.
  • Improves developer ergonomics and code clarity.
  • Aligns with common querying patterns.
  • Enhances performance for large datasets by allowing ECharts to optimize "in" checks internally.

What does the proposed API look like?

type RelationalExpressionOption = {
  dimension: DimensionName | DimensionIndex;
  parser?: 'time' | 'trim' | 'number';
  in?: DataValue[];  // New operator for array membership
  notIn?: DataValue[]; // Optional complement for exclusion
  // existing operators...
};

// Usage example:
transform: {
  type: 'filter',
  config: {
    in: ['Apple', 'Banana', 'Orange'],
    dimension: 'fruit'
  }
}

mrwunderbar666 avatar May 24 '25 21:05 mrwunderbar666

A valuable feature indeed, and does not seem hard to implement 👍 👍 Currently we can do similar filtering with 'or' - Demo, but 'in' would be more elegant.

helgasoft avatar May 26 '25 20:05 helgasoft