rusackas commented on code in PR #43684:
URL: https://github.com/apache/superset/pull/43684#discussion_r3890277470
##########
superset-frontend/plugins/plugin-chart-echarts/src/Butterfly/transformProps.ts:
##########
@@ -117,32 +114,59 @@ export default function transformProps(
...formData,
};
- const groupbyColumn = ensureIsArray(groupby)[0];
- const categoryLabel = getColumnLabel(groupbyColumn);
const leftMetricLabel = leftMetric ? getMetricLabel(leftMetric) : '';
const rightMetricLabel = rightMetric ? getMetricLabel(rightMetric) : '';
const leftSeriesName = leftLabel || leftMetricLabel;
const rightSeriesName = rightLabel || rightMetricLabel;
+ const coltypeMapping = getColtypesMapping(queriesData[0]);
+ const groupbyColumns = ensureIsArray(groupby);
+ const groupbyLabels = groupbyColumns.map(getColumnLabel);
+
const defaultFormatter = currencyFormat?.symbol
? new CurrencyFormatter({ d3Format: xAxisFormat, currency: currencyFormat
})
: getNumberFormatter(xAxisFormat);
- const categories = data.map(row => formatCategory(row[categoryLabel]));
- const leftData = data.map(row => {
- const value = Number(row[leftMetricLabel] ?? 0);
- return {
- value: -Math.abs(value),
- label: LABEL_LEFT,
- };
- });
- const rightData = data.map(row => {
- const value = Number(row[rightMetricLabel] ?? 0);
+ const categories = data.map(datum =>
+ extractGroupbyLabel({ datum, groupby: groupbyLabels, coltypeMapping }),
+ );
+
+ const labelMap = data.reduce<Record<string, string[]>>((acc, datum) => {
+ const label = extractGroupbyLabel({
+ datum,
+ groupby: groupbyLabels,
+ coltypeMapping,
+ });
return {
- value: Math.abs(value),
- label: LABEL_RIGHT,
+ ...acc,
+ [label]: groupbyLabels.map(col => datum[col] as string),
};
Review Comment:
This one's stale... the current code keys the label map by a composite key
(the label plus the JSON-encoded raw groupby values), so display collisions
can't overwrite each other, and there's a test covering the multi-groupby case.
Resolving.
--
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]