You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "YousufFFFF (via GitHub)" <gi...@apache.org> on 2025/11/27 10:39:34 UTC
[PR] fix(echarts): use scroll legend for horizontal layouts to prevent overlap [superset]
YousufFFFF opened a new pull request, #36306:
URL: https://github.com/apache/superset/pull/36306
fix(echarts): enable scroll legend for horizontal layouts to prevent overlap
### SUMMARY
Charts with many legend items can overlap or obscure the chart area when the legend is placed at the top or bottom. ECharts supports a scrollable legend, which prevents this issue by allowing legend items to scroll instead of expanding into the chart.
This PR introduces a sensible default:
- For horizontal legend orientations (`Top` and `Bottom`), if the user-selected legend type is `Plain`, it is automatically upgraded to `Scroll`.
- Vertical legends (Left/Right) remain unchanged.
- ECharts will only display scroll arrows when legend content overflows, so charts with small legends remain visually identical.
This prevents legend overlap without requiring additional configuration from users.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
<!-- Not required for small UI logic changes -->
N/A — behavior change is internal (scroll arrows appear only when needed).
### TESTING INSTRUCTIONS
1. Create a chart with many series/dimensions so that the legend contains many items.
2. Place the legend at the top or bottom.
3. BEFORE: The legend overlaps the chart area.
4. AFTER: The legend automatically becomes scrollable, preventing overlap.
5. For charts with only a few legend items, verify that the legend appears unchanged (scroll arrows do not show unless needed).
Type checking and frontend linting pass locally, and CI runs full Jest suite.
### ADDITIONAL INFORMATION
- [x] Has associated issue: Fixes #33880
- [ ] Required feature flags:
- [x] Changes UI (legend behavior)
- [ ] Includes DB Migration
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(echarts): use scroll legend for horizontal layouts to prevent overlap [superset]
Posted by "YousufFFFF (via GitHub)" <gi...@apache.org>.
YousufFFFF commented on code in PR #36306:
URL: https://github.com/apache/superset/pull/36306#discussion_r2578335489
##########
superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts:
##########
@@ -433,69 +433,47 @@ export function getLegendProps(
type: LegendType,
orientation: LegendOrientation,
show: boolean,
- theme: SupersetTheme,
+ theme?: SupersetTheme,
zoomable = false,
legendState?: LegendState,
padding?: LegendPaddingType,
): LegendComponentOption | LegendComponentOption[] {
+ const isHorizontal =
+ orientation === LegendOrientation.Top ||
+ orientation === LegendOrientation.Bottom;
+
+ // If user explicitly selected scroll, keep it.
+ // Otherwise, for horizontal legends (top/bottom) default to scroll
+ // so long legends don't overlap the chart.
+ const effectiveType =
+ type === LegendType.Scroll || !isHorizontal ? type : LegendType.Scroll;
+
const legend: LegendComponentOption | LegendComponentOption[] = {
- orient: [LegendOrientation.Top, LegendOrientation.Bottom].includes(
- orientation,
- )
- ? 'horizontal'
- : 'vertical',
+ orient: isHorizontal ? 'horizontal' : 'vertical',
show,
- type,
- selected: legendState,
- selector: ['all', 'inverse'],
- selectorLabel: {
- fontFamily: theme.fontFamily,
- fontSize: theme.fontSizeSM,
- color: theme.colorText,
- borderColor: theme.colorBorder,
- },
+ type: effectiveType,
};
- const MIN_LEGEND_WIDTH = 0;
Review Comment:
You’re right, this removed more than necessary.
I’ll restore the existing legend settings (selector buttons, theming, padding/text handling, etc.) and limit the change to just adjusting the legend type for horizontal layouts so we can use scroll without breaking current behaviour.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(echarts): use scroll legend for horizontal layouts to prevent overlap [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on code in PR #36306:
URL: https://github.com/apache/superset/pull/36306#discussion_r2578209852
##########
superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts:
##########
@@ -433,69 +433,47 @@ export function getLegendProps(
type: LegendType,
orientation: LegendOrientation,
show: boolean,
- theme: SupersetTheme,
+ theme?: SupersetTheme,
Review Comment:
Any reason to make this optional? Just curious
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(echarts): use scroll legend for horizontal layouts to prevent overlap [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #36306:
URL: https://github.com/apache/superset/pull/36306#issuecomment-3613543674
Heya... just a few outstanding questions:
* Any reason to remove `selected: undefined` from `expectedThemeProps`? I think that prop is still being set?
* Is that removal (or something else) the reason we now use `expect.objectContaining` in the subsequent test? That's a bit looser, and may mask regressions.
* I see now that All/Inv buttons are still there, so I'm not sure why they're being stripped from the test.
Otherwise, I think we're about there... the basic fix looks good, just trying to make sense of the other changes and if/why they're necessary :D
Thanks again for seeing this through!
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(echarts): use scroll legend for horizontal layouts to prevent overlap [superset]
Posted by "YousufFFFF (via GitHub)" <gi...@apache.org>.
YousufFFFF commented on PR #36306:
URL: https://github.com/apache/superset/pull/36306#issuecomment-3613887655
Thanks a lot for the thoughtful review, @rusackas really appreciate the clarity on these points!
You're absolutely right about the `selected: undefined` field.
I removed it during cleanup thinking it wasn’t required for the test, but I missed that the legend config still sets the `selected` prop. That removal is also the reason I switched to `expect.objectContaining`, since the stricter assertion no longer matched.
I’ll revert that change so the test continues validating the full legend object, as before. Thanks for calling that out. I definitely don’t want to weaken the test coverage.
Regarding the All/Inv buttons: yes, they are still present in the actual output (as expected), so removing them from the tests was unintentional on my part. I’ll restore those assertions so the test properly reflects the real behavior.
I’ll push the corrective updates shortly and re-run the test suite to confirm everything aligns again.
Thanks again for the thorough guidance and patience, really helping me understand the expectations and avoid regression🙏
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(echarts): use scroll legend for horizontal layouts to prevent overlap [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #36306:
URL: https://github.com/apache/superset/pull/36306#issuecomment-3598245005
Can we get before/after screenshots or videos?
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(echarts): use scroll legend for horizontal layouts to prevent overlap [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #36306:
URL: https://github.com/apache/superset/pull/36306#issuecomment-3585178930
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(echarts): use scroll legend for horizontal layouts to prevent overlap [superset]
Posted by "YousufFFFF (via GitHub)" <gi...@apache.org>.
YousufFFFF commented on PR #36306:
URL: https://github.com/apache/superset/pull/36306#issuecomment-3614144484
Hey @rusackas!, I’ve pushed an update:
• Restored selected: undefined in expectedThemeProps.
• Switched the legend tests back to strict toEqual assertions.
• Kept selector / selectorLabel and the All/Inv buttons in both implementation and tests.
Please let me know if you’d like any other tweaks!
Also, he pre-commit CI seems to have failed on an unrelated step (helm-docs broken pipe).
My local pre-commit checks and tests are passing.
Could you please re-run or approve the workflow when you get a moment?
Thanks!
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(echarts): use scroll legend for horizontal layouts to prevent overlap [superset]
Posted by "YousufFFFF (via GitHub)" <gi...@apache.org>.
YousufFFFF commented on PR #36306:
URL: https://github.com/apache/superset/pull/36306#issuecomment-3630418393
Thanks Evan! The latest CI run has passed, the only red checks are the older runs that GitHub auto-cancelled when the workflow was re-triggered. Everything else is green. Let me know if you need anything else from my side.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(echarts): use scroll legend for horizontal layouts to prevent overlap [superset]
Posted by "YousufFFFF (via GitHub)" <gi...@apache.org>.
YousufFFFF commented on PR #36306:
URL: https://github.com/apache/superset/pull/36306#issuecomment-3630478993
CI is all green now! 🎉
Let me know if you'd like any other tweaks.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(echarts): use scroll legend for horizontal layouts to prevent overlap [superset]
Posted by "YousufFFFF (via GitHub)" <gi...@apache.org>.
YousufFFFF commented on PR #36306:
URL: https://github.com/apache/superset/pull/36306#issuecomment-3604015241
Thanks for the review, @rusackas!
1.)Just to clarify the concern about the All/Inv buttons, they were not removed and still work as expected with the scroll legend.
I’ve added a short before/after video in the comment showing:
- All → correctly resets all series visibility
- Inv → correctly inverts the current selection
- All legend items remain accessible inside the scrollable container
The scroll mode only changes the legend layout (to prevent overflow), but does not modify the built-in ECharts legend controls.
2.)Regarding the `legend` variable typing — you're right, it's never used as an array.
I’ll simplify the type from:
LegendComponentOption | LegendComponentOption[]
to just:
LegendComponentOption
Please let me know if you'd like the video embedded directly in the pr summary or if any further adjustments are needed!
https://github.com/user-attachments/assets/a84a4292-69a8-43c4-9b1b-6ab3362a2cf4
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(echarts): use scroll legend for horizontal layouts to prevent overlap [superset]
Posted by "YousufFFFF (via GitHub)" <gi...@apache.org>.
YousufFFFF commented on code in PR #36306:
URL: https://github.com/apache/superset/pull/36306#discussion_r2582789488
##########
superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts:
##########
@@ -433,69 +433,47 @@ export function getLegendProps(
type: LegendType,
orientation: LegendOrientation,
show: boolean,
- theme: SupersetTheme,
+ theme?: SupersetTheme,
zoomable = false,
legendState?: LegendState,
padding?: LegendPaddingType,
): LegendComponentOption | LegendComponentOption[] {
+ const isHorizontal =
+ orientation === LegendOrientation.Top ||
+ orientation === LegendOrientation.Bottom;
+
+ // If user explicitly selected scroll, keep it.
+ // Otherwise, for horizontal legends (top/bottom) default to scroll
+ // so long legends don't overlap the chart.
+ const effectiveType =
+ type === LegendType.Scroll || !isHorizontal ? type : LegendType.Scroll;
+
const legend: LegendComponentOption | LegendComponentOption[] = {
Review Comment:
There is never an array being used for legend, so I will simplify it to just:
const legend: LegendComponentOption = { ... }
This removes the unnecessary union type and casting throughout the switch cases.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(echarts): use scroll legend for horizontal layouts to prevent overlap [superset]
Posted by "YousufFFFF (via GitHub)" <gi...@apache.org>.
YousufFFFF commented on PR #36306:
URL: https://github.com/apache/superset/pull/36306#issuecomment-3598483058
> Looks like there's a lot of stuff being removed/disabled here that would be considered breaking changes.
Thanks a lot for the detailed review, this is very helpful.
I agree that I unintentionally removed/disabled existing legend behaviour here.
I’ll rework the PR to:
– keep the current legend features (selector buttons, theming, padding/text behaviour, legend state persistence),
– only switch the legend to scroll for horizontal orientations when needed to avoid overlap, and
– add before/after screenshots to demonstrate the issue and the fix.
I’ll push an updated revision shortly.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(echarts): use scroll legend for horizontal layouts to prevent overlap [superset]
Posted by "YousufFFFF (via GitHub)" <gi...@apache.org>.
YousufFFFF commented on PR #36306:
URL: https://github.com/apache/superset/pull/36306#issuecomment-3598473979
> Can we get before/after screenshots or videos?
Sure!
I’ll add before/after screenshots of the legend overlap issue (current behaviour vs this change) once I push the updated implementation.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(echarts): use scroll legend for horizontal layouts to prevent overlap [superset]
Posted by "YousufFFFF (via GitHub)" <gi...@apache.org>.
YousufFFFF commented on code in PR #36306:
URL: https://github.com/apache/superset/pull/36306#discussion_r2582857572
##########
superset-frontend/plugins/plugin-chart-echarts/test/Gantt/transformProps.test.ts:
##########
@@ -139,7 +139,6 @@ describe('Gantt transformProps', () => {
legend: expect.objectContaining({
show: true,
type: 'scroll',
- selector: ['all', 'inverse'],
Review Comment:
Yess sure, I'll add them back in the transformProps.test.ts!
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(echarts): use scroll legend for horizontal layouts to prevent overlap [superset]
Posted by "YousufFFFF (via GitHub)" <gi...@apache.org>.
YousufFFFF commented on PR #36306:
URL: https://github.com/apache/superset/pull/36306#issuecomment-3643271714
Hey Evan! Just resurfacing this in case the earlier notification got buried, the CI is all green now. Let me know if anything else is needed.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(echarts): use scroll legend for horizontal layouts to prevent overlap [superset]
Posted by "FedQa (via GitHub)" <gi...@apache.org>.
FedQa commented on code in PR #36306:
URL: https://github.com/apache/superset/pull/36306#discussion_r3303591317
##########
superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts:
##########
@@ -437,15 +437,21 @@ export function getLegendProps(
zoomable = false,
legendState?: LegendState,
padding?: LegendPaddingType,
-): LegendComponentOption | LegendComponentOption[] {
- const legend: LegendComponentOption | LegendComponentOption[] = {
+): LegendComponentOption {
+ const isHorizontal =
+ orientation === LegendOrientation.Top ||
+ orientation === LegendOrientation.Bottom;
+
+ const effectiveType =
+ type === LegendType.Scroll || !isHorizontal ? type : LegendType.Scroll;
Review Comment:
type === LegendType.Scroll || !isHorizontal ? LegendType.Plain : LegendType.Scroll;
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(echarts): use scroll legend for horizontal layouts to prevent overlap [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #36306:
URL: https://github.com/apache/superset/pull/36306#issuecomment-3630289843
Kicking CI again, but it seems like we're pretty darn close here! Let me know if it passes and I don't catch it ;)
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(echarts): use scroll legend for horizontal layouts to prevent overlap [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on code in PR #36306:
URL: https://github.com/apache/superset/pull/36306#discussion_r2582706646
##########
superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts:
##########
@@ -433,69 +433,47 @@ export function getLegendProps(
type: LegendType,
orientation: LegendOrientation,
show: boolean,
- theme: SupersetTheme,
+ theme?: SupersetTheme,
zoomable = false,
legendState?: LegendState,
padding?: LegendPaddingType,
): LegendComponentOption | LegendComponentOption[] {
+ const isHorizontal =
+ orientation === LegendOrientation.Top ||
+ orientation === LegendOrientation.Bottom;
+
+ // If user explicitly selected scroll, keep it.
+ // Otherwise, for horizontal legends (top/bottom) default to scroll
+ // so long legends don't overlap the chart.
+ const effectiveType =
+ type === LegendType.Scroll || !isHorizontal ? type : LegendType.Scroll;
+
const legend: LegendComponentOption | LegendComponentOption[] = {
Review Comment:
@YousufFFFF is there ever an array here? If not, simplifying is good :)
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(echarts): use scroll legend for horizontal layouts to prevent overlap [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #36306:
URL: https://github.com/apache/superset/pull/36306#issuecomment-3604183409
CodeAnt AI is reviewing your PR.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(echarts): use scroll legend for horizontal layouts to prevent overlap [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #36306:
URL: https://github.com/apache/superset/pull/36306#issuecomment-3598674403
Superset uses Git pre-commit hooks courtesy of [pre-commit](https://pre-commit.com/). To install run the following:
```
pip3 install -r requirements/development.txt
pre-commit install
```
A series of checks will now run when you make a git commit.
Alternatively it is possible to run pre-commit by running pre-commit manually:
```
pre-commit run --all-files
```
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(echarts): use scroll legend for horizontal layouts to prevent overlap [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas merged PR #36306:
URL: https://github.com/apache/superset/pull/36306
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(echarts): use scroll legend for horizontal layouts to prevent overlap [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #36306:
URL: https://github.com/apache/superset/pull/36306#issuecomment-3604189665
CodeAnt AI finished reviewing your PR.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(echarts): use scroll legend for horizontal layouts to prevent overlap [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on code in PR #36306:
URL: https://github.com/apache/superset/pull/36306#discussion_r2578212037
##########
superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts:
##########
@@ -433,69 +433,47 @@ export function getLegendProps(
type: LegendType,
orientation: LegendOrientation,
show: boolean,
- theme: SupersetTheme,
+ theme?: SupersetTheme,
zoomable = false,
legendState?: LegendState,
padding?: LegendPaddingType,
): LegendComponentOption | LegendComponentOption[] {
+ const isHorizontal =
+ orientation === LegendOrientation.Top ||
+ orientation === LegendOrientation.Bottom;
+
+ // If user explicitly selected scroll, keep it.
+ // Otherwise, for horizontal legends (top/bottom) default to scroll
+ // so long legends don't overlap the chart.
+ const effectiveType =
+ type === LegendType.Scroll || !isHorizontal ? type : LegendType.Scroll;
+
const legend: LegendComponentOption | LegendComponentOption[] = {
- orient: [LegendOrientation.Top, LegendOrientation.Bottom].includes(
- orientation,
- )
- ? 'horizontal'
- : 'vertical',
+ orient: isHorizontal ? 'horizontal' : 'vertical',
show,
- type,
- selected: legendState,
- selector: ['all', 'inverse'],
- selectorLabel: {
- fontFamily: theme.fontFamily,
- fontSize: theme.fontSizeSM,
- color: theme.colorText,
- borderColor: theme.colorBorder,
- },
+ type: effectiveType,
};
- const MIN_LEGEND_WIDTH = 0;
Review Comment:
Are we sure we want to remove all these settings? Looks dangerous.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(echarts): use scroll legend for horizontal layouts to prevent overlap [superset]
Posted by "YousufFFFF (via GitHub)" <gi...@apache.org>.
YousufFFFF commented on code in PR #36306:
URL: https://github.com/apache/superset/pull/36306#discussion_r2582863573
##########
superset-frontend/plugins/plugin-chart-echarts/test/utils/series.test.ts:
##########
@@ -51,16 +51,7 @@ import {
import { defaultLegendPadding } from '../../src/defaults';
import { NULL_STRING } from '../../src/constants';
-const expectedThemeProps = {
- selector: ['all', 'inverse'],
- selected: undefined,
- selectorLabel: {
- fontFamily: theme.fontFamily,
- fontSize: theme.fontSizeSM,
- color: theme.colorText,
- borderColor: theme.colorBorder,
- },
-};
+const expectedThemeProps = {};
Review Comment:
Since I removed the selector: ['all', 'inverse'] from the transformProps.test.ts, It was necessary to remove these from it too ( To pass the sanity checks)
I'll restore everything quickly!
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(echarts): use scroll legend for horizontal layouts to prevent overlap [superset]
Posted by "YousufFFFF (via GitHub)" <gi...@apache.org>.
YousufFFFF commented on PR #36306:
URL: https://github.com/apache/superset/pull/36306#issuecomment-3601394687
Update:
- I’ve added a short before/after demo video to clearly show what this PR fixes.
Before (current behavior):
- Legends with many series overflow outside the chart area
- No scrolling or pagination
- Users cannot access all legend items
After (with this PR):
- Legend now uses ECharts’ type: 'scroll'
- Adds proper horizontal scrolling + pagination
- All legend items remain accessible
- Improves usability for charts with large numbers of metrics/series
This change only affects the legend configuration and does not modify any other behavior.
Let me know if anything else is needed , happy to adjust!
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(echarts): use scroll legend for horizontal layouts to prevent overlap [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #36306:
URL: https://github.com/apache/superset/pull/36306#issuecomment-3614069910
CodeAnt AI is running Incremental review
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(echarts): use scroll legend for horizontal layouts to prevent overlap [superset]
Posted by "YousufFFFF (via GitHub)" <gi...@apache.org>.
YousufFFFF commented on PR #36306:
URL: https://github.com/apache/superset/pull/36306#issuecomment-3596631615
/dosu review
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(echarts): use scroll legend for horizontal layouts to prevent overlap [superset]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #36306:
URL: https://github.com/apache/superset/pull/36306#discussion_r2578222119
##########
superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts:
##########
@@ -433,69 +433,47 @@ export function getLegendProps(
type: LegendType,
orientation: LegendOrientation,
show: boolean,
- theme: SupersetTheme,
+ theme?: SupersetTheme,
Review Comment:
The `theme` parameter was changed from required to optional, but theme properties are no longer being applied to the legend. This removes the `selector` and `selectorLabel` configuration that provided styled toggle buttons ('all', 'inverse') in the legend with proper theming (font family, font size, colors, borders).
Either the theme parameter should be removed entirely if these properties are no longer needed, or they should be restored:
```typescript
selector: ['all', 'inverse'],
selectorLabel: {
fontFamily: theme.fontFamily,
fontSize: theme.fontSizeSM,
color: theme.colorText,
borderColor: theme.colorBorder,
},
```
##########
superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts:
##########
@@ -433,69 +433,47 @@ export function getLegendProps(
type: LegendType,
orientation: LegendOrientation,
show: boolean,
- theme: SupersetTheme,
+ theme?: SupersetTheme,
zoomable = false,
legendState?: LegendState,
Review Comment:
The `legendState` parameter is accepted but never used in the function body. This breaks legend state persistence - when users toggle legend items on/off, their selections won't be preserved. The `selected` property should be set in the legend object:
```typescript
const legend: LegendComponentOption | LegendComponentOption[] = {
orient: isHorizontal ? 'horizontal' : 'vertical',
show,
type: effectiveType,
selected: legendState,
};
```
##########
superset-frontend/plugins/plugin-chart-echarts/test/utils/series.test.ts:
##########
@@ -51,16 +51,7 @@ import {
import { defaultLegendPadding } from '../../src/defaults';
import { NULL_STRING } from '../../src/constants';
-const expectedThemeProps = {
- selector: ['all', 'inverse'],
- selected: undefined,
- selectorLabel: {
- fontFamily: theme.fontFamily,
- fontSize: theme.fontSizeSM,
- color: theme.colorText,
- borderColor: theme.colorBorder,
- },
-};
+const expectedThemeProps = {};
Review Comment:
The `expectedThemeProps` object was changed from containing theme-related legend properties to an empty object. This means the tests are no longer validating that theme properties (`selector`, `selectorLabel`) are correctly applied to legends.
If these properties are intentionally removed from the implementation (as seen in series.ts), the tests should be updated to explicitly verify they are NOT present, rather than spreading an empty object. If they should be present, the tests need to be reverted to validate them properly.
##########
superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts:
##########
@@ -433,69 +433,47 @@ export function getLegendProps(
type: LegendType,
orientation: LegendOrientation,
show: boolean,
- theme: SupersetTheme,
+ theme?: SupersetTheme,
zoomable = false,
legendState?: LegendState,
padding?: LegendPaddingType,
): LegendComponentOption | LegendComponentOption[] {
+ const isHorizontal =
+ orientation === LegendOrientation.Top ||
+ orientation === LegendOrientation.Bottom;
+
+ // If user explicitly selected scroll, keep it.
+ // Otherwise, for horizontal legends (top/bottom) default to scroll
+ // so long legends don't overlap the chart.
+ const effectiveType =
+ type === LegendType.Scroll || !isHorizontal ? type : LegendType.Scroll;
+
const legend: LegendComponentOption | LegendComponentOption[] = {
Review Comment:
[nitpick] The `legend` variable is declared with type `LegendComponentOption | LegendComponentOption[]`, but it's always initialized as a single object and never as an array. This requires unnecessary type casting throughout the switch statement.
Consider either:
1. Changing the type to just `LegendComponentOption` if arrays are not needed
2. Or keeping the union type but initializing `legend` with explicit type assertion: `const legend = { ... } as LegendComponentOption;`
This would eliminate the need for repeated type casting on lines 464, 469, 473, and 474.
##########
superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts:
##########
@@ -433,69 +433,47 @@ export function getLegendProps(
type: LegendType,
orientation: LegendOrientation,
show: boolean,
- theme: SupersetTheme,
+ theme?: SupersetTheme,
zoomable = false,
legendState?: LegendState,
padding?: LegendPaddingType,
Review Comment:
The `padding` parameter is accepted but never used in the function body. This removes important functionality where legend text was truncated based on available space for left/right orientations, and legend positioning was adjusted based on padding for top/bottom orientations.
For left/right orientations, the original implementation set:
```typescript
legend.textStyle = {
overflow: 'truncate',
width: getLegendWidth(padding.left), // or padding.right
};
```
For top/bottom orientations, it set:
```typescript
legend.left = padding.left;
```
Either this parameter should be removed from the function signature, or the padding logic should be restored.
##########
superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts:
##########
@@ -433,69 +433,47 @@ export function getLegendProps(
type: LegendType,
orientation: LegendOrientation,
show: boolean,
- theme: SupersetTheme,
+ theme?: SupersetTheme,
zoomable = false,
legendState?: LegendState,
padding?: LegendPaddingType,
): LegendComponentOption | LegendComponentOption[] {
+ const isHorizontal =
+ orientation === LegendOrientation.Top ||
+ orientation === LegendOrientation.Bottom;
+
+ // If user explicitly selected scroll, keep it.
+ // Otherwise, for horizontal legends (top/bottom) default to scroll
+ // so long legends don't overlap the chart.
+ const effectiveType =
+ type === LegendType.Scroll || !isHorizontal ? type : LegendType.Scroll;
+
const legend: LegendComponentOption | LegendComponentOption[] = {
- orient: [LegendOrientation.Top, LegendOrientation.Bottom].includes(
- orientation,
- )
- ? 'horizontal'
- : 'vertical',
+ orient: isHorizontal ? 'horizontal' : 'vertical',
show,
- type,
- selected: legendState,
- selector: ['all', 'inverse'],
- selectorLabel: {
- fontFamily: theme.fontFamily,
- fontSize: theme.fontSizeSM,
- color: theme.colorText,
- borderColor: theme.colorBorder,
- },
+ type: effectiveType,
};
- const MIN_LEGEND_WIDTH = 0;
- const MARGIN_GUTTER = 45;
- const getLegendWidth = (paddingWidth: number) =>
- Math.max(paddingWidth - MARGIN_GUTTER, MIN_LEGEND_WIDTH);
switch (orientation) {
case LegendOrientation.Left:
legend.left = 0;
- if (padding?.left) {
- legend.textStyle = {
- overflow: 'truncate',
- width: getLegendWidth(padding.left),
- };
- }
break;
case LegendOrientation.Right:
legend.right = 0;
- legend.top = zoomable ? TIMESERIES_CONSTANTS.legendRightTopOffset : 0;
- if (padding?.right) {
- legend.textStyle = {
- overflow: 'truncate',
- width: getLegendWidth(padding.right),
- };
- }
+ // keep existing offset behavior for zoomable charts
+ (legend as LegendComponentOption).top = zoomable
+ ? TIMESERIES_CONSTANTS.legendRightTopOffset
+ : 0;
break;
case LegendOrientation.Bottom:
- legend.bottom = 0;
- if (padding?.left) {
- legend.left = padding.left;
- }
+ (legend as LegendComponentOption).bottom = 0;
break;
case LegendOrientation.Top:
- legend.top = 0;
- legend.right = zoomable ? TIMESERIES_CONSTANTS.legendTopRightOffset : 0;
- if (padding?.left) {
- legend.left = padding.left;
- }
- break;
default:
Review Comment:
[nitpick] The `LegendOrientation.Top` case falls through to the `default` case. While this works correctly, it would be clearer and more maintainable to either:
1. Remove the explicit `case LegendOrientation.Top:` line and just handle it in the default
2. Or add a comment explaining the intentional fall-through
3. Or combine them: `case LegendOrientation.Top: default:`
This makes the intent clearer that Top and the default case are handled identically.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(echarts): use scroll legend for horizontal layouts to prevent overlap [superset]
Posted by "YousufFFFF (via GitHub)" <gi...@apache.org>.
YousufFFFF commented on code in PR #36306:
URL: https://github.com/apache/superset/pull/36306#discussion_r2578332512
##########
superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts:
##########
@@ -433,69 +433,47 @@ export function getLegendProps(
type: LegendType,
orientation: LegendOrientation,
show: boolean,
- theme: SupersetTheme,
+ theme?: SupersetTheme,
Review Comment:
There’s no strong reason for making theme optional.
That came from an earlier experiment and I forgot to change it back.
I’ll keep theme required and continue using it for the legend/selector styling so existing behaviour isn’t changed.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(echarts): use scroll legend for horizontal layouts to prevent overlap [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on code in PR #36306:
URL: https://github.com/apache/superset/pull/36306#discussion_r2582702566
##########
superset-frontend/plugins/plugin-chart-echarts/test/utils/series.test.ts:
##########
@@ -51,16 +51,7 @@ import {
import { defaultLegendPadding } from '../../src/defaults';
import { NULL_STRING } from '../../src/constants';
-const expectedThemeProps = {
- selector: ['all', 'inverse'],
- selected: undefined,
- selectorLabel: {
- fontFamily: theme.fontFamily,
- fontSize: theme.fontSizeSM,
- color: theme.colorText,
- borderColor: theme.colorBorder,
- },
-};
+const expectedThemeProps = {};
Review Comment:
@YousufFFFF did these need to be removed at all?
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org