alex-poor opened a new issue, #41102:
URL: https://github.com/apache/superset/issues/41102
# Cross-filter on a horizontal bar chart (no dimensions) emits the metric
value instead of the x-axis category
### Bug description
Cross-filtering by x-axis value on `echarts_timeseries_bar` charts that have
**no dimensions** (added in #37407 for #25334, and backported to 6.0 in #39913)
does not work when the chart's **orientation is horizontal**. Clicking a bar
emits a cross-filter whose value is the **metric (count) value** rather than
the **x-axis category**, so every other chart on the dashboard is filtered down
to zero rows.
The same chart with `orientation: vertical` works correctly.
### Root cause
In
`superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/EchartsTimeseries.tsx`,
the `click` event handler cross-filters using `props.data[0]`:
```ts
} else if (canCrossFilterByXAxis && props.data?.[0] != null) {
// Cross-filter by X-axis value when no dimensions (issue #25334)
handleXAxisChange(props.data[0]);
}
```
`getXAxisCrossFilterDataMask` then builds the filter as:
```ts
filters: [{ col: xAxis.label, op: 'IN', val: [String(xAxisValue)] }]
```
For a **vertical** bar the ECharts data tuple is `[category, value]`, so
`data[0]` is the category — correct.
For a **horizontal** bar the tuple is effectively `[value, category]`, so
`data[0]` is the **metric value**. The emitted filter becomes e.g.
`my_category_col IN ['54886']`, which matches no rows, and all in-scope charts
return empty.
Note the **context-menu / drill-to-detail** handler in the same file already
does this correctly by using the orientation-independent `eventParams.name`:
```ts
const values = [...(eventParams.name ? [eventParams.name] : []),
...(labelMap[seriesName] ?? [])];
```
The cross-filter click path should likewise use the category name
(`props.name`) rather than `props.data[0]`.
### How to reproduce
1. Create a dataset with a categorical text column (e.g. `category`) and
some rows.
2. Create a **Bar Chart** (`echarts_timeseries_bar`):
- X-axis: `category` (categorical, not temporal)
- Metric: `COUNT(*)`
- **Dimensions: leave empty**
- **Orientation: Horizontal**
3. Add it to a dashboard with at least one other chart on the same/related
dataset, with cross-filters enabled.
4. Click a bar.
**Expected:** other charts filter to the clicked category (e.g. `category =
'European'`).
**Actual:** other charts go to zero rows. Inspecting the applied
cross-filter shows the value is the bar's count, not the category.
Setting the same chart's orientation to **Vertical** makes cross-filtering
work as expected.
### Proposed fix
In the `click` handler, pass the category name instead of the value-axis
element so it is orientation-independent, e.g.:
```ts
} else if (canCrossFilterByXAxis && props.name != null) {
handleXAxisChange(props.name);
}
```
(or select `props.data[0]` vs `props.data[1]` based on `orientation`).
### Environment
- Superset version: 6.0.0 (also present on `master`). The offending
`props.data[0]` access was introduced in #37407 and is carried unchanged into
the 6.0 backport #39913 — neither handles horizontal orientation.
- Affected viz: `echarts_timeseries_bar` with categorical x-axis, no
dimensions, `orientation: horizontal`
- Browser: any
### Checklist
- [x] I have searched Superset docs and GitHub issues for a similar report
and found none.
- [x] I have reproduced the issue with the latest relevant code path
(#37407).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]