codeant-ai-for-open-source[bot] commented on code in PR #43684:
URL: https://github.com/apache/superset/pull/43684#discussion_r3886879659
##########
superset-frontend/plugins/plugin-chart-echarts/src/Butterfly/transformProps.ts:
##########
@@ -117,32 +114,59 @@ export default function transformProps(
...formData,
};
- const groupbyColumn = ensureIsArray(groupby)[0];
- const categoryLabel = getColumnLabel(groupbyColumn);
const leftMetricLabel = leftMetric ? getMetricLabel(leftMetric) : '';
const rightMetricLabel = rightMetric ? getMetricLabel(rightMetric) : '';
const leftSeriesName = leftLabel || leftMetricLabel;
const rightSeriesName = rightLabel || rightMetricLabel;
+ const coltypeMapping = getColtypesMapping(queriesData[0]);
+ const groupbyColumns = ensureIsArray(groupby);
+ const groupbyLabels = groupbyColumns.map(getColumnLabel);
+
const defaultFormatter = currencyFormat?.symbol
? new CurrencyFormatter({ d3Format: xAxisFormat, currency: currencyFormat
})
: getNumberFormatter(xAxisFormat);
- const categories = data.map(row => formatCategory(row[categoryLabel]));
- const leftData = data.map(row => {
- const value = Number(row[leftMetricLabel] ?? 0);
- return {
- value: -Math.abs(value),
- label: LABEL_LEFT,
- };
- });
- const rightData = data.map(row => {
- const value = Number(row[rightMetricLabel] ?? 0);
+ const categories = data.map(datum =>
+ extractGroupbyLabel({ datum, groupby: groupbyLabels, coltypeMapping }),
+ );
+
+ const labelMap = data.reduce<Record<string, string[]>>((acc, datum) => {
+ const label = extractGroupbyLabel({
+ datum,
+ groupby: groupbyLabels,
+ coltypeMapping,
+ });
return {
- value: Math.abs(value),
- label: LABEL_RIGHT,
+ ...acc,
+ [label]: groupbyLabels.map(col => datum[col] as string),
};
Review Comment:
**Suggestion:** The label map uses the formatted, joined category label as
its sole key. Distinct groupby rows can produce the same label after formatting
or joining values, causing the later row to overwrite the earlier one.
Drill-to-detail and cross-filter handlers will then use the wrong underlying
dimension values for one of the displayed bars. Use a collision-free row key or
preserve the mapping by category index. [logic error]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ Drill-to-detail can target the wrong groupby values.
- ❌ Cross-filtering can filter an unintended dimension combination.
- ⚠️ Affects multi-groupby labels with display collisions.
```
</details>
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=7a998772403b463fa8c8cae1136a9a3c&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=7a998772403b463fa8c8cae1136a9a3c&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:**
superset-frontend/plugins/plugin-chart-echarts/src/Butterfly/transformProps.ts
**Line:** 134:143
**Comment:**
*Logic Error: The label map uses the formatted, joined category label
as its sole key. Distinct groupby rows can produce the same label after
formatting or joining values, causing the later row to overwrite the earlier
one. Drill-to-detail and cross-filter handlers will then use the wrong
underlying dimension values for one of the displayed bars. Use a collision-free
row key or preserve the mapping by category index.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43684&comment_hash=409c210f65b2c36426ed42568e38b7b5d2092cb84201a14783b58dafafe23fdb&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43684&comment_hash=409c210f65b2c36426ed42568e38b7b5d2092cb84201a14783b58dafafe23fdb&reaction=dislike'>👎</a>
--
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]