You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "eschutho (via GitHub)" <gi...@apache.org> on 2024/12/07 00:56:16 UTC
[PR] fix: remove sort values on stacked totals [superset]
eschutho opened a new pull request, #31333:
URL: https://github.com/apache/superset/pull/31333
<!---
Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/
Example:
fix(dashboard): load charts correctly
-->
### SUMMARY
<!--- Describe the change below, including rationale and design decisions -->
When a y axis sort is selected with a stacked bar chart with totals shown, the y axis column value was being added to the total. This pr checks that only the metrics are being used in calculating totals.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
<!--- Skip this if not applicable -->
Before:

<img width="2323" alt="Screenshot 2024-12-06 at 4 54 10 PM" src="https://github.com/user-attachments/assets/8ebd321c-4ead-4fe6-974d-fc0b9df8f91e">
### TESTING INSTRUCTIONS
<!--- Required! What steps can be taken to manually verify the changes? -->
Create a chart with one metric, and a sort value. Turn on stacked and show values. The sort value column should not be added to the total of the metric.
### ADDITIONAL INFORMATION
<!--- Check any relevant boxes with "x" -->
<!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] 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
--
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: remove sort values on stacked totals [superset]
Posted by "eschutho (via GitHub)" <gi...@apache.org>.
eschutho merged PR #31333:
URL: https://github.com/apache/superset/pull/31333
--
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: remove sort values on stacked totals [superset]
Posted by "kgabryje (via GitHub)" <gi...@apache.org>.
kgabryje commented on code in PR #31333:
URL: https://github.com/apache/superset/pull/31333#discussion_r1922921763
##########
superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts:
##########
@@ -290,12 +291,24 @@ export default function transformProps(
const showValueIndexesB = extractShowValueIndexes(rawSeriesB, {
stack,
});
+
+ const metricMapFunc = (metric: string | AdhocMetric) => {
+ if (metric.hasOwnProperty('label')) {
+ return (metric as AdhocMetric).label;
Review Comment:
I think we already have a util `getMetricLabel` for that
--
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: remove sort values on stacked totals [superset]
Posted by "eschutho (via GitHub)" <gi...@apache.org>.
eschutho commented on code in PR #31333:
URL: https://github.com/apache/superset/pull/31333#discussion_r1947332421
##########
superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts:
##########
@@ -291,12 +292,20 @@ export default function transformProps(
const showValueIndexesB = extractShowValueIndexes(rawSeriesB, {
stack,
});
+
+ const metricsLabels = metrics
+ .map(metric => getMetricLabel(metric, undefined, undefined, verboseMap))
Review Comment:
Since the map function is always going to pass the index and array as second and third args, I can't move them around, but I was thinking of changing `getMetricLabel` to accept an object, but there are over 40 places in the codebase where this map function is used, and in some cases, it's passed in directly like `map(getMetricLabel)` instead of as an anonymous function. It just seemed less risky to do it this way, but I agree that it's not pretty.
--
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: remove sort values on stacked totals [superset]
Posted by "eschutho (via GitHub)" <gi...@apache.org>.
eschutho commented on code in PR #31333:
URL: https://github.com/apache/superset/pull/31333#discussion_r1876416219
##########
superset-frontend/webpack.config.js:
##########
@@ -568,7 +568,7 @@ if (isDevMode) {
warnings: false,
runtimeErrors: error => !/ResizeObserver/.test(error.message),
},
- logging: 'error',
+ logging: 'verbose',
Review Comment:
thanks for catching.. no that was just for testing.
--
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: remove sort values on stacked totals [superset]
Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina commented on code in PR #31333:
URL: https://github.com/apache/superset/pull/31333#discussion_r1876366562
##########
superset-frontend/webpack.config.js:
##########
@@ -568,7 +568,7 @@ if (isDevMode) {
warnings: false,
runtimeErrors: error => !/ResizeObserver/.test(error.message),
},
- logging: 'error',
+ logging: 'verbose',
Review Comment:
Is this intended?
--
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: remove sort values on stacked totals [superset]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #31333:
URL: https://github.com/apache/superset/pull/31333#issuecomment-2599440133
@eschutho Processing your ephemeral environment request [here](https://github.com/apache/superset/actions/runs/12839369800).
--
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: remove sort values on stacked totals [superset]
Posted by "geido (via GitHub)" <gi...@apache.org>.
geido commented on code in PR #31333:
URL: https://github.com/apache/superset/pull/31333#discussion_r1941126511
##########
superset-frontend/packages/superset-ui-core/src/query/getMetricLabel.ts:
##########
@@ -19,17 +19,23 @@
import { QueryFormMetric, isSavedMetric, isAdhocMetricSimple } from './types';
-export default function getMetricLabel(metric: QueryFormMetric): string {
+export default function getMetricLabel(
+ metric: QueryFormMetric,
+ index?: number,
+ queryFormMetrics?: QueryFormMetric[],
+ verboseMap: Record<string, string> = {},
Review Comment:
Nit. Does it need to be defaulting to an empty object or can make this also optional and check for both undefined and empty?
##########
superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts:
##########
@@ -291,12 +292,20 @@ export default function transformProps(
const showValueIndexesB = extractShowValueIndexes(rawSeriesB, {
stack,
});
+
+ const metricsLabels = metrics
+ .map(metric => getMetricLabel(metric, undefined, undefined, verboseMap))
Review Comment:
Can we move the `verboseMap` before the other two optional parameters in the function so we don't have to pass the `undefined`s here at all? I don't see many other places mapping these values, so it might be safe to just revise the params positions, but if you feel that might introduce issues, feel free to skip this comment
--
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: remove sort values on stacked totals [superset]
Posted by "eschutho (via GitHub)" <gi...@apache.org>.
eschutho commented on code in PR #31333:
URL: https://github.com/apache/superset/pull/31333#discussion_r1938107616
##########
superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts:
##########
@@ -290,12 +292,20 @@ export default function transformProps(
const showValueIndexesB = extractShowValueIndexes(rawSeriesB, {
stack,
});
+
+ const metricsLabels = metrics
+ .map(metric => getMetricLabel(metric, undefined, undefined, verboseMap))
+ .filter((label): label is string => label !== undefined);
+ const metricsLabelsB = metricsB.map((metric: QueryFormMetric) =>
+ getMetricLabel(metric, undefined, undefined, verboseMap),
Review Comment:
@kgabryje lmk what you think. I don't like having to pass a bunch of undefined values, but it felt safer here than changing the args to kwargs (a js object). A bunch of the map functions are passing values that were unused in getMetricLabel.
--
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: remove sort values on stacked totals [superset]
Posted by "eschutho (via GitHub)" <gi...@apache.org>.
eschutho commented on code in PR #31333:
URL: https://github.com/apache/superset/pull/31333#discussion_r1931202208
##########
superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts:
##########
@@ -290,12 +291,24 @@ export default function transformProps(
const showValueIndexesB = extractShowValueIndexes(rawSeriesB, {
stack,
});
+
+ const metricMapFunc = (metric: string | AdhocMetric) => {
+ if (metric.hasOwnProperty('label')) {
+ return (metric as AdhocMetric).label;
Review Comment:
Ah, yes. How should that function work with the verboseMap, though?
--
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: remove sort values on stacked totals [superset]
Posted by "eschutho (via GitHub)" <gi...@apache.org>.
eschutho commented on PR #31333:
URL: https://github.com/apache/superset/pull/31333#issuecomment-2599440044
/testenv up
--
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