sadpandajoe commented on code in PR #36050:
URL: https://github.com/apache/superset/pull/36050#discussion_r2674309091
##########
superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/TableRenderers.jsx:
##########
@@ -348,6 +433,108 @@ export class TableRenderer extends Component {
return spans;
}
+ getAggregatedData(pivotData, visibleColName, rowPartialOnTop) {
+ // Transforms flat row keys into a hierarchical group structure where each
level
+ // represents a grouping dimension. For each row key path, it calculates
the
+ // aggregated value for the specified column and builds a nested object
that
+ // preserves the hierarchy while storing aggregation values at each level.
+ const groups = {};
+ const rows = pivotData.rowKeys;
+ rows.forEach(rowKey => {
+ const aggValue =
+ pivotData.getAggregator(rowKey, visibleColName).value() ?? 0;
+
+ if (rowPartialOnTop) {
+ const parent = rowKey
+ .slice(0, -1)
+ .reduce((acc, key) => (acc[key] ??= {}), groups);
+ parent[rowKey.at(-1)] = { currentVal: aggValue };
+ } else {
+ rowKey.reduce((acc, key) => {
Review Comment:
When `rowPartialOnTop` is `false`, parent `currentVal` gets overwritten for
each leaf, so group order depends on the last leaf value. Should this be an
aggregate across children?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]