Skip to content

feat(stack by dimension): add a stack by dimension dropdown list #32707

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
May 22, 2025

Conversation

jpchev
Copy link
Contributor

@jpchev jpchev commented Mar 17, 2025

SUMMARY

feature for bar chart, to stack by dimension, see
#32496

basically, this is a new option to let users select a dimension to 'stack by', see the video here

stackByDimension.mp4

the dimension to 'stack by' can be selected between the dimensions defined by the user, in the Customize tab

fixes: #32496

@dosubot dosubot bot added the viz:charts:bar Related to the Bar chart label Mar 17, 2025
Copy link

@korbit-ai korbit-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by Korbit AI

Korbit automatically attempts to detect when you fix issues in new commits.
Category Issue Fix Detected
Functionality Missing conditional visibility for stack dimension control ▹ view
Readability Redundant shouldMapStateToProps Function ▹ view
Functionality Incorrect Operator Precedence in Dimension Index Calculation ▹ view
Files scanned
File Path Reviewed
superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/constants.ts
superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/types.ts
superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Bar/controlPanel.tsx
superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts

Explore our documentation to understand the languages and file types we support and the files we ignore.

Need a new review? Comment /korbit-review on this PR and I'll review your latest changes.

Korbit Guide: Usage and Customization

Interacting with Korbit

  • You can manually ask Korbit to review your PR using the /korbit-review command in a comment at the root of your PR.
  • You can ask Korbit to generate a new PR description using the /korbit-generate-pr-description command in any comment on your PR.
  • Too many Korbit comments? I can resolve all my comment threads if you use the /korbit-resolve command in any comment on your PR.
  • On any given comment that Korbit raises on your pull request, you can have a discussion with Korbit by replying to the comment.
  • Help train Korbit to improve your reviews by giving a 👍 or 👎 on the comments Korbit posts.

Customizing Korbit

  • Check out our docs on how you can make Korbit work best for you and your team.
  • Customize Korbit for your organization through the Korbit Console.

Feedback and Support

Comment on lines 427 to 428
const idxSelectedDimension = formData.metrics.length > 1 ? 1 : 0
+ chartProps.rawFormData.groupby.indexOf(stackdimension);

This comment was marked as resolved.

@jpchev jpchev changed the title stack by dimension feat(stack by dimension): add a stack by dimension dropdown list Mar 17, 2025
@villebro
Copy link
Member

@jpchev please add a comprehensive description + screens to this PR so reviewers can first validate the design, and then look at the implementation details. I know these may be covered by the linked GH Issue, but the discussion is pretty lengthy. I think the feature is great, but I feel we need to be very careful of how this is implemented to ensure we don't pile on technical/design debt that will be difficult to clean up later.

@rusackas
Copy link
Member

This is looking cool!

Do you need to add the "Stack by" dimension to the "Dimensions" input? If so, this works fine as-is.

If you don't, I'd be still be happy with:
• Renaming "Dimension" to "Split By"
• Moving the "Stack By" to the main control panel
• Killing the checkbox

... but if that entails a lot of work (which it might) then I still like this improvement :)

@jpchev
Copy link
Contributor Author

jpchev commented Mar 17, 2025

@villebro I added a description for this PR

@michael-s-molina
Copy link
Member

How is this going to interact with the Stack control that already exists?

@sadpandajoe
Copy link
Member

I'm a little bit confused about this since not everything is stacked according to your video. Is this more of a group by dimension or something?

@villebro
Copy link
Member

@jpchev I reviewed the video and in general I think this is an elegant and backwards compatible solution to the problem 👍 I will review in more detail in the coming days.

@jpchev
Copy link
Contributor Author

jpchev commented Mar 18, 2025

How is this going to interact with the Stack control that already exists?

as far as I understand, the new feature has no interaction with the existing stack control

@jpchev
Copy link
Contributor Author

jpchev commented Mar 18, 2025

I'm a little bit confused about this since not everything is stacked according to your video. Is this more of a group by dimension or something?

yes, this is a sort of 'group by', but it's called 'stack' in the Apache Echarts vocabulary (see https://echarts.apache.org/handbook/en/how-to/chart-types/bar/stacked-bar/).
Actually the feature propagates a 'stack' parameter in the underlying Echarts component

@michael-s-molina
Copy link
Member

Wouldn't be better to offer a control to define how things are stacked AFTER you set Stacked Style to Stack? Right now, it find really confusing that we have 2 controls for stacking.

@jpchev
Copy link
Contributor Author

jpchev commented Mar 18, 2025

Wouldn't be better to offer a control to define how things are stacked AFTER you set Stacked Style to Stack? Right now, it find really confusing that we have 2 controls for stacking.

I don't know, what is the existing stack doing?

@michael-s-molina
Copy link
Member

michael-s-molina commented Mar 18, 2025

I don't know, what is the existing stack doing?

It's stacking the bars under a common name. That's why all bars appear in the same stacking group. It seems you're trying to offer a way to modify this logic and that's why I think they are related.

@jpchev
Copy link
Contributor Author

jpchev commented Mar 20, 2025

I don't know, what is the existing stack doing?

It's stacking the bars under a common name. That's why all bars appear in the same stacking group. It seems you're trying to offer a way to modify this logic and that's why I think they are related.

yes, they are probably related and I think that the existing stack feature should become a particular case of a broader feature which should let user stack by a label in each series. This label would work as a group by criteria, as it is implemented in Apache Echarts

@b4s36t4
Copy link

b4s36t4 commented Mar 25, 2025

