Skip to content

feat: Improves waterfall chart #33146

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

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

anantaoutlook
Copy link
Contributor

@anantaoutlook anantaoutlook commented Apr 16, 2025

SUMMARY

This PR includes the following improvements:

1.) Horizontal waterfall in addition to vertical.
image

2.) Axis label fixes to word-wrap longer labels instead of hiding them. This is extremely important for readability/usability.
For example. Prior to these fixes, roughly half of the following labels in this chart were hidden:
image

3.) Sorting of Waterfall: It is now possible to sort the waterfall by a field other than the field indicated in the waterfall column headers. Again, extremely important. As an example, in the following chart, we are bridging from gross revenue to Profit. It's vital that these grouping appear in the correct order:
image
image

4.) Added option to use first value as subtotal, and bold first value as subtotal. These are important optional settings for the waterfall. In the example, these allow the Gross Revenue bar to be presented as a subtotal (full bar and grey), and the label for Gross Revenue is bold.
Before:
image
After:
image

5.) Cross-filtering is now feasible for the waterfall chart.

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

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 Status
Readability Deeply nested complex function ▹ view ✅ Fix detected
Readability Scattered series transformation logic ▹ view ✅ Fix detected
Readability Suspicious file suffix in types import ▹ view ✅ Fix detected
Functionality Inaccurate Text Wrapping Calculation ▹ view ✅ Fix detected
Functionality Order Direction Control Not Dependent on Column Selection ▹ view ✅ Fix detected
Readability Remove or implement commented validators ▹ view ✅ Fix detected
Readability Type inconsistency in default value ▹ view ✅ Fix detected
Error Handling Inadequate Error Handling for Invalid Label Distance ▹ view ✅ Fix detected
Functionality Inconsistent Mixed-Type Data Sorting ▹ view ✅ Fix detected
Documentation Missing documentation for complex click handler ▹ view
Files scanned
File Path Reviewed
superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/buildQuery.ts
superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/types.ts
superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/index.ts
superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/transformProps.ts
superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/controlPanel.tsx
superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/EchartsWaterfall.tsx

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

Check out our docs on how you can make Korbit work best for you and your team.

Loving Korbit!? Share us on LinkedIn Reddit and X

@rusackas
Copy link
Member

Can you add some details to the Description so we know the intent of the change? Thanks!

@anantaoutlook
Copy link
Contributor Author

anantaoutlook commented Apr 21, 2025

Can you add some details to the Description so we know the intent of the change? Thanks!

Details are attached. Please let me know if you need more info.
waterfall-changes doc.pdf

@rea725
Copy link

rea725 commented Apr 24, 2025

The work performed on Superset by @anantaoutlook in this PR includes the following improvements:

1.) Horizontal waterfall in addition to vertical.
image

2.) Axis label fixes to word-wrap longer labels instead of hiding them. This is extremely important for readability/usability.
For example. Prior to these fixes, roughly half of the following labels in this chart were hidden:
image

3.) Sorting of Waterfall: It is now possible to sort the waterfall by a field other than the field indicated in the waterfall column headers. Again, extremely important. As an example, in the following chart, we are bridging from gross revenue to Profit. It's vital that these grouping appear in the correct order:
image
image

4.) Added option to use first value as subtotal, and bold first value as subtotal. These are important optional settings for the waterfall. In the example, these allow the Gross Revenue bar to be presented as a subtotal (full bar and grey), and the label for Gross Revenue is bold.
Before:
image
After:
image

5.) Cross-filtering is now feasible for the waterfall chart.

@michael-s-molina
Copy link
Member

Thanks @anantaoutlook @rea725 for the great improvements! I updated the PR description with @rea725's comment.

2.) Axis label fixes to word-wrap longer labels instead of hiding them.

ECharts automatically calculates what labels will be displayed to avoid label overlaps when the number of bars is high. I think the solution here would be to provide a checkbox to show all labels (disabled by default). The same feature is currently being discussed in #33191 so please check the comments of that PR.

4.) Added option to use first value as subtotal, and bold first value as subtotal.

Can we assume that if the first value is used as a subtotal, it's always displayed with bold? It's good to avoid additional controls if possible.

@michael-s-molina michael-s-molina changed the title improve waterfall feat: Improves waterfall chart Apr 24, 2025
@michael-s-molina
Copy link
Member

@anantaoutlook Could you also fill the Testing Instructions part of the PR description?

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.

First-pass comments. Great work!

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.

@anantaoutlook Could you make sure all labels of all controls and select values follow the sentence case which capitalizes only the first letter of the first word in a sentence?

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.

Thanks for the changes @anantaoutlook. Second-pass review below.

@@ -28,6 +28,25 @@ export default function buildQuery(formData: QueryFormData) {
...ensureIsArray(x_axis || granularity_sqla),
...ensureIsArray(groupby),
];

if (columns.indexOf(formData.seriesOrderByColumn) === -1) {
Copy link
Member

Choose a reason for hiding this comment

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

I noticed that you're adding the Order series by column to the GROUP BY clause which will produce incorrect results. Take this chart as an example where we have year broke down by product_line.

Screenshot 2025-05-15 at 11 54 35

If we set Order series by column to status the chart will be further broke down splitting Classic Cars into multiple values.

Screenshot 2025-05-15 at 11 54 55

This control should not affect the original breakdown. If your intention is to allow more than one breakdown, we would need to change the Breakdown control to support multiple values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one I need some time to figure out (edited)

Copy link
Member

Choose a reason for hiding this comment

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

Got it. Let me know when this is fixed and I can review again.

Copy link

Choose a reason for hiding this comment

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

@michael-s-molina This is a feature, albeit one that merits caution and an explanation. The reason for this is that we need to have the ability to prescribe the order based on a sort order that is different than an alphanumeric sort that is affected by the dimension used in the x-axis.

For example. I have a waterfall below that bridges from Gross Revenue to Enterprise Profit.

It's important that the order is as follows:
Gross Revenue
Net Revenue
Gross Profit
Pre-Hurdle Profit
Enterprise Profit

We create this sort by sorting on Tier Sort v2, an engineered field that is designed to produce the result we need.

image

If we don't do this, we get the original behavior of the waterfall chart, which is to order the groupings as follows:

Enterprise Profit
Gross Profit
Net Revenue
Pre-Hurdle Profit

This creates an unacceptable result for this particular use case, and without the ability to mandate sort order by a different column, we are forced to rename our grouping entities with numeric prefixes or something (highly undesirable) in order to get something approximating correct behavior.

image

Perhaps we need a helper tip in the configure screen to provide instructions / context for the sort feature?

Copy link
Member

Choose a reason for hiding this comment

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

Your use case is valid @rea725, thanks for sharing. We have a similar feature in the Bar chart where users can sort the x-axis by a specific column. This is different than affecting the GROUP BY clause which is used in the Waterfall for the breakdowns. In the example below, you can think of Dimensions as the breakdowns, and users have the ability to sort the x-axis (product_line) by year. Notice how the GROUP BY is not affected.

Screen.Recording.2025-05-29.at.13.05.32.mov

I think we need to change this PR to match the X-Axis Sort By control of the Bar chart.

@anantaoutlook
Copy link
Contributor Author

@justinpark @kgabryje @michael-s-molina , please review this.

@michael-s-molina
Copy link
Member

@justinpark @kgabryje @michael-s-molina , please review this.

@anantaoutlook Was this comment resolved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants