@shapesos/clay 0.16.0 → 0.17.0

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.
@@ -1087,11 +1087,6 @@ function coerceNumericColumns(rows, numericKeys) {
1087
1087
 
1088
1088
  // src/components/chart/bar-chart/bar-chart.tsx
1089
1089
  var import_jsx_runtime12 = require("react/jsx-runtime");
1090
- var STACK_TOTAL_KEY = "__stackTotal";
1091
- var VALUE_LABEL_HEADROOM = 20;
1092
- function sumSeries(row, keys) {
1093
- return keys.reduce((sum, key) => sum + (Number(row[key]) || 0), 0);
1094
- }
1095
1090
  function BarChart({
1096
1091
  data,
1097
1092
  xKey,
@@ -1106,7 +1101,6 @@ function BarChart({
1106
1101
  showGrid = true,
1107
1102
  showXAxis = true,
1108
1103
  showYAxis = true,
1109
- showValueLabels,
1110
1104
  xAxisInterval = 0,
1111
1105
  xAxisAngle,
1112
1106
  xAxisTickFormatter
@@ -1117,24 +1111,14 @@ function BarChart({
1117
1111
  [data, seriesKeys]
1118
1112
  );
1119
1113
  const resolvedShowLegend = showLegend ?? series.length > 1;
1120
- const resolvedShowValueLabels = showValueLabels ?? true;
1121
- const plotData = (0, import_react9.useMemo)(() => {
1122
- if (!stacked || !resolvedShowValueLabels) return coercedData;
1123
- return coercedData.map((row) => ({ ...row, [STACK_TOTAL_KEY]: sumSeries(row, seriesKeys) }));
1124
- }, [coercedData, stacked, resolvedShowValueLabels, seriesKeys]);
1125
1114
  const resolvedAngle = xAxisAngle ?? (coercedData.length >= 8 ? -30 : 0);
1126
1115
  const resolvedTickFormatter = (0, import_react9.useMemo)(
1127
1116
  () => xAxisTickFormatter ?? defaultBarTickFormatter(coercedData.length),
1128
1117
  [xAxisTickFormatter, coercedData.length]
1129
1118
  );
1130
1119
  const angledLabelPad = resolvedAngle === 0 ? 0 : Math.min(Math.abs(resolvedAngle) * 0.7, 40);
1131
- const valueLabelHeadroom = resolvedShowValueLabels ? VALUE_LABEL_HEADROOM : 0;
1132
- const chartMargin = {
1133
- ...CHART_MARGIN,
1134
- top: CHART_MARGIN.top + valueLabelHeadroom,
1135
- bottom: CHART_MARGIN.bottom + angledLabelPad
1136
- };
1137
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ChartContainer, { height, width, className, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_recharts2.BarChart, { data: plotData, margin: chartMargin, barCategoryGap: "22%", children: [
1120
+ const chartMargin = { ...CHART_MARGIN, bottom: CHART_MARGIN.bottom + angledLabelPad };
1121
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ChartContainer, { height, width, className, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_recharts2.BarChart, { data: coercedData, margin: chartMargin, barCategoryGap: "22%", children: [
1138
1122
  showGrid ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_recharts2.CartesianGrid, { ...CHART_GRID_PROPS }) : null,
1139
1123
  showXAxis ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1140
1124
  import_recharts2.XAxis,
@@ -1161,23 +1145,17 @@ function BarChart({
1161
1145
  content: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ChartLegendContent, { iconType: "square" })
1162
1146
  }
1163
1147
  ) : null,
1164
- series.map((s, i) => {
1165
- const isTopSegment = i === series.length - 1;
1166
- const labelDataKey = stacked ? STACK_TOTAL_KEY : s.key;
1167
- const showLabel = resolvedShowValueLabels && (!stacked || isTopSegment);
1168
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1169
- import_recharts2.Bar,
1170
- {
1171
- dataKey: s.key,
1172
- name: s.label,
1173
- fill: colorForSeriesIndex(i, palette),
1174
- stackId: stacked ? "default" : s.key,
1175
- radius: barRadius(stacked, i, series.length),
1176
- children: showLabel ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_recharts2.LabelList, { dataKey: labelDataKey, position: "top", style: CHART_VALUE_LABEL_STYLE }) : null
1177
- },
1178
- s.key
1179
- );
1180
- })
1148
+ series.map((s, i) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1149
+ import_recharts2.Bar,
1150
+ {
1151
+ dataKey: s.key,
1152
+ name: s.label,
1153
+ fill: colorForSeriesIndex(i, palette),
1154
+ stackId: stacked ? "default" : s.key,
1155
+ radius: barRadius(stacked, i, series.length)
1156
+ },
1157
+ s.key
1158
+ ))
1181
1159
  ] }) });
1182
1160
  }
1183
1161
  function barRadius(stacked, seriesIndex, seriesCount) {