Fix bar chart X-axis labels when groupBy matches aggregate field (#15473)

closes -
https://discord.com/channels/1130383047699738754/1430899754728030309
This commit is contained in:
nitin
2025-10-30 20:23:17 +05:30
committed by GitHub
parent abcc891aed
commit 33eaa4f2a2
@@ -45,6 +45,11 @@ export const transformOneDimensionalGroupByToBarChartData = ({
subFieldName: primaryAxisSubFieldName ?? undefined,
});
const aggregateValueKey =
indexByKey === aggregateField.name
? `${aggregateField.name}-aggregate`
: aggregateField.name;
// TODO: Add a limit to the query instead of slicing here (issue: twentyhq/core-team-issues#1600)
const limitedResults = rawResults.slice(0, GRAPH_MAXIMUM_NUMBER_OF_GROUPS);
@@ -71,13 +76,13 @@ export const transformOneDimensionalGroupByToBarChartData = ({
return {
[indexByKey]: xValue,
[aggregateField.name]: aggregateValue,
[aggregateValueKey]: aggregateValue,
};
});
const series: BarChartSeries[] = [
{
key: aggregateField.name,
key: aggregateValueKey,
label: aggregateField.label,
color: (configuration.color ?? GRAPH_DEFAULT_COLOR) as GraphColor,
},
@@ -86,7 +91,7 @@ export const transformOneDimensionalGroupByToBarChartData = ({
return {
data,
indexBy: indexByKey,
keys: [aggregateField.name],
keys: [aggregateValueKey],
series,
hasTooManyGroups: rawResults.length > GRAPH_MAXIMUM_NUMBER_OF_GROUPS,
};