@alpic-ai/ui 0.0.0-dev.g21c4835 → 0.0.0-dev.g21e767c

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -22,12 +22,23 @@ function BarChart({ data, index, series, variant = "stacked", legend = false, va
22
22
  const withTotal = stacked && rendered.length > 1;
23
23
  const numericMax = React$1.useMemo(() => {
24
24
  let max = 0;
25
- for (const row of data) for (const entry of series) {
26
- const value = Number(row[entry.key]);
27
- if (Number.isFinite(value) && value > max) max = value;
25
+ for (const row of data) {
26
+ let rowTotal = 0;
27
+ for (const entry of series) {
28
+ const value = Number(row[entry.key]);
29
+ if (Number.isFinite(value)) {
30
+ rowTotal += value;
31
+ if (!stacked && value > max) max = value;
32
+ }
33
+ }
34
+ if (stacked && rowTotal > max) max = rowTotal;
28
35
  }
29
36
  return max;
30
- }, [data, series]);
37
+ }, [
38
+ data,
39
+ series,
40
+ stacked
41
+ ]);
31
42
  const margin = {
32
43
  top: markers?.length || valueLabels ? 18 : 8,
33
44
  right: 8,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alpic-ai/ui",
3
- "version": "0.0.0-dev.g21c4835",
3
+ "version": "0.0.0-dev.g21e767c",
4
4
  "description": "Alpic design system — shared UI components",
5
5
  "type": "module",
6
6
  "exports": {
@@ -75,18 +75,27 @@ function BarChart({
75
75
  const lead = resolved[0];
76
76
  const withTotal = stacked && rendered.length > 1;
77
77
 
78
+ // Stacked bars reach the stack height (sum per x-point), not the tallest single
79
+ // series, so the explicit YAxis domain must not clip a tall stack short.
78
80
  const numericMax = React.useMemo(() => {
79
81
  let max = 0;
80
82
  for (const row of data) {
83
+ let rowTotal = 0;
81
84
  for (const entry of series) {
82
85
  const value = Number(row[entry.key]);
83
- if (Number.isFinite(value) && value > max) {
84
- max = value;
86
+ if (Number.isFinite(value)) {
87
+ rowTotal += value;
88
+ if (!stacked && value > max) {
89
+ max = value;
90
+ }
85
91
  }
86
92
  }
93
+ if (stacked && rowTotal > max) {
94
+ max = rowTotal;
95
+ }
87
96
  }
88
97
  return max;
89
- }, [data, series]);
98
+ }, [data, series, stacked]);
90
99
 
91
100
  const margin = { top: markers?.length || valueLabels ? 18 : 8, right: 8, bottom: 2, left: 0 };
92
101