Hi, @jpchev. I'm trying to implement the stacked chart as you did above for the below dataset.

id,sprint,stories,p0_issues,p1_p2_issues,effieciency
1,2023#07,24,1,5,4
7,2023#06,25,4,10,1.785714286
2,2023#05,26,4,12,1.625
3,2023#04,26,8,20,0.7878787879
4,2023#03,22,10,30,0.55
5,2023#02,23,9,40,0.4693877551
6,2023#01,21,15,28,0.488372093

Can you help me understand by giving a demo for this, I'm not able to build the chart for the dataset as you did.
You can hit me @b4s36t4 in discord or telegram we can take things over there. Thanks for the help!

@jpchev
Copy link
Contributor Author

jpchev commented Mar 25, 2025

Hi, @jpchev. I'm trying to implement the stacked chart as you did above for the below dataset.

id,sprint,stories,p0_issues,p1_p2_issues,effieciency
1,2023#07,24,1,5,4
7,2023#06,25,4,10,1.785714286
2,2023#05,26,4,12,1.625
3,2023#04,26,8,20,0.7878787879
4,2023#03,22,10,30,0.55
5,2023#02,23,9,40,0.4693877551
6,2023#01,21,15,28,0.488372093

Can you help me understand by giving a demo for this, I'm not able to build the chart for the dataset as you did. You can hit me @b4s36t4 in discord or telegram we can take things over there. Thanks for the help!

hello,
if you want to stack together p0_issues and p1_p2_issues, and keep 'stories' in a separate stack, in order to use my approach you can change your dataset (you can always modify your SQL query) like the following dataset (I put only the data for the sprint '2023#07'): getting one row per measure, measures types are stored in the 'type' column and their values are in the 'val' column. The the 'cat' column lets you separate the stacks, and that's the dimension you can stack by.

id,    sprint,           cat,       type,                 no,
1,      2023#07,         S1,         stories,             24
1,      2023#07,         S2,         p0_issues,           1
1,      2023#07,         S2,         p1_p2_issues,        5
1,      2023#07,         S3,         efficiency,          4

@sadpandajoe sadpandajoe requested a review from villebro March 25, 2025 15:59
@jpchev
Copy link
Contributor Author

jpchev commented Apr 16, 2025

@kgabryje @michael-s-molina @rusackas I've removed the checkbox and bound the visibility of the "dimension to stack by" dropdown to the value "Stack" of the existing "Stacked style" control.

Can you please have a look?

Copy link
Contributor

@michael-s-molina Processing your ephemeral environment request here. Action: up. More information on how to use or configure ephemeral environments

Copy link
Contributor

@michael-s-molina Ephemeral environment spinning up at http://35.167.64.30:8080. Credentials are 'admin'/'admin'. Please allow several minutes for bootstrapping and startup.

@rusackas
Copy link
Member

Added a test chart here. Controls look a lot cleaner with the conditional rendering now, thank you! Seems to work well in both vertical and horizontal mode. I still feel the dimension added to "Stack by" feels more like a "Split by" or "Create Stacks for" but again, maybe it's just me expecting "Stack by" to be the dimension that IS stacked. I think the tooltip does help explain the situation, though.

@jpchev
Copy link
Contributor Author

jpchev commented Apr 22, 2025

Added a test chart here. Controls look a lot cleaner with the conditional rendering now, thank you! Seems to work well in both vertical and horizontal mode. I still feel the dimension added to "Stack by" feels more like a "Split by" or "Create Stacks for" but again, maybe it's just me expecting "Stack by" to be the dimension that IS stacked. I think the tooltip does help explain the situation, though.

Good, thanks for reviewing, can we consider having the feature merged? I can change the labels if that's better (replace "Stack by")

@jpchev
Copy link
Contributor Author

jpchev commented Apr 25, 2025

@rusackas I replaced "Dimension to stack by" with "Dimension to split by", is that better?

@jpchev
Copy link
Contributor Author

jpchev commented May 6, 2025

@rusackas @michael-s-molina @villebro any update on this feature?

@jpchev
Copy link
Contributor Author

jpchev commented May 22, 2025

is this feature considered as abandoned or not relevant anymore? @rusackas @michael-s-molina @villebro

@michael-s-molina
Copy link
Member

michael-s-molina commented May 22, 2025

Thanks for the patience @jpchev but as you can imagine, we receive many review requests. I pulled your branch and it looks good.

  • Can you remove the package-lock.json changes?
  • I believe a better name for the control would be Split stack by.

I can approve and merge the PR with these changes.

@michael-s-molina
Copy link
Member

@jpchev You deleted the package-lock.json file but I meant to just delete the changes.

@jpchev
Copy link
Contributor Author

jpchev commented May 22, 2025

@michael-s-molina I've restored the package-lock.json without my changes
and renamed the control to "Split stack by"

thank you

Copy link
Member

@michael-s-molina michael-s-molina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the improvement, for addressing the comments, and for the patience @jpchev!

@jpchev
Copy link
Contributor Author

jpchev commented May 22, 2025

thank you, I'm very happy and it creates huge value for me

@michael-s-molina michael-s-molina merged commit 5b2f1bb into apache:master May 22, 2025
53 checks passed
@jpchev jpchev deleted the feature/stack branch May 23, 2025 12:12
LevisNgigi pushed a commit to LevisNgigi/superset that referenced this pull request Jun 18, 2025
alexandrusoare pushed a commit to alexandrusoare/superset that referenced this pull request Jun 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugins size/M viz:charts:bar Related to the Bar chart
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: stacked grouped mixed chart
8 participants