codeant-ai-for-open-source[bot] commented on code in PR #42855:
URL: https://github.com/apache/superset/pull/42855#discussion_r3737504355
##########
superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts:
##########
@@ -387,20 +387,33 @@ export function extractDataTotalValues(
percentageThreshold: number;
xAxisCol: string;
legendState?: LegendState;
+ extraMetricLabels?: string[];
},
): {
totalStackedValues: number[];
thresholdValues: number[];
} {
const totalStackedValues: number[] = [];
const thresholdValues: number[] = [];
- const { stack, percentageThreshold, xAxisCol, legendState } = opts;
+ const {
+ stack,
+ percentageThreshold,
+ xAxisCol,
+ legendState,
+ extraMetricLabels = [],
+ } = opts;
+ // Extra metrics, such as a sort metric, are present in the data but are not
+ // rendered as series, so they must not contribute to the stacked total.
+ const extraMetricLabelsSet = new Set(extraMetricLabels);
if (stack) {
data.forEach(datum => {
const values = Object.keys(datum).reduce((prev, curr) => {
if (curr === xAxisCol) {
return prev;
}
+ if (extraMetricLabelsSet.has(curr)) {
+ return prev;
+ }
Review Comment:
**Suggestion:** The exclusion only compares the raw column key against
`extraMetricLabels`, but `extractDataTotalValues` receives `rebasedData`, whose
metric keys may be renamed through `verboseMap` or suffixed for time-comparison
series. In those cases a hidden sort metric such as `Sort__1 day ago` or its
verbose label is not matched and is still added to the stacked total and
threshold, so the reported inflation persists for forecast/time-comparison
charts. Normalize the extra labels to the same rendered key format, or match
derived keys consistently with `extractSeries`. [api mismatch]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ Time-comparison stacked totals include hidden sort metrics.
- ❌ Verbose-mapped extra metrics inflate displayed totals.
- ⚠️ Incorrect totals affect threshold-based label visibility.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=988c2f1ad3e54353932b0e078fa1ef8c&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=988c2f1ad3e54353932b0e078fa1ef8c&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
*(Use Cmd/Ctrl + Click for best experience)*
<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/utils/series.ts
**Line:** 414:416
**Comment:**
*Api Mismatch: The exclusion only compares the raw column key against
`extraMetricLabels`, but `extractDataTotalValues` receives `rebasedData`, whose
metric keys may be renamed through `verboseMap` or suffixed for time-comparison
series. In those cases a hidden sort metric such as `Sort__1 day ago` or its
verbose label is not matched and is still added to the stacked total and
threshold, so the reported inflation persists for forecast/time-comparison
charts. Normalize the extra labels to the same rendered key format, or match
derived keys consistently with `extractSeries`.
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%2F42855&comment_hash=4e87ab1ccad66cd4337f70fd566a1d8ee3f0ab791c32a73372856c941ad0bdf6&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42855&comment_hash=4e87ab1ccad66cd4337f70fd566a1d8ee3f0ab791c32a73372856c941ad0bdf6&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]