codeant-ai-for-open-source[bot] commented on code in PR #38695:
URL: https://github.com/apache/superset/pull/38695#discussion_r3555270906
##########
superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformProps.test.ts:
##########
@@ -697,6 +697,146 @@ describe('Does transformProps transform series
correctly', () => {
});
});
+ test('should respect labelPosition configuration', () => {
+ const chartProps = createTestChartProps({
+ formData: {
+ ...formData,
+ labelPosition: 'insideBottom',
+ },
+ queriesData,
+ });
+
+ const transformedSeries = transformProps(chartProps).echartOptions
+ .series as any[];
+
+ transformedSeries.forEach(series => {
+ expect(series.label.position).toBe('insideBottom');
+ expect(series.label.overflow).toBeUndefined();
+ });
+ });
+
+ test('should default to top when labelPosition is auto and orientation is
vertical', () => {
+ const chartProps = createTestChartProps({
+ formData: {
+ ...formData,
+ labelPosition: 'auto',
+ orientation: OrientationType.Vertical,
+ },
+ queriesData,
+ });
+
+ const transformedSeries = transformProps(chartProps).echartOptions
+ .series as any[];
+
+ transformedSeries.forEach(series => {
+ expect(series.label.position).toBe('top');
+ expect(series.label.overflow).toBeUndefined();
+ });
+ });
+
+ test('should default to right when labelPosition is auto and orientation is
horizontal', () => {
+ const chartProps = createTestChartProps({
+ formData: {
+ ...formData,
+ labelPosition: 'auto',
+ orientation: OrientationType.Horizontal,
+ },
+ queriesData,
+ });
+
+ const transformedSeries = transformProps(chartProps).echartOptions
+ .series as any[];
+
+ transformedSeries.forEach(series => {
+ expect(series.label.position).toBe('right');
Review Comment:
**Suggestion:** The horizontal auto-default expectation is incorrect for
this feature: the PR requirement says auto should preserve existing horizontal
behavior (`inside`), but this assertion locks in `right`. That will either fail
valid implementations or, worse, bless a regression in default label placement.
Update the expected value to match the intended horizontal auto default. [logic
error]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ⚠️ Horizontal timeseries charts show labels outside instead of inside.
- ⚠️ Stacked horizontal bars may confuse users about label segments.
- ⚠️ Unit tests cement wrong default, blocking spec-compliant fixes.
```
</details>
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Configure an Echarts Timeseries chart via the Timeseries plugin
(`superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/index.ts:34-74`)
with
`orientation` set to `Horizontal` and enable "Show value" (wired from
`show_value` and
`orientation` controls in `src/controls.tsx:3-35`).
2. Leave the Label Position control at its default "Auto" (SelectControl
`label_position`
defined in `src/controls.tsx:14-35`, which sets `labelPosition` in formData
to `'auto'`).
3. When the chart renders, `EchartsTimeseriesChartPlugin` calls
`transformProps`
(`src/Timeseries/transformProps.ts:181-277`), which computes `isHorizontal`
from
`orientation` (`line 302`) and passes both `isHorizontal` and
`labelPosition` into
`transformSeries` (`src/Timeseries/transformProps.ts:485-523`, see
`labelPosition` in the
options object at line 522).
4. Inside `transformSeries` (`src/Timeseries/transformers.ts:201-475`), the
label
configuration at lines 429-435 sets `series.label.position` using
`(labelPosition ===
'auto' || !labelPosition ? isHorizontal ? 'right' : 'top' : labelPosition)`,
so for
horizontal charts with `labelPosition: 'auto'` the runtime label position
becomes
`'right'` instead of the intended `'inside'`.
5. The unit test `should default to right when labelPosition is auto and
orientation is
horizontal` in `test/Timeseries/transformProps.test.ts:737-753` asserts this
behavior with
`expect(series.label.position).toBe('right');` at line 751, meaning any
future
implementation that correctly uses `'inside'` for horizontal Auto mode (per
the PR
description) will fail this test, cementing the wrong default and allowing
the UX
regression to persist.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=e5b0fedcad2d42c9b2d1a52b898e6850&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=e5b0fedcad2d42c9b2d1a52b898e6850&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/test/Timeseries/transformProps.test.ts
**Line:** 751:751
**Comment:**
*Logic Error: The horizontal auto-default expectation is incorrect for
this feature: the PR requirement says auto should preserve existing horizontal
behavior (`inside`), but this assertion locks in `right`. That will either fail
valid implementations or, worse, bless a regression in default label placement.
Update the expected value to match the intended horizontal auto default.
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%2F38695&comment_hash=6159f5d2a8350d3ad11393cf82ee94ed511be1c7a3b1d935c9a5142743008b85&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38695&comment_hash=6159f5d2a8350d3ad11393cf82ee94ed511be1c7a3b1d935c9a5142743008b85&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]