codeant-ai-for-open-source[bot] commented on code in PR #41962:
URL: https://github.com/apache/superset/pull/41962#discussion_r3565319941
##########
superset-frontend/plugins/plugin-chart-echarts/src/Radar/transformProps.ts:
##########
@@ -254,14 +254,27 @@ export default function transformProps(
{},
);
- const normalizeArray = (arr: number[], decimals = 10, seriesName: string) =>
+ const normalizeArray = (
+ arr: (number | null)[],
+ decimals = 10,
+ seriesName: string,
+ ): (number | null)[] =>
arr.map((value, index) => {
const metricLabel = metricLabels[index];
if (metricsWithCustomBounds.has(metricLabel)) {
return value;
}
- const max = Math.max(...arr);
+ // Preserve missing (null/undefined) metric values so they render as a
+ // gap. Dividing null/undefined by max coerces it to 0, which would plot
+ // the point at the center of the radar as if it were a real zero.
+ if (value == null || !Number.isFinite(value)) {
+ return null;
Review Comment:
**Suggestion:** Returning early for null/non-finite values skips population
of the denormalization map, so downstream label/tooltip code falls back to
`Number("null")` and formats missing metrics as `NaN`. Preserve an explicit
denormalized entry for missing values (or handle null explicitly in
denormalization lookup) so missing radar points render as gaps without showing
`NaN` in formatted output. [logic error]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
❌ Radar chart tooltips display NaN for missing metrics.
⚠️ Radar point labels may show NaN instead of gaps.
⚠️ Misleading metric values confuse users analyzing radar charts.
```
</details>
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. In the front-end, select the Radar chart visualization, which uses
`EchartsRadarChartPlugin` registered in
`superset-frontend/src/visualizations/presets/MainPreset.ts:60,129` and
wired to
`transformProps` via
`superset-frontend/plugins/plugin-chart-echarts/src/Radar/index.ts:15-63`.
2. Provide query data that includes a missing (null) metric value for a
normalized metric
(no custom bounds), as illustrated by the regression test dataset in
`superset-frontend/plugins/plugin-chart-echarts/test/Radar/transformProps.test.ts:215-235`
where `SUM(other_sales)` is `null` for `Series A`.
3. When `transformProps` runs, it builds `denormalizedSeriesValues` and
normalizes each
series via `normalizeArray`
(`superset-frontend/plugins/plugin-chart-echarts/src/Radar/transformProps.ts:257-276`).
For the null metric, the early return at lines 271-272 (`if (value == null ||
!Number.isFinite(value)) { return null; }`) skips
`denormalizedSeriesValues[seriesName][String(normalizedValue)] = value`, so
no
denormalized entry is stored for that null slot.
4. On hover, ECharts calls the tooltip formatter `NormalizedTooltipFormater`
(`transformProps.ts:57-70 in the 316-455 range`), which delegates to
`renderNormalizedTooltip`
(`superset-frontend/plugins/plugin-chart-echarts/src/Radar/utils.ts:55-77`).
For
normalized metrics, this calls `getDenormalizedSeriesValue(name,
String(value))` where
`value` is `null`, so `normalizedValue` becomes `"null"`. Since
`denormalizedSeriesValues[seriesName]['null']` is missing,
`getDenormalizedSeriesValue`
falls back to `Number(normalizedValue)` (`transformProps.ts:134-139`),
producing `NaN`,
and the `NumberFormatter` then formats this `NaN` into the tooltip/label
output, so the
missing metric is shown as `NaN` instead of a clean gap.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=b96cb29a735d487bbed610b07f93a40c&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=b96cb29a735d487bbed610b07f93a40c&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/Radar/transformProps.ts
**Line:** 271:272
**Comment:**
*Logic Error: Returning early for null/non-finite values skips
population of the denormalization map, so downstream label/tooltip code falls
back to `Number("null")` and formats missing metrics as `NaN`. Preserve an
explicit denormalized entry for missing values (or handle null explicitly in
denormalization lookup) so missing radar points render as gaps without showing
`NaN` in formatted output.
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%2F41962&comment_hash=6e60e9bea96e9359a9edbef6cf8d99aeb6cf6ddf1f5c05a102622eb1f88a5373&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41962&comment_hash=6e60e9bea96e9359a9edbef6cf8d99aeb6cf6ddf1f5c05a102622eb1f88a5373&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]