-
Notifications
You must be signed in to change notification settings - Fork 15k
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 |
---|---|---|
Deeply nested complex function ▹ view | ✅ Fix detected | |
Scattered series transformation logic ▹ view | ✅ Fix detected | |
Suspicious file suffix in types import ▹ view | ✅ Fix detected | |
Inaccurate Text Wrapping Calculation ▹ view | ✅ Fix detected | |
Order Direction Control Not Dependent on Column Selection ▹ view | ✅ Fix detected | |
Remove or implement commented validators ▹ view | ✅ Fix detected | |
Type inconsistency in default value ▹ view | ✅ Fix detected | |
Inadequate Error Handling for Invalid Label Distance ▹ view | ✅ Fix detected | |
Inconsistent Mixed-Type Data Sorting ▹ view | ✅ Fix detected | |
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.
superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/index.ts
Outdated
Show resolved
Hide resolved
superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/controlPanel.tsx
Outdated
Show resolved
Hide resolved
superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/controlPanel.tsx
Outdated
Show resolved
Hide resolved
superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/controlPanel.tsx
Outdated
Show resolved
Hide resolved
superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/EchartsWaterfall.tsx
Show resolved
Hide resolved
superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/EchartsWaterfall.tsx
Outdated
Show resolved
Hide resolved
superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/EchartsWaterfall.tsx
Outdated
Show resolved
Hide resolved
superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/EchartsWaterfall.tsx
Outdated
Show resolved
Hide resolved
superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/EchartsWaterfall.tsx
Outdated
Show resolved
Hide resolved
superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/EchartsWaterfall.tsx
Outdated
Show resolved
Hide resolved
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. |
The work performed on Superset by @anantaoutlook in this PR includes the following improvements: 1.) Horizontal waterfall in addition to vertical. 2.) Axis label fixes to word-wrap longer labels instead of hiding them. This is extremely important for readability/usability. 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: 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. 5.) Cross-filtering is now feasible for the waterfall chart. |
Thanks @anantaoutlook @rea725 for the great improvements! I updated the PR description with @rea725's comment.
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.
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. |
@anantaoutlook Could you also fill the Testing Instructions part of the PR description? |
There was a problem hiding this 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!
superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/controlPanel.tsx
Outdated
Show resolved
Hide resolved
superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/controlPanel.tsx
Outdated
Show resolved
Hide resolved
superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/controlPanel.tsx
Outdated
Show resolved
Hide resolved
superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/controlPanel.tsx
Outdated
Show resolved
Hide resolved
superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/controlPanel.tsx
Outdated
Show resolved
Hide resolved
superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/controlPanel.tsx
Outdated
Show resolved
Hide resolved
superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/controlPanel.tsx
Outdated
Show resolved
Hide resolved
superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/controlPanel.tsx
Outdated
Show resolved
Hide resolved
superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/controlPanel.tsx
Outdated
Show resolved
Hide resolved
superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/controlPanel.tsx
Outdated
Show resolved
Hide resolved
superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/controlPanel.tsx
Outdated
Show resolved
Hide resolved
superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/controlPanel.tsx
Outdated
Show resolved
Hide resolved
superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/controlPanel.tsx
Outdated
Show resolved
Hide resolved
superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/controlPanel.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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?
superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/EchartsWaterfall.tsx
Outdated
Show resolved
Hide resolved
} | ||
|
||
// get the width of xAxis to calculate the maxCharsPerLine | ||
const getAxisRange = (options: EChartsCoreOption) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still trying to understand why all these calculations are needed given that ECharts makes most of them already. There is even an option to force all labels to be rendered. What use case is not covered by ECharts? Can you create an example using their code editor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example, using a combination of interval, overflow, and width, I can have something like:
axisLabel.interval = 0;
axisLabel.overflow = 'break';
axisLabel.width = 25;

Here's a live editor where you can play with the settings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still trying to understand why all these calculations are needed given that ECharts makes most of them already. There is even an option to force all labels to be rendered. What use case is not covered by ECharts? Can you create an example using their code editor?
Here the label break arbitrarily on any point
https://echarts.apache.org/examples/en/editor.html?c=bar-waterfall2&code=PYBwLglsB2AEC[…]JlyPLW3bNv630Olm2jzlmrnpc52jfR47A2oI5jsCvDp2rygkHmwM3qiNEAA
but the current change supports breaking at the end of word
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@villebro As one of maintainers of ECharts, are we missing some configuration here or ECharts doesn't support this? I'm just worried that this problem affects all charts and it's not an exclusivity of the Waterfall.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed this issue now, used a combination of overflow, width and interval
superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/controlPanel.tsx
Outdated
Show resolved
Hide resolved
superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/controlPanel.tsx
Outdated
Show resolved
Hide resolved
superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/controlPanel.tsx
Outdated
Show resolved
Hide resolved
@@ -16,16 +16,46 @@ | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
import React from 'react'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shoudn't need a React import... there are two linting errors caused by this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -25,6 +25,7 @@ import { | |||
formatSelectOptions, | |||
sharedControls, | |||
} from '@superset-ui/chart-controls'; | |||
import React from 'react'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the other one. You shouldn't need it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
There was a problem hiding this 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.
}, | ||
], | ||
[ | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
[ | ||
{ | ||
name: 'sort_x_axis', | ||
config: { | ||
type: 'SelectControl', | ||
label: t('Sort x axis'), | ||
default: 'none', | ||
choices: [ | ||
['none', t('None')], | ||
['asc', t('Ascending')], | ||
['desc', t('Descending')], | ||
], | ||
renderTrigger: true, | ||
description: t('Sort X axis in ascending or descending order'), | ||
}, | ||
}, | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this the same as Order direction?
[ | |
{ | |
name: 'sort_x_axis', | |
config: { | |
type: 'SelectControl', | |
label: t('Sort x axis'), | |
default: 'none', | |
choices: [ | |
['none', t('None')], | |
['asc', t('Ascending')], | |
['desc', t('Descending')], | |
], | |
renderTrigger: true, | |
description: t('Sort X axis in ascending or descending order'), | |
}, | |
}, | |
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -28,6 +28,25 @@ export default function buildQuery(formData: QueryFormData) { | |||
...ensureIsArray(x_axis || granularity_sqla), | |||
...ensureIsArray(groupby), | |||
]; | |||
|
|||
if (columns.indexOf(formData.seriesOrderByColumn) === -1) { |
There was a problem hiding this comment.
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
.

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

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.
There was a problem hiding this comment.
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)
SUMMARY
This PR includes the following improvements:
1.) Horizontal waterfall in addition to vertical.

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:
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:


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:
After:
5.) Cross-filtering is now feasible for the waterfall chart.
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION