@object-ui/plugin-charts 6.2.3 → 7.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,105 +1,126 @@
1
- import { ComponentRegistry as e, compareToTrendLabelKey as t, computeDrillFilter as n, extractRecords as r, isDrillEnabled as i, resolveDateMacros as a, resolveDrillTitle as o, shiftFilterByCompareTo as s } from "@object-ui/core";
2
- import * as c from "react";
3
- import l, { Suspense as u, useCallback as d, useContext as f, useEffect as p, useMemo as m, useRef as h, useState as g } from "react";
4
- import { Dialog as _, DialogContent as ee, DialogHeader as v, DialogTitle as y, RefreshIndicator as te, Sheet as ne, SheetContent as re, SheetHeader as ie, SheetTitle as ae, Skeleton as b } from "@object-ui/components";
5
- import { Fragment as x, jsx as S, jsxs as C } from "react/jsx-runtime";
6
- import { Area as w, AreaChart as oe, Bar as T, BarChart as E, CartesianGrid as D, Cell as O, Funnel as se, FunnelChart as k, LabelList as A, Legend as j, Line as M, LineChart as ce, Pie as le, PieChart as N, PolarAngleAxis as ue, PolarGrid as de, PolarRadiusAxis as P, Radar as F, RadarChart as I, ResponsiveContainer as L, Scatter as R, ScatterChart as z, Tooltip as B, XAxis as V, YAxis as H, ZAxis as fe } from "recharts";
7
- import { SchemaRenderer as pe, SchemaRendererContext as me, useDataScope as he } from "@object-ui/react";
8
- import { AlertCircle as ge } from "lucide-react";
9
- import { useSafeFieldLabel as _e } from "@object-ui/i18n";
1
+ import { ComponentRegistry as e, buildChartSeries as t, buildOptionColorMap as n, compareToTrendLabelKey as r, computeDrillFilter as i, extractRecords as a, isDrillEnabled as o, resolveDateMacros as s, resolveDrillTitle as c, shiftFilterByCompareTo as l } from "@object-ui/core";
2
+ import * as u from "react";
3
+ import d, { Suspense as f, useCallback as p, useContext as m, useEffect as h, useMemo as g, useRef as ee, useState as _ } from "react";
4
+ import { Button as te, Dialog as ne, DialogContent as re, DialogHeader as ie, DialogTitle as ae, RefreshIndicator as oe, Sheet as se, SheetContent as ce, SheetHeader as le, SheetTitle as v, Skeleton as y } from "@object-ui/components";
5
+ import { Fragment as b, jsx as x, jsxs as S } from "react/jsx-runtime";
6
+ import { Area as C, AreaChart as ue, Bar as de, BarChart as w, CartesianGrid as T, Cell as E, Funnel as fe, FunnelChart as pe, LabelList as me, Legend as D, Line as O, LineChart as k, Pie as he, PieChart as A, PolarAngleAxis as j, PolarGrid as ge, PolarRadiusAxis as _e, Radar as M, RadarChart as ve, ResponsiveContainer as N, Sankey as ye, Scatter as be, ScatterChart as P, Tooltip as F, Treemap as I, XAxis as L, YAxis as R, ZAxis as xe } from "recharts";
7
+ import { SchemaRenderer as Se, SchemaRendererContext as Ce, useDataScope as z, useDrillNavigation as we } from "@object-ui/react";
8
+ import { AlertCircle as Te, ArrowUpRight as B } from "lucide-react";
9
+ import { useSafeFieldLabel as Ee, useSafeTranslate as De } from "@object-ui/i18n";
10
10
  //#region \0rolldown/runtime.js
