apache / apache/echarts

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

Open
#20,990 1 comment 0 reactions 0 assignees View on GitHub
en new-feature pending
Dominant language
TypeScript
Stars
67.3k
Forks
19.8k
Avg merge
11d 14h
Merged PRs (30d)
8

Description

### 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?

```javascript
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'
}
}

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.