@ai-matrx/records-ui 0.116.12 → 0.116.14
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.
- package/CHANGELOG.md +31 -1
- package/dist/{chunk-HL7ZIVVJ.js → chunk-NE72B4OK.js} +163 -139
- package/dist/{chunk-HL7ZIVVJ.js.map → chunk-NE72B4OK.js.map} +1 -1
- package/dist/index.cjs +2569 -2441
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +125 -20
- package/dist/index.js.map +1 -1
- package/dist/pickers.cjs +212 -188
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.js +1 -1
- package/package.json +5 -5
package/dist/index.d.cts
CHANGED
|
@@ -5360,6 +5360,13 @@ interface ChartBlockProps {
|
|
|
5360
5360
|
* ("–"). Absent: the drawn groups added up.
|
|
5361
5361
|
*/
|
|
5362
5362
|
centerTotal?: number | null | undefined;
|
|
5363
|
+
/**
|
|
5364
|
+
* Value labels on the marks (the chart menu's "Data labels" switch): bars and columns at their end, line points
|
|
5365
|
+
* above, donut slices inside the ring (or outside with a leader for a thin slice). Labels that would collide are
|
|
5366
|
+
* left out, never drawn over each other; the card never changes size. `true`: values on bars and lines, each
|
|
5367
|
+
* slice's share on a donut; "value" / "share" choose for a donut.
|
|
5368
|
+
*/
|
|
5369
|
+
dataLabels?: boolean | "value" | "share" | undefined;
|
|
5363
5370
|
/** `false` draws no legend beside a donut and no value list under bars or a line. Default `true`. */
|
|
5364
5371
|
legend?: boolean | undefined;
|
|
5365
5372
|
/**
|
|
@@ -5383,7 +5390,7 @@ interface ChartBlockProps {
|
|
|
5383
5390
|
token: string;
|
|
5384
5391
|
} | undefined;
|
|
5385
5392
|
}
|
|
5386
|
-
declare function ChartBlock({ block, subject, tableName, className, centerValue, centerTotal, legend, groupColors, variant, source }: ChartBlockProps): react.JSX.Element;
|
|
5393
|
+
declare function ChartBlock({ block, subject, tableName, className, centerValue, centerTotal, dataLabels, legend, groupColors, variant, source }: ChartBlockProps): react.JSX.Element;
|
|
5387
5394
|
|
|
5388
5395
|
type ChartLayoutKind = "bar" | "line" | "donut";
|
|
5389
5396
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -5360,6 +5360,13 @@ interface ChartBlockProps {
|
|
|
5360
5360
|
* ("–"). Absent: the drawn groups added up.
|
|
5361
5361
|
*/
|
|
5362
5362
|
centerTotal?: number | null | undefined;
|
|
5363
|
+
/**
|
|
5364
|
+
* Value labels on the marks (the chart menu's "Data labels" switch): bars and columns at their end, line points
|
|
5365
|
+
* above, donut slices inside the ring (or outside with a leader for a thin slice). Labels that would collide are
|
|
5366
|
+
* left out, never drawn over each other; the card never changes size. `true`: values on bars and lines, each
|
|
5367
|
+
* slice's share on a donut; "value" / "share" choose for a donut.
|
|
5368
|
+
*/
|
|
5369
|
+
dataLabels?: boolean | "value" | "share" | undefined;
|
|
5363
5370
|
/** `false` draws no legend beside a donut and no value list under bars or a line. Default `true`. */
|
|
5364
5371
|
legend?: boolean | undefined;
|
|
5365
5372
|
/**
|
|
@@ -5383,7 +5390,7 @@ interface ChartBlockProps {
|
|
|
5383
5390
|
token: string;
|
|
5384
5391
|
} | undefined;
|
|
5385
5392
|
}
|
|
5386
|
-
declare function ChartBlock({ block, subject, tableName, className, centerValue, centerTotal, legend, groupColors, variant, source }: ChartBlockProps): react.JSX.Element;
|
|
5393
|
+
declare function ChartBlock({ block, subject, tableName, className, centerValue, centerTotal, dataLabels, legend, groupColors, variant, source }: ChartBlockProps): react.JSX.Element;
|
|
5387
5394
|
|
|
5388
5395
|
type ChartLayoutKind = "bar" | "line" | "donut";
|
|
5389
5396
|
/**
|
package/dist/index.js
CHANGED
|
@@ -172,7 +172,7 @@ import {
|
|
|
172
172
|
withoutAddition,
|
|
173
173
|
withoutLeadingBlank,
|
|
174
174
|
workedOutErrorFor
|
|
175
|
-
} from "./chunk-
|
|
175
|
+
} from "./chunk-NE72B4OK.js";
|
|
176
176
|
import {
|
|
177
177
|
CHART_PLOT_PX,
|
|
178
178
|
RECORDS_GRID_ROW_PX,
|
|
@@ -22976,6 +22976,7 @@ import {
|
|
|
22976
22976
|
BarChart,
|
|
22977
22977
|
CartesianGrid,
|
|
22978
22978
|
Cell,
|
|
22979
|
+
LabelList,
|
|
22979
22980
|
Legend,
|
|
22980
22981
|
Line as Line2,
|
|
22981
22982
|
LineChart,
|
|
@@ -23479,7 +23480,7 @@ function colorOfGroup(groups, colors) {
|
|
|
23479
23480
|
return colors[raw === null || raw === void 0 ? "" : String(raw)] ?? null;
|
|
23480
23481
|
}
|
|
23481
23482
|
var NO_GROUPS = { title: "", kind: "bar", group_by: [], rows: [] };
|
|
23482
|
-
function ChartBlock({ block, subject, tableName: tableName2, className, centerValue, centerTotal, legend = true, groupColors, variant = "card", source }) {
|
|
23483
|
+
function ChartBlock({ block, subject, tableName: tableName2, className, centerValue, centerTotal, dataLabels, legend = true, groupColors, variant = "card", source }) {
|
|
23483
23484
|
const bare = variant === "bare";
|
|
23484
23485
|
const host = useRecordsUi();
|
|
23485
23486
|
const kind2 = block.kind;
|
|
@@ -23592,7 +23593,8 @@ function ChartBlock({ block, subject, tableName: tableName2, className, centerVa
|
|
|
23592
23593
|
config,
|
|
23593
23594
|
onDrill: drill,
|
|
23594
23595
|
goal,
|
|
23595
|
-
...centerValue ? { center: centerTotal !== void 0 ? centerTotal : points
|
|
23596
|
+
...centerValue ? { center: centerTotal !== void 0 ? centerTotal : centerOfGroups(points, primary, measures[0].op) } : {},
|
|
23597
|
+
...dataLabels ? { dataLabels } : {},
|
|
23596
23598
|
showLegend: legend
|
|
23597
23599
|
}
|
|
23598
23600
|
),
|
|
@@ -23608,7 +23610,7 @@ function BigNumber({
|
|
|
23608
23610
|
onDrill,
|
|
23609
23611
|
block
|
|
23610
23612
|
}) {
|
|
23611
|
-
const summed = points
|
|
23613
|
+
const summed = centerOfGroups(points, measure, String(block.measures?.[0]?.op ?? "count"));
|
|
23612
23614
|
const total = block.totals && typeof block.totals.current === "number" ? block.totals.current : summed;
|
|
23613
23615
|
const records = points.reduce((sum, p) => sum + p.n, 0);
|
|
23614
23616
|
const windows = block.compare ?? null;
|
|
@@ -23616,7 +23618,7 @@ function BigNumber({
|
|
|
23616
23618
|
const priorTotal = block.totals?.prior;
|
|
23617
23619
|
const body = /* @__PURE__ */ jsxs72(Fragment34, { children: [
|
|
23618
23620
|
/* @__PURE__ */ jsxs72("span", { className: "flex items-baseline gap-2", children: [
|
|
23619
|
-
/* @__PURE__ */ jsx79("span", { className: "text-2xl font-semibold tabular-nums", children: pretty(total) }),
|
|
23621
|
+
/* @__PURE__ */ jsx79("span", { className: "text-2xl font-semibold tabular-nums", children: total === null ? "\u2013" : pretty(total) }),
|
|
23620
23622
|
windows ? /* @__PURE__ */ jsx79(Trend, { pct: block.totals?.change_pct, aimingUp: !!target, className: "text-sm" }) : null
|
|
23621
23623
|
] }),
|
|
23622
23624
|
/* @__PURE__ */ jsx79("span", { className: "text-xs text-muted-foreground", children: windows && typeof priorTotal === "number" ? `${windowName(windows.window, windows.period)} \xB7 ${pretty(priorTotal)} in ${windowName(windows.prior_window, windows.period)}` : `from ${formatCount4(records)} ${records === 1 ? "record" : "records"}` })
|
|
@@ -23735,6 +23737,11 @@ function StuckList({ rows }) {
|
|
|
23735
23737
|
] });
|
|
23736
23738
|
}
|
|
23737
23739
|
var HEIGHT = CHART_PLOT_PX;
|
|
23740
|
+
var MANY_SLICES = 24;
|
|
23741
|
+
function donutGap(slices) {
|
|
23742
|
+
if (slices <= 1) return 0;
|
|
23743
|
+
return slices > MANY_SLICES ? 180 / slices : 1;
|
|
23744
|
+
}
|
|
23738
23745
|
var DONUT_LEGEND_MAX_PX = 264;
|
|
23739
23746
|
function compactTick(value) {
|
|
23740
23747
|
if (typeof value !== "number" || !Number.isFinite(value)) return String(value ?? "");
|
|
@@ -23804,8 +23811,10 @@ function Drawing({
|
|
|
23804
23811
|
onDrill,
|
|
23805
23812
|
goal,
|
|
23806
23813
|
center,
|
|
23814
|
+
dataLabels,
|
|
23807
23815
|
showLegend = true
|
|
23808
23816
|
}) {
|
|
23817
|
+
const labelText = (v) => typeof v === "number" ? pretty(v).length > 7 ? compactTick(v) : pretty(v) : "";
|
|
23809
23818
|
const compared = series.length > 1;
|
|
23810
23819
|
const drawOrder = compared ? [series[1], series[0]] : series;
|
|
23811
23820
|
const goalLine = (horizontal2) => goal && typeof goal.value === "number" ? /* @__PURE__ */ jsx79(
|
|
@@ -23845,12 +23854,13 @@ function Drawing({
|
|
|
23845
23854
|
data,
|
|
23846
23855
|
dataKey: series[0],
|
|
23847
23856
|
nameKey: "label",
|
|
23848
|
-
innerRadius: 44,
|
|
23849
|
-
outerRadius: 66,
|
|
23850
|
-
|
|
23857
|
+
innerRadius: dataLabels ? DONUT_LABELLED.inner : 44,
|
|
23858
|
+
outerRadius: dataLabels ? DONUT_LABELLED.outer : 66,
|
|
23859
|
+
...dataLabels ? donutLabelProps(points.map((p) => p.values[series[0]] ?? 0), dataLabels === "value" ? (v) => labelText(v) : null) : {},
|
|
23860
|
+
paddingAngle: donutGap(points.length),
|
|
23851
23861
|
isAnimationActive: false,
|
|
23852
23862
|
...click ? { onClick: click, className: "cursor-pointer" } : {},
|
|
23853
|
-
children: points.map((point, at) => /* @__PURE__ */ jsx79(Cell, { fill: String(config[point.label]?.color ?? SERIES_COLORS[at % SERIES_COLORS.length]) }, `${at}:${point.label}`))
|
|
23863
|
+
children: points.map((point, at) => /* @__PURE__ */ jsx79(Cell, { fill: String(config[point.label]?.color ?? SERIES_COLORS[at % SERIES_COLORS.length]), ...points.length > MANY_SLICES ? { stroke: "none" } : {} }, `${at}:${point.label}`))
|
|
23854
23864
|
}
|
|
23855
23865
|
)
|
|
23856
23866
|
] }) });
|
|
@@ -23876,14 +23886,14 @@ function Drawing({
|
|
|
23876
23886
|
/* @__PURE__ */ jsx79("span", { className: "h-2.5 w-2.5 shrink-0 rounded-[2px]", style: { background: String(config[point.label]?.color ?? SERIES_COLORS[at % SERIES_COLORS.length]) } }),
|
|
23877
23887
|
/* @__PURE__ */ jsx79("span", { className: "min-w-0 flex-1 truncate", title: point.label, children: point.label }),
|
|
23878
23888
|
/* @__PURE__ */ jsx79("span", { className: "tabular-nums", "data-records-donut-value": "", children: pretty(value) }),
|
|
23879
|
-
/* @__PURE__ */ jsx79("span", { className: "w-10 shrink-0 text-right tabular-nums text-muted-foreground", "data-records-donut-share": "", children: `${share}%` })
|
|
23889
|
+
/* @__PURE__ */ jsx79("span", { className: "min-w-10 shrink-0 whitespace-nowrap text-right tabular-nums text-muted-foreground", "data-records-donut-share": "", children: `${share}%` })
|
|
23880
23890
|
] });
|
|
23881
23891
|
return /* @__PURE__ */ jsx79("li", { className: "min-w-0 text-xs", children: onDrill ? /* @__PURE__ */ jsx79("button", { type: "button", className: "flex w-full min-w-0 items-center gap-2 rounded px-1 py-0.5 text-left hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", onClick: () => onDrill(point), children: row }) : /* @__PURE__ */ jsx79("span", { className: "flex w-full min-w-0 items-center gap-2 px-1 py-0.5", children: row }) }, `${at}:${point.label}`);
|
|
23882
23892
|
}) }) : null
|
|
23883
23893
|
] });
|
|
23884
23894
|
}
|
|
23885
23895
|
if (kind2 === "line") {
|
|
23886
|
-
return /* @__PURE__ */ jsx79(ChartFrame, { config, height: HEIGHT, children: (width) => /* @__PURE__ */ jsxs72(LineChart, { width, height: HEIGHT, data, margin: { top: 6, right: 6, bottom: 0, left: 0 }, children: [
|
|
23896
|
+
return /* @__PURE__ */ jsx79(ChartFrame, { config, height: HEIGHT, children: (width) => /* @__PURE__ */ jsxs72(LineChart, { width, height: HEIGHT, data, margin: { top: dataLabels ? 16 : 6, right: dataLabels ? 14 : 6, bottom: 0, left: 0 }, children: [
|
|
23887
23897
|
/* @__PURE__ */ jsx79(CartesianGrid, { vertical: false }),
|
|
23888
23898
|
/* @__PURE__ */ jsx79(XAxis, { dataKey: "label", ...axis }),
|
|
23889
23899
|
/* @__PURE__ */ jsx79(YAxis, { width: 44, ...axis }),
|
|
@@ -23900,7 +23910,8 @@ function Drawing({
|
|
|
23900
23910
|
...key !== series[0] ? { strokeDasharray: "4 3" } : {},
|
|
23901
23911
|
dot: false,
|
|
23902
23912
|
isAnimationActive: false,
|
|
23903
|
-
...click ? { className: "cursor-pointer" } : {}
|
|
23913
|
+
...click ? { className: "cursor-pointer" } : {},
|
|
23914
|
+
children: dataLabels && key === series[0] ? /* @__PURE__ */ jsx79(LabelList, { dataKey: key, content: /* @__PURE__ */ jsx79(SpacedLabel, { show: labelsThatFit(points.map((p) => labelText(p.values[key])), width - 50), text: labelText, placement: "above" }) }) : null
|
|
23904
23915
|
},
|
|
23905
23916
|
key
|
|
23906
23917
|
))
|
|
@@ -23914,7 +23925,7 @@ function Drawing({
|
|
|
23914
23925
|
height: HEIGHT,
|
|
23915
23926
|
data,
|
|
23916
23927
|
layout: horizontal ? "vertical" : "horizontal",
|
|
23917
|
-
margin: { top: 6, right: 6, bottom: 0, left: 0 },
|
|
23928
|
+
margin: { top: dataLabels && !horizontal ? 16 : 6, right: dataLabels && horizontal ? 40 : 6, bottom: 0, left: 0 },
|
|
23918
23929
|
children: [
|
|
23919
23930
|
/* @__PURE__ */ jsx79(CartesianGrid, { vertical: horizontal, horizontal: !horizontal }),
|
|
23920
23931
|
horizontal ? /* @__PURE__ */ jsxs72(Fragment34, { children: [
|
|
@@ -23927,7 +23938,7 @@ function Drawing({
|
|
|
23927
23938
|
tooltip,
|
|
23928
23939
|
legend,
|
|
23929
23940
|
goalLine(horizontal),
|
|
23930
|
-
drawOrder.map((key, index) => /* @__PURE__ */
|
|
23941
|
+
drawOrder.map((key, index) => /* @__PURE__ */ jsxs72(
|
|
23931
23942
|
Bar,
|
|
23932
23943
|
{
|
|
23933
23944
|
dataKey: key,
|
|
@@ -23935,7 +23946,23 @@ function Drawing({
|
|
|
23935
23946
|
isAnimationActive: false,
|
|
23936
23947
|
fill: `var(--color-${key})`,
|
|
23937
23948
|
...click ? { onClick: click, className: "cursor-pointer" } : {},
|
|
23938
|
-
children:
|
|
23949
|
+
children: [
|
|
23950
|
+
series.length === 1 ? points.map((point, at) => /* @__PURE__ */ jsx79(Cell, { fill: String(config[point.label]?.color ?? SERIES_COLORS[index]) }, `${at}:${point.label}`)) : null,
|
|
23951
|
+
dataLabels && key === series[0] ? /* @__PURE__ */ jsx79(
|
|
23952
|
+
LabelList,
|
|
23953
|
+
{
|
|
23954
|
+
dataKey: key,
|
|
23955
|
+
content: /* @__PURE__ */ jsx79(
|
|
23956
|
+
SpacedLabel,
|
|
23957
|
+
{
|
|
23958
|
+
show: horizontal ? labelsThatFit(points.map(() => "0"), HEIGHT - 20, 11, true) : labelsThatFit(points.map((p) => labelText(p.values[key])), width - 50),
|
|
23959
|
+
text: labelText,
|
|
23960
|
+
placement: horizontal ? "end" : "above"
|
|
23961
|
+
}
|
|
23962
|
+
)
|
|
23963
|
+
}
|
|
23964
|
+
) : null
|
|
23965
|
+
]
|
|
23939
23966
|
},
|
|
23940
23967
|
key
|
|
23941
23968
|
))
|
|
@@ -23943,6 +23970,79 @@ function Drawing({
|
|
|
23943
23970
|
}
|
|
23944
23971
|
) });
|
|
23945
23972
|
}
|
|
23973
|
+
function centerOfGroups(points, key, op) {
|
|
23974
|
+
const vals = points.map((p) => p.values[key]).filter((v) => typeof v === "number" && Number.isFinite(v));
|
|
23975
|
+
if (op === "count" || op === "sum" || op === "filled" || op === "empty") return vals.reduce((a, b) => a + b, 0);
|
|
23976
|
+
if (!vals.length) return null;
|
|
23977
|
+
if (op === "min") return Math.min(...vals);
|
|
23978
|
+
if (op === "max") return Math.max(...vals);
|
|
23979
|
+
return null;
|
|
23980
|
+
}
|
|
23981
|
+
var LABEL_CHAR_PX = 6;
|
|
23982
|
+
function labelsThatFit(texts, span, fixedPx, fixed = false, gap = 4) {
|
|
23983
|
+
const n = texts.length;
|
|
23984
|
+
if (!n) return [];
|
|
23985
|
+
const band = Math.max(1, span / n);
|
|
23986
|
+
const widest = fixed ? fixedPx ?? 11 : Math.max(...texts.map((t) => t.length * LABEL_CHAR_PX)) + gap;
|
|
23987
|
+
const step2 = Math.max(1, Math.ceil(widest / band));
|
|
23988
|
+
return texts.map((_t, i) => i % step2 === 0);
|
|
23989
|
+
}
|
|
23990
|
+
function SpacedLabel(props) {
|
|
23991
|
+
const { show, text, placement, value, index = 0 } = props;
|
|
23992
|
+
const x = Number(props.x ?? 0);
|
|
23993
|
+
const y = Number(props.y ?? 0);
|
|
23994
|
+
const w = Number(props.width ?? 0);
|
|
23995
|
+
const h = Number(props.height ?? 0);
|
|
23996
|
+
if (!show[index]) return null;
|
|
23997
|
+
const words2 = text(value);
|
|
23998
|
+
if (!words2) return null;
|
|
23999
|
+
return placement === "end" ? /* @__PURE__ */ jsx79("text", { x: x + w + 4, y: y + h / 2, dominantBaseline: "central", fontSize: 10, className: "fill-muted-foreground tabular-nums", "data-records-chart-label": "", children: words2 }) : /* @__PURE__ */ jsx79("text", { x: x + w / 2, y: y - 5, textAnchor: "middle", fontSize: 10, className: "fill-muted-foreground tabular-nums", "data-records-chart-label": "", children: words2 });
|
|
24000
|
+
}
|
|
24001
|
+
var DONUT_LABELLED = { inner: 30, outer: 46 };
|
|
24002
|
+
function donutLabelPlan(values, outer = DONUT_LABELLED.outer) {
|
|
24003
|
+
const total = values.reduce((a, b) => a + (b > 0 ? b : 0), 0);
|
|
24004
|
+
if (total <= 0) return values.map(() => "none");
|
|
24005
|
+
let acc = 0;
|
|
24006
|
+
const lastY = { left: null, right: null };
|
|
24007
|
+
return values.map((v) => {
|
|
24008
|
+
const share = v > 0 ? v / total : 0;
|
|
24009
|
+
const mid = (acc + share / 2) * 2 * Math.PI;
|
|
24010
|
+
acc += share;
|
|
24011
|
+
if (share >= 0.09) return "inside";
|
|
24012
|
+
if (share < 0.03) return "none";
|
|
24013
|
+
const y = -Math.sin(mid) * (outer + 10);
|
|
24014
|
+
const side = Math.cos(mid) >= 0 ? "right" : "left";
|
|
24015
|
+
const prev = lastY[side];
|
|
24016
|
+
if (prev !== null && Math.abs(prev - y) < 11) return "none";
|
|
24017
|
+
lastY[side] = y;
|
|
24018
|
+
return "outside";
|
|
24019
|
+
});
|
|
24020
|
+
}
|
|
24021
|
+
function donutLabelProps(values, asValue) {
|
|
24022
|
+
const plan = donutLabelPlan(values);
|
|
24023
|
+
const total = values.reduce((a, b) => a + (b > 0 ? b : 0), 0);
|
|
24024
|
+
const words2 = (i) => asValue ? asValue(values[i] ?? 0) : `${Math.round((values[i] ?? 0) / (total || 1) * 100)}%`;
|
|
24025
|
+
return {
|
|
24026
|
+
labelLine: (p) => {
|
|
24027
|
+
const at = p.index ?? 0;
|
|
24028
|
+
const pts = p.points ?? [];
|
|
24029
|
+
if (plan[at] !== "outside" || pts.length < 2) return /* @__PURE__ */ jsx79("g", {});
|
|
24030
|
+
return /* @__PURE__ */ jsx79("polyline", { points: pts.map((q) => `${q.x},${q.y}`).join(" "), fill: "none", stroke: "currentColor", strokeOpacity: 0.4, strokeWidth: 1, "data-records-chart-leader": "" });
|
|
24031
|
+
},
|
|
24032
|
+
label: (p) => {
|
|
24033
|
+
const at = p.index ?? 0;
|
|
24034
|
+
const where = plan[at];
|
|
24035
|
+
if (!where || where === "none") return /* @__PURE__ */ jsx79("g", {});
|
|
24036
|
+
const rad = Math.PI / 180;
|
|
24037
|
+
const mid = p.midAngle ?? 0;
|
|
24038
|
+
if (where === "inside") {
|
|
24039
|
+
const r = ((p.innerRadius ?? 0) + (p.outerRadius ?? 0)) / 2;
|
|
24040
|
+
return /* @__PURE__ */ jsx79("text", { x: (p.cx ?? 0) + r * Math.cos(-mid * rad), y: (p.cy ?? 0) + r * Math.sin(-mid * rad), textAnchor: "middle", dominantBaseline: "central", fontSize: 9, className: "fill-background font-medium tabular-nums", "data-records-chart-label": "", children: words2(at) });
|
|
24041
|
+
}
|
|
24042
|
+
return /* @__PURE__ */ jsx79("text", { x: p.x ?? 0, y: p.y ?? 0, textAnchor: Math.cos(-mid * rad) >= 0 ? "start" : "end", dominantBaseline: "central", fontSize: 9, className: "fill-muted-foreground tabular-nums", "data-records-chart-label": "", children: words2(at) });
|
|
24043
|
+
}
|
|
24044
|
+
};
|
|
24045
|
+
}
|
|
23946
24046
|
function onlyWholeNumbers(rows) {
|
|
23947
24047
|
return rows.every(
|
|
23948
24048
|
(row) => Object.entries(row).every(([key, value]) => key === "label" || typeof value !== "number" || Number.isInteger(value))
|
|
@@ -23986,21 +24086,25 @@ function ChartLayout({ view, fields, filter, onChange, remembered }) {
|
|
|
23986
24086
|
let cancelled = false;
|
|
23987
24087
|
const asked2 = JSON.parse(filterKey);
|
|
23988
24088
|
const question = JSON.parse(qKey);
|
|
23989
|
-
|
|
24089
|
+
const whole = question.kind === "donut" ? client.recordAggregate({ table_id: view.subject, groupBy: [], measures: [question.measure], ...Object.keys(asked2).length > 0 ? { filter: asked2 } : {} }) : Promise.resolve(null);
|
|
24090
|
+
void Promise.all([client.recordAggregate({
|
|
23990
24091
|
table_id: view.subject,
|
|
23991
24092
|
groupBy: question.groupBy,
|
|
23992
24093
|
...question.bucket ? { bucket: question.bucket } : {},
|
|
23993
24094
|
measures: [question.measure],
|
|
23994
24095
|
limit: 200,
|
|
23995
24096
|
...Object.keys(asked2).length > 0 ? { filter: asked2 } : {}
|
|
23996
|
-
}).then((answered) => {
|
|
24097
|
+
}), whole]).then(([answered, overall]) => {
|
|
23997
24098
|
if (cancelled) return;
|
|
23998
24099
|
if (!answered.ok) {
|
|
23999
24100
|
setState({ block: null, error: answered.error });
|
|
24000
24101
|
return;
|
|
24001
24102
|
}
|
|
24103
|
+
const wholeRow = overall && overall.ok ? (overall.data ?? [])[0] : void 0;
|
|
24104
|
+
const wholeValue = wholeRow ? wholeRow.measures[measureKey4(question.measure)] : void 0;
|
|
24002
24105
|
setState({
|
|
24003
24106
|
error: null,
|
|
24107
|
+
...question.kind === "donut" ? { total: typeof wholeValue === "number" ? wholeValue : null } : {},
|
|
24004
24108
|
block: {
|
|
24005
24109
|
title: view.name,
|
|
24006
24110
|
kind: question.kind,
|
|
@@ -24047,7 +24151,7 @@ function ChartLayout({ view, fields, filter, onChange, remembered }) {
|
|
|
24047
24151
|
MEASURE_LABEL2[isChartMeasure(view.chartMeasure) ? view.chartMeasure : "count"],
|
|
24048
24152
|
" needs a number field \u2014 pick one above. Counting until then."
|
|
24049
24153
|
] }) : null,
|
|
24050
|
-
state.error ? /* @__PURE__ */ jsx80(RefusalNotice, { error: state.error }) : state.block ? /* @__PURE__ */ jsx80(ChartBlock, { block: state.block, subject: view.subject, variant: "bare", centerValue: true }) : null
|
|
24154
|
+
state.error ? /* @__PURE__ */ jsx80(RefusalNotice, { error: state.error }) : state.block ? /* @__PURE__ */ jsx80(ChartBlock, { block: state.block, subject: view.subject, variant: "bare", centerValue: true, ...state.total !== void 0 ? { centerTotal: state.total } : {} }) : null
|
|
24051
24155
|
] });
|
|
24052
24156
|
}
|
|
24053
24157
|
|
|
@@ -40756,7 +40860,8 @@ function blockOfAnswer(answer, base, by) {
|
|
|
40756
40860
|
for (const [k, v] of Object.entries(r.measures ?? {})) measuresOut[k] = typeof v === "number" ? v : v === null ? null : Number(v);
|
|
40757
40861
|
return { groups, measures: measuresOut, row_count: Number(r.row_count) };
|
|
40758
40862
|
});
|
|
40759
|
-
|
|
40863
|
+
const totalValue = answer.data.total?.measures ? Object.values(answer.data.total.measures)[0] : void 0;
|
|
40864
|
+
return { ...base, rows, center_total: typeof totalValue === "number" ? totalValue : totalValue === null || totalValue === void 0 ? null : Number(totalValue) };
|
|
40760
40865
|
}
|
|
40761
40866
|
function EntityChartBlock({ source, kind: kind2, by, measure, title, where, organization, centerValue, variant, className }) {
|
|
40762
40867
|
const client = useRecordsClient91();
|
|
@@ -40790,7 +40895,7 @@ function EntityChartBlock({ source, kind: kind2, by, measure, title, where, orga
|
|
|
40790
40895
|
block,
|
|
40791
40896
|
subject: source.token,
|
|
40792
40897
|
source,
|
|
40793
|
-
...centerValue ? { centerValue } : {},
|
|
40898
|
+
...centerValue ? { centerValue, ...block.center_total !== void 0 ? { centerTotal: block.center_total } : {} } : {},
|
|
40794
40899
|
...variant ? { variant } : {},
|
|
40795
40900
|
...className ? { className } : {}
|
|
40796
40901
|
}
|