11
- var ve = Object.defineProperty, ye = (e, t) => () => (e && (t = e(e = 0)), t), be = (e, t) => {
11
+ var V = Object.defineProperty, H = (e, t) => () => (e && (t = e(e = 0)), t), Oe = (e, t) => {
12
12
  let n = {};
13
- for (var r in e) ve(n, r, {
13
+ for (var r in e) V(n, r, {
14
14
  get: e[r],
15
15
  enumerable: !0
16
16
  });
17
- return t || ve(n, Symbol.toStringTag, { value: "Module" }), n;
18
- }, xe = /* @__PURE__ */ be({ default: () => Se });
19
- function Se({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height: r = 400, className: i = "", color: a = "hsl(var(--primary))" }) {
20
- return /* @__PURE__ */ S("div", {
17
+ return t || V(n, Symbol.toStringTag, { value: "Module" }), n;
18
+ }, ke = /* @__PURE__ */ Oe({ default: () => Me });
19
+ function Ae(e, t = 14) {
20
+ return e.length > t ? `${e.slice(0, t - 1)}…` : e;
21
+ }
22
+ function je({ x: e, y: t, payload: n }) {
23
+ let r = String(n?.value ?? ""), i = Ae(r);
24
+ return /* @__PURE__ */ x("g", {
25
+ transform: `translate(${e},${t})`,
26
+ children: /* @__PURE__ */ S("text", {
27
+ dy: 10,
28
+ textAnchor: "end",
29
+ transform: "rotate(-32)",
30
+ fill: "hsl(var(--muted-foreground))",
31
+ fontSize: 11,
32
+ fontFamily: "monospace",
33
+ children: [r !== i && /* @__PURE__ */ x("title", { children: r }), i]
34
+ })
35
+ });
36
+ }
37
+ function Me({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height: r = 400, className: i = "", color: a = "hsl(var(--primary))" }) {
38
+ let o = e.map((e) => String(e?.[n] ?? "")), s = o.length > 4 || o.some((e) => e.length > 8);
39
+ return /* @__PURE__ */ x("div", {
21
40
  className: `p-2 sm:p-3 md:p-4 rounded-xl border border-border bg-card/40 backdrop-blur-sm shadow-lg shadow-background/5 ${i}`,
22
- children: /* @__PURE__ */ S(L, {
41
+ children: /* @__PURE__ */ x(N, {
23
42
  width: "100%",
24
43
  height: r,
25
- children: /* @__PURE__ */ C(E, {
44
+ children: /* @__PURE__ */ S(w, {
26
45
  data: e,
27
46
  margin: {
28
47
  top: 10,
29
48
  right: 10,
30
49
  left: 10,
31
- bottom: 5
50
+ bottom: s ? 24 : 5
32
51
  },
33
52
  children: [
34
- /* @__PURE__ */ C("defs", { children: [/* @__PURE__ */ C("linearGradient", {
53
+ /* @__PURE__ */ S("defs", { children: [/* @__PURE__ */ S("linearGradient", {
35
54
  id: "barGradient",
36
55
  x1: "0",
37
56
  y1: "0",
38
57
  x2: "0",
39
58
  y2: "1",
40
59
  children: [
41
- /* @__PURE__ */ S("stop", {
60
+ /* @__PURE__ */ x("stop", {
42
61
  offset: "0%",
43
62
  stopColor: a,
44
63
  stopOpacity: 1
45
64
  }),
46
- /* @__PURE__ */ S("stop", {
65
+ /* @__PURE__ */ x("stop", {
47
66
  offset: "90%",
48
67
  stopColor: a,
49
68
  stopOpacity: .6
50
69
  }),
51
- /* @__PURE__ */ S("stop", {
70
+ /* @__PURE__ */ x("stop", {
52
71
  offset: "100%",
53
72
  stopColor: a,
54
73
  stopOpacity: .3
55
74
  })
56
75
  ]
57
- }), /* @__PURE__ */ C("filter", {
76
+ }), /* @__PURE__ */ S("filter", {
58
77
  id: "glow",
59
78
  height: "130%",
60
79
  children: [
61
- /* @__PURE__ */ S("feGaussianBlur", {
80
+ /* @__PURE__ */ x("feGaussianBlur", {
62
81
  in: "SourceAlpha",
63
82
  stdDeviation: "3",
64
83
  result: "blur"
65
84
  }),
66
- /* @__PURE__ */ S("feOffset", {
85
+ /* @__PURE__ */ x("feOffset", {
67
86
  in: "blur",
68
87
  dx: "0",
69
88
  dy: "0",
70
89
  result: "offsetBlur"
71
90
  }),
72
- /* @__PURE__ */ S("feFlood", {
91
+ /* @__PURE__ */ x("feFlood", {
73
92
  floodColor: a,
74
93
  floodOpacity: "0.5",
75
94
  result: "offsetColor"
76
95
  }),
77
- /* @__PURE__ */ S("feComposite", {
96
+ /* @__PURE__ */ x("feComposite", {
78
97
  in: "offsetColor",
79
98
  in2: "offsetBlur",
80
99
  operator: "in",
81
100
  result: "offsetBlur"
82
101
  }),
83
- /* @__PURE__ */ C("feMerge", { children: [/* @__PURE__ */ S("feMergeNode", { in: "offsetBlur" }), /* @__PURE__ */ S("feMergeNode", { in: "SourceGraphic" })] })
102
+ /* @__PURE__ */ S("feMerge", { children: [/* @__PURE__ */ x("feMergeNode", { in: "offsetBlur" }), /* @__PURE__ */ x("feMergeNode", { in: "SourceGraphic" })] })
84
103
  ]
85
104
  })] }),
86
- /* @__PURE__ */ S(D, {
105
+ /* @__PURE__ */ x(T, {
87
106
  strokeDasharray: "3 3",
88
107
  stroke: "hsl(var(--border))",
89
108
  vertical: !1
90
109
  }),
91
- /* @__PURE__ */ S(V, {
110
+ /* @__PURE__ */ x(L, {
92
111
  dataKey: n,
93
- tick: {
112
+ tick: s ? /* @__PURE__ */ x(je, {}) : {
94
113
  fill: "hsl(var(--muted-foreground))",
95
114
  fontSize: 12,
96
115
  fontFamily: "monospace"
97
116
  },
98
117
  tickLine: !1,
99
118
  axisLine: { stroke: "hsl(var(--border))" },
100
- dy: 10
119
+ interval: s ? 0 : "preserveStartEnd",
120
+ height: s ? 56 : void 0,
121
+ dy: s ? void 0 : 10
101
122
  }),
102
- /* @__PURE__ */ S(H, {
123
+ /* @__PURE__ */ x(R, {
103
124
  tick: {
104
125
  fill: "hsl(var(--muted-foreground))",
105
126
  fontSize: 12,
@@ -108,7 +129,7 @@ function Se({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height:
108
129
  tickLine: !1,
109
130
  axisLine: !1
110
131
  }),
111
- /* @__PURE__ */ S(B, {
132
+ /* @__PURE__ */ x(F, {
112
133
  cursor: {
113
134
  fill: "hsl(var(--muted))",
114
135
  opacity: .2
@@ -123,11 +144,11 @@ function Se({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height:
123
144
  },
124
145
  itemStyle: { color: "hsl(var(--primary))" }
125
146
  }),
126
- /* @__PURE__ */ S(j, { wrapperStyle: {
147
+ /* @__PURE__ */ x(D, { wrapperStyle: {
127
148
  paddingTop: "20px",
128
149
  fontFamily: "monospace"
129
150
  } }),
130
- /* @__PURE__ */ S(T, {
151
+ /* @__PURE__ */ x(de, {
131
152
  dataKey: t,
132
153
  fill: "url(#barGradient)",
133
154
  radius: [
@@ -144,32 +165,32 @@ function Se({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height:
144
165
  })
145
166
  });
146
167
  }
147
- var Ce = ye((() => {}));
168
+ var Ne = H((() => {}));
148
169
  //#endregion
149
170
  //#region src/ChartContainerImpl.tsx
150
- function we() {
151
- let e = c.useContext(De);
171
+ function Pe() {
172
+ let e = u.useContext(Le);
152
173
  if (!e) throw Error("useChart must be used within a <ChartContainer />");
153
174
  return e;
154
175
  }
155
176
  function U({ id: e, className: t, children: n, config: r, ...i }) {
156
- let a = c.useId(), o = `chart-${e || a.replace(/:/g, "")}`;
157
- return /* @__PURE__ */ S(De.Provider, {
177
+ let a = u.useId(), o = `chart-${e || a.replace(/:/g, "")}`;
178
+ return /* @__PURE__ */ x(Le.Provider, {
158
179
  value: { config: r },
159
- children: /* @__PURE__ */ C("div", {
180
+ children: /* @__PURE__ */ S("div", {
160
181
  "data-slot": "chart",
161
182
  "data-chart": o,
162
- className: K("flex w-full h-[350px] justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground", t),
183
+ className: K("block w-full h-[350px] text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground", t),
163
184
  style: {
164
185
  minHeight: 280,
165
186
  minWidth: 0,
166
187
  ...i.style
167
188
  },
168
189
  ...i,
169
- children: [/* @__PURE__ */ S(Oe, {
190
+ children: [/* @__PURE__ */ x(Re, {
170
191
  id: o,
171
192
  config: r
172
- }), /* @__PURE__ */ S(L, {
193
+ }), /* @__PURE__ */ x(N, {
173
194
  width: "100%",
174
195
  height: "100%",
175
196
  children: n
@@ -177,15 +198,15 @@ function U({ id: e, className: t, children: n, config: r, ...i }) {
177
198
  })
178
199
  });
179
200
  }
180
- function W({ active: e, payload: t, className: n, indicator: r = "dot", hideLabel: i = !1, hideIndicator: a = !1, label: o, labelFormatter: s, labelClassName: l, formatter: u, color: d, nameKey: f, labelKey: p }) {
181
- let { config: m } = we(), h = c.useMemo(() => {
201
+ function W({ active: e, payload: t, className: n, indicator: r = "dot", hideLabel: i = !1, hideIndicator: a = !1, label: o, labelFormatter: s, labelClassName: c, formatter: l, color: d, nameKey: f, labelKey: p }) {
202
+ let { config: m } = Pe(), h = u.useMemo(() => {
182
203
  if (i || !t?.length) return null;
183
- let [e] = t, n = Te(m, e, `${p || e?.dataKey || e?.name || "value"}`), r = !p && typeof o == "string" ? m[o]?.label || o : n?.label;
184
- return s ? /* @__PURE__ */ S("div", {
185
- className: K("font-medium", l),
204
+ let [e] = t, n = Fe(m, e, `${p || e?.dataKey || e?.name || "value"}`), r = !p && typeof o == "string" ? m[o]?.label || o : n?.label;
205
+ return s ? /* @__PURE__ */ x("div", {
206
+ className: K("font-medium", c),
186
207
  children: s(r, t)
187
- }) : r ? /* @__PURE__ */ S("div", {
188
- className: K("font-medium", l),
208
+ }) : r ? /* @__PURE__ */ x("div", {
209
+ className: K("font-medium", c),
189
210
  children: r
190
211
  }) : null;
191
212
  }, [
@@ -193,35 +214,35 @@ function W({ active: e, payload: t, className: n, indicator: r = "dot", hideLabe
193
214
  s,
194
215
  t,
195
216
  i,
196
- l,
217
+ c,
197
218
  m,
198
219
  p
199
220
  ]);
200
221
  if (!e || !t?.length) return null;
201
222
  let g = t.length === 1 && r !== "dot";
202
- return /* @__PURE__ */ C("div", {
223
+ return /* @__PURE__ */ S("div", {
203
224
  className: K("border-border/50 bg-background grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl", n),
204
- children: [g ? null : h, /* @__PURE__ */ S("div", {
225
+ children: [g ? null : h, /* @__PURE__ */ x("div", {
205
226
  className: "grid gap-1.5",
206
227
  children: t.filter((e) => e.type !== "none").map((e, t) => {
207
- let n = Te(m, e, `${f || e.name || e.dataKey || "value"}`), i = d || e.payload.fill || e.color;
208
- return /* @__PURE__ */ S("div", {
228
+ let n = Fe(m, e, `${f || e.name || e.dataKey || "value"}`), i = d || e.payload.fill || e.color;
229
+ return /* @__PURE__ */ x("div", {
209
230
  className: K("[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5", r === "dot" ? "items-center" : ""),
210
- children: u && e?.value !== void 0 && e.name ? u(e.value, e.name, e, t, e.payload) : /* @__PURE__ */ C(x, { children: [n?.icon ? /* @__PURE__ */ S(n.icon, {}) : !a && /* @__PURE__ */ S("div", {
231
+ children: l && e?.value !== void 0 && e.name ? l(e.value, e.name, e, t, e.payload) : /* @__PURE__ */ S(b, { children: [n?.icon ? /* @__PURE__ */ x(n.icon, {}) : !a && /* @__PURE__ */ x("div", {
211
232
  className: K("shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)", r === "dot" ? "h-2.5 w-2.5" : "", r === "line" ? "w-1" : "", r === "dashed" ? "w-0 border-[1.5px] border-dashed bg-transparent" : "", g && r === "dashed" ? "my-0.5" : ""),
212
233
  style: {
213
234
  "--color-bg": i,
214
235
  "--color-border": i
215
236
  }
216
- }), /* @__PURE__ */ C("div", {
237
+ }), /* @__PURE__ */ S("div", {
217
238
  className: K("flex flex-1 justify-between leading-none", g ? "items-end" : "items-center"),
218
- children: [/* @__PURE__ */ C("div", {
239
+ children: [/* @__PURE__ */ S("div", {
219
240
  className: "grid gap-1.5",
220
- children: [g ? h : null, /* @__PURE__ */ S("span", {
241
+ children: [g ? h : null, /* @__PURE__ */ x("span", {
221
242
  className: "text-muted-foreground",
222
243
  children: n?.label || e.name
223
244
  })]
224
- }), e.value && /* @__PURE__ */ S("span", {
245
+ }), e.value && /* @__PURE__ */ x("span", {
225
246
  className: "text-foreground font-mono font-medium tabular-nums",
226
247
  children: e.value.toLocaleString()
227
248
  })]
@@ -232,14 +253,14 @@ function W({ active: e, payload: t, className: n, indicator: r = "dot", hideLabe
232
253
  });
233
254
  }
234
255
  function G({ className: e, hideIcon: t = !1, payload: n, verticalAlign: r = "bottom", nameKey: i }) {
235
- let { config: a } = we();
236
- return n?.length ? /* @__PURE__ */ S("div", {
256
+ let { config: a } = Pe();
257
+ return n?.length ? /* @__PURE__ */ x("div", {
237
258
  className: K("flex items-center justify-center gap-4", r === "top" ? "pb-3" : "pt-3", e),
238
259
  children: n.filter((e) => e.type !== "none").map((e) => {
239
- let n = Te(a, e, `${i || e.dataKey || "value"}`);
240
- return /* @__PURE__ */ C("div", {
260
+ let n = Fe(a, e, `${i || e.dataKey || "value"}`);
261
+ return /* @__PURE__ */ S("div", {
241
262
  className: K("[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3"),
242
- children: [n?.icon && !t ? /* @__PURE__ */ S(n.icon, {}) : /* @__PURE__ */ S("div", {
263
+ children: [n?.icon && !t ? /* @__PURE__ */ x(n.icon, {}) : /* @__PURE__ */ x("div", {
243
264
  className: "h-2 w-2 shrink-0 rounded-[2px]",
244
265
  style: { backgroundColor: e.color }
245
266
  }), n?.label]
@@ -247,18 +268,18 @@ function G({ className: e, hideIcon: t = !1, payload: n, verticalAlign: r = "bot
247
268
  })
248
269
  }) : null;
249
270
  }
250
- function Te(e, t, n) {
271
+ function Fe(e, t, n) {
251
272
  if (typeof t != "object" || !t) return;
252
273
  let r = "payload" in t && typeof t.payload == "object" && t.payload !== null ? t.payload : void 0, i = n;
253
274
  return n in t && typeof t[n] == "string" ? i = t[n] : r && n in r && typeof r[n] == "string" && (i = r[n]), i in e ? e[i] : e[n];
254
275
  }
255
- var K, Ee, De, Oe, q, J, ke = ye((() => {
256
- K = (...e) => e.filter(Boolean).join(" "), Ee = {
276
+ var K, Ie, Le, Re, q, J, ze = H((() => {
277
+ K = (...e) => e.filter(Boolean).join(" "), Ie = {
257
278
  light: "",
258
279
  dark: ".dark"
259
- }, De = c.createContext(null), Oe = ({ id: e, config: t }) => {
280
+ }, Le = u.createContext(null), Re = ({ id: e, config: t }) => {
260
281
  let n = Object.entries(t).filter(([, e]) => e.theme || e.color);
261
- return n.length ? /* @__PURE__ */ S("style", { dangerouslySetInnerHTML: { __html: Object.entries(Ee).map(([t, r]) => `
282
+ return n.length ? /* @__PURE__ */ x("style", { dangerouslySetInnerHTML: { __html: Object.entries(Ie).map(([t, r]) => `
262
283
  ${r} [data-chart=${e}] {
263
284
  ${n.map(([e, n]) => {
264
285
  let r = n.theme?.[t] || n.color;
@@ -266,58 +287,122 @@ ${n.map(([e, n]) => {
266
287
  }).join("\n")}
267
288
  }
268
289
  `).join("\n") } }) : null;
269
- }, q = B, J = j;
270
- })), Ae = /* @__PURE__ */ be({ default: () => je });
271
- function je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r = "name", series: i = [], className: a = "", onChartClick: o }) {
272
- let s = e === "column" ? "bar" : e, l = Array.isArray(t) ? t : [], [u, d] = c.useState(!1), f = c.useCallback((e) => {
273
- if (!o || !e) return;
290
+ }, q = F, J = D;
291
+ }));
292
+ //#endregion
293
+ //#region src/chartDrillEvents.ts
294
+ function Be(e) {
295
+ return e?.[0]?.dataKey || "value";
296
+ }
297
+ function Ve(e, t, n) {
298
+ if (!e) return null;
299
+ let r = e.payload ?? e, i = r?.[t];
300
+ if (i == null) return null;
301
+ let a = Be(n);
302
+ return {
303
+ category: String(i),
304
+ series: a,
305
+ value: typeof r?.[a] == "number" ? r[a] : void 0
306
+ };
307
+ }
308
+ function He(e, t) {
309
+ if (!e) return null;
310
+ let n = e.name ?? e.payload?.name ?? e.root?.name;
311
+ if (n == null) return null;
312
+ let r = e.value ?? e.size ?? e.payload?.size;
313
+ return {
314
+ category: String(n),
315
+ series: Be(t),
316
+ value: typeof r == "number" ? r : void 0
317
+ };
318
+ }
319
+ function Ue(e, t) {
320
+ if (!e) return null;
321
+ let n = e.payload ?? e, r = n?.name;
322
+ return r == null || n?.depth === 0 ? null : {
323
+ category: String(r),
324
+ series: Be(t),
325
+ value: typeof n?.value == "number" ? n.value : void 0
326
+ };
327
+ }
328
+ var We = H((() => {})), Ge = /* @__PURE__ */ Oe({ default: () => Ke });
329
+ function Ke({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r = "name", series: i = [], className: a = "", colors: o, categoryColors: s, onChartClick: c, isAnimationActive: l }) {
330
+ let d = e === "column" ? "bar" : e, f = Array.isArray(t) ? t : [], p = l === !1 ? { isAnimationActive: !1 } : {}, [m, h] = u.useState(!1), g = u.useCallback((e) => {
331
+ if (!c || !e) return;
274
332
  let t = Array.isArray(e.activePayload) ? e.activePayload[0] : void 0;
275
- o({
333
+ c({
276
334
  category: e.activeLabel == null ? void 0 : String(e.activeLabel),
277
335
  series: t?.dataKey ? String(t.dataKey) : void 0,
278
336
  value: typeof t?.value == "number" ? t.value : void 0
279
337
  });
280
- }, [o]), p = c.useCallback((e) => {
281
- if (!o || !e) return;
338
+ }, [c]), ee = u.useCallback((e) => {
339
+ if (!c || !e) return;
282
340
  let t = e.payload?.[r], n = i[0]?.dataKey || "value";
283
- o({
341
+ c({
284
342
  category: t == null ? void 0 : String(t),
285
343
  series: n,
286
344
  value: typeof e.payload?.[n] == "number" ? e.payload[n] : void 0
287
345
  });
288
346
  }, [
289
- o,
347
+ c,
348
+ r,
349
+ i
350
+ ]), _ = c ? {
351
+ onClick: g,
352
+ style: { cursor: "pointer" }
353
+ } : {}, te = c ? {
354
+ onClick: ee,
355
+ style: { cursor: "pointer" }
356
+ } : {}, ne = u.useCallback((e, t, n) => s && s[e == null ? "" : String(e)] || n[t % n.length], [s]), re = u.useCallback((e) => {
357
+ if (!c) return;
358
+ let t = Ve(e, r, i);
359
+ t && c(t);
360
+ }, [
361
+ c,
290
362
  r,
291
363
  i
292
- ]), m = o ? {
293
- onClick: f,
364
+ ]), ie = u.useCallback((e) => {
365
+ if (!c) return;
366
+ let t = He(e, i);
367
+ t && c(t);
368
+ }, [c, i]), ae = u.useCallback((e) => {
369
+ if (!c) return;
370
+ let t = Ue(e, i);
371
+ t && c(t);
372
+ }, [c, i]), oe = c ? {
373
+ onClick: re,
374
+ cursor: "pointer"
375
+ } : {}, se = c ? {
376
+ onClick: ie,
294
377
  style: { cursor: "pointer" }
295
- } : {}, h = o ? {
296
- onClick: p,
378
+ } : {}, ce = c ? {
379
+ onClick: ae,
297
380
  style: { cursor: "pointer" }
298
381
  } : {};
299
- c.useEffect(() => {
300
- let e = () => d(window.innerWidth < 640);
382
+ u.useEffect(() => {
383
+ let e = () => h(window.innerWidth < 640);
301
384
  return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
302
385
  }, []);
303
- let g = {
304
- bar: E,
305
- "horizontal-bar": E,
306
- line: ce,
307
- area: oe,
308
- pie: N,
309
- donut: N,
310
- radar: I,
311
- scatter: z,
312
- funnel: k,
313
- combo: E
314
- }[s] || E, _ = c.useCallback((e) => {
386
+ let le = {
387
+ bar: w,
388
+ "horizontal-bar": w,
389
+ line: k,
390
+ area: ue,
391
+ pie: A,
392
+ donut: A,
393
+ radar: ve,
394
+ scatter: P,
395
+ funnel: pe,
396
+ combo: w,
397
+ treemap: w,
398
+ sankey: w
399
+ }[d] || w, v = u.useCallback((e) => {
315
400
  if (e == null || e === "") return "";
316
401
  let t = typeof e == "string" ? e : String(e);
317
402
  if (/^\d{4}-\d{2}-\d{2}/.test(t)) {
318
403
  let e = new Date(t);
319
404
  if (!Number.isNaN(e.getTime())) {
320
- let t = (l.length > 1 ? Math.abs(new Date(String(l[l.length - 1][r] ?? "")).getTime() - new Date(String(l[0][r] ?? "")).getTime()) : 0) / (1e3 * 60 * 60 * 24);
405
+ let t = (f.length > 1 ? Math.abs(new Date(String(f[f.length - 1][r] ?? "")).getTime() - new Date(String(f[0][r] ?? "")).getTime()) : 0) / (1e3 * 60 * 60 * 24);
321
406
  try {
322
407
  return t <= 62 ? e.toLocaleDateString(void 0, {
323
408
  month: "short",
@@ -331,18 +416,18 @@ function je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
331
416
  }
332
417
  }
333
418
  }
334
- return u && t.length > 8 ? t.slice(0, 8) + "…" : t;
419
+ return m && t.length > 8 ? t.slice(0, 8) + "…" : t;
335
420
  }, [
336
- l,
421
+ f,
337
422
  r,
338
- u
339
- ]), ee = c.useMemo(() => l.some((e) => String(e[r] || "").length > 5), [l, r]), v = () => [
423
+ m
424
+ ]), y = u.useMemo(() => f.some((e) => String(e[r] || "").length > 5), [f, r]), D = () => Array.isArray(o) && o.length > 0 ? o : [
340
425
  "hsl(var(--chart-1))",
341
426
  "hsl(var(--chart-2))",
342
427
  "hsl(var(--chart-3))",
343
428
  "hsl(var(--chart-4))",
344
429
  "hsl(var(--chart-5))"
345
- ], y = c.useCallback((e) => {
430
+ ], N = u.useCallback((e) => {
346
431
  if (e == null || e === "") return "";
347
432
  let t = typeof e == "number" ? e : Number(e);
348
433
  if (!Number.isFinite(t)) return String(e);
@@ -354,62 +439,60 @@ function je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
354
439
  } catch {
355
440
  return String(t);
356
441
  }
357
- }, []), te = c.useMemo(() => ({
442
+ }, []), Se = u.useMemo(() => ({
358
443
  tickLine: !1,
359
444
  tickMargin: 10,
360
445
  axisLine: !1,
361
446
  interval: "preserveStartEnd",
362
- minTickGap: u ? 32 : 48,
363
- tickFormatter: _,
364
- ...!u && ee && {
447
+ minTickGap: m ? 32 : 48,
448
+ tickFormatter: v,
449
+ ...!m && y && {
365
450
  angle: -35,
366
451
  textAnchor: "end",
367
452
  height: 60
368
453
  }
369
454
  }), [
370
- u,
371
- ee,
372
- _
455
+ m,
456
+ y,
457
+ v
373
458
  ]);
374
- if (s === "pie" || s === "donut") {
375
- let e = s === "donut" ? 60 : 0, t = v(), o = { ...n };
376
- return l.forEach((e, n) => {
459
+ if (d === "pie" || d === "donut") {
460
+ let e = d === "donut" ? "52%" : 0, t = D(), o = { ...n };
461
+ return f.forEach((e, n) => {
377
462
  let i = e?.[r];
378
463
  if (i == null || i === "") return;
379
464
  let a = String(i);
380
465
  o[a] || (o[a] = {
381
466
  label: a,
382
- color: t[n % t.length]
467
+ color: ne(i, n, t)
383
468
  });
384
- }), /* @__PURE__ */ S(U, {
469
+ }), /* @__PURE__ */ x(U, {
385
470
  config: o,
386
471
  className: a,
387
- children: /* @__PURE__ */ C(N, { children: [
388
- /* @__PURE__ */ S(q, {
472
+ children: /* @__PURE__ */ S(A, { children: [
473
+ /* @__PURE__ */ x(q, {
389
474
  cursor: !1,
390
- content: /* @__PURE__ */ S(W, { hideLabel: !0 })
475
+ content: /* @__PURE__ */ x(W, { hideLabel: !0 })
391
476
  }),
392
- /* @__PURE__ */ S(le, {
393
- data: l,
477
+ /* @__PURE__ */ x(he, {
478
+ data: f,
394
479
  dataKey: i[0]?.dataKey || "value",
395
480
  nameKey: r || "name",
396
481
  innerRadius: e,
397
482
  strokeWidth: 5,
398
483
  paddingAngle: 2,
399
- outerRadius: 80,
400
- ...h,
401
- children: l.map((e, n) => {
402
- let i = o[String(e[r])]?.color;
403
- return i ||= t[n % t.length], /* @__PURE__ */ S(O, { fill: X(i) }, `cell-${n}`);
404
- })
484
+ outerRadius: "85%",
485
+ ...p,
486
+ ...te,
487
+ children: f.map((e, n) => /* @__PURE__ */ x(E, { fill: X(ne(e?.[r], n, t)) }, `cell-${n}`))
405
488
  }),
406
- /* @__PURE__ */ S(J, {
489
+ /* @__PURE__ */ x(J, {
407
490
  verticalAlign: "bottom",
408
491
  wrapperStyle: {
409
- fontSize: u ? "11px" : "12px",
492
+ fontSize: m ? "11px" : "12px",
410
493
  paddingTop: "8px"
411
494
  },
412
- content: /* @__PURE__ */ S(G, {
495
+ content: /* @__PURE__ */ x(G, {
413
496
  nameKey: r,
414
497
  className: "flex-wrap"
415
498
  })
@@ -417,50 +500,113 @@ function je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
417
500
  ] })
418
501
  });
419
502
  }
420
- if (s === "funnel") {
421
- let e = i[0]?.dataKey || "value", t = v(), s = o ? (t) => {
422
- t && o({
503
+ if (d === "funnel") {
504
+ let e = i[0]?.dataKey || "value", t = D(), o = c ? (t) => {
505
+ t && c({
423
506
  category: t?.payload?.[r] ?? t?.[r],
424
507
  value: t?.payload?.[e] ?? t?.[e]
425
508
  });
426
- } : void 0, c = s ? {
427
- onClick: s,
509
+ } : void 0, s = o ? {
510
+ onClick: o,
428
511
  style: { cursor: "pointer" }
429
- } : {}, u = [...l].sort((t, n) => {
512
+ } : {}, l = [...f].sort((t, n) => {
430
513
  let r = Number(t?.[e] ?? 0);
431
514
  return Number(n?.[e] ?? 0) - r;
432
515
  });
433
- return /* @__PURE__ */ S(U, {
516
+ return /* @__PURE__ */ x(U, {
434
517
  config: n,
435
518
  className: a,
436
- children: /* @__PURE__ */ C(k, { children: [/* @__PURE__ */ S(q, { content: /* @__PURE__ */ S(W, {}) }), /* @__PURE__ */ C(se, {
519
+ children: /* @__PURE__ */ S(pe, { children: [/* @__PURE__ */ x(q, { content: /* @__PURE__ */ x(W, {}) }), /* @__PURE__ */ S(fe, {
437
520
  dataKey: e,
438
- data: u,
521
+ data: l,
439
522
  nameKey: r,
440
523
  isAnimationActive: !0,
441
- ...c,
442
- children: [/* @__PURE__ */ S(A, {
524
+ ...s,
525
+ children: [/* @__PURE__ */ x(me, {
443
526
  position: "right",
444
527
  fill: "hsl(var(--foreground))",
445
528
  stroke: "none",
446
529
  dataKey: r
447
- }), u.map((e, n) => /* @__PURE__ */ S(O, { fill: X(t[n % t.length]) }, `funnel-cell-${n}`))]
530
+ }), l.map((e, n) => /* @__PURE__ */ x(E, { fill: X(t[n % t.length]) }, `funnel-cell-${n}`))]
448
531
  })] })
449
532
  });
450
533
  }
451
- if (s === "radar") return /* @__PURE__ */ S(U, {
534
+ if (d === "treemap") {
535
+ let e = i[0]?.dataKey || "value", t = D();
536
+ return /* @__PURE__ */ x(U, {
537
+ config: n,
538
+ className: a,
539
+ children: /* @__PURE__ */ x(I, {
540
+ data: f.map((n, i) => ({
541
+ name: String(n?.[r] ?? ""),
542
+ size: Number(n?.[e]) || 0,
543
+ fill: X(t[i % t.length])
544
+ })),
545
+ dataKey: "size",
546
+ nameKey: "name",
547
+ isAnimationActive: !0,
548
+ content: /* @__PURE__ */ x((e) => {
549
+ let { x: t, y: n, width: r, height: i, name: a, fill: o } = e;
550
+ return r <= 0 || i <= 0 ? null : /* @__PURE__ */ S("g", { children: [/* @__PURE__ */ x("rect", {
551
+ x: t,
552
+ y: n,
553
+ width: r,
554
+ height: i,
555
+ fill: o,
556
+ stroke: "hsl(var(--background))",
557
+ strokeWidth: 2
558
+ }), r > 48 && i > 18 ? /* @__PURE__ */ x("text", {
559
+ x: t + 6,
560
+ y: n + 18,
561
+ fill: "#fff",
562
+ fontSize: 12,
563
+ className: "pointer-events-none",
564
+ children: a
565
+ }) : null] });
566
+ }, {}),
567
+ ...se,
568
+ children: /* @__PURE__ */ x(F, {})
569
+ })
570
+ });
571
+ }
572
+ if (d === "sankey") {
573
+ let e = i[0]?.dataKey || "value", t = i[0]?.label || e, o = f.filter((t) => (Number(t?.[e]) || 0) > 0), s = [{ name: t }, ...o.map((e) => ({ name: String(e?.[r] ?? "") }))], c = o.map((t, n) => ({
574
+ source: 0,
575
+ target: n + 1,
576
+ value: Number(t?.[e]) || 0
577
+ }));
578
+ return c.length === 0 ? /* @__PURE__ */ x("div", { className: a }) : /* @__PURE__ */ x(U, {
579
+ config: n,
580
+ className: a,
581
+ children: /* @__PURE__ */ x(ye, {
582
+ data: {
583
+ nodes: s,
584
+ links: c
585
+ },
586
+ nodePadding: 24,
587
+ link: {
588
+ stroke: "hsl(var(--muted-foreground))",
589
+ strokeOpacity: .25
590
+ },
591
+ node: { fill: "hsl(var(--chart-1))" },
592
+ ...ce,
593
+ children: /* @__PURE__ */ x(F, {})
594
+ })
595
+ });
596
+ }
597
+ if (d === "radar") return /* @__PURE__ */ x(U, {
452
598
  config: n,
453
599
  className: a,
454
- children: /* @__PURE__ */ C(I, {
455
- data: l,
600
+ children: /* @__PURE__ */ S(ve, {
601
+ data: f,
456
602
  children: [
457
- /* @__PURE__ */ S(de, {}),
458
- /* @__PURE__ */ S(ue, { dataKey: r }),
459
- /* @__PURE__ */ S(P, {}),
460
- /* @__PURE__ */ S(q, { content: /* @__PURE__ */ S(W, {}) }),
461
- /* @__PURE__ */ S(J, {
462
- content: /* @__PURE__ */ S(G, {}),
463
- ...u && {
603
+ /* @__PURE__ */ x(ge, {}),
604
+ /* @__PURE__ */ x(j, { dataKey: r }),
605
+ /* @__PURE__ */ x(_e, {}),
606
+ /* @__PURE__ */ x(q, { content: /* @__PURE__ */ x(W, {}) }),
607
+ /* @__PURE__ */ x(J, {
608
+ content: /* @__PURE__ */ x(G, {}),
609
+ ...m && {
464
610
  verticalAlign: "bottom",
465
611
  wrapperStyle: {
466
612
  fontSize: "11px",
@@ -470,7 +616,7 @@ function je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
470
616
  }),
471
617
  i.map((e) => {
472
618
  let t = X(n[e.dataKey]?.color || Y);
473
- return /* @__PURE__ */ S(F, {
619
+ return /* @__PURE__ */ x(M, {
474
620
  dataKey: e.dataKey,
475
621
  stroke: t,
476
622
  fill: t,
@@ -480,36 +626,36 @@ function je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
480
626
  ]
481
627
  })
482
628
  });
483
- if (s === "scatter") return /* @__PURE__ */ S(U, {
629
+ if (d === "scatter") return /* @__PURE__ */ x(U, {
484
630
  config: n,
485
631
  className: a,
486
- children: /* @__PURE__ */ C(z, { children: [
487
- /* @__PURE__ */ S(D, { vertical: !1 }),
488
- /* @__PURE__ */ S(V, {
632
+ children: /* @__PURE__ */ S(P, { children: [
633
+ /* @__PURE__ */ x(T, { vertical: !1 }),
634
+ /* @__PURE__ */ x(L, {
489
635
  type: "number",
490
636
  dataKey: r,
491
637
  name: String(n[r]?.label || r),
492
638
  tickLine: !1,
493
639
  axisLine: !1,
494
- minTickGap: u ? 32 : 48
640
+ minTickGap: m ? 32 : 48
495
641
  }),
496
- /* @__PURE__ */ S(H, {
642
+ /* @__PURE__ */ x(R, {
497
643
  type: "number",
498
644
  dataKey: i[0]?.dataKey || "value",
499
645
  name: String(n[i[0]?.dataKey]?.label || i[0]?.dataKey),
500
646
  tickLine: !1,
501
647
  axisLine: !1,
502
- tickFormatter: y,
648
+ tickFormatter: N,
503
649
  width: 48
504
650
  }),
505
- /* @__PURE__ */ S(fe, {
651
+ /* @__PURE__ */ x(xe, {
506
652
  type: "number",
507
653
  range: [60, 400]
508
654
  }),
509
- /* @__PURE__ */ S(q, { content: /* @__PURE__ */ S(W, {}) }),
510
- /* @__PURE__ */ S(J, {
511
- content: /* @__PURE__ */ S(G, {}),
512
- ...u && {
655
+ /* @__PURE__ */ x(q, { content: /* @__PURE__ */ x(W, {}) }),
656
+ /* @__PURE__ */ x(J, {
657
+ content: /* @__PURE__ */ x(G, {}),
658
+ ...m && {
513
659
  verticalAlign: "bottom",
514
660
  wrapperStyle: {
515
661
  fontSize: "11px",
@@ -518,46 +664,47 @@ function je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
518
664
  }
519
665
  }),
520
666
  i.map((e, t) => {
521
- let r = v(), i = X(n[e.dataKey]?.color || r[t % r.length]), a = Z(e, "scatter");
522
- return /* @__PURE__ */ S(R, {
667
+ let r = D(), i = X(n[e.dataKey]?.color || r[t % r.length]), a = Z(e, "scatter");
668
+ return /* @__PURE__ */ x(be, {
523
669
  name: n[e.dataKey]?.label || e.dataKey,
524
- data: l,
670
+ data: f,
525
671
  fill: i,
526
- fillOpacity: a?.fillOpacity
672
+ fillOpacity: a?.fillOpacity,
673
+ ...oe
527
674
  }, e.dataKey);
528
675
  })
529
676
  ] })
530
677
  });
531
- if (s === "combo") return /* @__PURE__ */ S(U, {
678
+ if (d === "combo") return /* @__PURE__ */ x(U, {
532
679
  config: n,
533
680
  className: a,
534
- children: /* @__PURE__ */ C(E, {
535
- data: l,
681
+ children: /* @__PURE__ */ S(w, {
682
+ data: f,
536
683
  children: [
537
- /* @__PURE__ */ S(D, { vertical: !1 }),
538
- /* @__PURE__ */ S(V, {
684
+ /* @__PURE__ */ x(T, { vertical: !1 }),
685
+ /* @__PURE__ */ x(L, {
539
686
  dataKey: r,
540
- ...te
687
+ ...Se
541
688
  }),
542
- /* @__PURE__ */ S(H, {
689
+ /* @__PURE__ */ x(R, {
543
690
  yAxisId: "left",
544
691
  tickLine: !1,
545
692
  axisLine: !1,
546
- tickFormatter: y,
693
+ tickFormatter: N,
547
694
  width: 48
548
695
  }),
549
- /* @__PURE__ */ S(H, {
696
+ /* @__PURE__ */ x(R, {
550
697
  yAxisId: "right",
551
698
  orientation: "right",
552
699
  tickLine: !1,
553
700
  axisLine: !1,
554
- tickFormatter: y,
701
+ tickFormatter: N,
555
702
  width: 48
556
703
  }),
557
- /* @__PURE__ */ S(q, { content: /* @__PURE__ */ S(W, {}) }),
558
- /* @__PURE__ */ S(J, {
559
- content: /* @__PURE__ */ S(G, {}),
560
- ...u && {
704
+ /* @__PURE__ */ x(q, { content: /* @__PURE__ */ x(W, {}) }),
705
+ /* @__PURE__ */ x(J, {
706
+ content: /* @__PURE__ */ x(G, {}),
707
+ ...m && {
561
708
  verticalAlign: "bottom",
562
709
  wrapperStyle: {
563
710
  fontSize: "11px",
@@ -567,7 +714,7 @@ function je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
567
714
  }),
568
715
  i.map((e, t) => {
569
716
  let r = X(n[e.dataKey]?.color || Y), i = e.chartType || (t === 0 ? "bar" : "line"), a = i === "bar" ? "left" : "right", o = Z(e, i);
570
- return i === "line" ? /* @__PURE__ */ S(M, {
717
+ return i === "line" ? /* @__PURE__ */ x(O, {
571
718
  yAxisId: a,
572
719
  type: "monotone",
573
720
  dataKey: e.dataKey,
@@ -575,8 +722,9 @@ function je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
575
722
  strokeWidth: 2,
576
723
  dot: !1,
577
724
  strokeOpacity: o?.strokeOpacity,
578
- strokeDasharray: o?.strokeDasharray
579
- }, e.dataKey) : i === "area" ? /* @__PURE__ */ S(w, {
725
+ strokeDasharray: o?.strokeDasharray,
726
+ ...p
727
+ }, e.dataKey) : i === "area" ? /* @__PURE__ */ x(C, {
580
728
  yAxisId: a,
581
729
  type: "monotone",
582
730
  dataKey: e.dataKey,
@@ -584,53 +732,90 @@ function je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
584
732
  stroke: r,
585
733
  fillOpacity: o?.fillOpacity ?? .4,
586
734
  strokeOpacity: o?.strokeOpacity,
587
- strokeDasharray: o?.strokeDasharray
588
- }, e.dataKey) : /* @__PURE__ */ S(T, {
735
+ strokeDasharray: o?.strokeDasharray,
736
+ ...p
737
+ }, e.dataKey) : /* @__PURE__ */ x(de, {
589
738
  yAxisId: a,
590
739
  dataKey: e.dataKey,
591
740
  fill: r,
592
741
  radius: 4,
593
- fillOpacity: o?.fillOpacity
742
+ fillOpacity: o?.fillOpacity,
743
+ ...p
594
744
  }, e.dataKey);
595
745
  })
596
746
  ]
597
747
  })
598
748
  });
599
- let ne = s === "horizontal-bar";
600
- return /* @__PURE__ */ S(U, {
749
+ let Ce = d === "horizontal-bar", z = D(), we = s ? Object.values(s).map((e) => X(String(e))) : [], Te = Array.from(new Set([
750
+ ...z,
751
+ ...we,
752
+ ...i.map((e, t) => X(n[e.dataKey]?.color || z[t % z.length] || Y))
753
+ ])), B = (e) => "g" + e.replace(/[^a-zA-Z0-9]/g, "");
754
+ return /* @__PURE__ */ x(U, {
601
755
  config: n,
602
756
  className: a,
603
- children: /* @__PURE__ */ C(g, {
604
- data: l,
605
- layout: ne ? "vertical" : "horizontal",
606
- ...m,
757
+ children: /* @__PURE__ */ S(le, {
758
+ data: f,
759
+ layout: Ce ? "vertical" : "horizontal",
760
+ ..._,
607
761
  children: [
608
- /* @__PURE__ */ S(D, { vertical: !1 }),
609
- ne ? /* @__PURE__ */ C(x, { children: [/* @__PURE__ */ S(V, {
762
+ /* @__PURE__ */ x("defs", { children: Te.map((e) => /* @__PURE__ */ S(u.Fragment, { children: [/* @__PURE__ */ S("linearGradient", {
763
+ id: `bg-${B(e)}`,
764
+ x1: "0",
765
+ y1: "0",
766
+ x2: "0",
767
+ y2: "1",
768
+ children: [/* @__PURE__ */ x("stop", {
769
+ offset: "0%",
770
+ style: { stopColor: e },
771
+ stopOpacity: .95
772
+ }), /* @__PURE__ */ x("stop", {
773
+ offset: "100%",
774
+ style: { stopColor: e },
775
+ stopOpacity: .5
776
+ })]
777
+ }), /* @__PURE__ */ S("linearGradient", {
778
+ id: `ag-${B(e)}`,
779
+ x1: "0",
780
+ y1: "0",
781
+ x2: "0",
782
+ y2: "1",
783
+ children: [/* @__PURE__ */ x("stop", {
784
+ offset: "0%",
785
+ style: { stopColor: e },
786
+ stopOpacity: .5
787
+ }), /* @__PURE__ */ x("stop", {
788
+ offset: "95%",
789
+ style: { stopColor: e },
790
+ stopOpacity: .05
791
+ })]
792
+ })] }, B(e))) }),
793
+ /* @__PURE__ */ x(T, { vertical: !1 }),
794
+ Ce ? /* @__PURE__ */ S(b, { children: [/* @__PURE__ */ x(L, {
610
795
  type: "number",
611
796
  tickLine: !1,
612
797
  axisLine: !1,
613
- tickFormatter: y
614
- }), /* @__PURE__ */ S(H, {
798
+ tickFormatter: N
799
+ }), /* @__PURE__ */ x(R, {
615
800
  type: "category",
616
801
  dataKey: r,
617
802
  tickLine: !1,
618
803
  axisLine: !1,
619
- width: Math.min(140, Math.max(60, Math.max(...l.map((e) => String(e[r] ?? "").length)) * 7)),
620
- tickFormatter: _
621
- })] }) : /* @__PURE__ */ C(x, { children: [/* @__PURE__ */ S(V, {
804
+ width: Math.min(140, Math.max(60, Math.max(...f.map((e) => String(e[r] ?? "").length)) * 7)),
805
+ tickFormatter: v
806
+ })] }) : /* @__PURE__ */ S(b, { children: [/* @__PURE__ */ x(L, {
622
807
  dataKey: r,
623
- ...te
624
- }), /* @__PURE__ */ S(H, {
808
+ ...Se
809
+ }), /* @__PURE__ */ x(R, {
625
810
  tickLine: !1,
626
811
  axisLine: !1,
627
- tickFormatter: y,
812
+ tickFormatter: N,
628
813
  width: 48
629
814
  })] }),
630
- /* @__PURE__ */ S(q, { content: /* @__PURE__ */ S(W, {}) }),
631
- /* @__PURE__ */ S(J, {
632
- content: /* @__PURE__ */ S(G, {}),
633
- ...u && {
815
+ /* @__PURE__ */ x(q, { content: /* @__PURE__ */ x(W, {}) }),
816
+ /* @__PURE__ */ x(J, {
817
+ content: /* @__PURE__ */ x(G, {}),
818
+ ...m && {
634
819
  verticalAlign: "bottom",
635
820
  wrapperStyle: {
636
821
  fontSize: "11px",
@@ -639,39 +824,43 @@ function je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
639
824
  }
640
825
  }),
641
826
  i.map((e, t) => {
642
- let r = v(), a = e.variant === "comparison", o = a ? i.slice(0, t).find((e) => e.variant !== "comparison") || i[0] : e, c = a ? i.indexOf(o) : t, u = X(n[o.dataKey]?.color || r[c % r.length] || Y);
643
- if (s === "bar" || s === "horizontal-bar") {
644
- let t = i.filter((e) => e.variant !== "comparison").length === 1 && !a && i.length === 1 && l.length > 1, n = Z(e, "bar");
645
- return /* @__PURE__ */ S(T, {
827
+ let a = D(), o = e.variant === "comparison", s = o ? i.slice(0, t).find((e) => e.variant !== "comparison") || i[0] : e, c = o ? i.indexOf(s) : t, l = X(n[s.dataKey]?.color || a[c % a.length] || Y);
828
+ if (d === "bar" || d === "horizontal-bar") {
829
+ let t = i.filter((e) => e.variant !== "comparison").length === 1 && !o && i.length === 1 && f.length > 1, n = Z(e, "bar");
830
+ return /* @__PURE__ */ x(de, {
646
831
  dataKey: e.dataKey,
647
- fill: u,
832
+ fill: `url(#bg-${B(l)})`,
648
833
  radius: 4,
649
834
  fillOpacity: n?.fillOpacity,
650
- children: t && l.map((e, t) => /* @__PURE__ */ S(O, { fill: X(r[t % r.length]) }, `cell-${t}`))
835
+ ...p,
836
+ children: t && f.map((e, t) => /* @__PURE__ */ x(E, { fill: `url(#bg-${B(X(ne(e?.[r], t, a)))})` }, `cell-${t}`))
651
837
  }, e.dataKey);
652
838
  }
653
- if (s === "line") {
839
+ if (d === "line") {
654
840
  let t = Z(e, "line");
655
- return /* @__PURE__ */ S(M, {
841
+ return /* @__PURE__ */ x(O, {
656
842
  type: "monotone",
657
843
  dataKey: e.dataKey,
658
- stroke: u,
844
+ stroke: l,
659
845
  strokeWidth: 2,
660
846
  dot: !1,
661
847
  strokeOpacity: t?.strokeOpacity,
662
- strokeDasharray: t?.strokeDasharray
848
+ strokeDasharray: t?.strokeDasharray,
849
+ ...p
663
850
  }, e.dataKey);
664
851
  }
665
- if (s === "area") {
852
+ if (d === "area") {
666
853
  let t = Z(e, "area");
667
- return /* @__PURE__ */ S(w, {
854
+ return /* @__PURE__ */ x(C, {
668
855
  type: "monotone",
669
856
  dataKey: e.dataKey,
670
- fill: u,
671
- stroke: u,
672
- fillOpacity: t?.fillOpacity ?? .4,
857
+ fill: `url(#ag-${B(l)})`,
858
+ stroke: l,
859
+ strokeWidth: 2,
860
+ fillOpacity: t?.fillOpacity ?? 1,
673
861
  strokeOpacity: t?.strokeOpacity,
674
- strokeDasharray: t?.strokeDasharray
862
+ strokeDasharray: t?.strokeDasharray,
863
+ ...p
675
864
  }, e.dataKey);
676
865
  }
677
866
  return null;
@@ -680,8 +869,8 @@ function je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
680
869
  })
681
870
  });
682
871
  }
683
- var Y, Me, X, Z, Ne = ye((() => {
684
- ke(), Y = "hsl(var(--primary))", Me = {
872
+ var Y, qe, X, Z, Je = H((() => {
873
+ ze(), We(), Y = "hsl(var(--primary))", qe = {
685
874
  slate: "#64748b",
686
875
  gray: "#6b7280",
687
876
  zinc: "#71717a",
@@ -704,14 +893,14 @@ var Y, Me, X, Z, Ne = ye((() => {
704
893
  fuchsia: "#d946ef",
705
894
  pink: "#ec4899",
706
895
  rose: "#f43f5e"
707
- }, X = (e) => Me[e] || e, Z = (e, t) => e?.variant === "comparison" ? {
896
+ }, X = (e) => qe[e] || e, Z = (e, t) => e?.variant === "comparison" ? {
708
897
  strokeOpacity: typeof e.opacity == "number" ? e.opacity : t === "line" || t === "scatter" ? .5 : .6,
709
898
  fillOpacity: typeof e.opacity == "number" ? e.opacity : t === "bar" ? .4 : t === "area" ? .2 : .5,
710
899
  strokeDasharray: e.dashArray ?? (t === "line" || t === "area" ? "4 4" : void 0)
711
900
  } : null;
712
- })), Pe = l.lazy(() => Promise.resolve().then(() => (Ce(), xe))), Fe = l.lazy(() => Promise.resolve().then(() => (Ne(), Ae))), Ie = ({ schema: e }) => /* @__PURE__ */ S(u, {
713
- fallback: /* @__PURE__ */ S(b, { className: "w-full h-48 sm:h-64 md:h-80 lg:h-[400px]" }),
714
- children: /* @__PURE__ */ S(Pe, {
901
+ })), Ye = d.lazy(() => Promise.resolve().then(() => (Ne(), ke))), Xe = d.lazy(() => Promise.resolve().then(() => (Je(), Ge))), Ze = ({ schema: e }) => /* @__PURE__ */ x(f, {
902
+ fallback: /* @__PURE__ */ x(y, { className: "w-full h-48 sm:h-64 md:h-80 lg:h-[400px]" }),
903
+ children: /* @__PURE__ */ x(Ye, {
715
904
  data: e.data,
716
905
  dataKey: e.dataKey,
717
906
  xAxisKey: e.xAxisKey,
@@ -720,7 +909,7 @@ var Y, Me, X, Z, Ne = ye((() => {
720
909
  color: e.color
721
910
  })
722
911
  }), Q = ({ schema: e, onChartClick: t }) => {
723
- let n = l.useMemo(() => {
912
+ let n = d.useMemo(() => {
724
913
  let t = e.series, n = e.xAxisKey, r = e.config;
725
914
  if (n || (e.index ? n = e.index : e.category && (n = e.category)), t || (e.categories ? t = e.categories.map((e) => ({ dataKey: e })) : e.value && (t = [{ dataKey: e.value }])), !r && t) {
726
915
  let n = e.colors || [
@@ -744,15 +933,18 @@ var Y, Me, X, Z, Ne = ye((() => {
744
933
  className: e.className
745
934
  };
746
935
  }, [e]);
747
- return /* @__PURE__ */ S(u, {
748
- fallback: /* @__PURE__ */ S(b, { className: "w-full h-48 sm:h-64 md:h-80 lg:h-[400px]" }),
749
- children: /* @__PURE__ */ S(Fe, {
936
+ return /* @__PURE__ */ x(f, {
937
+ fallback: /* @__PURE__ */ x(y, { className: "w-full h-48 sm:h-64 md:h-80 lg:h-[400px]" }),
938
+ children: /* @__PURE__ */ x(Xe, {
750
939
  chartType: n.chartType,
751
940
  data: n.data,
752
941
  config: n.config,
753
942
  xAxisKey: n.xAxisKey,
754
943
  series: n.series,
755
944
  className: n.className,
945
+ colors: Array.isArray(e.colors) ? e.colors : void 0,
946
+ categoryColors: e.categoryColors,
947
+ isAnimationActive: e.isAnimationActive,
756
948
  onChartClick: t
757
949
  })
758
950
  });
@@ -762,7 +954,7 @@ var Y, Me, X, Z, Ne = ye((() => {
762
954
  function $(e) {
763
955
  return e.replace(/[_-]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase());
764
956
  }
765
- function Le(e, t) {
957
+ function Qe(e, t) {
766
958
  let { field: n, function: r, groupBy: i } = t, a = {};
767
959
  for (let t of e) {
768
960
  let e = String(t[i] ?? "Unknown");
@@ -793,9 +985,9 @@ function Le(e, t) {
793
985
  };
794
986
  });
795
987
  }
796
- async function Re(e, t, n, i, a) {
988
+ async function $e(e, t, n, r, i) {
797
989
  if (!e.length || !t) return e;
798
- let o = a || ((e, t) => t), s = `__raw_${t}`, c = n?.fields?.[t];
990
+ let o = i || ((e, t) => t), s = `__raw_${t}`, c = n?.fields?.[t];
799
991
  if (!c) {
800
992
  let n = /^\d{4}-\d{2}-\d{2}/;
801
993
  return e.map((e) => {
@@ -831,20 +1023,20 @@ async function Re(e, t, n, i, a) {
831
1023
  }
832
1024
  if (l === "lookup" || l === "master_detail") {
833
1025
  let n = c.reference_to || c.reference;
834
- if (!n || !i || typeof i.find != "function") return e.map((e) => ({
1026
+ if (!n || !r || typeof r.find != "function") return e.map((e) => ({
835
1027
  ...e,
836
1028
  [s]: e[t]
837
1029
  }));
838
- let a = [...new Set(e.map((e) => e[t]).filter((e) => e != null))];
839
- if (a.length === 0) return e.map((e) => ({
1030
+ let i = [...new Set(e.map((e) => e[t]).filter((e) => e != null))];
1031
+ if (i.length === 0) return e.map((e) => ({
840
1032
  ...e,
841
1033
  [s]: e[t]
842
1034
  }));
843
1035
  let o = c.id_field || "id";
844
1036
  try {
845
- let l = r(await i.find(n, {
846
- $filter: { [o]: { $in: a } },
847
- $top: a.length
1037
+ let l = a(await r.find(n, {
1038
+ $filter: { [o]: { $in: i } },
1039
+ $top: i.length
848
1040
  })), u = c.reference_field || c.display_field || "name", d = {};
849
1041
  for (let e of l) {
850
1042
  let t = String(e[o] ?? e.id ?? e._id ?? ""), n = e[u] || e.name || e.label || e.title || t;
@@ -879,57 +1071,107 @@ async function Re(e, t, n, i, a) {
879
1071
  };
880
1072
  });
881
1073
  }
882
- var ze = (e) => {
883
- let { schema: c } = e, l = f(me), u = e.dataSource || l?.dataSource, b = he(c.bind), { fieldOptionLabel: x } = _e(), w = h(x);
884
- p(() => {
885
- w.current = x;
886
- }, [x]);
887
- let [oe, T] = g([]), [E, D] = g(() => !(Array.isArray(c.data) && c.data.length > 0) && !!c.objectName), [O, se] = g(null), [k, A] = g(null), j = m(() => c.aggregate ? JSON.stringify(c.aggregate) : "", [c.aggregate]), M = m(() => c.filter ? JSON.stringify(c.filter) : "", [c.filter]), ce = m(() => c.compareTo ? JSON.stringify(c.compareTo) : "", [c.compareTo]), le = (e) => e !== "pie" && e !== "donut" && e !== "funnel", N = d(async (e, t) => {
888
- if (c.aggregate && typeof e.aggregate == "function") {
889
- let n = c.aggregate.groupBy;
1074
+ var et = (e) => {
1075
+ let { schema: u } = e, d = e.onSegmentClick, f = m(Ce), y = e.dataSource || f?.dataSource, b = z(u.bind), { fieldOptionLabel: C } = Ee(), ue = ee(C);
1076
+ h(() => {
1077
+ ue.current = C;
1078
+ }, [C]);
1079
+ let [de, w] = _([]), [T, E] = _(() => !(Array.isArray(u.data) && u.data.length > 0) && (!!u.objectName || !!u.dataset)), [fe, pe] = _(null), [me, D] = _(null), [O, k] = _(null), { openRecordList: he } = we(), A = De(), j = g(() => u.aggregate ? JSON.stringify(u.aggregate) : "", [u.aggregate]), ge = g(() => u.filter ? JSON.stringify(u.filter) : "", [u.filter]), _e = g(() => u.compareTo ? JSON.stringify(u.compareTo) : "", [u.compareTo]), M = g(() => u.dataset ? JSON.stringify({
1080
+ d: u.dataset,
1081
+ dim: u.dimensions ?? [],
1082
+ val: u.values ?? []
1083
+ }) : "", [
1084
+ u.dataset,
1085
+ u.dimensions,
1086
+ u.values
1087
+ ]), ve = (e) => e !== "pie" && e !== "donut" && e !== "funnel";
1088
+ h(() => {
1089
+ let e = !1;
1090
+ return (async () => {
1091
+ try {
1092
+ let t = {
1093
+ headers: { accept: "application/json" },
1094
+ credentials: "include"
1095
+ }, r = u.objectName, i, a = u.aggregate?.groupBy;
1096
+ if (r) i = a && typeof a == "object" && !Array.isArray(a) ? a.field : typeof a == "string" ? a : u.xAxisKey;
1097
+ else if (u.dataset) {
1098
+ let e = Array.isArray(u.dimensions) && u.dimensions.length ? u.dimensions[0] : void 0, n = await (await fetch(`/api/v1/meta/dataset/${encodeURIComponent(u.dataset)}`, t)).json().catch(() => null), a = n?.item ?? n?.data ?? n;
1099
+ r = a?.object, i = ((a?.dimensions || []).find((t) => t?.name === e) ?? (a?.dimensions || [])[0])?.field ?? e;
1100
+ }
1101
+ if (!r || !i) {
1102
+ e || k(null);
1103
+ return;
1104
+ }
1105
+ let o = await (await fetch(`/api/v1/meta/object/${encodeURIComponent(r)}`, t)).json().catch(() => null), s = n((o?.item ?? o?.data ?? o)?.fields?.[i]?.options);
1106
+ e || k(s);
1107
+ } catch {
1108
+ e || k(null);
1109
+ }
1110
+ })(), () => {
1111
+ e = !0;
1112
+ };
1113
+ }, [
1114
+ u.objectName,
1115
+ u.dataset,
1116
+ M,
1117
+ j,
1118
+ u.xAxisKey
1119
+ ]);
1120
+ let N = p(async (e, t) => {
1121
+ if (u.aggregate && typeof e.aggregate == "function") {
1122
+ let n = u.aggregate.groupBy;
890
1123
  if (n && typeof n == "object" && !Array.isArray(n)) {
891
- let r = c.aggregate.field, i = c.aggregate.function, a = {
1124
+ let r = u.aggregate.field, i = u.aggregate.function, a = {
892
1125
  function: i,
893
1126
  alias: r || i
894
1127
  };
895
1128
  i !== "count" && r && (a.field = r);
896
- let o = await e.aggregate(c.objectName, {
1129
+ let o = await e.aggregate(u.objectName, {
897
1130
  groupBy: [n],
898
1131
  aggregations: [a],
899
1132
  where: t
900
1133
  });
901
1134
  return Array.isArray(o) ? o : [];
902
1135
  }
903
- let r = await e.aggregate(c.objectName, {
904
- field: c.aggregate.field,
905
- function: c.aggregate.function,
1136
+ let r = await e.aggregate(u.objectName, {
1137
+ field: u.aggregate.field,
1138
+ function: u.aggregate.function,
906
1139
  groupBy: n,
907
1140
  filter: t
908
1141
  });
909
1142
  return Array.isArray(r) ? r : [];
910
1143
  }
911
1144
  if (typeof e.find == "function") {
912
- let n = r(await e.find(c.objectName, { $filter: t }));
913
- return c.aggregate && n.length > 0 && (n = Le(n, c.aggregate)), n;
1145
+ let n = a(await e.find(u.objectName, { $filter: t }));
1146
+ return u.aggregate && n.length > 0 && (n = Qe(n, u.aggregate)), n;
914
1147
  }
915
1148
  return [];
916
- }, [c.objectName, j]), ue = d(async (e, t) => {
917
- if (!e || !c.objectName) {
918
- t.current && D(!1);
1149
+ }, [u.objectName, j]), ye = p(async (e, t) => {
1150
+ if (!e || !u.objectName && !u.dataset) {
1151
+ t.current && E(!1);
919
1152
  return;
920
1153
  }
921
- t.current && (D(!0), se(null));
1154
+ t.current && (E(!0), pe(null));
922
1155
  try {
923
- let n = a(c.filter), r = c.compareTo, i = !!r && le(c.chartType), o = i ? s(c.filter, r) : null, [l, u] = await Promise.all([N(e, n), o ? N(e, o) : Promise.resolve([])]), d = l, f = c.aggregate?.groupBy, p = f && typeof f == "object" && !Array.isArray(f) ? f.alias || f.field : f || c.xAxisKey;
924
- if (i && u.length > 0 && c.aggregate) {
925
- let e = c.aggregate.field, t = c.aggregate.function, n = (n) => {
1156
+ if (u.dataset && typeof e.queryDataset == "function") {
1157
+ let n = s(u.filter), r = await e.queryDataset(u.dataset, {
1158
+ dimensions: Array.isArray(u.dimensions) ? u.dimensions : [],
1159
+ measures: Array.isArray(u.values) ? u.values : [],
1160
+ ...n ? { runtimeFilter: n } : {}
1161
+ });
1162
+ t.current && w(Array.isArray(r?.rows) ? r.rows : []);
1163
+ return;
1164
+ }
1165
+ let n = s(u.filter), r = u.compareTo, i = !!r && ve(u.chartType), a = i ? l(u.filter, r) : null, [o, c] = await Promise.all([N(e, n), a ? N(e, a) : Promise.resolve([])]), d = o, f = u.aggregate?.groupBy, p = f && typeof f == "object" && !Array.isArray(f) ? f.alias || f.field : f || u.xAxisKey;
1166
+ if (i && c.length > 0 && u.aggregate) {
1167
+ let e = u.aggregate.field, t = u.aggregate.function, n = (n) => {
926
1168
  if (n == null) return null;
927
1169
  let r = `${e}_${t}`;
928
1170
  return r in n ? Number(n[r]) : t === "count" && `${e}_count` in n ? Number(n[`${e}_count`]) : e in n ? Number(n[e]) : "value" in n ? Number(n.value) : "count" in n ? Number(n.count) : null;
929
1171
  }, r = `${e}__comparison`, i = p;
930
- if (i && d.some((e) => e[i] != null) && u.some((e) => e[i] != null)) {
1172
+ if (i && d.some((e) => e[i] != null) && c.some((e) => e[i] != null)) {
931
1173
  let e = /* @__PURE__ */ new Map();
932
- for (let t of u) {
1174
+ for (let t of c) {
933
1175
  let r = String(t[i] ?? "");
934
1176
  e.set(r, n(t));
935
1177
  }
@@ -941,7 +1183,7 @@ var ze = (e) => {
941
1183
  };
942
1184
  });
943
1185
  let t = new Set(d.map((e) => String(e[i] ?? "")));
944
- for (let e of u) {
1186
+ for (let e of c) {
945
1187
  let a = String(e[i] ?? "");
946
1188
  t.has(a) || d.push({
947
1189
  [i]: a,
@@ -949,9 +1191,9 @@ var ze = (e) => {
949
1191
  });
950
1192
  }
951
1193
  } else {
952
- let e = Math.max(d.length, u.length), t = [];
1194
+ let e = Math.max(d.length, c.length), t = [];
953
1195
  for (let i = 0; i < e; i++) {
954
- let e = d[i] || {}, a = u[i];
1196
+ let e = d[i] || {}, a = c[i];
955
1197
  t.push(a ? {
956
1198
  ...e,
957
1199
  [r]: n(a)
@@ -961,40 +1203,42 @@ var ze = (e) => {
961
1203
  }
962
1204
  }
963
1205
  if (p && typeof e.getObjectSchema == "function") try {
964
- let t = await e.getObjectSchema(c.objectName);
965
- d = await Re(d, p, t, e, (e, t) => w.current(c.objectName, p, e, t));
1206
+ let t = await e.getObjectSchema(u.objectName);
1207
+ d = await $e(d, p, t, e, (e, t) => ue.current(u.objectName, p, e, t));
966
1208
  } catch {}
967
- t.current && T(d);
1209
+ t.current && w(d);
968
1210
  } catch (e) {
969
- console.error("[ObjectChart] Fetch error:", e), t.current && se(e instanceof Error ? e.message : "Failed to load chart data");
1211
+ console.error("[ObjectChart] Fetch error:", e), t.current && pe(e instanceof Error ? e.message : "Failed to load chart data");
970
1212
  } finally {
971
- t.current && D(!1);
1213
+ t.current && E(!1);
972
1214
  }
973
1215
  }, [
974
- c.objectName,
975
- j,
1216
+ u.objectName,
976
1217
  M,
977
- ce,
978
- c.xAxisKey,
979
- c.chartType,
1218
+ j,
1219
+ ge,
1220
+ _e,
1221
+ u.xAxisKey,
1222
+ u.chartType,
980
1223
  N
981
1224
  ]);
982
- p(() => {
1225
+ h(() => {
983
1226
  let e = { current: !0 };
984
- return c.objectName && !b && !c.data ? ue(u, e) : e.current && D(!1), () => {
1227
+ return (u.objectName || u.dataset) && !b && !u.data ? ye(y, e) : e.current && E(!1), () => {
985
1228
  e.current = !1;
986
1229
  };
987
1230
  }, [
988
- c.objectName,
989
- u,
990
- b,
991
- c.data,
1231
+ u.objectName,
992
1232
  M,
1233
+ y,
1234
+ b,
1235
+ u.data,
1236
+ ge,
993
1237
  j,
994
- ce,
995
- ue
1238
+ _e,
1239
+ ye
996
1240
  ]);
997
- let de = b || c.data || oe, P = Array.isArray(de) ? de : [], F = c.drillDown, I = c.aggregate?.groupBy || c.xAxisKey, L = m(() => {
1241
+ let be = b || u.data || de, P = Array.isArray(be) ? be : [], F = u.drillDown, I = u.aggregate?.groupBy || u.xAxisKey, L = g(() => {
998
1242
  if (!I) return /* @__PURE__ */ new Map();
999
1243
  let e = /* @__PURE__ */ new Map(), t = `__raw_${I}`;
1000
1244
  for (let n of P) {
@@ -1004,130 +1248,162 @@ var ze = (e) => {
1004
1248
  e.set(String(r), i);
1005
1249
  }
1006
1250
  return e;
1007
- }, [P, I]), R = c.compareTo, z = !!R && le(c.chartType) && !!c.aggregate && P.some((e) => e[`${c.aggregate.field}__comparison`] != null), B = m(() => {
1008
- let e = Array.isArray(c.series) ? c.series : null;
1009
- if (!z) return e;
1010
- let n = e || [{ dataKey: c.aggregate.field }], r = {
1251
+ }, [P, I]), R = u.compareTo, xe = !!R && ve(u.chartType) && !!u.aggregate && P.some((e) => e[`${u.aggregate.field}__comparison`] != null), V = g(() => {
1252
+ let e = Array.isArray(u.series) ? u.series : null;
1253
+ if (!xe) return e;
1254
+ let t = e || [{ dataKey: u.aggregate.field }], n = {
1011
1255
  vsLastWeek: "Previous week",
1012
1256
  vsLastMonth: "Previous month",
1013
1257
  vsLastQuarter: "Previous quarter",
1014
1258
  vsLastYear: "Previous year",
1015
1259
  vsYesterday: "Yesterday",
1016
1260
  vsPreviousPeriod: "Previous period"
1017
- }[t(R, c.filter)] || "Previous period";
1018
- return [...n.map((e) => ({
1261
+ }[r(R, u.filter)] || "Previous period";
1262
+ return [...t.map((e) => ({
1019
1263
  ...e,
1020
1264
  variant: e.variant || "current"
1021
1265
  })), {
1022
- dataKey: `${c.aggregate.field}__comparison`,
1023
- label: r,
1266
+ dataKey: `${u.aggregate.field}__comparison`,
1267
+ label: n,
1024
1268
  variant: "comparison"
1025
1269
  }];
1026
1270
  }, [
1027
- z,
1028
- c.series,
1029
- c.aggregate,
1030
- c.filter,
1271
+ xe,
1272
+ u.series,
1273
+ u.aggregate,
1274
+ u.filter,
1031
1275
  R
1032
- ]), V = {
1033
- ...c,
1276
+ ]), H = u.dataset ? t(P, u.dimensions, u.values) : null, Oe = H ? {
1277
+ ...u,
1278
+ data: H.data,
1279
+ xAxisKey: H.xAxisKey,
1280
+ series: H.series
1281
+ } : {
1282
+ ...u,
1034
1283
  data: P,
1035
- ...B ? { series: B } : {}
1284
+ ...V ? { series: V } : {}
1285
+ }, ke = u.colors && !Array.isArray(u.colors) && typeof u.colors == "object" ? u.colors : null, Ae = Array.isArray(u.colors) ? u.colors : void 0, je = O || ke ? {
1286
+ ...O || {},
1287
+ ...ke || {}
1288
+ } : void 0, Me = {
1289
+ ...Oe,
1290
+ colors: Ae,
1291
+ ...je ? { categoryColors: je } : {}
1036
1292
  };
1037
- if (E && P.length === 0) return /* @__PURE__ */ S("div", {
1038
- className: "flex items-center justify-center text-muted-foreground text-sm p-4 " + (c.className || ""),
1293
+ if (T && P.length === 0) return /* @__PURE__ */ x("div", {
1294
+ className: "flex items-center justify-center text-muted-foreground text-sm p-4 " + (u.className || ""),
1039
1295
  "data-testid": "chart-loading",
1040
1296
  children: "Loading chart data…"
1041
1297
  });
1042
- if (O) return /* @__PURE__ */ C("div", {
1043
- className: "flex flex-col items-center justify-center gap-2 p-4 " + (c.className || ""),
1298
+ if (fe) return /* @__PURE__ */ S("div", {
1299
+ className: "flex flex-col items-center justify-center gap-2 p-4 " + (u.className || ""),
1044
1300
  "data-testid": "chart-error",
1045
1301
  role: "alert",
1046
1302
  children: [
1047
- /* @__PURE__ */ S(ge, { className: "h-6 w-6 text-destructive opacity-60" }),
1048
- /* @__PURE__ */ S("p", {
1303
+ /* @__PURE__ */ x(Te, { className: "h-6 w-6 text-destructive opacity-60" }),
1304
+ /* @__PURE__ */ x("p", {
1049
1305
  className: "text-xs text-destructive font-medium",
1050
1306
  children: "Failed to load chart data"
1051
1307
  }),
1052
- /* @__PURE__ */ S("p", {
1308
+ /* @__PURE__ */ x("p", {
1053
1309
  className: "text-xs text-muted-foreground max-w-xs text-center",
1054
- children: O
1310
+ children: fe
1055
1311
  })
1056
1312
  ]
1057
1313
  });
1058
- if (!u && c.objectName && P.length === 0) return /* @__PURE__ */ C("div", {
1059
- className: "flex items-center justify-center text-muted-foreground text-sm p-4 " + (c.className || ""),
1314
+ if (!y && u.objectName && P.length === 0) return /* @__PURE__ */ S("div", {
1315
+ className: "flex items-center justify-center text-muted-foreground text-sm p-4 " + (u.className || ""),
1060
1316
  "data-testid": "chart-no-datasource",
1061
1317
  children: [
1062
1318
  "No data source available for “",
1063
- c.objectName,
1319
+ u.objectName,
1064
1320
  "”"
1065
1321
  ]
1066
1322
  });
1067
- let H = i(F) ? (e) => {
1323
+ let Ne = o(F) ? (e) => {
1068
1324
  let t = e.category, n = t != null && L.has(String(t)) ? L.get(String(t)) : t;
1069
- A({
1325
+ D({
1070
1326
  ...e,
1071
1327
  category: n,
1072
1328
  categoryLabel: t,
1073
1329
  scope: "cell"
1074
1330
  });
1075
- } : void 0, fe = k && c.objectName ? (() => {
1076
- let e = n(F, k, { groupByField: I }), t = {
1077
- ...c.filter || {},
1331
+ } : void 0, Pe = d ?? Ne, U = !d && me && u.objectName ? (() => {
1332
+ let e = i(F, me, { groupByField: I }), t = {
1333
+ ...u.filter || {},
1078
1334
  ...e
1079
- }, r = o(F, k, c.title || "Details"), i = F?.target ?? "drawer", a = /* @__PURE__ */ S("div", {
1335
+ }, n = c(F, me, u.title || "Details"), r = F?.target ?? "drawer", a = /* @__PURE__ */ x("div", {
1080
1336
  className: "overflow-auto",
1081
1337
  "data-testid": "chart-drill-body",
1082
- children: /* @__PURE__ */ S(pe, {
1338
+ children: /* @__PURE__ */ x(Se, {
1083
1339
  schema: {
1084
1340
  type: "object-data-table",
1085
- objectName: c.objectName,
1341
+ objectName: u.objectName,
1086
1342
  filter: t,
1087
1343
  pagination: !0,
1088
1344
  pageSize: F?.maxRows,
1089
1345
  columns: F?.columns?.map((e) => ({
1090
1346
  accessorKey: e,
1091
1347
  header: e
1092
- }))
1348
+ })),
1349
+ drillDown: {
1350
+ enabled: !0,
1351
+ mode: "record",
1352
+ target: "dialog"
1353
+ }
1093
1354
  },
1094
- dataSource: u
1355
+ dataSource: y
1095
1356
  })
1096
- });
1097
- return i === "dialog" ? /* @__PURE__ */ S(_, {
1357
+ }), o = he && u.objectName ? /* @__PURE__ */ S(te, {
1358
+ type: "button",
1359
+ variant: "ghost",
1360
+ size: "sm",
1361
+ "data-testid": "drill-open-in-list",
1362
+ onClick: () => {
1363
+ he(u.objectName, t), D(null);
1364
+ },
1365
+ children: [A("dashboard.openInList", "Open in list"), /* @__PURE__ */ x(B, { className: "ml-1 h-3.5 w-3.5" })]
1366
+ }) : null;
1367
+ return r === "dialog" ? /* @__PURE__ */ x(ne, {
1098
1368
  open: !0,
1099
- onOpenChange: (e) => !e && A(null),
1100
- children: /* @__PURE__ */ C(ee, {
1369
+ onOpenChange: (e) => !e && D(null),
1370
+ children: /* @__PURE__ */ S(re, {
1101
1371
  className: "max-w-4xl",
1102
- children: [/* @__PURE__ */ S(v, { children: /* @__PURE__ */ S(y, { children: r }) }), a]
1372
+ children: [/* @__PURE__ */ S(ie, {
1373
+ className: "flex-row items-center justify-between gap-4 pr-8",
1374
+ children: [/* @__PURE__ */ x(ae, { children: n }), o]
1375
+ }), a]
1103
1376
  })
1104
- }) : /* @__PURE__ */ S(ne, {
1377
+ }) : /* @__PURE__ */ x(se, {
1105
1378
  open: !0,
1106
- onOpenChange: (e) => !e && A(null),
1107
- children: /* @__PURE__ */ C(re, {
1379
+ onOpenChange: (e) => !e && D(null),
1380
+ children: /* @__PURE__ */ S(ce, {
1108
1381
  side: "right",
1109
1382
  className: "w-full sm:max-w-2xl md:max-w-3xl lg:max-w-4xl flex flex-col",
1110
- children: [/* @__PURE__ */ S(ie, { children: /* @__PURE__ */ S(ae, { children: r }) }), /* @__PURE__ */ S("div", {
1383
+ children: [/* @__PURE__ */ S(le, {
1384
+ className: "flex-row items-center justify-between gap-4 pr-8",
1385
+ children: [/* @__PURE__ */ x(v, { children: n }), o]
1386
+ }), /* @__PURE__ */ x("div", {
1111
1387
  className: "flex-1 overflow-hidden mt-2",
1112
1388
  children: a
1113
1389
  })]
1114
1390
  })
1115
1391
  });
1116
1392
  })() : null;
1117
- return /* @__PURE__ */ C("div", {
1393
+ return /* @__PURE__ */ S("div", {
1118
1394
  className: "relative",
1119
1395
  children: [
1120
- /* @__PURE__ */ S(te, { active: E && P.length > 0 }),
1121
- /* @__PURE__ */ S(Q, {
1396
+ /* @__PURE__ */ x(oe, { active: T && P.length > 0 }),
1397
+ /* @__PURE__ */ x(Q, {
1122
1398
  ...e,
1123
- schema: V,
1124
- onChartClick: H
1399
+ schema: Me,
1400
+ onChartClick: Pe
1125
1401
  }),
1126
- fe
1402
+ U
1127
1403
  ]
1128
1404
  });
1129
1405
  };
1130
- e.register("object-chart", ze, {
1406
+ e.register("object-chart", et, {
1131
1407
  namespace: "plugin-charts",
1132
1408
  label: "Object Chart",
1133
1409
  category: "view",
@@ -1159,11 +1435,11 @@ e.register("object-chart", ze, {
1159
1435
  });
1160
1436
  //#endregion
1161
1437
  //#region src/index.tsx
1162
- var Be = {
1163
- "bar-chart": Ie,
1438
+ var tt = {
1439
+ "bar-chart": Ze,
1164
1440
  chart: Q
1165
1441
  };
1166
- e.register("bar-chart", Ie, {
1442
+ e.register("bar-chart", Ze, {
1167
1443
  namespace: "plugin-charts",
1168
1444
  label: "Bar Chart",
1169
1445
  category: "plugin",
@@ -1227,7 +1503,7 @@ e.register("bar-chart", Ie, {
1227
1503
  height: 400,
1228
1504
  color: "#8884d8"
1229
1505
  }
1230
- }), e.register("chart", ze, {
1506
+ }), e.register("chart", et, {
1231
1507
  namespace: "view",
1232
1508
  category: "view",
1233
1509
  label: "Chart",
@@ -1393,4 +1669,4 @@ e.register("bar-chart", Ie, {
1393
1669
  defaultProps: { chartType: "scatter" }
1394
1670
  });
1395
1671
  //#endregion
1396
- export { Ie as ChartBarRenderer, Q as ChartRenderer, ze as ObjectChart, Be as chartComponents };
1672
+ export { Ze as ChartBarRenderer, Q as ChartRenderer, et as ObjectChart, tt as chartComponents };