drizzle-cube 0.2.11 → 0.2.13
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/dist/adapters/compiler-CMwSRhTS.cjs +22 -0
- package/dist/adapters/{compiler-gcKytLwd.js → compiler-DrkCCzf0.js} +16 -11
- package/dist/adapters/express/index.cjs +1 -1
- package/dist/adapters/express/index.js +8 -8
- package/dist/adapters/fastify/index.cjs +1 -1
- package/dist/adapters/fastify/index.js +9 -9
- package/dist/adapters/hono/index.cjs +1 -1
- package/dist/adapters/hono/index.js +11 -11
- package/dist/adapters/nextjs/index.cjs +1 -1
- package/dist/adapters/nextjs/index.js +59 -59
- package/dist/client/charts.js +11 -11
- package/dist/client/chunks/{chart-activitygridchart-D17Fxiuf.js → chart-activitygridchart-CUGN9Xq9.js} +3 -2
- package/dist/client/chunks/chart-activitygridchart-CUGN9Xq9.js.map +1 -0
- package/dist/client/chunks/{chart-areachart-udSbAzl1.js → chart-areachart-B4tknnsY.js} +25 -25
- package/dist/client/chunks/{chart-areachart-udSbAzl1.js.map → chart-areachart-B4tknnsY.js.map} +1 -1
- package/dist/client/chunks/{chart-axisformatcontrols-DqSa245M.js → chart-axisformatcontrols-Ch_IYF94.js} +18 -18
- package/dist/client/chunks/chart-axisformatcontrols-Ch_IYF94.js.map +1 -0
- package/dist/client/chunks/{chart-barchart-CDIpqCKS.js → chart-barchart-D_op06r-.js} +6 -6
- package/dist/client/chunks/{chart-barchart-CDIpqCKS.js.map → chart-barchart-D_op06r-.js.map} +1 -1
- package/dist/client/chunks/{chart-bubblechart-CivK_yfh.js → chart-bubblechart-BsaIXUbS.js} +3 -3
- package/dist/client/chunks/chart-bubblechart-BsaIXUbS.js.map +1 -0
- package/dist/client/chunks/{chart-charttooltip-BVEdz4Q-.js → chart-charttooltip-Bx3I8jQv.js} +2 -2
- package/dist/client/chunks/{chart-charttooltip-BVEdz4Q-.js.map → chart-charttooltip-Bx3I8jQv.js.map} +1 -1
- package/dist/client/chunks/{chart-datatable-NHE7BTMr.js → chart-datatable-C7MS9q4Y.js} +2 -2
- package/dist/client/chunks/{chart-datatable-NHE7BTMr.js.map → chart-datatable-C7MS9q4Y.js.map} +1 -1
- package/dist/client/chunks/{chart-kpidelta-D-FR2o4V.js → chart-kpidelta-7-KOmb3w.js} +62 -60
- package/dist/client/chunks/chart-kpidelta-7-KOmb3w.js.map +1 -0
- package/dist/client/chunks/{chart-kpinumber-DSH8RJxb.js → chart-kpinumber-HOPfcK2N.js} +4 -4
- package/dist/client/chunks/{chart-kpinumber-DSH8RJxb.js.map → chart-kpinumber-HOPfcK2N.js.map} +1 -1
- package/dist/client/chunks/{chart-kpitext-Z9oh0bJq.js → chart-kpitext-BZkC9u3A.js} +24 -24
- package/dist/client/chunks/{chart-kpitext-Z9oh0bJq.js.map → chart-kpitext-BZkC9u3A.js.map} +1 -1
- package/dist/client/chunks/{chart-linechart-D4r0uD1j.js → chart-linechart-DqFmLbRe.js} +7 -7
- package/dist/client/chunks/{chart-linechart-D4r0uD1j.js.map → chart-linechart-DqFmLbRe.js.map} +1 -1
- package/dist/client/chunks/chart-markdownchart-9n_TemoB.js +256 -0
- package/dist/client/chunks/chart-markdownchart-9n_TemoB.js.map +1 -0
- package/dist/client/chunks/{chart-piechart-BhttUWuH.js → chart-piechart-CrXFd9pE.js} +6 -6
- package/dist/client/chunks/{chart-piechart-BhttUWuH.js.map → chart-piechart-CrXFd9pE.js.map} +1 -1
- package/dist/client/chunks/{chart-radarchart-DnqlfoGr.js → chart-radarchart-tar2GBkO.js} +5 -5
- package/dist/client/chunks/{chart-radarchart-DnqlfoGr.js.map → chart-radarchart-tar2GBkO.js.map} +1 -1
- package/dist/client/chunks/{chart-radialbarchart-BFxxiqLw.js → chart-radialbarchart-ab8Swtal.js} +5 -5
- package/dist/client/chunks/{chart-radialbarchart-BFxxiqLw.js.map → chart-radialbarchart-ab8Swtal.js.map} +1 -1
- package/dist/client/chunks/{chart-scatterchart-MN4SM-w7.js → chart-scatterchart-BP06BeU5.js} +5 -5
- package/dist/client/chunks/{chart-scatterchart-MN4SM-w7.js.map → chart-scatterchart-BP06BeU5.js.map} +1 -1
- package/dist/client/chunks/{chart-treemapchart-Nozh2m26.js → chart-treemapchart-DAiixITm.js} +31 -31
- package/dist/client/chunks/{chart-treemapchart-Nozh2m26.js.map → chart-treemapchart-DAiixITm.js.map} +1 -1
- package/dist/client/chunks/{charts-BSDHSv4l.js → charts-CHzWeaY1.js} +26 -26
- package/dist/client/chunks/charts-CHzWeaY1.js.map +1 -0
- package/dist/client/chunks/{components-CbDovlG-.js → components-DnM9CCUS.js} +2453 -2445
- package/dist/client/chunks/components-DnM9CCUS.js.map +1 -0
- package/dist/client/chunks/{index-th92_8oL.js → index-DlsvcKXf.js} +135 -135
- package/dist/client/chunks/index-DlsvcKXf.js.map +1 -0
- package/dist/client/components/AnalysisBuilder/AnalysisAxisDropZone.d.ts +5 -5
- package/dist/client/components/AnalysisBuilder/SectionHeading.d.ts +2 -7
- package/dist/client/components/AnalysisBuilder/types.d.ts +8 -8
- package/dist/client/components.js +2 -2
- package/dist/client/hooks/useResponsiveDashboard.d.ts +2 -8
- package/dist/client/hooks.js +2 -2
- package/dist/client/hooks.js.map +1 -1
- package/dist/client/icons/types.d.ts +2 -2
- package/dist/client/index.js +3 -3
- package/dist/client/providers.js +1 -1
- package/dist/client/styles.css +1 -1
- package/dist/client-bundle-stats.html +1 -1
- package/dist/server/index.cjs +2 -2
- package/dist/server/index.js +16 -11
- package/package.json +3 -3
- package/dist/adapters/compiler-DP1pPIcg.cjs +0 -22
- package/dist/client/chunks/chart-activitygridchart-D17Fxiuf.js.map +0 -1
- package/dist/client/chunks/chart-axisformatcontrols-DqSa245M.js.map +0 -1
- package/dist/client/chunks/chart-bubblechart-CivK_yfh.js.map +0 -1
- package/dist/client/chunks/chart-kpidelta-D-FR2o4V.js.map +0 -1
- package/dist/client/chunks/chart-markdownchart-C3FAQFuO.js +0 -254
- package/dist/client/chunks/chart-markdownchart-C3FAQFuO.js.map +0 -1
- package/dist/client/chunks/charts-BSDHSv4l.js.map +0 -1
- package/dist/client/chunks/components-CbDovlG-.js.map +0 -1
- package/dist/client/chunks/index-th92_8oL.js.map +0 -1
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as i, jsxs as c } from "react/jsx-runtime";
|
|
2
2
|
import { useState as K, useRef as _, useEffect as te } from "react";
|
|
3
3
|
import { ac as ne, k as se } from "./icons-B2XSxpVK.js";
|
|
4
|
-
import { u as re } from "./chart-activitygridchart-
|
|
4
|
+
import { u as re } from "./chart-activitygridchart-CUGN9Xq9.js";
|
|
5
5
|
function ie(s, r) {
|
|
6
6
|
const e = new Date(s);
|
|
7
7
|
switch (r.toLowerCase()) {
|
|
8
8
|
case "day":
|
|
9
9
|
e.setHours(23, 59, 59, 999);
|
|
10
10
|
break;
|
|
11
|
-
case "week":
|
|
11
|
+
case "week": {
|
|
12
12
|
const n = 6 - e.getDay();
|
|
13
13
|
e.setDate(e.getDate() + n), e.setHours(23, 59, 59, 999);
|
|
14
14
|
break;
|
|
15
|
+
}
|
|
15
16
|
case "month":
|
|
16
17
|
e.setMonth(e.getMonth() + 1, 0), e.setHours(23, 59, 59, 999);
|
|
17
18
|
break;
|
|
18
|
-
case "quarter":
|
|
19
|
-
const
|
|
20
|
-
e.setMonth(
|
|
19
|
+
case "quarter": {
|
|
20
|
+
const l = e.getMonth(), n = Math.floor(l / 3) * 3 + 2;
|
|
21
|
+
e.setMonth(n + 1, 0), e.setHours(23, 59, 59, 999);
|
|
21
22
|
break;
|
|
23
|
+
}
|
|
22
24
|
case "year":
|
|
23
25
|
e.setMonth(11, 31), e.setHours(23, 59, 59, 999);
|
|
24
26
|
break;
|
|
@@ -49,36 +51,36 @@ function ae(s, r) {
|
|
|
49
51
|
return s.timeDimensions[0]?.granularity || null;
|
|
50
52
|
}
|
|
51
53
|
function ce(s, r, e, l, n = !1) {
|
|
52
|
-
const
|
|
54
|
+
const o = {
|
|
53
55
|
filteredData: s,
|
|
54
56
|
excludedIncompletePeriod: !1,
|
|
55
57
|
skippedLastPeriod: !1,
|
|
56
58
|
granularity: null
|
|
57
59
|
};
|
|
58
60
|
if (s.length < 2)
|
|
59
|
-
return
|
|
60
|
-
const
|
|
61
|
+
return o;
|
|
62
|
+
const a = ae(e, r);
|
|
61
63
|
if (n)
|
|
62
64
|
return {
|
|
63
65
|
filteredData: s.slice(0, -1),
|
|
64
66
|
excludedIncompletePeriod: !1,
|
|
65
67
|
skippedLastPeriod: !0,
|
|
66
|
-
granularity:
|
|
68
|
+
granularity: a
|
|
67
69
|
};
|
|
68
70
|
if (!l)
|
|
69
|
-
return { ...
|
|
71
|
+
return { ...o, granularity: a };
|
|
70
72
|
if (!r)
|
|
71
|
-
return { ...
|
|
73
|
+
return { ...o, granularity: a };
|
|
72
74
|
if (!e?.timeDimensions || e.timeDimensions.length === 0)
|
|
73
|
-
return { ...
|
|
74
|
-
if (!
|
|
75
|
-
return
|
|
75
|
+
return { ...o, granularity: a };
|
|
76
|
+
if (!a)
|
|
77
|
+
return o;
|
|
76
78
|
const N = s[s.length - 1];
|
|
77
|
-
return oe(N, r,
|
|
79
|
+
return oe(N, r, a) ? { ...o, granularity: a } : {
|
|
78
80
|
filteredData: s.slice(0, -1),
|
|
79
81
|
excludedIncompletePeriod: !0,
|
|
80
82
|
skippedLastPeriod: !1,
|
|
81
|
-
granularity:
|
|
83
|
+
granularity: a
|
|
82
84
|
};
|
|
83
85
|
}
|
|
84
86
|
function le({
|
|
@@ -87,31 +89,31 @@ function le({
|
|
|
87
89
|
positiveColor: e,
|
|
88
90
|
negativeColor: l,
|
|
89
91
|
formatValue: n,
|
|
90
|
-
width:
|
|
91
|
-
height:
|
|
92
|
+
width: o,
|
|
93
|
+
height: a
|
|
92
94
|
}) {
|
|
93
|
-
const N = Math.max(10, Math.floor(
|
|
95
|
+
const N = Math.max(10, Math.floor(o / 10)), g = s.length > N ? s.slice(-N) : s, y = g.map((h) => h - r), d = Math.min(...y, 0), f = Math.max(...y, 0);
|
|
94
96
|
if (Math.max(Math.abs(d), Math.abs(f)) === 0 || y.length === 0)
|
|
95
|
-
return /* @__PURE__ */
|
|
97
|
+
return /* @__PURE__ */ i(
|
|
96
98
|
"div",
|
|
97
99
|
{
|
|
98
|
-
className: "flex items-center justify-center bg-
|
|
99
|
-
style: { width: `${
|
|
100
|
-
children: /* @__PURE__ */
|
|
100
|
+
className: "flex items-center justify-center bg-dc-bg-secondary rounded-sm border border-dc-border",
|
|
101
|
+
style: { width: `${o}px`, height: `${a}px` },
|
|
102
|
+
children: /* @__PURE__ */ i("span", { className: "text-xs text-dc-text-muted", children: "No variance data" })
|
|
101
103
|
}
|
|
102
104
|
);
|
|
103
|
-
const M = 2, k =
|
|
105
|
+
const M = 2, k = o - (g.length - 1) * M, w = Math.max(4, k / g.length), x = f - d, b = x > 0 ? f / x * 100 : 50;
|
|
104
106
|
return /* @__PURE__ */ c("div", { className: "flex items-center space-x-2", children: [
|
|
105
107
|
/* @__PURE__ */ c(
|
|
106
108
|
"div",
|
|
107
109
|
{
|
|
108
110
|
className: "relative",
|
|
109
111
|
style: {
|
|
110
|
-
width: `${
|
|
111
|
-
height: `${
|
|
112
|
+
width: `${o}px`,
|
|
113
|
+
height: `${a}px`
|
|
112
114
|
},
|
|
113
115
|
children: [
|
|
114
|
-
/* @__PURE__ */
|
|
116
|
+
/* @__PURE__ */ i(
|
|
115
117
|
"div",
|
|
116
118
|
{
|
|
117
119
|
className: "absolute left-0 right-0",
|
|
@@ -124,8 +126,8 @@ function le({
|
|
|
124
126
|
}
|
|
125
127
|
),
|
|
126
128
|
y.map((h, D) => {
|
|
127
|
-
const I = Math.abs(h) / x, P = Math.max(2, I * (
|
|
128
|
-
return /* @__PURE__ */
|
|
129
|
+
const I = Math.abs(h) / x, P = Math.max(2, I * (a - 4)), z = h >= 0, H = D === g.length - 1, j = z ? e : l, u = D * (w + M);
|
|
130
|
+
return /* @__PURE__ */ i(
|
|
129
131
|
"div",
|
|
130
132
|
{
|
|
131
133
|
className: "absolute rounded-xs",
|
|
@@ -151,7 +153,7 @@ function le({
|
|
|
151
153
|
"div",
|
|
152
154
|
{
|
|
153
155
|
className: "flex flex-col justify-between text-xs text-dc-text-muted",
|
|
154
|
-
style: { height: `${
|
|
156
|
+
style: { height: `${a}px` },
|
|
155
157
|
children: [
|
|
156
158
|
/* @__PURE__ */ c("span", { children: [
|
|
157
159
|
"+",
|
|
@@ -172,9 +174,9 @@ function de({
|
|
|
172
174
|
displayConfig: e = {},
|
|
173
175
|
queryObject: l,
|
|
174
176
|
height: n = "100%",
|
|
175
|
-
colorPalette:
|
|
177
|
+
colorPalette: o
|
|
176
178
|
}) {
|
|
177
|
-
const [
|
|
179
|
+
const [a, N] = K(32), [g, y] = K(250), d = _(null), f = _(null), { getFieldLabel: W } = re();
|
|
178
180
|
if (te(() => {
|
|
179
181
|
const t = () => {
|
|
180
182
|
if (d.current) {
|
|
@@ -199,7 +201,7 @@ function de({
|
|
|
199
201
|
clearTimeout(p), v.disconnect();
|
|
200
202
|
};
|
|
201
203
|
}, [s, r]), !s || s.length === 0)
|
|
202
|
-
return /* @__PURE__ */
|
|
204
|
+
return /* @__PURE__ */ i(
|
|
203
205
|
"div",
|
|
204
206
|
{
|
|
205
207
|
className: "flex items-center justify-center w-full h-full",
|
|
@@ -208,14 +210,14 @@ function de({
|
|
|
208
210
|
minHeight: n === "100%" ? "200px" : void 0
|
|
209
211
|
},
|
|
210
212
|
children: /* @__PURE__ */ c("div", { className: "text-center text-dc-text-muted", children: [
|
|
211
|
-
/* @__PURE__ */
|
|
212
|
-
/* @__PURE__ */
|
|
213
|
+
/* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
|
|
214
|
+
/* @__PURE__ */ i("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display" })
|
|
213
215
|
] })
|
|
214
216
|
}
|
|
215
217
|
);
|
|
216
218
|
let M = [], k = [];
|
|
217
219
|
if (r?.yAxis && (M = Array.isArray(r.yAxis) ? r.yAxis : [r.yAxis]), r?.xAxis && (k = Array.isArray(r.xAxis) ? r.xAxis : [r.xAxis]), M.length === 0)
|
|
218
|
-
return /* @__PURE__ */
|
|
220
|
+
return /* @__PURE__ */ i(
|
|
219
221
|
"div",
|
|
220
222
|
{
|
|
221
223
|
className: "flex items-center justify-center w-full h-full",
|
|
@@ -227,8 +229,8 @@ function de({
|
|
|
227
229
|
borderColor: "var(--dc-danger-border)"
|
|
228
230
|
},
|
|
229
231
|
children: /* @__PURE__ */ c("div", { className: "text-center", children: [
|
|
230
|
-
/* @__PURE__ */
|
|
231
|
-
/* @__PURE__ */
|
|
232
|
+
/* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
|
|
233
|
+
/* @__PURE__ */ i("div", { className: "text-xs", children: "No measure field configured" })
|
|
232
234
|
] })
|
|
233
235
|
}
|
|
234
236
|
);
|
|
@@ -251,7 +253,7 @@ function de({
|
|
|
251
253
|
D
|
|
252
254
|
), u = I.map((t) => t[w]).filter((t) => t != null && !isNaN(Number(t))).map((t) => Number(t));
|
|
253
255
|
if (u.length < 2)
|
|
254
|
-
return /* @__PURE__ */
|
|
256
|
+
return /* @__PURE__ */ i(
|
|
255
257
|
"div",
|
|
256
258
|
{
|
|
257
259
|
className: "flex items-center justify-center w-full h-full",
|
|
@@ -263,8 +265,8 @@ function de({
|
|
|
263
265
|
borderColor: "var(--dc-warning-border)"
|
|
264
266
|
},
|
|
265
267
|
children: /* @__PURE__ */ c("div", { className: "text-center", children: [
|
|
266
|
-
/* @__PURE__ */
|
|
267
|
-
/* @__PURE__ */
|
|
268
|
+
/* @__PURE__ */ i("div", { className: "text-sm font-semibold mb-1", children: "Insufficient Data" }),
|
|
269
|
+
/* @__PURE__ */ i("div", { className: "text-xs", children: "Delta calculation requires at least 2 data points" }),
|
|
268
270
|
/* @__PURE__ */ c("div", { className: "text-xs", children: [
|
|
269
271
|
"Current data points: ",
|
|
270
272
|
u.length
|
|
@@ -281,17 +283,17 @@ function de({
|
|
|
281
283
|
let m;
|
|
282
284
|
return Math.abs(t) >= 1e9 ? m = (t / 1e9).toFixed(p) + "B" : Math.abs(t) >= 1e6 ? m = (t / 1e6).toFixed(p) + "M" : Math.abs(t) >= 1e3 ? m = (t / 1e3).toFixed(p) + "K" : m = t.toFixed(p), v + m;
|
|
283
285
|
}, G = () => {
|
|
284
|
-
if (e.positiveColorIndex !== void 0 &&
|
|
286
|
+
if (e.positiveColorIndex !== void 0 && o?.colors) {
|
|
285
287
|
const t = e.positiveColorIndex;
|
|
286
|
-
if (t >= 0 && t <
|
|
287
|
-
return
|
|
288
|
+
if (t >= 0 && t < o.colors.length)
|
|
289
|
+
return o.colors[t];
|
|
288
290
|
}
|
|
289
291
|
return "#10b981";
|
|
290
292
|
}, O = () => {
|
|
291
|
-
if (e.negativeColorIndex !== void 0 &&
|
|
293
|
+
if (e.negativeColorIndex !== void 0 && o?.colors) {
|
|
292
294
|
const t = e.negativeColorIndex;
|
|
293
|
-
if (t >= 0 && t <
|
|
294
|
-
return
|
|
295
|
+
if (t >= 0 && t < o.colors.length)
|
|
296
|
+
return o.colors[t];
|
|
295
297
|
}
|
|
296
298
|
return "#ef4444";
|
|
297
299
|
}, E = G(), F = O(), R = $ ? E : F;
|
|
@@ -314,16 +316,16 @@ function de({
|
|
|
314
316
|
lineHeight: "1.2"
|
|
315
317
|
},
|
|
316
318
|
children: [
|
|
317
|
-
/* @__PURE__ */
|
|
319
|
+
/* @__PURE__ */ i("span", { children: (() => {
|
|
318
320
|
const t = W(w);
|
|
319
321
|
return t && t.length > 1 ? t : w;
|
|
320
322
|
})() }),
|
|
321
|
-
(P || z) && /* @__PURE__ */
|
|
323
|
+
(P || z) && /* @__PURE__ */ i(
|
|
322
324
|
"span",
|
|
323
325
|
{
|
|
324
326
|
title: z ? `Excludes last ${H || "period"}` : `Excludes current incomplete ${H}`,
|
|
325
327
|
className: "cursor-help",
|
|
326
|
-
children: /* @__PURE__ */
|
|
328
|
+
children: /* @__PURE__ */ i(
|
|
327
329
|
ne,
|
|
328
330
|
{
|
|
329
331
|
icon: se,
|
|
@@ -336,13 +338,13 @@ function de({
|
|
|
336
338
|
}
|
|
337
339
|
),
|
|
338
340
|
/* @__PURE__ */ c("div", { className: "flex items-center justify-center space-x-4 mb-2", children: [
|
|
339
|
-
/* @__PURE__ */
|
|
341
|
+
/* @__PURE__ */ i(
|
|
340
342
|
"div",
|
|
341
343
|
{
|
|
342
344
|
ref: f,
|
|
343
345
|
className: "font-bold leading-none",
|
|
344
346
|
style: {
|
|
345
|
-
fontSize: `${
|
|
347
|
+
fontSize: `${a}px`,
|
|
346
348
|
color: "var(--dc-text)"
|
|
347
349
|
// Keep main value neutral
|
|
348
350
|
},
|
|
@@ -350,13 +352,13 @@ function de({
|
|
|
350
352
|
}
|
|
351
353
|
),
|
|
352
354
|
/* @__PURE__ */ c("div", { className: "flex items-center space-x-1", children: [
|
|
353
|
-
/* @__PURE__ */
|
|
355
|
+
/* @__PURE__ */ i(
|
|
354
356
|
"div",
|
|
355
357
|
{
|
|
356
358
|
className: "font-bold",
|
|
357
359
|
style: {
|
|
358
360
|
color: R,
|
|
359
|
-
fontSize: `${
|
|
361
|
+
fontSize: `${a * 0.35}px`
|
|
360
362
|
},
|
|
361
363
|
children: $ ? "▲" : "▼"
|
|
362
364
|
}
|
|
@@ -367,7 +369,7 @@ function de({
|
|
|
367
369
|
{
|
|
368
370
|
className: "font-bold leading-tight",
|
|
369
371
|
style: {
|
|
370
|
-
fontSize: `${
|
|
372
|
+
fontSize: `${a * 0.35}px`,
|
|
371
373
|
color: R
|
|
372
374
|
},
|
|
373
375
|
children: [
|
|
@@ -381,7 +383,7 @@ function de({
|
|
|
381
383
|
{
|
|
382
384
|
className: "font-semibold leading-tight",
|
|
383
385
|
style: {
|
|
384
|
-
fontSize: `${
|
|
386
|
+
fontSize: `${a * 0.28}px`,
|
|
385
387
|
color: R,
|
|
386
388
|
opacity: 0.8
|
|
387
389
|
},
|
|
@@ -395,7 +397,7 @@ function de({
|
|
|
395
397
|
] })
|
|
396
398
|
] })
|
|
397
399
|
] }),
|
|
398
|
-
e.suffix && !e.formatValue && /* @__PURE__ */
|
|
400
|
+
e.suffix && !e.formatValue && /* @__PURE__ */ i(
|
|
399
401
|
"div",
|
|
400
402
|
{
|
|
401
403
|
className: "text-dc-text-muted text-center mb-3",
|
|
@@ -407,7 +409,7 @@ function de({
|
|
|
407
409
|
children: e.suffix
|
|
408
410
|
}
|
|
409
411
|
),
|
|
410
|
-
e.showHistogram !== !1 && u.length > 2 && /* @__PURE__ */
|
|
412
|
+
e.showHistogram !== !1 && u.length > 2 && /* @__PURE__ */ i("div", { className: "mt-2 w-full flex justify-center overflow-hidden", children: /* @__PURE__ */ i(
|
|
411
413
|
le,
|
|
412
414
|
{
|
|
413
415
|
values: u,
|
|
@@ -431,4 +433,4 @@ export {
|
|
|
431
433
|
pe as K,
|
|
432
434
|
ce as f
|
|
433
435
|
};
|
|
434
|
-
//# sourceMappingURL=chart-kpidelta-
|
|
436
|
+
//# sourceMappingURL=chart-kpidelta-7-KOmb3w.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chart-kpidelta-7-KOmb3w.js","sources":["../../../src/client/utils/periodUtils.ts","../../../src/client/components/charts/KpiDelta.tsx"],"sourcesContent":["/**\n * Utility functions for detecting incomplete time periods in KPI charts\n */\n\n/**\n * Get the end date of a period based on granularity\n * @param date - The date within the period\n * @param granularity - The time granularity (day, week, month, quarter, year)\n * @returns The end date of the period (end of day)\n */\nexport function getPeriodEndDate(date: Date, granularity: string): Date {\n const endDate = new Date(date)\n\n switch (granularity.toLowerCase()) {\n case 'day':\n // End of the same day\n endDate.setHours(23, 59, 59, 999)\n break\n\n case 'week': {\n // End of the week (Saturday, assuming week starts Sunday)\n const dayOfWeek = endDate.getDay()\n const daysUntilSaturday = 6 - dayOfWeek\n endDate.setDate(endDate.getDate() + daysUntilSaturday)\n endDate.setHours(23, 59, 59, 999)\n break\n }\n\n case 'month':\n // Last day of the month\n endDate.setMonth(endDate.getMonth() + 1, 0) // Set to day 0 of next month = last day of current month\n endDate.setHours(23, 59, 59, 999)\n break\n\n case 'quarter': {\n // Last day of the quarter\n const currentMonth = endDate.getMonth()\n const quarterEndMonth = Math.floor(currentMonth / 3) * 3 + 2 // 0->2, 3->5, 6->8, 9->11\n endDate.setMonth(quarterEndMonth + 1, 0) // Last day of quarter end month\n endDate.setHours(23, 59, 59, 999)\n break\n }\n\n case 'year':\n // December 31st\n endDate.setMonth(11, 31) // December 31\n endDate.setHours(23, 59, 59, 999)\n break\n\n default:\n // Unknown granularity - treat as complete\n endDate.setHours(23, 59, 59, 999)\n }\n\n return endDate\n}\n\n/**\n * Check if the last period in the data is complete based on granularity\n * @param lastDataPoint - The last data point in the sorted dataset\n * @param timeDimensionField - The field name containing the time value\n * @param granularity - The time granularity\n * @returns true if the period is complete, false if it's incomplete\n */\nexport function isLastPeriodComplete(\n lastDataPoint: any,\n timeDimensionField: string,\n granularity: string\n): boolean {\n if (!lastDataPoint || !timeDimensionField || !granularity) {\n return true // Assume complete if we can't determine\n }\n\n const timeValue = lastDataPoint[timeDimensionField]\n if (!timeValue) {\n return true // Assume complete if no time value\n }\n\n // Parse the time value\n const date = new Date(timeValue)\n if (isNaN(date.getTime())) {\n return true // Assume complete if invalid date\n }\n\n // Get the end of this period\n const periodEnd = getPeriodEndDate(date, granularity)\n\n // Compare with current time\n const now = new Date()\n\n // If the period end is in the future, the period is incomplete\n return periodEnd <= now\n}\n\n/**\n * Extract granularity from a query object\n * @param queryObject - The CubeQuery object\n * @param dimensionField - Optional specific dimension field to match\n * @returns The granularity string or null if not found\n */\nexport function getQueryGranularity(\n queryObject: any,\n dimensionField?: string\n): string | null {\n if (!queryObject?.timeDimensions || queryObject.timeDimensions.length === 0) {\n return null\n }\n\n // If a specific dimension field is provided, try to find its granularity\n if (dimensionField) {\n const matchingDim = queryObject.timeDimensions.find((td: any) =>\n td.dimension === dimensionField ||\n td.dimension?.includes(dimensionField) ||\n dimensionField?.includes(td.dimension)\n )\n if (matchingDim?.granularity) {\n return matchingDim.granularity\n }\n }\n\n // Fallback to first time dimension's granularity\n const firstTimeDim = queryObject.timeDimensions[0]\n return firstTimeDim?.granularity || null\n}\n\n/**\n * Filter data to exclude incomplete or last period\n * @param data - The data array sorted by time\n * @param timeDimensionField - The field containing time values\n * @param queryObject - The query object containing timeDimensions\n * @param useLastCompletePeriod - Whether to check for incomplete periods\n * @param skipLastPeriod - Whether to always skip the last period (overrides useLastCompletePeriod)\n * @returns Object with filtered data and whether filtering was applied\n */\nexport function filterIncompletePeriod(\n data: any[],\n timeDimensionField: string | undefined,\n queryObject: any,\n useLastCompletePeriod: boolean,\n skipLastPeriod: boolean = false\n): { filteredData: any[]; excludedIncompletePeriod: boolean; skippedLastPeriod: boolean; granularity: string | null } {\n // Default return - no filtering\n const noFilter = {\n filteredData: data,\n excludedIncompletePeriod: false,\n skippedLastPeriod: false,\n granularity: null\n }\n\n // Need at least 2 data points to filter\n if (data.length < 2) {\n return noFilter\n }\n\n const granularity = getQueryGranularity(queryObject, timeDimensionField)\n\n // If skipLastPeriod is enabled, always skip the last period\n if (skipLastPeriod) {\n return {\n filteredData: data.slice(0, -1),\n excludedIncompletePeriod: false,\n skippedLastPeriod: true,\n granularity\n }\n }\n\n // Skip incomplete period check if feature is disabled\n if (!useLastCompletePeriod) {\n return { ...noFilter, granularity }\n }\n\n // Skip if no time dimension field\n if (!timeDimensionField) {\n return { ...noFilter, granularity }\n }\n\n // Skip if no time dimensions in query\n if (!queryObject?.timeDimensions || queryObject.timeDimensions.length === 0) {\n return { ...noFilter, granularity }\n }\n\n if (!granularity) {\n return noFilter\n }\n\n // Check if last period is incomplete\n const lastRow = data[data.length - 1]\n if (!isLastPeriodComplete(lastRow, timeDimensionField, granularity)) {\n return {\n filteredData: data.slice(0, -1),\n excludedIncompletePeriod: true,\n skippedLastPeriod: false,\n granularity\n }\n }\n\n return { ...noFilter, granularity }\n}\n","import { useState, useRef, useEffect } from \"react\";\nimport { Icon } from \"@iconify/react\";\nimport infoCircleIcon from \"@iconify-icons/tabler/info-circle\";\nimport { useCubeContext } from \"../../providers/CubeProvider\";\nimport { filterIncompletePeriod } from \"../../utils/periodUtils\";\nimport type { ChartProps } from \"../../types\";\n\ninterface VarianceHistogramProps {\n values: number[];\n lastValue: number;\n positiveColor: string;\n negativeColor: string;\n formatValue: (value: number) => string;\n width: number;\n height: number;\n}\n\nfunction VarianceHistogram({\n values,\n lastValue,\n positiveColor,\n negativeColor,\n formatValue,\n width,\n height,\n}: VarianceHistogramProps) {\n // Limit to most recent N values to fit in the histogram\n // Calculate max bars based on width (minimum 8px per bar including gap)\n const maxBars = Math.max(10, Math.floor(width / 10));\n const limitedValues =\n values.length > maxBars\n ? values.slice(-maxBars) // Take the most recent values\n : values;\n\n // Calculate variance (difference) from current/last value for each point\n const variances = limitedValues.map((value) => value - lastValue);\n\n // Find min/max variance for scaling (include 0 as baseline)\n const minVariance = Math.min(...variances, 0);\n const maxVariance = Math.max(...variances, 0);\n const range = Math.max(Math.abs(minVariance), Math.abs(maxVariance));\n\n if (range === 0 || variances.length === 0) {\n return (\n <div\n className=\"flex items-center justify-center bg-dc-bg-secondary rounded-sm border border-dc-border\"\n style={{ width: `${width}px`, height: `${height}px` }}\n >\n <span className=\"text-xs text-dc-text-muted\">No variance data</span>\n </div>\n );\n }\n\n // Calculate bar dimensions\n const barGap = 2;\n const availableWidth = width - (limitedValues.length - 1) * barGap;\n const barWidth = Math.max(4, availableWidth / limitedValues.length);\n\n // Calculate where zero line should be positioned (as percentage from top)\n // If maxVariance = 67 and minVariance = -24, total range = 91\n // Zero should be at 67/91 = 73.6% from top\n const totalRange = maxVariance - minVariance;\n const zeroLinePercent =\n totalRange > 0 ? (maxVariance / totalRange) * 100 : 50;\n\n return (\n <div className=\"flex items-center space-x-2\">\n {/* Histogram bars */}\n <div\n className=\"relative\"\n style={{\n width: `${width}px`,\n height: `${height}px`,\n }}\n >\n {/* Zero line (represents current value) */}\n <div\n className=\"absolute left-0 right-0\"\n style={{\n height: \"1px\",\n top: `${zeroLinePercent}%`,\n backgroundColor: \"var(--dc-border)\",\n zIndex: 1,\n }}\n />\n\n {/* Variance bars - oldest to newest (left to right) */}\n {variances.map((variance, index) => {\n // Calculate bar height as proportion of total range\n const normalizedHeight = Math.abs(variance) / totalRange;\n const barHeight = Math.max(2, normalizedHeight * (height - 4));\n const isPositive = variance >= 0;\n const isLastValue = index === limitedValues.length - 1;\n const color = isPositive ? positiveColor : negativeColor;\n const xPosition = index * (barWidth + barGap);\n\n return (\n <div\n key={index}\n className=\"absolute rounded-xs\"\n style={{\n left: `${xPosition}px`,\n width: `${barWidth}px`,\n height: `${barHeight}px`,\n backgroundColor: color,\n opacity: isLastValue ? 1 : 0.6,\n // Position bar relative to zero line\n ...(isPositive\n ? { bottom: `${100 - zeroLinePercent}%` }\n : { top: `${zeroLinePercent}%` }),\n zIndex: 2,\n }}\n title={`${formatValue(limitedValues[index])}: ${variance >= 0 ? \"+\" : \"\"}${formatValue(variance)} vs current`}\n />\n );\n })}\n </div>\n\n {/* Variance labels on the right - show actual value difference */}\n <div\n className=\"flex flex-col justify-between text-xs text-dc-text-muted\"\n style={{ height: `${height}px` }}\n >\n <span>+{formatValue(maxVariance)}</span>\n <span>\n {minVariance < 0 ? \"\" : \"\"}\n {formatValue(minVariance)}\n </span>\n </div>\n </div>\n );\n}\n\nexport default function KpiDelta({\n data,\n chartConfig,\n displayConfig = {},\n queryObject,\n height = \"100%\",\n colorPalette,\n}: ChartProps) {\n const [fontSize, setFontSize] = useState(32);\n const [textWidth, setTextWidth] = useState(250);\n const containerRef = useRef<HTMLDivElement>(null);\n const valueRef = useRef<HTMLDivElement>(null);\n const { getFieldLabel } = useCubeContext();\n\n // Calculate font size and text width based on container dimensions\n useEffect(() => {\n const updateDimensions = () => {\n if (containerRef.current) {\n const container = containerRef.current;\n const rect = container.getBoundingClientRect();\n const containerWidth = rect.width;\n const containerHeight = rect.height;\n\n if (containerWidth > 0 && containerHeight > 0) {\n const widthBasedSize = containerWidth / 4;\n const heightBasedSize = containerHeight / 4;\n const baseFontSize = Math.min(widthBasedSize, heightBasedSize);\n const clampedFontSize = Math.max(28, Math.min(baseFontSize, 140));\n setFontSize(clampedFontSize);\n\n setTimeout(() => {\n if (valueRef.current) {\n const textRect = valueRef.current.getBoundingClientRect();\n const measuredWidth = textRect.width;\n // Scale histogram width with container, accounting for labels on the right (~60px)\n const maxHistogramWidth = containerWidth - 100; // Leave room for padding and labels\n const effectiveWidth = Math.max(\n measuredWidth,\n Math.min(maxHistogramWidth, containerWidth * 0.7),\n );\n setTextWidth(Math.max(100, effectiveWidth)); // Minimum 100px\n }\n }, 10);\n }\n }\n };\n\n const timer = setTimeout(updateDimensions, 50);\n\n const resizeObserver = new ResizeObserver(() => {\n setTimeout(updateDimensions, 10);\n });\n\n if (containerRef.current) {\n resizeObserver.observe(containerRef.current);\n }\n\n return () => {\n clearTimeout(timer);\n resizeObserver.disconnect();\n };\n }, [data, chartConfig]);\n\n if (!data || data.length === 0) {\n return (\n <div\n className=\"flex items-center justify-center w-full h-full\"\n style={{\n height: height === \"100%\" ? \"100%\" : height,\n minHeight: height === \"100%\" ? \"200px\" : undefined,\n }}\n >\n <div className=\"text-center text-dc-text-muted\">\n <div className=\"text-sm font-semibold mb-1\">No data available</div>\n <div className=\"text-xs text-dc-text-secondary\">\n No data points to display\n </div>\n </div>\n </div>\n );\n }\n\n // Extract value and dimension fields from chart config\n let valueFields: string[] = [];\n let dimensionFields: string[] = [];\n\n if (chartConfig?.yAxis) {\n valueFields = Array.isArray(chartConfig.yAxis)\n ? chartConfig.yAxis\n : [chartConfig.yAxis];\n }\n\n if (chartConfig?.xAxis) {\n dimensionFields = Array.isArray(chartConfig.xAxis)\n ? chartConfig.xAxis\n : [chartConfig.xAxis];\n }\n\n if (valueFields.length === 0) {\n return (\n <div\n className=\"flex items-center justify-center w-full h-full\"\n style={{\n height: height === \"100%\" ? \"100%\" : height,\n minHeight: height === \"100%\" ? \"200px\" : undefined,\n backgroundColor: \"var(--dc-danger-bg)\",\n color: \"var(--dc-danger)\",\n borderColor: \"var(--dc-danger-border)\",\n }}\n >\n <div className=\"text-center\">\n <div className=\"text-sm font-semibold mb-1\">Configuration Error</div>\n <div className=\"text-xs\">No measure field configured</div>\n </div>\n </div>\n );\n }\n\n const valueField = valueFields[0];\n const dimensionField = dimensionFields[0]; // Optional\n\n // Sort data by dimension if available (for time series)\n let sortedData = [...data];\n if (dimensionField) {\n sortedData = sortedData.sort((a, b) => {\n const aVal = a[dimensionField];\n const bVal = b[dimensionField];\n if (aVal < bVal) return -1;\n if (aVal > bVal) return 1;\n return 0;\n });\n }\n\n // Filter out incomplete or last period if enabled\n const { useLastCompletePeriod = true, skipLastPeriod = false } =\n displayConfig;\n const {\n filteredData,\n excludedIncompletePeriod,\n skippedLastPeriod,\n granularity,\n } = filterIncompletePeriod(\n sortedData,\n dimensionField,\n queryObject,\n useLastCompletePeriod,\n skipLastPeriod,\n );\n\n // Use filtered data for calculations\n const dataToUse = filteredData;\n\n // Extract values from filtered data\n const values = dataToUse\n .map((row) => row[valueField])\n .filter((val) => val !== null && val !== undefined && !isNaN(Number(val)))\n .map((val) => Number(val));\n\n if (values.length < 2) {\n return (\n <div\n className=\"flex items-center justify-center w-full h-full\"\n style={{\n height: height === \"100%\" ? \"100%\" : height,\n minHeight: height === \"100%\" ? \"200px\" : undefined,\n backgroundColor: \"var(--dc-warning-bg)\",\n color: \"var(--dc-warning)\",\n borderColor: \"var(--dc-warning-border)\",\n }}\n >\n <div className=\"text-center\">\n <div className=\"text-sm font-semibold mb-1\">Insufficient Data</div>\n <div className=\"text-xs\">\n Delta calculation requires at least 2 data points\n </div>\n <div className=\"text-xs\">Current data points: {values.length}</div>\n </div>\n </div>\n );\n }\n\n // Calculate delta between last and second-last values\n const lastValue = values[values.length - 1];\n const secondLastValue = values[values.length - 2];\n const absoluteChange = lastValue - secondLastValue;\n const percentageChange =\n secondLastValue !== 0\n ? (absoluteChange / Math.abs(secondLastValue)) * 100\n : 0;\n\n const isPositiveChange = absoluteChange >= 0;\n\n // Format number with appropriate units and decimals\n const formatNumber = (value: number | null | undefined): string => {\n // If custom formatValue is provided, use it exclusively\n if (displayConfig.formatValue) {\n return displayConfig.formatValue(value);\n }\n\n // Null handling: Show placeholder for missing data\n if (value === null || value === undefined) {\n return \"—\";\n }\n\n const decimals = displayConfig.decimals ?? 0;\n const prefix = displayConfig.prefix ?? \"\";\n\n let formattedValue: string;\n\n if (Math.abs(value) >= 1e9) {\n formattedValue = (value / 1e9).toFixed(decimals) + \"B\";\n } else if (Math.abs(value) >= 1e6) {\n formattedValue = (value / 1e6).toFixed(decimals) + \"M\";\n } else if (Math.abs(value) >= 1e3) {\n formattedValue = (value / 1e3).toFixed(decimals) + \"K\";\n } else {\n formattedValue = value.toFixed(decimals);\n }\n\n return prefix + formattedValue;\n };\n\n // Get colors from palette\n const getPositiveColor = (): string => {\n if (\n displayConfig.positiveColorIndex !== undefined &&\n colorPalette?.colors\n ) {\n const colorIndex = displayConfig.positiveColorIndex;\n if (colorIndex >= 0 && colorIndex < colorPalette.colors.length) {\n return colorPalette.colors[colorIndex];\n }\n }\n return \"#10b981\"; // Default green\n };\n\n const getNegativeColor = (): string => {\n if (\n displayConfig.negativeColorIndex !== undefined &&\n colorPalette?.colors\n ) {\n const colorIndex = displayConfig.negativeColorIndex;\n if (colorIndex >= 0 && colorIndex < colorPalette.colors.length) {\n return colorPalette.colors[colorIndex];\n }\n }\n return \"#ef4444\"; // Default red\n };\n\n const positiveColor = getPositiveColor();\n const negativeColor = getNegativeColor();\n const currentColor = isPositiveChange ? positiveColor : negativeColor;\n\n return (\n <div\n ref={containerRef}\n className=\"flex flex-col items-center justify-center w-full h-full p-4\"\n style={{\n height: height === \"100%\" ? \"100%\" : height,\n minHeight: height === \"100%\" ? \"200px\" : undefined,\n }}\n >\n {/* Field Label */}\n <div\n className=\"text-dc-text-secondary font-bold text-center mb-2 flex items-center justify-center gap-1\"\n style={{\n fontSize: \"14px\",\n lineHeight: \"1.2\",\n }}\n >\n <span>\n {(() => {\n const label = getFieldLabel(valueField);\n return label && label.length > 1 ? label : valueField;\n })()}\n </span>\n {(excludedIncompletePeriod || skippedLastPeriod) && (\n <span\n title={\n skippedLastPeriod\n ? `Excludes last ${granularity || \"period\"}`\n : `Excludes current incomplete ${granularity}`\n }\n className=\"cursor-help\"\n >\n <Icon\n icon={infoCircleIcon}\n className=\"w-4 h-4 text-dc-text-muted opacity-70\"\n />\n </span>\n )}\n </div>\n\n {/* Main KPI Value and Delta */}\n <div className=\"flex items-center justify-center space-x-4 mb-2\">\n {/* Main KPI Value */}\n <div\n ref={valueRef}\n className=\"font-bold leading-none\"\n style={{\n fontSize: `${fontSize}px`,\n color: \"var(--dc-text)\", // Keep main value neutral\n }}\n >\n {formatNumber(lastValue)}\n </div>\n\n {/* Delta Information */}\n <div className=\"flex items-center space-x-1\">\n {/* Arrow */}\n <div\n className=\"font-bold\"\n style={{\n color: currentColor,\n fontSize: `${fontSize * 0.35}px`,\n }}\n >\n {isPositiveChange ? \"▲\" : \"▼\"}\n </div>\n\n {/* Delta Values */}\n <div className=\"text-left\">\n <div\n className=\"font-bold leading-tight\"\n style={{\n fontSize: `${fontSize * 0.35}px`,\n color: currentColor,\n }}\n >\n {isPositiveChange ? \"+\" : \"\"}\n {formatNumber(absoluteChange)}\n </div>\n <div\n className=\"font-semibold leading-tight\"\n style={{\n fontSize: `${fontSize * 0.28}px`,\n color: currentColor,\n opacity: 0.8,\n }}\n >\n {isPositiveChange ? \"+\" : \"\"}\n {percentageChange.toFixed(1)}%\n </div>\n </div>\n </div>\n </div>\n\n {/* Unit/Suffix (hidden when formatValue is provided) */}\n {displayConfig.suffix && !displayConfig.formatValue && (\n <div\n className=\"text-dc-text-muted text-center mb-3\"\n style={{\n fontSize: \"14px\",\n lineHeight: \"1.2\",\n opacity: 0.8,\n }}\n >\n {displayConfig.suffix}\n </div>\n )}\n\n {/* Variance Histogram */}\n {displayConfig.showHistogram !== false && values.length > 2 && (\n <div className=\"mt-2 w-full flex justify-center overflow-hidden\">\n <VarianceHistogram\n values={values}\n lastValue={lastValue}\n positiveColor={positiveColor}\n negativeColor={negativeColor}\n formatValue={formatNumber}\n width={textWidth}\n height={64}\n />\n </div>\n )}\n </div>\n );\n}\n"],"names":["getPeriodEndDate","date","granularity","endDate","daysUntilSaturday","currentMonth","quarterEndMonth","isLastPeriodComplete","lastDataPoint","timeDimensionField","timeValue","getQueryGranularity","queryObject","dimensionField","matchingDim","td","filterIncompletePeriod","data","useLastCompletePeriod","skipLastPeriod","noFilter","lastRow","VarianceHistogram","values","lastValue","positiveColor","negativeColor","formatValue","width","height","maxBars","limitedValues","variances","value","minVariance","maxVariance","jsx","barGap","availableWidth","barWidth","totalRange","zeroLinePercent","jsxs","variance","index","normalizedHeight","barHeight","isPositive","isLastValue","color","xPosition","KpiDelta","chartConfig","displayConfig","colorPalette","fontSize","setFontSize","useState","textWidth","setTextWidth","containerRef","useRef","valueRef","getFieldLabel","useCubeContext","useEffect","updateDimensions","rect","containerWidth","containerHeight","widthBasedSize","heightBasedSize","baseFontSize","clampedFontSize","measuredWidth","maxHistogramWidth","effectiveWidth","timer","resizeObserver","valueFields","dimensionFields","valueField","sortedData","a","b","aVal","bVal","filteredData","excludedIncompletePeriod","skippedLastPeriod","row","val","secondLastValue","absoluteChange","percentageChange","isPositiveChange","formatNumber","decimals","prefix","formattedValue","getPositiveColor","colorIndex","getNegativeColor","currentColor","label","Icon","infoCircleIcon"],"mappings":";;;;AAUO,SAASA,GAAiBC,GAAYC,GAA2B;AACtE,QAAMC,IAAU,IAAI,KAAKF,CAAI;AAE7B,UAAQC,EAAY,eAAY;AAAA,IAC9B,KAAK;AAEH,MAAAC,EAAQ,SAAS,IAAI,IAAI,IAAI,GAA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AAiB,EAAc;AAAA,UAAA;AAAA,QAAA;AAAA,QAKlBA,EAAc,kBAAkB,MAAS9B,EAAO,SAAS,KACxD,gBAAAa,EAAC,OAAA,EAAI,WAAU,mDACb,UAAA,gBAAAA;AAAA,UAACd;AAAA,UAAA;AAAA,YACC,QAAAC;AAAA,YACA,WAAAC;AAAA,YACA,eAAAC;AAAA,YACA,eAAAC;AAAA,YACA,aAAasE;AAAA,YACb,OAAOtC;AAAA,YACP,QAAQ;AAAA,UAAA;AAAA,QAAA,EACV,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR;;;;;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsxs as a, jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import { useState as W, useRef as E, useEffect as Z } from "react";
|
|
3
3
|
import { ac as q, k as ee } from "./icons-B2XSxpVK.js";
|
|
4
|
-
import { u as te } from "./chart-activitygridchart-
|
|
5
|
-
import { p as se, f as ne, c as ie } from "./chart-areachart-
|
|
6
|
-
import { f as re } from "./chart-kpidelta-
|
|
4
|
+
import { u as te } from "./chart-activitygridchart-CUGN9Xq9.js";
|
|
5
|
+
import { p as se, f as ne, c as ie } from "./chart-areachart-B4tknnsY.js";
|
|
6
|
+
import { f as re } from "./chart-kpidelta-7-KOmb3w.js";
|
|
7
7
|
function oe({
|
|
8
8
|
values: m,
|
|
9
9
|
min: o,
|
|
@@ -395,4 +395,4 @@ export {
|
|
|
395
395
|
oe as D,
|
|
396
396
|
ge as K
|
|
397
397
|
};
|
|
398
|
-
//# sourceMappingURL=chart-kpinumber-
|
|
398
|
+
//# sourceMappingURL=chart-kpinumber-HOPfcK2N.js.map
|
package/dist/client/chunks/{chart-kpinumber-DSH8RJxb.js.map → chart-kpinumber-HOPfcK2N.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart-kpinumber-DSH8RJxb.js","sources":["../../../src/client/components/DataHistogram.tsx","../../../src/client/components/charts/KpiNumber.tsx"],"sourcesContent":["\ninterface DataHistogramProps {\n /** Array of numeric values to create histogram from */\n values: number[]\n /** Minimum value in the dataset */\n min: number\n /** Maximum value in the dataset */\n max: number\n /** Color for the histogram bars */\n color?: string\n /** Number of buckets/bars to create (default: 12) */\n bucketCount?: number\n /** Height of the histogram in pixels (default: 32) */\n height?: number\n /** Format function for min/max labels */\n formatValue?: (value: number) => string\n /** Width of the histogram to match text above */\n width?: number\n /** Whether to show average indicator line (default: true) */\n showAverageIndicator?: boolean\n /** Target value to show as green line */\n targetValue?: number\n}\n\n/**\n * Reusable histogram component that shows the distribution of actual data values\n */\nexport default function DataHistogram({\n values,\n min,\n max,\n color = '#1f2937',\n bucketCount = 12,\n height = 32,\n formatValue = (val) => val.toString(),\n width,\n showAverageIndicator = true,\n targetValue\n}: DataHistogramProps) {\n // Create histogram buckets from actual data\n const buckets = new Array(bucketCount).fill(0)\n const range = max - min\n \n // Distribute actual values into buckets\n values.forEach(value => {\n if (range === 0) {\n // All values are the same, put everything in middle bucket\n buckets[Math.floor(bucketCount / 2)]++\n } else {\n // Calculate which bucket this value belongs to\n let bucketIndex = Math.floor(((value - min) / range) * (bucketCount - 1))\n // Clamp to valid bucket range\n bucketIndex = Math.max(0, Math.min(bucketCount - 1, bucketIndex))\n buckets[bucketIndex]++\n }\n })\n \n // Find max bucket count for normalization\n const maxBucketCount = Math.max(...buckets)\n \n // Calculate average for indicator positioning\n const average = values.reduce((sum, val) => sum + val, 0) / values.length\n \n // Calculate average position as percentage of histogram width\n const averagePosition = range === 0 ? 50 : ((average - min) / range) * 100\n \n // Calculate target position if target value is provided\n const targetPosition = targetValue !== undefined && range > 0 \n ? ((targetValue - min) / range) * 100 \n : null\n\n return (\n <div className=\"flex flex-col items-center\">\n {/* Horizontal bars representing actual data distribution */}\n <div \n className=\"relative flex items-end justify-center space-x-0.5\" \n style={{ \n height: `${height}px`,\n width: width ? `${width}px` : '200px',\n minWidth: '200px'\n }}\n >\n {buckets.map((count, i) => {\n // Normalize height based on actual data frequency\n const normalizedHeight = maxBucketCount > 0 ? count / maxBucketCount : 0\n const minHeight = 0.1 // minimum height for empty buckets\n const displayHeight = count > 0 ? Math.max(minHeight, normalizedHeight) : minHeight\n \n return (\n <div\n key={i}\n className=\"flex-1 rounded-t-sm transition-all duration-300 ease-out\"\n style={{\n height: `${displayHeight * height}px`,\n backgroundColor: color,\n opacity: count > 0 ? 0.7 + (normalizedHeight * 0.3) : 0.2 // higher opacity for buckets with data\n }}\n title={`${count} values in this range`} // tooltip showing actual count\n />\n )\n })}\n \n {/* Average indicator line */}\n {showAverageIndicator && (\n <div\n className=\"absolute top-0 bottom-0 pointer-events-none\"\n style={{\n left: `${averagePosition}%`,\n transform: 'translateX(-50%)',\n width: '2px',\n backgroundColor: '#ef4444',\n opacity: 0.8,\n zIndex: 10\n }}\n title={`Average: ${formatValue(average)}`}\n >\n {/* Small triangle at top to indicate average */}\n <div\n className=\"absolute -top-1\"\n style={{\n left: '50%',\n transform: 'translateX(-50%)',\n width: '0',\n height: '0',\n borderLeft: '4px solid transparent',\n borderRight: '4px solid transparent',\n borderTop: '6px solid #ef4444'\n }}\n />\n </div>\n )}\n \n {/* Target indicator line */}\n {targetPosition !== null && targetValue !== undefined && (\n <div\n className=\"absolute top-0 bottom-0 pointer-events-none\"\n style={{\n left: `${Math.max(0, Math.min(100, targetPosition))}%`,\n transform: 'translateX(-50%)',\n width: '2px',\n backgroundColor: '#10b981',\n opacity: 0.8,\n zIndex: 11\n }}\n title={`Target: ${formatValue(targetValue)}`}\n >\n {/* Small triangle at top to indicate target */}\n <div\n className=\"absolute -top-1\"\n style={{\n left: '50%',\n transform: 'translateX(-50%)',\n width: '0',\n height: '0',\n borderLeft: '4px solid transparent',\n borderRight: '4px solid transparent',\n borderTop: '6px solid #10b981'\n }}\n />\n </div>\n )}\n </div>\n \n {/* Min/Max values aligned with histogram width */}\n <div\n className=\"flex justify-between mt-2 text-xs text-dc-text-muted\"\n style={{\n width: width ? `${width}px` : '200px',\n minWidth: '200px'\n }}\n >\n <span>{formatValue(min)}</span>\n <span>{formatValue(max)}</span>\n </div>\n\n {/* Average indicator */}\n <div className=\"text-center mt-1 text-xs text-dc-text-muted\">\n Average of {values.length} values\n </div>\n </div>\n )\n}","import { useState, useRef, useEffect } from 'react'\nimport { Icon } from '@iconify/react'\nimport infoCircleIcon from '@iconify-icons/tabler/info-circle'\nimport { useCubeContext } from '../../providers/CubeProvider'\nimport DataHistogram from '../DataHistogram'\nimport { parseTargetValues, calculateVariance, formatVariance } from '../../utils/targetUtils'\nimport { filterIncompletePeriod } from '../../utils/periodUtils'\nimport type { ChartProps } from '../../types'\n\nexport default function KpiNumber({\n data,\n chartConfig,\n displayConfig = {},\n queryObject,\n height = \"100%\",\n colorPalette\n}: ChartProps) {\n const [fontSize, setFontSize] = useState(32)\n const [textWidth, setTextWidth] = useState(250)\n const containerRef = useRef<HTMLDivElement>(null)\n const valueRef = useRef<HTMLDivElement>(null)\n const { getFieldLabel } = useCubeContext()\n\n // Calculate font size and text width based on container dimensions\n useEffect(() => {\n const updateDimensions = () => {\n if (containerRef.current) {\n const container = containerRef.current\n const rect = container.getBoundingClientRect()\n const containerWidth = rect.width\n const containerHeight = rect.height\n \n if (containerWidth > 0 && containerHeight > 0) {\n // Calculate font size based on container dimensions\n // For KPI displays, we want the text to be large and prominent\n // Reserve space for the label by using more conservative sizing\n const widthBasedSize = containerWidth / 5\n const heightBasedSize = containerHeight / 4 // More conservative to leave room for label\n const baseFontSize = Math.min(widthBasedSize, heightBasedSize)\n const clampedFontSize = Math.max(24, Math.min(baseFontSize, 120)) // Lower max to ensure label fits\n setFontSize(clampedFontSize)\n \n // Use a timeout to measure text width after font size is applied\n setTimeout(() => {\n if (valueRef.current) {\n const textRect = valueRef.current.getBoundingClientRect()\n const measuredWidth = textRect.width\n // Ensure we have a minimum width and use container width as fallback\n const effectiveWidth = Math.max(measuredWidth, Math.min(containerWidth * 0.6, 300))\n setTextWidth(effectiveWidth)\n }\n }, 10)\n }\n }\n }\n\n // Initial calculation - reduce delay for faster initial render\n const timer = setTimeout(updateDimensions, 50)\n \n const resizeObserver = new ResizeObserver(() => {\n // Debounce the resize updates\n setTimeout(updateDimensions, 10)\n })\n \n if (containerRef.current) {\n resizeObserver.observe(containerRef.current)\n }\n\n return () => {\n clearTimeout(timer)\n resizeObserver.disconnect()\n }\n }, [data, chartConfig])\n\n if (!data || data.length === 0) {\n return (\n <div\n className=\"flex items-center justify-center w-full h-full\"\n style={{\n height: height === \"100%\" ? \"100%\" : height,\n minHeight: height === \"100%\" ? '200px' : undefined\n }}\n >\n <div className=\"text-center text-dc-text-muted\">\n <div className=\"text-sm font-semibold mb-1\">No data available</div>\n <div className=\"text-xs text-dc-text-secondary\">No data points to display</div>\n </div>\n </div>\n )\n }\n\n // Extract value field from chart config - handle both string and array formats\n let valueFields: string[] = []\n if (chartConfig?.yAxis) {\n // Handle both string and array formats\n if (typeof chartConfig.yAxis === 'string') {\n valueFields = [chartConfig.yAxis]\n } else if (Array.isArray(chartConfig.yAxis)) {\n valueFields = chartConfig.yAxis\n }\n }\n \n \n if (valueFields.length === 0) {\n return (\n <div\n className=\"flex items-center justify-center w-full h-full\"\n style={{\n height: height === \"100%\" ? \"100%\" : height,\n minHeight: height === \"100%\" ? '200px' : undefined,\n backgroundColor: 'var(--dc-danger-bg)',\n color: 'var(--dc-danger)',\n borderColor: 'var(--dc-danger-border)'\n }}\n >\n <div className=\"text-center\">\n <div className=\"text-sm font-semibold mb-1\">Configuration Error</div>\n <div className=\"text-xs\">No measure fields configured</div>\n </div>\n </div>\n )\n }\n\n const valueField = valueFields[0] // Use first measure field\n\n // Get time dimension field if present (for incomplete period filtering)\n const timeDimensionField = queryObject?.timeDimensions?.[0]?.dimension || undefined\n\n // Sort data by time dimension if available (for proper filtering)\n let sortedData = [...data]\n if (timeDimensionField) {\n sortedData = sortedData.sort((a, b) => {\n const aVal = a[timeDimensionField]\n const bVal = b[timeDimensionField]\n if (aVal < bVal) return -1\n if (aVal > bVal) return 1\n return 0\n })\n }\n\n // Filter out incomplete or last period if enabled\n const { useLastCompletePeriod = true, skipLastPeriod = false } = displayConfig\n const {\n filteredData,\n excludedIncompletePeriod,\n skippedLastPeriod,\n granularity\n } = filterIncompletePeriod(sortedData, timeDimensionField, queryObject, useLastCompletePeriod, skipLastPeriod)\n\n // Use filtered data for calculations\n const dataToUse = filteredData\n\n // Extract values for the selected field\n const rawValues = dataToUse.map(row => {\n // Try direct field access first\n if (row[valueField] !== undefined) {\n return row[valueField]\n }\n \n // If not found, try finding the first numeric field as fallback\n const numericFields = Object.keys(row).filter(key => \n typeof row[key] === 'number' && !isNaN(row[key])\n )\n \n if (numericFields.length > 0) {\n return row[numericFields[0]]\n }\n \n return undefined\n })\n \n const values = rawValues\n .filter(val => val !== null && val !== undefined && !isNaN(Number(val)))\n .map(val => Number(val))\n \n\n // Null handling: If all values are null, show placeholder instead of error\n if (values.length === 0) {\n return (\n <div\n ref={containerRef}\n className=\"flex flex-col items-center justify-center w-full h-full p-4\"\n style={{\n height: height === \"100%\" ? \"100%\" : height,\n minHeight: height === \"100%\" ? '200px' : undefined\n }}\n >\n {/* Field Label */}\n <div\n className=\"text-dc-text-secondary font-bold text-center mb-3\"\n style={{\n fontSize: '14px',\n lineHeight: '1.2'\n }}\n >\n {getFieldLabel(valueField)}\n </div>\n\n {/* No Data Placeholder */}\n <div\n className=\"font-bold leading-none text-dc-text-muted\"\n style={{\n fontSize: `${fontSize}px`\n }}\n >\n —\n </div>\n\n <div className=\"text-xs text-dc-text-muted mt-2\">No data</div>\n </div>\n )\n }\n\n // Calculate statistics\n const sum = values.reduce((acc, val) => acc + val, 0)\n const avg = sum / values.length\n const min = Math.min(...values)\n const max = Math.max(...values)\n\n // Format number with appropriate units and decimals (no prefix/suffix here, handled separately)\n const formatNumber = (value: number | null | undefined): string => {\n // If custom formatValue is provided, use it exclusively\n if (displayConfig.formatValue) {\n return displayConfig.formatValue(value)\n }\n\n // Null handling: Show placeholder for missing data\n if (value === null || value === undefined) {\n return '—'\n }\n\n const decimals = displayConfig.decimals ?? 0\n const prefix = displayConfig.prefix ?? ''\n\n let formattedValue: string\n\n if (Math.abs(value) >= 1e9) {\n formattedValue = (value / 1e9).toFixed(decimals) + 'B'\n } else if (Math.abs(value) >= 1e6) {\n formattedValue = (value / 1e6).toFixed(decimals) + 'M'\n } else if (Math.abs(value) >= 1e3) {\n formattedValue = (value / 1e3).toFixed(decimals) + 'K'\n } else {\n formattedValue = value.toFixed(decimals)\n }\n\n return prefix + formattedValue\n }\n\n const mainValue = values.length === 1 ? values[0] : avg\n const showStats = values.length > 1\n\n // Get color from palette by index, default to first color in palette\n const getValueColor = (): string => {\n if (displayConfig.valueColorIndex !== undefined && colorPalette?.colors) {\n const colorIndex = displayConfig.valueColorIndex\n if (colorIndex >= 0 && colorIndex < colorPalette.colors.length) {\n return colorPalette.colors[colorIndex]\n }\n }\n // Default to first color in palette if available, otherwise fallback to dark gray\n return colorPalette?.colors?.[0] || '#1f2937'\n }\n\n const valueColor = getValueColor()\n \n // Process target values for variance calculation\n const targetValues = parseTargetValues(displayConfig?.target || '')\n const targetValue = targetValues.length > 0 ? targetValues[0] : null // Use first target value\n const variance = targetValue !== null ? calculateVariance(mainValue, targetValue) : null\n \n // Get colors for variance display (similar to KpiDelta)\n const getVarianceColor = (): string => {\n if (variance === null) return '#6B7280' // Gray for no target\n \n if (variance >= 0) {\n // Positive variance - use positive color from palette\n const positiveIndex = displayConfig.positiveColorIndex ?? 1\n return colorPalette?.colors?.[positiveIndex] || '#10B981' // Green fallback\n } else {\n // Negative variance - use negative color from palette \n const negativeIndex = displayConfig.negativeColorIndex ?? 7\n return colorPalette?.colors?.[negativeIndex] || '#EF4444' // Red fallback\n }\n }\n\n return (\n <div \n ref={containerRef}\n className=\"flex flex-col items-center justify-center w-full h-full p-4\"\n style={{ \n height: height === \"100%\" ? \"100%\" : height,\n minHeight: height === \"100%\" ? '200px' : undefined\n }}\n >\n {/* Field Label - Bolder and bigger */}\n <div\n className=\"text-dc-text-secondary font-bold text-center mb-3 flex items-center justify-center gap-1\"\n style={{\n fontSize: '14px',\n lineHeight: '1.2'\n }}\n >\n <span>\n {(() => {\n const label = getFieldLabel(valueField)\n // Temporary fix: if label seems wrong, use the field name directly\n const displayLabel = (label && label.length > 1) ? label : valueField\n return displayLabel\n })()}\n </span>\n {(excludedIncompletePeriod || skippedLastPeriod) && (\n <span\n title={skippedLastPeriod\n ? `Excludes last ${granularity || 'period'}`\n : `Excludes current incomplete ${granularity}`}\n className=\"cursor-help\"\n >\n <Icon icon={infoCircleIcon} className=\"w-4 h-4 text-dc-text-muted opacity-70\" />\n </span>\n )}\n </div>\n\n {/* Main KPI Value and Variance - Horizontal layout */}\n <div className=\"flex items-center justify-center gap-4 mb-3\">\n <div \n ref={valueRef}\n className=\"font-bold leading-none\"\n style={{ \n fontSize: `${fontSize}px`,\n color: valueColor\n }}\n >\n {formatNumber(mainValue)}\n </div>\n \n {/* Target Variance Display - To the right of main value */}\n {targetValue !== null && variance !== null && (\n <div className=\"flex flex-col items-start\">\n <div \n className=\"font-semibold\"\n style={{ \n fontSize: `${Math.max(12, fontSize * 0.3)}px`,\n color: getVarianceColor(),\n lineHeight: '1.2'\n }}\n >\n {formatVariance(variance, 1)}\n </div>\n <div\n className=\"text-dc-text-muted text-xs\"\n style={{\n opacity: 0.7,\n fontSize: `${Math.max(10, fontSize * 0.2)}px`\n }}\n >\n vs {formatNumber(targetValue)}\n </div>\n </div>\n )}\n </div>\n\n {/* Unit/Suffix - Larger, not bold (hidden when formatValue is provided) */}\n {displayConfig.suffix && !displayConfig.formatValue && (\n <div\n className=\"text-dc-text-muted text-center\"\n style={{\n fontSize: '14px',\n lineHeight: '1.2',\n opacity: 0.8\n }}\n >\n {displayConfig.suffix}\n </div>\n )}\n\n {/* Data Histogram for multiple values */}\n {showStats && (\n <div className=\"mt-4\">\n <DataHistogram\n values={values}\n min={min}\n max={max}\n color={valueColor}\n formatValue={formatNumber}\n height={24}\n width={textWidth}\n targetValue={targetValue || undefined}\n />\n </div>\n )}\n </div>\n )\n}"],"names":["DataHistogram","values","min","max","color","bucketCount","height","formatValue","val","width","showAverageIndicator","targetValue","buckets","range","value","bucketIndex","maxBucketCount","average","sum","averagePosition","targetPosition","jsxs","count","i","normalizedHeight","minHeight","displayHeight","jsx","KpiNumber","data","chartConfig","displayConfig","queryObject","colorPalette","fontSize","setFontSize","useState","textWidth","setTextWidth","containerRef","useRef","valueRef","getFieldLabel","useCubeContext","useEffect","updateDimensions","rect","containerWidth","containerHeight","widthBasedSize","heightBasedSize","baseFontSize","clampedFontSize","measuredWidth","effectiveWidth","timer","resizeObserver","valueFields","valueField","timeDimensionField","sortedData","a","b","aVal","bVal","useLastCompletePeriod","skipLastPeriod","filteredData","excludedIncompletePeriod","skippedLastPeriod","granularity","filterIncompletePeriod","row","numericFields","key","avg","acc","formatNumber","decimals","prefix","formattedValue","mainValue","showStats","valueColor","colorIndex","targetValues","parseTargetValues","variance","calculateVariance","getVarianceColor","positiveIndex","negativeIndex","label","Icon","infoCircleIcon","formatVariance"],"mappings":";;;;;;AA2BA,SAAwBA,GAAc;AAAA,EACpC,QAAAC;AAAA,EACA,KAAAC;AAAA,EACA,KAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,aAAAC,IAAc;AAAA,EACd,QAAAC,IAAS;AAAA,EACT,aAAAC,IAAc,CAACC,MAAQA,EAAI,SAAA;AAAA,EAC3B,OAAAC;AAAA,EACA,sBAAAC,IAAuB;AAAA,EACvB,aAAAC;AACF,GAAuB;AAErB,QAAMC,IAAU,IAAI,MAAMP,CAAW,EAAE,KAAK,CAAC,GACvCQ,IAAQV,IAAMD;AAGpB,EAAAD,EAAO,QAAQ,CAAAa,MAAS;AACtB,QAAID,MAAU;AAEZ,MAAAD,EAAQ,KAAK,MAAMP,IAAc,CAAC,CAAC;AAAA,SAC9B;AAEL,UAAIU,IAAc,KAAK,OAAQD,IAAQZ,KAAOW,K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AAC;AAAA,cAAA;AAAA,gBACC,WAAU;AAAA,gBACV,OAAO;AAAA,kBACL,SAAS;AAAA,kBACT,UAAU,GAAG,KAAK,IAAI,IAAIa,IAAW,GAAG,CAAC;AAAA,gBAAA;AAAA,gBAE5C,UAAA;AAAA,kBAAA;AAAA,kBACK2C,EAAalE,CAAW;AAAA,gBAAA;AAAA,cAAA;AAAA,YAAA;AAAA,UAC9B,EAAA,CACF;AAAA,QAAA,GAEJ;AAAA,QAGCoB,EAAc,UAAU,CAACA,EAAc,eACtC,gBAAAJ;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAU;AAAA,YACV,OAAO;AAAA,cACL,UAAU;AAAA,cACV,YAAY;AAAA,cACZ,SAAS;AAAA,YAAA;AAAA,YAGV,UAAAI,EAAc;AAAA,UAAA;AAAA,QAAA;AAAA,QAKlBmD,KACC,gBAAAvD,EAAC,OAAA,EAAI,WAAU,QACb,UAAA,gBAAAA;AAAA,UAAC3B;AAAA,UAAA;AAAA,YACC,QAAAC;AAAA,YACA,KAAAC;AAAA,YACA,KAAAC;AAAA,YACA,OAAOgF;AAAA,YACP,aAAaN;AAAA,YACb,QAAQ;AAAA,YACR,OAAOxC;AAAA,YACP,aAAa1B,KAAe;AAAA,UAAA;AAAA,QAAA,EAC9B,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIV;;;;;"}
|
|
1
|
+
{"version":3,"file":"chart-kpinumber-HOPfcK2N.js","sources":["../../../src/client/components/DataHistogram.tsx","../../../src/client/components/charts/KpiNumber.tsx"],"sourcesContent":["\ninterface DataHistogramProps {\n /** Array of numeric values to create histogram from */\n values: number[]\n /** Minimum value in the dataset */\n min: number\n /** Maximum value in the dataset */\n max: number\n /** Color for the histogram bars */\n color?: string\n /** Number of buckets/bars to create (default: 12) */\n bucketCount?: number\n /** Height of the histogram in pixels (default: 32) */\n height?: number\n /** Format function for min/max labels */\n formatValue?: (value: number) => string\n /** Width of the histogram to match text above */\n width?: number\n /** Whether to show average indicator line (default: true) */\n showAverageIndicator?: boolean\n /** Target value to show as green line */\n targetValue?: number\n}\n\n/**\n * Reusable histogram component that shows the distribution of actual data values\n */\nexport default function DataHistogram({\n values,\n min,\n max,\n color = '#1f2937',\n bucketCount = 12,\n height = 32,\n formatValue = (val) => val.toString(),\n width,\n showAverageIndicator = true,\n targetValue\n}: DataHistogramProps) {\n // Create histogram buckets from actual data\n const buckets = new Array(bucketCount).fill(0)\n const range = max - min\n \n // Distribute actual values into buckets\n values.forEach(value => {\n if (range === 0) {\n // All values are the same, put everything in middle bucket\n buckets[Math.floor(bucketCount / 2)]++\n } else {\n // Calculate which bucket this value belongs to\n let bucketIndex = Math.floor(((value - min) / range) * (bucketCount - 1))\n // Clamp to valid bucket range\n bucketIndex = Math.max(0, Math.min(bucketCount - 1, bucketIndex))\n buckets[bucketIndex]++\n }\n })\n \n // Find max bucket count for normalization\n const maxBucketCount = Math.max(...buckets)\n \n // Calculate average for indicator positioning\n const average = values.reduce((sum, val) => sum + val, 0) / values.length\n \n // Calculate average position as percentage of histogram width\n const averagePosition = range === 0 ? 50 : ((average - min) / range) * 100\n \n // Calculate target position if target value is provided\n const targetPosition = targetValue !== undefined && range > 0 \n ? ((targetValue - min) / range) * 100 \n : null\n\n return (\n <div className=\"flex flex-col items-center\">\n {/* Horizontal bars representing actual data distribution */}\n <div \n className=\"relative flex items-end justify-center space-x-0.5\" \n style={{ \n height: `${height}px`,\n width: width ? `${width}px` : '200px',\n minWidth: '200px'\n }}\n >\n {buckets.map((count, i) => {\n // Normalize height based on actual data frequency\n const normalizedHeight = maxBucketCount > 0 ? count / maxBucketCount : 0\n const minHeight = 0.1 // minimum height for empty buckets\n const displayHeight = count > 0 ? Math.max(minHeight, normalizedHeight) : minHeight\n \n return (\n <div\n key={i}\n className=\"flex-1 rounded-t-sm transition-all duration-300 ease-out\"\n style={{\n height: `${displayHeight * height}px`,\n backgroundColor: color,\n opacity: count > 0 ? 0.7 + (normalizedHeight * 0.3) : 0.2 // higher opacity for buckets with data\n }}\n title={`${count} values in this range`} // tooltip showing actual count\n />\n )\n })}\n \n {/* Average indicator line */}\n {showAverageIndicator && (\n <div\n className=\"absolute top-0 bottom-0 pointer-events-none\"\n style={{\n left: `${averagePosition}%`,\n transform: 'translateX(-50%)',\n width: '2px',\n backgroundColor: '#ef4444',\n opacity: 0.8,\n zIndex: 10\n }}\n title={`Average: ${formatValue(average)}`}\n >\n {/* Small triangle at top to indicate average */}\n <div\n className=\"absolute -top-1\"\n style={{\n left: '50%',\n transform: 'translateX(-50%)',\n width: '0',\n height: '0',\n borderLeft: '4px solid transparent',\n borderRight: '4px solid transparent',\n borderTop: '6px solid #ef4444'\n }}\n />\n </div>\n )}\n \n {/* Target indicator line */}\n {targetPosition !== null && targetValue !== undefined && (\n <div\n className=\"absolute top-0 bottom-0 pointer-events-none\"\n style={{\n left: `${Math.max(0, Math.min(100, targetPosition))}%`,\n transform: 'translateX(-50%)',\n width: '2px',\n backgroundColor: '#10b981',\n opacity: 0.8,\n zIndex: 11\n }}\n title={`Target: ${formatValue(targetValue)}`}\n >\n {/* Small triangle at top to indicate target */}\n <div\n className=\"absolute -top-1\"\n style={{\n left: '50%',\n transform: 'translateX(-50%)',\n width: '0',\n height: '0',\n borderLeft: '4px solid transparent',\n borderRight: '4px solid transparent',\n borderTop: '6px solid #10b981'\n }}\n />\n </div>\n )}\n </div>\n \n {/* Min/Max values aligned with histogram width */}\n <div\n className=\"flex justify-between mt-2 text-xs text-dc-text-muted\"\n style={{\n width: width ? `${width}px` : '200px',\n minWidth: '200px'\n }}\n >\n <span>{formatValue(min)}</span>\n <span>{formatValue(max)}</span>\n </div>\n\n {/* Average indicator */}\n <div className=\"text-center mt-1 text-xs text-dc-text-muted\">\n Average of {values.length} values\n </div>\n </div>\n )\n}","import { useState, useRef, useEffect } from 'react'\nimport { Icon } from '@iconify/react'\nimport infoCircleIcon from '@iconify-icons/tabler/info-circle'\nimport { useCubeContext } from '../../providers/CubeProvider'\nimport DataHistogram from '../DataHistogram'\nimport { parseTargetValues, calculateVariance, formatVariance } from '../../utils/targetUtils'\nimport { filterIncompletePeriod } from '../../utils/periodUtils'\nimport type { ChartProps } from '../../types'\n\nexport default function KpiNumber({\n data,\n chartConfig,\n displayConfig = {},\n queryObject,\n height = \"100%\",\n colorPalette\n}: ChartProps) {\n const [fontSize, setFontSize] = useState(32)\n const [textWidth, setTextWidth] = useState(250)\n const containerRef = useRef<HTMLDivElement>(null)\n const valueRef = useRef<HTMLDivElement>(null)\n const { getFieldLabel } = useCubeContext()\n\n // Calculate font size and text width based on container dimensions\n useEffect(() => {\n const updateDimensions = () => {\n if (containerRef.current) {\n const container = containerRef.current\n const rect = container.getBoundingClientRect()\n const containerWidth = rect.width\n const containerHeight = rect.height\n \n if (containerWidth > 0 && containerHeight > 0) {\n // Calculate font size based on container dimensions\n // For KPI displays, we want the text to be large and prominent\n // Reserve space for the label by using more conservative sizing\n const widthBasedSize = containerWidth / 5\n const heightBasedSize = containerHeight / 4 // More conservative to leave room for label\n const baseFontSize = Math.min(widthBasedSize, heightBasedSize)\n const clampedFontSize = Math.max(24, Math.min(baseFontSize, 120)) // Lower max to ensure label fits\n setFontSize(clampedFontSize)\n \n // Use a timeout to measure text width after font size is applied\n setTimeout(() => {\n if (valueRef.current) {\n const textRect = valueRef.current.getBoundingClientRect()\n const measuredWidth = textRect.width\n // Ensure we have a minimum width and use container width as fallback\n const effectiveWidth = Math.max(measuredWidth, Math.min(containerWidth * 0.6, 300))\n setTextWidth(effectiveWidth)\n }\n }, 10)\n }\n }\n }\n\n // Initial calculation - reduce delay for faster initial render\n const timer = setTimeout(updateDimensions, 50)\n \n const resizeObserver = new ResizeObserver(() => {\n // Debounce the resize updates\n setTimeout(updateDimensions, 10)\n })\n \n if (containerRef.current) {\n resizeObserver.observe(containerRef.current)\n }\n\n return () => {\n clearTimeout(timer)\n resizeObserver.disconnect()\n }\n }, [data, chartConfig])\n\n if (!data || data.length === 0) {\n return (\n <div\n className=\"flex items-center justify-center w-full h-full\"\n style={{\n height: height === \"100%\" ? \"100%\" : height,\n minHeight: height === \"100%\" ? '200px' : undefined\n }}\n >\n <div className=\"text-center text-dc-text-muted\">\n <div className=\"text-sm font-semibold mb-1\">No data available</div>\n <div className=\"text-xs text-dc-text-secondary\">No data points to display</div>\n </div>\n </div>\n )\n }\n\n // Extract value field from chart config - handle both string and array formats\n let valueFields: string[] = []\n if (chartConfig?.yAxis) {\n // Handle both string and array formats\n if (typeof chartConfig.yAxis === 'string') {\n valueFields = [chartConfig.yAxis]\n } else if (Array.isArray(chartConfig.yAxis)) {\n valueFields = chartConfig.yAxis\n }\n }\n \n \n if (valueFields.length === 0) {\n return (\n <div\n className=\"flex items-center justify-center w-full h-full\"\n style={{\n height: height === \"100%\" ? \"100%\" : height,\n minHeight: height === \"100%\" ? '200px' : undefined,\n backgroundColor: 'var(--dc-danger-bg)',\n color: 'var(--dc-danger)',\n borderColor: 'var(--dc-danger-border)'\n }}\n >\n <div className=\"text-center\">\n <div className=\"text-sm font-semibold mb-1\">Configuration Error</div>\n <div className=\"text-xs\">No measure fields configured</div>\n </div>\n </div>\n )\n }\n\n const valueField = valueFields[0] // Use first measure field\n\n // Get time dimension field if present (for incomplete period filtering)\n const timeDimensionField = queryObject?.timeDimensions?.[0]?.dimension || undefined\n\n // Sort data by time dimension if available (for proper filtering)\n let sortedData = [...data]\n if (timeDimensionField) {\n sortedData = sortedData.sort((a, b) => {\n const aVal = a[timeDimensionField]\n const bVal = b[timeDimensionField]\n if (aVal < bVal) return -1\n if (aVal > bVal) return 1\n return 0\n })\n }\n\n // Filter out incomplete or last period if enabled\n const { useLastCompletePeriod = true, skipLastPeriod = false } = displayConfig\n const {\n filteredData,\n excludedIncompletePeriod,\n skippedLastPeriod,\n granularity\n } = filterIncompletePeriod(sortedData, timeDimensionField, queryObject, useLastCompletePeriod, skipLastPeriod)\n\n // Use filtered data for calculations\n const dataToUse = filteredData\n\n // Extract values for the selected field\n const rawValues = dataToUse.map(row => {\n // Try direct field access first\n if (row[valueField] !== undefined) {\n return row[valueField]\n }\n \n // If not found, try finding the first numeric field as fallback\n const numericFields = Object.keys(row).filter(key => \n typeof row[key] === 'number' && !isNaN(row[key])\n )\n \n if (numericFields.length > 0) {\n return row[numericFields[0]]\n }\n \n return undefined\n })\n \n const values = rawValues\n .filter(val => val !== null && val !== undefined && !isNaN(Number(val)))\n .map(val => Number(val))\n \n\n // Null handling: If all values are null, show placeholder instead of error\n if (values.length === 0) {\n return (\n <div\n ref={containerRef}\n className=\"flex flex-col items-center justify-center w-full h-full p-4\"\n style={{\n height: height === \"100%\" ? \"100%\" : height,\n minHeight: height === \"100%\" ? '200px' : undefined\n }}\n >\n {/* Field Label */}\n <div\n className=\"text-dc-text-secondary font-bold text-center mb-3\"\n style={{\n fontSize: '14px',\n lineHeight: '1.2'\n }}\n >\n {getFieldLabel(valueField)}\n </div>\n\n {/* No Data Placeholder */}\n <div\n className=\"font-bold leading-none text-dc-text-muted\"\n style={{\n fontSize: `${fontSize}px`\n }}\n >\n —\n </div>\n\n <div className=\"text-xs text-dc-text-muted mt-2\">No data</div>\n </div>\n )\n }\n\n // Calculate statistics\n const sum = values.reduce((acc, val) => acc + val, 0)\n const avg = sum / values.length\n const min = Math.min(...values)\n const max = Math.max(...values)\n\n // Format number with appropriate units and decimals (no prefix/suffix here, handled separately)\n const formatNumber = (value: number | null | undefined): string => {\n // If custom formatValue is provided, use it exclusively\n if (displayConfig.formatValue) {\n return displayConfig.formatValue(value)\n }\n\n // Null handling: Show placeholder for missing data\n if (value === null || value === undefined) {\n return '—'\n }\n\n const decimals = displayConfig.decimals ?? 0\n const prefix = displayConfig.prefix ?? ''\n\n let formattedValue: string\n\n if (Math.abs(value) >= 1e9) {\n formattedValue = (value / 1e9).toFixed(decimals) + 'B'\n } else if (Math.abs(value) >= 1e6) {\n formattedValue = (value / 1e6).toFixed(decimals) + 'M'\n } else if (Math.abs(value) >= 1e3) {\n formattedValue = (value / 1e3).toFixed(decimals) + 'K'\n } else {\n formattedValue = value.toFixed(decimals)\n }\n\n return prefix + formattedValue\n }\n\n const mainValue = values.length === 1 ? values[0] : avg\n const showStats = values.length > 1\n\n // Get color from palette by index, default to first color in palette\n const getValueColor = (): string => {\n if (displayConfig.valueColorIndex !== undefined && colorPalette?.colors) {\n const colorIndex = displayConfig.valueColorIndex\n if (colorIndex >= 0 && colorIndex < colorPalette.colors.length) {\n return colorPalette.colors[colorIndex]\n }\n }\n // Default to first color in palette if available, otherwise fallback to dark gray\n return colorPalette?.colors?.[0] || '#1f2937'\n }\n\n const valueColor = getValueColor()\n \n // Process target values for variance calculation\n const targetValues = parseTargetValues(displayConfig?.target || '')\n const targetValue = targetValues.length > 0 ? targetValues[0] : null // Use first target value\n const variance = targetValue !== null ? calculateVariance(mainValue, targetValue) : null\n \n // Get colors for variance display (similar to KpiDelta)\n const getVarianceColor = (): string => {\n if (variance === null) return '#6B7280' // Gray for no target\n \n if (variance >= 0) {\n // Positive variance - use positive color from palette\n const positiveIndex = displayConfig.positiveColorIndex ?? 1\n return colorPalette?.colors?.[positiveIndex] || '#10B981' // Green fallback\n } else {\n // Negative variance - use negative color from palette \n const negativeIndex = displayConfig.negativeColorIndex ?? 7\n return colorPalette?.colors?.[negativeIndex] || '#EF4444' // Red fallback\n }\n }\n\n return (\n <div \n ref={containerRef}\n className=\"flex flex-col items-center justify-center w-full h-full p-4\"\n style={{ \n height: height === \"100%\" ? \"100%\" : height,\n minHeight: height === \"100%\" ? '200px' : undefined\n }}\n >\n {/* Field Label - Bolder and bigger */}\n <div\n className=\"text-dc-text-secondary font-bold text-center mb-3 flex items-center justify-center gap-1\"\n style={{\n fontSize: '14px',\n lineHeight: '1.2'\n }}\n >\n <span>\n {(() => {\n const label = getFieldLabel(valueField)\n // Temporary fix: if label seems wrong, use the field name directly\n const displayLabel = (label && label.length > 1) ? label : valueField\n return displayLabel\n })()}\n </span>\n {(excludedIncompletePeriod || skippedLastPeriod) && (\n <span\n title={skippedLastPeriod\n ? `Excludes last ${granularity || 'period'}`\n : `Excludes current incomplete ${granularity}`}\n className=\"cursor-help\"\n >\n <Icon icon={infoCircleIcon} className=\"w-4 h-4 text-dc-text-muted opacity-70\" />\n </span>\n )}\n </div>\n\n {/* Main KPI Value and Variance - Horizontal layout */}\n <div className=\"flex items-center justify-center gap-4 mb-3\">\n <div \n ref={valueRef}\n className=\"font-bold leading-none\"\n style={{ \n fontSize: `${fontSize}px`,\n color: valueColor\n }}\n >\n {formatNumber(mainValue)}\n </div>\n \n {/* Target Variance Display - To the right of main value */}\n {targetValue !== null && variance !== null && (\n <div className=\"flex flex-col items-start\">\n <div \n className=\"font-semibold\"\n style={{ \n fontSize: `${Math.max(12, fontSize * 0.3)}px`,\n color: getVarianceColor(),\n lineHeight: '1.2'\n }}\n >\n {formatVariance(variance, 1)}\n </div>\n <div\n className=\"text-dc-text-muted text-xs\"\n style={{\n opacity: 0.7,\n fontSize: `${Math.max(10, fontSize * 0.2)}px`\n }}\n >\n vs {formatNumber(targetValue)}\n </div>\n </div>\n )}\n </div>\n\n {/* Unit/Suffix - Larger, not bold (hidden when formatValue is provided) */}\n {displayConfig.suffix && !displayConfig.formatValue && (\n <div\n className=\"text-dc-text-muted text-center\"\n style={{\n fontSize: '14px',\n lineHeight: '1.2',\n opacity: 0.8\n }}\n >\n {displayConfig.suffix}\n </div>\n )}\n\n {/* Data Histogram for multiple values */}\n {showStats && (\n <div className=\"mt-4\">\n <DataHistogram\n values={values}\n min={min}\n max={max}\n color={valueColor}\n formatValue={formatNumber}\n height={24}\n width={textWidth}\n targetValue={targetValue || undefined}\n />\n </div>\n )}\n </div>\n )\n}"],"names":["DataHistogram","values","min","max","color","bucketCount","height","formatValue","val","width","showAverageIndicator","targetValue","buckets","range","value","bucketIndex","maxBucketCount","average","sum","averagePosition","targetPosition","jsxs","count","i","normalizedHeight","minHeight","displayHeight","jsx","KpiNumber","data","chartConfig","displayConfig","queryObject","colorPalette","fontSize","setFontSize","useState","textWidth","setTextWidth","containerRef","useRef","valueRef","getFieldLabel","useCubeContext","useEffect","updateDimensions","rect","containerWidth","containerHeight","widthBasedSize","heightBasedSize","baseFontSize","clampedFontSize","measuredWidth","effectiveWidth","timer","resizeObserver","valueFields","valueField","timeDimensionField","sortedData","a","b","aVal","bVal","useLastCompletePeriod","skipLastPeriod","filteredData","excludedIncompletePeriod","skippedLastPeriod","granularity","filterIncompletePeriod","row","numericFields","key","avg","acc","formatNumber","decimals","prefix","formattedValue","mainValue","showStats","valueColor","colorIndex","targetValues","parseTargetValues","variance","calculateVariance","getVarianceColor","positiveIndex","negativeIndex","label","Icon","infoCircleIcon","formatVariance"],"mappings":";;;;;;AA2BA,SAAwBA,GAAc;AAAA,EACpC,QAAAC;AAAA,EACA,KAAAC;AAAA,EACA,KAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,aAAAC,IAAc;AAAA,EACd,QAAAC,IAAS;AAAA,EACT,aAAAC,IAAc,CAACC,MAAQA,EAAI,SAAA;AAAA,EAC3B,OAAAC;AAAA,EACA,sBAAAC,IAAuB;AAAA,EACvB,aAAAC;AACF,GAAuB;AAErB,QAAMC,IAAU,IAAI,MAAMP,CAAW,EAAE,KAAK,CAAC,GACvCQ,IAAQV,IAAMD;AAGpB,EAAAD,EAAO,QAAQ,CAAAa,MAAS;AACtB,QAAID,MAAU;AAEZ,MAAAD,EAAQ,KAAK,MAAMP,IAAc,CAAC,CAAC;AAAA,SAC9B;AAEL,UAAIU,IAAc,KAAK,OAAQD,IAAQZ,KAAOW,KAAUR,IAAc,EAAE;AAExE,MAAAU,IAAc,KAAK,IAAI,GAAG,KAAK,IAAIV,IAAc,GAAGU,CAAW,CAAC,GAChEH,EAAQG,CAAW;AAAA,IACrB;AAAA,EACF,CAAC;AAGD,QAAMC,IAAiB,KAAK,IAAI,GAAGJ,CAAO,GAGpCK,IAAUhB,EAAO,OAAO,CAACiB,GAAKV,MAAQU,IAAMV,GAAK,CAAC,IAAIP,EAAO,QAG7DkB,I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