korbit-ai[bot] commented on code in PR #32849:
URL: https://github.com/apache/superset/pull/32849#discussion_r2012751714
##########
superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts:
##########
@@ -627,3 +627,41 @@ export function getPadding(
isHorizontal,
);
}
+
+export function transformNegativeLabelsPosition(
+ series: SeriesOption[],
+ isHorizontal: boolean,
+ seriesType: EchartsTimeseriesSeriesType,
+ stack: StackType,
+): SeriesOption[] {
+ /*
+ * Adjusts label position for negative values in bar series
+ * @param series - Array of series options
+ * @param isHorizontal - Whether chart is horizontal
+ * @param seriesType - Type of the series (only 'bar' will be processed)
+ * @param stack - Stack configuration (no transformation if stacked)
+ * @returns Series with adjusted label positions for negative values
+ */
+ const shouldTransform = (item: SeriesOption): boolean =>
+ Array.isArray(item.data) && seriesType === 'bar' && !stack;
+
+ const transformValue = (value: any) => {
+ const axisValue = isHorizontal ? value[0] : value[1];
Review Comment:
### Unexplained Array Index Usage <sub></sub>
<details>
<summary>Tell me more</summary>
###### What is the issue?
Magic indices [0] and [1] are used without explanation of what they
represent in the data array.
###### Why this matters
Using unexplained array indices makes the code harder to understand and
maintain, as developers need to trace the data structure to understand what
these values represent.
###### Suggested change ∙ *Feature Preview*
```typescript
const X_INDEX = 0;
const Y_INDEX = 1;
// ...
const axisValue = isHorizontal ? value[X_INDEX] : value[Y_INDEX];
```
###### Provide feedback to improve future suggestions
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/e8c514f8-828d-4762-8423-532e10db0095/upvote)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/e8c514f8-828d-4762-8423-532e10db0095?what_not_true=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/e8c514f8-828d-4762-8423-532e10db0095?what_out_of_scope=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/e8c514f8-828d-4762-8423-532e10db0095?what_not_in_standard=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/e8c514f8-828d-4762-8423-532e10db0095)
</details>
<sub>
💬 Looking for more details? Reply to this comment to chat with Korbit.
</sub>
<!--- korbi internal id:7b90a448-a672-4c41-aa89-4da55eda7ed1 -->
[](7b90a448-a672-4c41-aa89-4da55eda7ed1)
--
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]