We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5df2fff commit 864a4e9Copy full SHA for 864a4e9
1 file changed
packages/ui-components/src/ui/chart/bar-chart.tsx
@@ -61,10 +61,15 @@ export function BarChart({
61
const yAxisDomain = useMemo<[number, number]>(() => {
62
let max = 0;
63
for (const row of data) {
64
+ const stackTotals: Record<string, number> = {};
65
for (const bar of bars) {
66
const v = Number(row[bar.dataKey] ?? 0);
- if (v > max) {
67
- max = v;
+ const groupKey = bar.stackId ?? bar.dataKey;
68
+ stackTotals[groupKey] = (stackTotals[groupKey] ?? 0) + v;
69
+ }
70
+ for (const total of Object.values(stackTotals)) {
71
+ if (total > max) {
72
+ max = total;
73
}
74
75
0 commit comments