drizzle-cube 0.2.10 → 0.2.12
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/chartConfigs.d.ts +3 -1
- package/dist/client/charts.js +11 -11
- package/dist/client/chunks/{chart-activitygridchart-C1ts13cL.js → chart-activitygridchart-CUGN9Xq9.js} +848 -738
- package/dist/client/chunks/chart-activitygridchart-CUGN9Xq9.js.map +1 -0
- package/dist/client/chunks/chart-areachart-B4tknnsY.js +239 -0
- package/dist/client/chunks/chart-areachart-B4tknnsY.js.map +1 -0
- package/dist/client/chunks/{chart-areachart-config-0ICuIaRP.js → chart-areachart-config-D9pPUKHZ.js} +15 -2
- package/dist/client/chunks/chart-areachart-config-D9pPUKHZ.js.map +1 -0
- package/dist/client/chunks/chart-axisformatcontrols-Ch_IYF94.js +196 -0
- package/dist/client/chunks/chart-axisformatcontrols-Ch_IYF94.js.map +1 -0
- package/dist/client/chunks/chart-barchart-D_op06r-.js +216 -0
- package/dist/client/chunks/chart-barchart-D_op06r-.js.map +1 -0
- package/dist/client/chunks/{chart-barchart-config-DalFHdmP.js → chart-barchart-config-iniz62ni.js} +15 -2
- package/dist/client/chunks/chart-barchart-config-iniz62ni.js.map +1 -0
- package/dist/client/chunks/chart-bubblechart-BsaIXUbS.js +214 -0
- package/dist/client/chunks/chart-bubblechart-BsaIXUbS.js.map +1 -0
- package/dist/client/chunks/{chart-bubblechart-config-WjiDlqnP.js → chart-bubblechart-config-yLq2oyR3.js} +18 -4
- package/dist/client/chunks/{chart-bubblechart-config-WjiDlqnP.js.map → chart-bubblechart-config-yLq2oyR3.js.map} +1 -1
- package/dist/client/chunks/{chart-charttooltip-5tzcFRt0.js → chart-charttooltip-Bx3I8jQv.js} +4 -4
- package/dist/client/chunks/{chart-charttooltip-5tzcFRt0.js.map → chart-charttooltip-Bx3I8jQv.js.map} +1 -1
- package/dist/client/chunks/chart-datatable-C7MS9q4Y.js +283 -0
- package/dist/client/chunks/chart-datatable-C7MS9q4Y.js.map +1 -0
- package/dist/client/chunks/{chart-datatable-config-C7TgMD3u.js → chart-datatable-config-DmEA3A-7.js} +10 -2
- package/dist/client/chunks/{chart-datatable-config-C7TgMD3u.js.map → chart-datatable-config-DmEA3A-7.js.map} +1 -1
- package/dist/client/chunks/{chart-kpidelta-D_VuZaVL.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-DeCkVi2e.js → chart-kpinumber-HOPfcK2N.js} +4 -4
- package/dist/client/chunks/{chart-kpinumber-DeCkVi2e.js.map → chart-kpinumber-HOPfcK2N.js.map} +1 -1
- package/dist/client/chunks/{chart-kpitext-D8OpA0CY.js → chart-kpitext-BZkC9u3A.js} +24 -24
- package/dist/client/chunks/{chart-kpitext-D8OpA0CY.js.map → chart-kpitext-BZkC9u3A.js.map} +1 -1
- package/dist/client/chunks/chart-linechart-DqFmLbRe.js +198 -0
- package/dist/client/chunks/chart-linechart-DqFmLbRe.js.map +1 -0
- package/dist/client/chunks/{chart-linechart-config-C5tpU_2u.js → chart-linechart-config-DLVS2Zxc.js} +17 -4
- package/dist/client/chunks/chart-linechart-config-DLVS2Zxc.js.map +1 -0
- 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-CiFJQtC8.js → chart-piechart-CrXFd9pE.js} +61 -55
- package/dist/client/chunks/chart-piechart-CrXFd9pE.js.map +1 -0
- package/dist/client/chunks/{chart-piechart-config-CtP_JkGm.js → chart-piechart-config-DgwOeKHr.js} +12 -4
- package/dist/client/chunks/{chart-piechart-config-CtP_JkGm.js.map → chart-piechart-config-DgwOeKHr.js.map} +1 -1
- package/dist/client/chunks/{chart-radarchart-config-BkD_6Khq.js → chart-radarchart-config-BAV8D5PR.js} +12 -4
- package/dist/client/chunks/{chart-radarchart-config-BkD_6Khq.js.map → chart-radarchart-config-BAV8D5PR.js.map} +1 -1
- package/dist/client/chunks/chart-radarchart-tar2GBkO.js +131 -0
- package/dist/client/chunks/chart-radarchart-tar2GBkO.js.map +1 -0
- package/dist/client/chunks/chart-radialbarchart-ab8Swtal.js +120 -0
- package/dist/client/chunks/chart-radialbarchart-ab8Swtal.js.map +1 -0
- package/dist/client/chunks/{chart-radialbarchart-config-CBZDlB2k.js → chart-radialbarchart-config-CKozBBEC.js} +10 -2
- package/dist/client/chunks/{chart-radialbarchart-config-CBZDlB2k.js.map → chart-radialbarchart-config-CKozBBEC.js.map} +1 -1
- package/dist/client/chunks/{chart-scatterchart-DeGqPbYm.js → chart-scatterchart-BP06BeU5.js} +89 -87
- package/dist/client/chunks/chart-scatterchart-BP06BeU5.js.map +1 -0
- package/dist/client/chunks/{chart-scatterchart-config-DsdmlpHr.js → chart-scatterchart-config-UdHmbZ3s.js} +18 -4
- package/dist/client/chunks/{chart-scatterchart-config-DsdmlpHr.js.map → chart-scatterchart-config-UdHmbZ3s.js.map} +1 -1
- package/dist/client/chunks/chart-treemapchart-DAiixITm.js +265 -0
- package/dist/client/chunks/chart-treemapchart-DAiixITm.js.map +1 -0
- package/dist/client/chunks/{chart-treemapchart-config-CdF9NvPP.js → chart-treemapchart-config-D17VOwTM.js} +12 -4
- package/dist/client/chunks/{chart-treemapchart-config-CdF9NvPP.js.map → chart-treemapchart-config-D17VOwTM.js.map} +1 -1
- package/dist/client/chunks/{charts-DY7pF_-4.js → charts-CHzWeaY1.js} +36 -36
- package/dist/client/chunks/charts-CHzWeaY1.js.map +1 -0
- package/dist/client/chunks/components-DnM9CCUS.js +13931 -0
- package/dist/client/chunks/components-DnM9CCUS.js.map +1 -0
- package/dist/client/chunks/{index-DH5abYWH.js → index-DlsvcKXf.js} +135 -135
- package/dist/client/chunks/index-DlsvcKXf.js.map +1 -0
- package/dist/client/components/AnalysisBuilder/AnalysisAIPanel.d.ts +25 -0
- package/dist/client/components/AnalysisBuilder/AnalysisAxisDropZone.d.ts +8 -6
- package/dist/client/components/AnalysisBuilder/AnalysisChartConfigPanel.d.ts +2 -5
- package/dist/client/components/AnalysisBuilder/AnalysisDisplayConfigPanel.d.ts +9 -0
- package/dist/client/components/AnalysisBuilder/SectionHeading.d.ts +12 -0
- package/dist/client/components/AnalysisBuilder/types.d.ts +38 -9
- package/dist/client/components/charts/AxisFormatControls.d.ts +35 -0
- package/dist/client/components.js +2 -2
- package/dist/client/hooks/useResponsiveDashboard.d.ts +2 -8
- package/dist/client/hooks.js +10 -10
- package/dist/client/hooks.js.map +1 -1
- package/dist/client/icons/types.d.ts +2 -2
- package/dist/client/index.js +4 -4
- package/dist/client/providers.js +1 -1
- package/dist/client/styles.css +1 -1
- package/dist/client/types.d.ts +12 -0
- package/dist/client/utils/chartUtils.d.ts +20 -0
- package/dist/client/utils/pivotUtils.d.ts +11 -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 +4 -3
- package/dist/adapters/compiler-DP1pPIcg.cjs +0 -22
- package/dist/client/chunks/chart-activitygridchart-C1ts13cL.js.map +0 -1
- package/dist/client/chunks/chart-areachart-config-0ICuIaRP.js.map +0 -1
- package/dist/client/chunks/chart-areachart-fOi6lwUq.js +0 -204
- package/dist/client/chunks/chart-areachart-fOi6lwUq.js.map +0 -1
- package/dist/client/chunks/chart-barchart-CJfPZQin.js +0 -171
- package/dist/client/chunks/chart-barchart-CJfPZQin.js.map +0 -1
- package/dist/client/chunks/chart-barchart-config-DalFHdmP.js.map +0 -1
- package/dist/client/chunks/chart-bubblechart-BVk_qFly.js +0 -210
- package/dist/client/chunks/chart-bubblechart-BVk_qFly.js.map +0 -1
- package/dist/client/chunks/chart-datatable-BW_dWRbb.js +0 -249
- package/dist/client/chunks/chart-datatable-BW_dWRbb.js.map +0 -1
- package/dist/client/chunks/chart-kpidelta-D_VuZaVL.js.map +0 -1
- package/dist/client/chunks/chart-linechart-BdfBVl3m.js +0 -155
- package/dist/client/chunks/chart-linechart-BdfBVl3m.js.map +0 -1
- package/dist/client/chunks/chart-linechart-config-C5tpU_2u.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/chart-piechart-CiFJQtC8.js.map +0 -1
- package/dist/client/chunks/chart-radarchart-CJ4kpk5J.js +0 -124
- package/dist/client/chunks/chart-radarchart-CJ4kpk5J.js.map +0 -1
- package/dist/client/chunks/chart-radialbarchart-DLQqN_1Z.js +0 -109
- package/dist/client/chunks/chart-radialbarchart-DLQqN_1Z.js.map +0 -1
- package/dist/client/chunks/chart-scatterchart-DeGqPbYm.js.map +0 -1
- package/dist/client/chunks/chart-treemapchart-ClXsAOjr.js +0 -253
- package/dist/client/chunks/chart-treemapchart-ClXsAOjr.js.map +0 -1
- package/dist/client/chunks/charts-DY7pF_-4.js.map +0 -1
- package/dist/client/chunks/components-DAOVOiM_.js +0 -13429
- package/dist/client/chunks/components-DAOVOiM_.js.map +0 -1
- package/dist/client/chunks/index-DH5abYWH.js.map +0 -1
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { jsx as t, jsxs as o, Fragment as ee } from "react/jsx-runtime";
|
|
2
|
+
import { useState as te, useMemo as C } from "react";
|
|
3
|
+
import { ComposedChart as se, CartesianGrid as re, XAxis as ie, YAxis as H, Legend as ae, Bar as ne, Cell as le, Line as K } from "recharts";
|
|
4
|
+
import { C as oe } from "./chart-chartcontainer-CdwzIKP1.js";
|
|
5
|
+
import { C as ce } from "./chart-charttooltip-Bx3I8jQv.js";
|
|
6
|
+
import { u as de, t as xe, i as me, C as fe, f as S, N as he, P, a as W } from "./chart-activitygridchart-CUGN9Xq9.js";
|
|
7
|
+
import { p as ue, s as ge } from "./chart-areachart-B4tknnsY.js";
|
|
8
|
+
function Fe({
|
|
9
|
+
data: x,
|
|
10
|
+
chartConfig: s,
|
|
11
|
+
displayConfig: l = {},
|
|
12
|
+
queryObject: E,
|
|
13
|
+
height: h = "100%",
|
|
14
|
+
colorPalette: T
|
|
15
|
+
}) {
|
|
16
|
+
const [v, O] = te(null), { labelMap: V, getFieldLabel: A } = de(), z = l?.stackType ?? (l?.stacked ? "normal" : "none"), $ = z !== "none", X = z === "percent", I = {
|
|
17
|
+
showLegend: l?.showLegend ?? !0,
|
|
18
|
+
showGrid: l?.showGrid ?? !0,
|
|
19
|
+
showTooltip: l?.showTooltip ?? !0
|
|
20
|
+
}, u = l?.leftYAxisFormat, N = l?.rightYAxisFormat;
|
|
21
|
+
let m, a = [], L = [], c = null;
|
|
22
|
+
s?.xAxis && s?.yAxis ? (m = Array.isArray(s.xAxis) ? s.xAxis[0] : s.xAxis, a = Array.isArray(s.yAxis) ? s.yAxis : [s.yAxis], L = s.series || []) : s?.x && s?.y ? (m = s.x, a = Array.isArray(s.y) ? s.y : [s.y]) : c = "Invalid or missing chart axis configuration", !c && (!m || !a || a.length === 0) && (c = "Missing required X-axis or Y-axis fields");
|
|
23
|
+
const { data: k, seriesKeys: f } = C(() => c || !x || x.length === 0 || !m ? { data: [], seriesKeys: [] } : xe(
|
|
24
|
+
x,
|
|
25
|
+
m,
|
|
26
|
+
a,
|
|
27
|
+
E,
|
|
28
|
+
L,
|
|
29
|
+
V
|
|
30
|
+
), [x, m, a, E, L, V, c]), g = s?.yAxisAssignment || {}, G = C(() => {
|
|
31
|
+
const r = {};
|
|
32
|
+
return a.forEach((n) => {
|
|
33
|
+
const p = A(n);
|
|
34
|
+
r[p] = n;
|
|
35
|
+
}), r;
|
|
36
|
+
}, [a, A]), b = a.some((r) => g[r] === "right"), M = a.filter((r) => (g[r] || "left") === "left"), R = a.filter((r) => g[r] === "right"), { chartData: d, skippedCount: F } = C(() => {
|
|
37
|
+
if (k.length === 0 || f.length === 0)
|
|
38
|
+
return { chartData: [], skippedCount: 0 };
|
|
39
|
+
const r = k.filter((p) => f.some((w) => me(p[w]))), n = k.length - r.length;
|
|
40
|
+
return { chartData: r, skippedCount: n };
|
|
41
|
+
}, [k, f]);
|
|
42
|
+
try {
|
|
43
|
+
if (!x || x.length === 0)
|
|
44
|
+
return /* @__PURE__ */ t("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: h }, children: /* @__PURE__ */ o("div", { className: "text-center", children: [
|
|
45
|
+
/* @__PURE__ */ t("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
|
|
46
|
+
/* @__PURE__ */ t("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display in bar chart" })
|
|
47
|
+
] }) });
|
|
48
|
+
if (c)
|
|
49
|
+
return /* @__PURE__ */ t("div", { className: "flex items-center justify-center w-full text-dc-warning", style: { height: h }, children: /* @__PURE__ */ o("div", { className: "text-center", children: [
|
|
50
|
+
/* @__PURE__ */ t("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
|
|
51
|
+
/* @__PURE__ */ t("div", { className: "text-xs", children: c })
|
|
52
|
+
] }) });
|
|
53
|
+
const r = $ && !b, n = X && !b, p = n ? "expand" : void 0, w = f.length === 1 && d.some((e) => {
|
|
54
|
+
const i = e[f[0]];
|
|
55
|
+
return typeof i == "number" && i < 0;
|
|
56
|
+
}), U = I.showLegend, q = {
|
|
57
|
+
...fe,
|
|
58
|
+
left: 40,
|
|
59
|
+
// Space for left Y-axis label
|
|
60
|
+
right: b ? 40 : 20
|
|
61
|
+
// Extra space for right Y-axis label if needed
|
|
62
|
+
}, J = ue(l?.target || ""), D = ge(J, d.length);
|
|
63
|
+
let Y = d;
|
|
64
|
+
return D.length > 0 && (Y = d.map((e, i) => ({
|
|
65
|
+
...e,
|
|
66
|
+
__target: D[i] || null
|
|
67
|
+
}))), !d || d.length === 0 ? /* @__PURE__ */ t("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: h }, children: /* @__PURE__ */ o("div", { className: "text-center", children: [
|
|
68
|
+
/* @__PURE__ */ t("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
|
|
69
|
+
/* @__PURE__ */ t("div", { className: "text-xs text-dc-text-secondary", children: "No valid data points for bar chart after transformation" })
|
|
70
|
+
] }) }) : /* @__PURE__ */ o("div", { className: "relative w-full", style: { height: h }, children: [
|
|
71
|
+
/* @__PURE__ */ t(oe, { height: F > 0 ? "calc(100% - 20px)" : "100%", children: /* @__PURE__ */ o(se, { data: Y, margin: q, stackOffset: p, children: [
|
|
72
|
+
I.showGrid && /* @__PURE__ */ t(re, { strokeDasharray: "3 3" }),
|
|
73
|
+
/* @__PURE__ */ t(
|
|
74
|
+
ie,
|
|
75
|
+
{
|
|
76
|
+
dataKey: "name",
|
|
77
|
+
tick: { fontSize: 12 },
|
|
78
|
+
angle: -45,
|
|
79
|
+
textAnchor: "end",
|
|
80
|
+
height: 60
|
|
81
|
+
}
|
|
82
|
+
),
|
|
83
|
+
/* @__PURE__ */ t(
|
|
84
|
+
H,
|
|
85
|
+
{
|
|
86
|
+
yAxisId: "left",
|
|
87
|
+
orientation: "left",
|
|
88
|
+
tick: { fontSize: 12 },
|
|
89
|
+
tickFormatter: n ? (e) => `${(e * 100).toFixed(0)}%` : u ? (e) => S(e, u) : void 0,
|
|
90
|
+
domain: n ? [0, 1] : void 0,
|
|
91
|
+
label: n ? void 0 : M.length > 0 ? {
|
|
92
|
+
value: u?.label || A(M[0]),
|
|
93
|
+
angle: -90,
|
|
94
|
+
position: "left",
|
|
95
|
+
style: { textAnchor: "middle", fontSize: "12px" }
|
|
96
|
+
} : void 0
|
|
97
|
+
}
|
|
98
|
+
),
|
|
99
|
+
b && /* @__PURE__ */ t(
|
|
100
|
+
H,
|
|
101
|
+
{
|
|
102
|
+
yAxisId: "right",
|
|
103
|
+
orientation: "right",
|
|
104
|
+
tick: { fontSize: 12 },
|
|
105
|
+
tickFormatter: N ? (e) => S(e, N) : void 0,
|
|
106
|
+
label: R.length > 0 ? {
|
|
107
|
+
value: N?.label || A(R[0]),
|
|
108
|
+
angle: 90,
|
|
109
|
+
position: "right",
|
|
110
|
+
style: { textAnchor: "middle", fontSize: "12px" }
|
|
111
|
+
} : void 0
|
|
112
|
+
}
|
|
113
|
+
),
|
|
114
|
+
I.showTooltip && /* @__PURE__ */ t(
|
|
115
|
+
ce,
|
|
116
|
+
{
|
|
117
|
+
formatter: (e, i) => {
|
|
118
|
+
if (e == null)
|
|
119
|
+
return ["No data", i];
|
|
120
|
+
if (i === "Target")
|
|
121
|
+
return [S(e, u), "Target Value"];
|
|
122
|
+
if (n && typeof e == "number")
|
|
123
|
+
return [`${(e * 100).toFixed(1)}%`, i];
|
|
124
|
+
const y = G[i], _ = (y && g[y] === "right" ? "right" : "left") === "right" ? N : u;
|
|
125
|
+
return [S(e, _), i];
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
),
|
|
129
|
+
U && /* @__PURE__ */ t(
|
|
130
|
+
ae,
|
|
131
|
+
{
|
|
132
|
+
wrapperStyle: { fontSize: "12px", paddingTop: "25px" },
|
|
133
|
+
iconType: "rect",
|
|
134
|
+
iconSize: 8,
|
|
135
|
+
layout: "horizontal",
|
|
136
|
+
align: "center",
|
|
137
|
+
verticalAlign: "bottom",
|
|
138
|
+
onMouseEnter: (e) => O(String(e.dataKey || "")),
|
|
139
|
+
onMouseLeave: () => O(null)
|
|
140
|
+
}
|
|
141
|
+
),
|
|
142
|
+
f.map((e, i) => {
|
|
143
|
+
const y = G[e], j = y && g[y] === "right" ? "right" : "left";
|
|
144
|
+
return /* @__PURE__ */ t(
|
|
145
|
+
ne,
|
|
146
|
+
{
|
|
147
|
+
dataKey: e,
|
|
148
|
+
yAxisId: j,
|
|
149
|
+
stackId: r ? "stack" : void 0,
|
|
150
|
+
fill: w ? P : T?.colors && T.colors[i % T.colors.length] || W[i % W.length],
|
|
151
|
+
fillOpacity: v ? v === e ? 1 : 0.3 : 1,
|
|
152
|
+
children: w && d.map((_, Q) => {
|
|
153
|
+
const B = _[e], Z = typeof B == "number" && B < 0 ? he : P;
|
|
154
|
+
return /* @__PURE__ */ t(
|
|
155
|
+
le,
|
|
156
|
+
{
|
|
157
|
+
fill: Z,
|
|
158
|
+
fillOpacity: v ? v === e ? 1 : 0.3 : 1
|
|
159
|
+
},
|
|
160
|
+
`cell-${Q}`
|
|
161
|
+
);
|
|
162
|
+
})
|
|
163
|
+
},
|
|
164
|
+
e
|
|
165
|
+
);
|
|
166
|
+
}),
|
|
167
|
+
D.length > 0 && /* @__PURE__ */ o(ee, { children: [
|
|
168
|
+
/* @__PURE__ */ t(
|
|
169
|
+
K,
|
|
170
|
+
{
|
|
171
|
+
type: "monotone",
|
|
172
|
+
dataKey: "__target",
|
|
173
|
+
yAxisId: "left",
|
|
174
|
+
stroke: "#ffffff",
|
|
175
|
+
strokeWidth: 2,
|
|
176
|
+
dot: !1,
|
|
177
|
+
activeDot: !1,
|
|
178
|
+
connectNulls: !1
|
|
179
|
+
}
|
|
180
|
+
),
|
|
181
|
+
/* @__PURE__ */ t(
|
|
182
|
+
K,
|
|
183
|
+
{
|
|
184
|
+
type: "monotone",
|
|
185
|
+
dataKey: "__target",
|
|
186
|
+
yAxisId: "left",
|
|
187
|
+
name: "Target",
|
|
188
|
+
stroke: "#8B5CF6",
|
|
189
|
+
strokeWidth: 2,
|
|
190
|
+
strokeDasharray: "2 3",
|
|
191
|
+
dot: !1,
|
|
192
|
+
activeDot: !1,
|
|
193
|
+
connectNulls: !1
|
|
194
|
+
}
|
|
195
|
+
)
|
|
196
|
+
] })
|
|
197
|
+
] }) }),
|
|
198
|
+
F > 0 && /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-muted text-center mt-1", children: [
|
|
199
|
+
F,
|
|
200
|
+
" data point",
|
|
201
|
+
F !== 1 ? "s" : "",
|
|
202
|
+
" with no values hidden"
|
|
203
|
+
] })
|
|
204
|
+
] });
|
|
205
|
+
} catch (r) {
|
|
206
|
+
return /* @__PURE__ */ t("div", { className: "flex flex-col items-center justify-center w-full text-dc-error p-4", style: { height: h }, children: /* @__PURE__ */ o("div", { className: "text-center", children: [
|
|
207
|
+
/* @__PURE__ */ t("div", { className: "text-sm font-semibold mb-1", children: "Bar Chart Error" }),
|
|
208
|
+
/* @__PURE__ */ t("div", { className: "text-xs mb-2", children: r instanceof Error ? r.message : "Unknown rendering error" }),
|
|
209
|
+
/* @__PURE__ */ t("div", { className: "text-xs text-dc-text-muted", children: "Check the data and configuration" })
|
|
210
|
+
] }) });
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
export {
|
|
214
|
+
Fe as default
|
|
215
|
+
};
|
|
216
|
+
//# sourceMappingURL=chart-barchart-D_op06r-.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chart-barchart-D_op06r-.js","sources":["../../../src/client/components/charts/BarChart.tsx"],"sourcesContent":["import { useState, useMemo } from 'react'\nimport { ComposedChart, Bar, Line, XAxis, YAxis, CartesianGrid, Cell, Legend } from 'recharts'\nimport ChartContainer from './ChartContainer'\nimport ChartTooltip from './ChartTooltip'\nimport { CHART_COLORS, POSITIVE_COLOR, NEGATIVE_COLOR, CHART_MARGINS } from '../../utils/chartConstants'\nimport { transformChartDataWithSeries, isValidNumericValue, formatAxisValue } from '../../utils/chartUtils'\nimport { parseTargetValues, spreadTargetValues } from '../../utils/targetUtils'\nimport { useCubeContext } from '../../providers/CubeProvider'\nimport type { ChartProps } from '../../types'\n\nexport default function BarChart({\n data,\n chartConfig,\n displayConfig = {},\n queryObject,\n height = \"100%\",\n colorPalette\n}: ChartProps) {\n const [hoveredLegend, setHoveredLegend] = useState<string | null>(null)\n const { labelMap, getFieldLabel: contextGetFieldLabel } = useCubeContext()\n\n // Determine stacking from stackType (new) or stacked (legacy)\n const stackType = displayConfig?.stackType ?? (displayConfig?.stacked ? 'normal' : 'none')\n const shouldStack = stackType !== 'none'\n const isPercentStack = stackType === 'percent'\n\n const safeDisplayConfig = {\n showLegend: displayConfig?.showLegend ?? true,\n showGrid: displayConfig?.showGrid ?? true,\n showTooltip: displayConfig?.showTooltip ?? true\n }\n\n // Extract axis format configs\n const leftYAxisFormat = displayConfig?.leftYAxisFormat\n const rightYAxisFormat = displayConfig?.rightYAxisFormat\n\n // Validate chartConfig - support both legacy and new formats\n // Do validation but don't early return yet (hooks must come first)\n let xAxisField: string | undefined\n let yAxisFields: string[] = []\n let seriesFields: string[] = []\n let configError: string | null = null\n\n if (chartConfig?.xAxis && chartConfig?.yAxis) {\n // New format\n xAxisField = Array.isArray(chartConfig.xAxis) ? chartConfig.xAxis[0] : chartConfig.xAxis\n yAxisFields = Array.isArray(chartConfig.yAxis) ? chartConfig.yAxis : [chartConfig.yAxis]\n seriesFields = chartConfig.series || []\n } else if (chartConfig?.x && chartConfig?.y) {\n // Legacy format\n xAxisField = chartConfig.x\n yAxisFields = Array.isArray(chartConfig.y) ? chartConfig.y : [chartConfig.y]\n } else {\n configError = 'Invalid or missing chart axis configuration'\n }\n\n if (!configError && (!xAxisField || !yAxisFields || yAxisFields.length === 0)) {\n configError = 'Missing required X-axis or Y-axis fields'\n }\n\n // Transform data (will be empty arrays if config is invalid)\n const { data: transformedData, seriesKeys } = useMemo(() => {\n if (configError || !data || data.length === 0 || !xAxisField) {\n return { data: [], seriesKeys: [] }\n }\n return transformChartDataWithSeries(\n data,\n xAxisField,\n yAxisFields,\n queryObject,\n seriesFields,\n labelMap\n )\n }, [data, xAxisField, yAxisFields, queryObject, seriesFields, labelMap, configError])\n\n // Dual Y-axis support: extract yAxisAssignment from chartConfig\n const yAxisAssignment = chartConfig?.yAxisAssignment || {}\n\n // Build mapping from series key (label) to original field name\n const seriesKeyToField: Record<string, string> = useMemo(() => {\n const mapping: Record<string, string> = {}\n yAxisFields.forEach((field) => {\n const label = contextGetFieldLabel(field)\n mapping[label] = field\n })\n return mapping\n }, [yAxisFields, contextGetFieldLabel])\n\n // Determine if we need a right Y-axis\n const hasRightAxis = yAxisFields.some((field) => yAxisAssignment[field] === 'right')\n\n // Get fields for left and right axes for labels\n const leftAxisFields = yAxisFields.filter((f) => (yAxisAssignment[f] || 'left') === 'left')\n const rightAxisFields = yAxisFields.filter((f) => yAxisAssignment[f] === 'right')\n\n // Null handling: Filter out data points where ALL measure values are null\n // This prevents rendering empty bars and makes the chart clearer\n const { chartData, skippedCount } = useMemo(() => {\n if (transformedData.length === 0 || seriesKeys.length === 0) {\n return { chartData: [], skippedCount: 0 }\n }\n const filtered = transformedData.filter(row => {\n // Keep the row if at least one series has a valid numeric value\n return seriesKeys.some(key => isValidNumericValue(row[key]))\n })\n const skipped = transformedData.length - filtered.length\n return { chartData: filtered, skippedCount: skipped }\n }, [transformedData, seriesKeys])\n\n // Now handle early returns AFTER all hooks\n try {\n if (!data || data.length === 0) {\n return (\n <div className=\"flex items-center justify-center w-full text-dc-text-muted\" style={{ height }}>\n <div className=\"text-center\">\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 in bar chart</div>\n </div>\n </div>\n )\n }\n\n if (configError) {\n return (\n <div className=\"flex items-center justify-center w-full text-dc-warning\" style={{ height }}>\n <div className=\"text-center\">\n <div className=\"text-sm font-semibold mb-1\">Configuration Error</div>\n <div className=\"text-xs\">{configError}</div>\n </div>\n </div>\n )\n }\n\n // Determine stack offset for percentage stacking\n // Disable stacking when dual Y-axis is used (bars on different axes can't be stacked)\n const effectiveShouldStack = shouldStack && !hasRightAxis\n const effectiveIsPercentStack = isPercentStack && !hasRightAxis\n const stackOffset = effectiveIsPercentStack ? 'expand' as const : undefined\n\n // Check if we should use positive/negative coloring\n // This is enabled when we have single series data with mixed positive/negative values\n const usePositiveNegativeColoring = seriesKeys.length === 1 && chartData.some(row => {\n const value = row[seriesKeys[0]]\n return typeof value === 'number' && value < 0\n })\n\n // Determine if legend will be shown\n const showLegend = safeDisplayConfig.showLegend\n\n // Use custom chart margins with extra space for Y-axis labels\n const chartMargins = {\n ...CHART_MARGINS,\n left: 40, // Space for left Y-axis label\n right: hasRightAxis ? 40 : 20 // Extra space for right Y-axis label if needed\n }\n \n // Process target values and add to chart data\n const targetValues = parseTargetValues(displayConfig?.target || '')\n const spreadTargets = spreadTargetValues(targetValues, chartData.length)\n \n // Add target data to chart data if targets exist\n let enhancedChartData = chartData\n if (spreadTargets.length > 0) {\n enhancedChartData = chartData.map((dataPoint, index) => ({\n ...dataPoint,\n __target: spreadTargets[index] || null\n }))\n }\n \n // Validate transformed data\n if (!chartData || chartData.length === 0) {\n return (\n <div className=\"flex items-center justify-center w-full text-dc-text-muted\" style={{ height }}>\n <div className=\"text-center\">\n <div className=\"text-sm font-semibold mb-1\">No valid data</div>\n <div className=\"text-xs text-dc-text-secondary\">No valid data points for bar chart after transformation</div>\n </div>\n </div>\n )\n }\n\n return (\n <div className=\"relative w-full\" style={{ height }}>\n <ChartContainer height={skippedCount > 0 ? `calc(100% - 20px)` : \"100%\"}>\n <ComposedChart data={enhancedChartData} margin={chartMargins} stackOffset={stackOffset}>\n {safeDisplayConfig.showGrid && (\n <CartesianGrid strokeDasharray=\"3 3\" />\n )}\n <XAxis\n dataKey=\"name\"\n tick={{ fontSize: 12 }}\n angle={-45}\n textAnchor=\"end\"\n height={60}\n />\n <YAxis\n yAxisId=\"left\"\n orientation=\"left\"\n tick={{ fontSize: 12 }}\n tickFormatter={\n effectiveIsPercentStack\n ? (v) => `${(v * 100).toFixed(0)}%`\n : leftYAxisFormat\n ? (value) => formatAxisValue(value, leftYAxisFormat)\n : undefined\n }\n domain={effectiveIsPercentStack ? [0, 1] : undefined}\n label={\n effectiveIsPercentStack\n ? undefined\n : leftAxisFields.length > 0\n ? {\n value: leftYAxisFormat?.label || contextGetFieldLabel(leftAxisFields[0]),\n angle: -90,\n position: 'left',\n style: { textAnchor: 'middle', fontSize: '12px' }\n }\n : undefined\n }\n />\n {hasRightAxis && (\n <YAxis\n yAxisId=\"right\"\n orientation=\"right\"\n tick={{ fontSize: 12 }}\n tickFormatter={rightYAxisFormat ? (value) => formatAxisValue(value, rightYAxisFormat) : undefined}\n label={\n rightAxisFields.length > 0\n ? {\n value: rightYAxisFormat?.label || contextGetFieldLabel(rightAxisFields[0]),\n angle: 90,\n position: 'right',\n style: { textAnchor: 'middle', fontSize: '12px' }\n }\n : undefined\n }\n />\n )}\n {safeDisplayConfig.showTooltip && (\n <ChartTooltip\n formatter={(value: any, name: any) => {\n // Handle null values in tooltip\n if (value === null || value === undefined) {\n return ['No data', name]\n }\n if (name === 'Target') {\n // Use left Y-axis format for target values\n return [formatAxisValue(value, leftYAxisFormat), 'Target Value']\n }\n // Format as percentage when using percent stacking\n if (effectiveIsPercentStack && typeof value === 'number') {\n return [`${(value * 100).toFixed(1)}%`, name]\n }\n // Determine which axis format to use based on series name\n const originalField = seriesKeyToField[name]\n const axisId = originalField && yAxisAssignment[originalField] === 'right' ? 'right' : 'left'\n const formatConfig = axisId === 'right' ? rightYAxisFormat : leftYAxisFormat\n return [formatAxisValue(value, formatConfig), name]\n }}\n />\n )}\n {showLegend && (\n <Legend \n wrapperStyle={{ fontSize: '12px', paddingTop: '25px' }}\n iconType=\"rect\"\n iconSize={8}\n layout=\"horizontal\"\n align=\"center\"\n verticalAlign=\"bottom\"\n onMouseEnter={(o) => setHoveredLegend(String(o.dataKey || ''))}\n onMouseLeave={() => setHoveredLegend(null)}\n />\n )}\n {seriesKeys.map((seriesKey, index) => {\n // Look up the original field name to get its axis assignment\n const originalField = seriesKeyToField[seriesKey]\n const axisId = originalField && yAxisAssignment[originalField] === 'right' ? 'right' : 'left'\n return (\n <Bar\n key={seriesKey}\n dataKey={seriesKey}\n yAxisId={axisId}\n stackId={effectiveShouldStack ? 'stack' : undefined}\n fill={\n usePositiveNegativeColoring\n ? POSITIVE_COLOR\n : (colorPalette?.colors && colorPalette.colors[index % colorPalette.colors.length]) ||\n CHART_COLORS[index % CHART_COLORS.length]\n }\n fillOpacity={hoveredLegend ? (hoveredLegend === seriesKey ? 1 : 0.3) : 1}\n >\n {usePositiveNegativeColoring &&\n chartData.map((entry, entryIndex) => {\n const value = entry[seriesKey]\n const fillColor = typeof value === 'number' && value < 0 ? NEGATIVE_COLOR : POSITIVE_COLOR\n return (\n <Cell\n key={`cell-${entryIndex}`}\n fill={fillColor}\n fillOpacity={hoveredLegend ? (hoveredLegend === seriesKey ? 1 : 0.3) : 1}\n />\n )\n })}\n </Bar>\n )\n })}\n {spreadTargets.length > 0 && (\n <>\n {/* White background line */}\n <Line\n type=\"monotone\"\n dataKey=\"__target\"\n yAxisId=\"left\"\n stroke=\"#ffffff\"\n strokeWidth={2}\n dot={false}\n activeDot={false}\n connectNulls={false}\n />\n {/* Grey dashed line on top */}\n <Line\n type=\"monotone\"\n dataKey=\"__target\"\n yAxisId=\"left\"\n name=\"Target\"\n stroke=\"#8B5CF6\"\n strokeWidth={2}\n strokeDasharray=\"2 3\"\n dot={false}\n activeDot={false}\n connectNulls={false}\n />\n </>\n )}\n </ComposedChart>\n </ChartContainer>\n {skippedCount > 0 && (\n <div className=\"text-xs text-dc-text-muted text-center mt-1\">\n {skippedCount} data point{skippedCount !== 1 ? 's' : ''} with no values hidden\n </div>\n )}\n </div>\n )\n } catch (error) {\n // 'BarChart rendering error\n return (\n <div className=\"flex flex-col items-center justify-center w-full text-dc-error p-4\" style={{ height }}>\n <div className=\"text-center\">\n <div className=\"text-sm font-semibold mb-1\">Bar Chart Error</div>\n <div className=\"text-xs mb-2\">{error instanceof Error ? error.message : 'Unknown rendering error'}</div>\n <div className=\"text-xs text-dc-text-muted\">Check the data and configuration</div>\n </div>\n </div>\n )\n }\n}"],"names":["BarChart","data","chartConfig","displayConfig","queryObject","height","colorPalette","hoveredLegend","setHoveredLegend","useState","labelMap","contextGetFieldLabel","useCubeContext","stackType","shouldStack","isPercentStack","safeDisplayConfig","leftYAxisFormat","rightYAxisFormat","xAxisField","yAxisFields","seriesFields","configError","transformedData","seriesKeys","useMemo","transformChartDataWithSeries","yAxisAssignment","seriesKeyToField","mapping","field","label","hasRightAxis","leftAxisFields","f","rightAxisFields","chartData","skippedCount","filtered","row","key","isValidNumericValue","skipped","jsx","jsxs","effectiveShouldStack","effectiveIsPercentStack","stackOffset","usePositiveNegativeColoring","value","showLegend","chartMargins","CHART_MARGINS","targetValues","parseTargetValues","spreadTargets","spreadTargetValues","enhancedChartData","dataPoint","index","ChartContainer","ComposedChart","CartesianGrid","XAxis","YAxis","v","formatAxisValue","ChartTooltip","name","originalField","formatConfig","Legend","o","seriesKey","axisId","Bar","POSITIVE_COLOR","CHART_COLORS","entry","entryIndex","fillColor","NEGATIVE_COLOR","Cell","Fragment","Line","error"],"mappings":";;;;;;;AAUA,SAAwBA,GAAS;AAAA,EAC/B,MAAAC;AAAA,EACA,aAAAC;AAAA,EACA,eAAAC,IAAgB,CAAA;AAAA,EAChB,aAAAC;AAAA,EACA,QAAAC,IAAS;AAAA,EACT,cAAAC;AACF,GAAe;AACb,QAAM,CAACC,GAAeC,CAAgB,IAAIC,GAAwB,IAAI,GAChE,EAAE,UAAAC,GAAU,eAAeC,EAAA,IAAyBC,GAAA,GAGpDC,IAAYV,GAAe,cAAcA,GAAe,UAAU,WAAW,SAC7EW,IAAcD,MAAc,QAC5BE,IAAiBF,MAAc,WAE/BG,IAAoB;AAAA,IACxB,YAAYb,GAAe,cAAc;AAAA,IACzC,UAAUA,GAAe,YAAY;AAAA,IACrC,aAAaA,GAAe,eAAe;AAAA,EAAA,GAIvCc,IAAkBd,GAAe,iBACjCe,IAAmBf,GAAe;AAIxC,MAAIgB,GACAC,IAAwB,CAAA,GACx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,EAAE,QAAAtC,EAAA,GAC3F,UAAA,gBAAAuC,EAAC,OAAA,EAAI,WAAU,eACb,UAAA;AAAA,MAAA,gBAAAD,EAAC,OAAA,EAAI,WAAU,8BAA6B,UAAA,mBAAe;AAAA,MAC3D,gBAAAA,EAAC,SAAI,WAAU,gBAAgB,uBAAiB,QAAQ0C,EAAM,UAAU,0BAAA,CAA0B;AAAA,MAClG,gBAAA1C,EAAC,OAAA,EAAI,WAAU,8BAA6B,UAAA,mCAAA,CAAgC;AAAA,IAAA,EAAA,CAC9E,EAAA,CACF;AAAA,EAEJ;AACF;"}
|
package/dist/client/chunks/{chart-barchart-config-DalFHdmP.js → chart-barchart-config-iniz62ni.js}
RENAMED
|
@@ -18,7 +18,8 @@ const i = {
|
|
|
18
18
|
description: "Measures for bar heights",
|
|
19
19
|
mandatory: !0,
|
|
20
20
|
acceptTypes: ["measure"],
|
|
21
|
-
emptyText: "Drop measures here"
|
|
21
|
+
emptyText: "Drop measures here",
|
|
22
|
+
enableDualAxis: !0
|
|
22
23
|
},
|
|
23
24
|
{
|
|
24
25
|
key: "series",
|
|
@@ -49,10 +50,22 @@ const i = {
|
|
|
49
50
|
type: "string",
|
|
50
51
|
placeholder: "e.g., 100 or 50,75 for spread",
|
|
51
52
|
description: "Single value or comma-separated values to spread across X-axis"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
key: "leftYAxisFormat",
|
|
56
|
+
label: "Left Y-Axis Format",
|
|
57
|
+
type: "axisFormat",
|
|
58
|
+
description: "Number formatting for left Y-axis"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
key: "rightYAxisFormat",
|
|
62
|
+
label: "Right Y-Axis Format",
|
|
63
|
+
type: "axisFormat",
|
|
64
|
+
description: "Number formatting for right Y-axis"
|
|
52
65
|
}
|
|
53
66
|
]
|
|
54
67
|
};
|
|
55
68
|
export {
|
|
56
69
|
i as barChartConfig
|
|
57
70
|
};
|
|
58
|
-
//# sourceMappingURL=chart-barchart-config-
|
|
71
|
+
//# sourceMappingURL=chart-barchart-config-iniz62ni.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chart-barchart-config-iniz62ni.js","sources":["../../../src/client/components/charts/BarChart.config.tsx"],"sourcesContent":["import type { ChartTypeConfig } from '../../charts/chartConfigs'\nimport { getChartTypeIcon } from '../../icons'\n\n/**\n * Configuration for the bar chart type\n */\nexport const barChartConfig: ChartTypeConfig = {\n icon: getChartTypeIcon('bar'),\n description: 'Compare values across categories',\n useCase: 'Best for comparing discrete categories, showing rankings, or displaying changes over time',\n dropZones: [\n {\n key: 'xAxis',\n label: 'X-Axis (Categories)',\n description: 'Dimensions and time dimensions for grouping',\n mandatory: false,\n acceptTypes: ['dimension', 'timeDimension'],\n emptyText: 'Drop dimensions & time dimensions here'\n },\n {\n key: 'yAxis',\n label: 'Y-Axis (Values)',\n description: 'Measures for bar heights',\n mandatory: true,\n acceptTypes: ['measure'],\n emptyText: 'Drop measures here',\n enableDualAxis: true\n },\n {\n key: 'series',\n label: 'Series (Split into Multiple Series)',\n description: 'Dimensions to create separate data series',\n mandatory: false,\n acceptTypes: ['dimension'],\n emptyText: 'Drop dimensions here to split data into series'\n }\n ],\n displayOptions: ['showLegend', 'showGrid', 'showTooltip', 'hideHeader'],\n displayOptionsConfig: [\n {\n key: 'stackType',\n label: 'Stacking',\n type: 'select',\n defaultValue: 'none',\n options: [\n { value: 'none', label: 'None' },\n { value: 'normal', label: 'Stacked' },\n { value: 'percent', label: 'Stacked 100%' }\n ],\n description: 'How to stack multiple bar series'\n },\n {\n key: 'target',\n label: 'Target Values',\n type: 'string',\n placeholder: 'e.g., 100 or 50,75 for spread',\n description: 'Single value or comma-separated values to spread across X-axis'\n },\n {\n key: 'leftYAxisFormat',\n label: 'Left Y-Axis Format',\n type: 'axisFormat',\n description: 'Number formatting for left Y-axis'\n },\n {\n key: 'rightYAxisFormat',\n label: 'Right Y-Axis Format',\n type: 'axisFormat',\n description: 'Number formatting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;AAAA,IAAA;AAAA,EACf;AAEJ;"}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { jsx as y, jsxs as ee } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as ce, useState as C, useEffect as te, useLayoutEffect as be } from "react";
|
|
3
|
+
import { u as Ae, g as Fe, w as we, s as D, b as Se, c as de, i as ve, p as ue, C as me, l as xe, e as ye, d as ze, m as Te, q as $e, h as fe, o as pe, a as se, j as he, k as ge, f as T } from "./chart-activitygridchart-CUGN9Xq9.js";
|
|
4
|
+
function Re({
|
|
5
|
+
data: $,
|
|
6
|
+
chartConfig: r,
|
|
7
|
+
displayConfig: p = {},
|
|
8
|
+
queryObject: H,
|
|
9
|
+
height: q = "100%",
|
|
10
|
+
colorPalette: L
|
|
11
|
+
}) {
|
|
12
|
+
const U = ce(null), A = ce(null), [, re] = C(null), [N, E] = C({ width: 0, height: 0 }), [k, W] = C(!1), [le, ie] = C("light"), { getFieldLabel: F } = Ae();
|
|
13
|
+
te(() => (ie(Fe()), we((o) => {
|
|
14
|
+
ie(o);
|
|
15
|
+
})), []);
|
|
16
|
+
const s = {
|
|
17
|
+
showLegend: p?.showLegend ?? !0,
|
|
18
|
+
showGrid: p?.showGrid ?? !0,
|
|
19
|
+
showTooltip: p?.showTooltip ?? !0,
|
|
20
|
+
minBubbleSize: p?.minBubbleSize ?? 5,
|
|
21
|
+
maxBubbleSize: p?.maxBubbleSize ?? 50,
|
|
22
|
+
bubbleOpacity: p?.bubbleOpacity ?? 0.7,
|
|
23
|
+
xAxisFormat: p?.xAxisFormat,
|
|
24
|
+
leftYAxisFormat: p?.leftYAxisFormat
|
|
25
|
+
};
|
|
26
|
+
return be(() => {
|
|
27
|
+
let i = 0;
|
|
28
|
+
const o = 10;
|
|
29
|
+
let d, u;
|
|
30
|
+
const a = () => {
|
|
31
|
+
if (A.current) {
|
|
32
|
+
const { width: h, height: n } = A.current.getBoundingClientRect();
|
|
33
|
+
if (h > 0 && n > 0)
|
|
34
|
+
return E({ width: h, height: n }), W(!0), !0;
|
|
35
|
+
}
|
|
36
|
+
return !1;
|
|
37
|
+
};
|
|
38
|
+
if (!a() && i < o) {
|
|
39
|
+
const h = () => {
|
|
40
|
+
!a() && i < o && (i++, u = setTimeout(() => {
|
|
41
|
+
d = requestAnimationFrame(h);
|
|
42
|
+
}, 50 * i));
|
|
43
|
+
};
|
|
44
|
+
d = requestAnimationFrame(h);
|
|
45
|
+
}
|
|
46
|
+
return () => {
|
|
47
|
+
d && cancelAnimationFrame(d), u && clearTimeout(u);
|
|
48
|
+
};
|
|
49
|
+
}, []), te(() => {
|
|
50
|
+
let i = null;
|
|
51
|
+
const o = () => {
|
|
52
|
+
if (A.current) {
|
|
53
|
+
const { width: d, height: u } = A.current.getBoundingClientRect();
|
|
54
|
+
d > 0 && u > 0 && (E({ width: d, height: u }), k || W(!0));
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
return A.current && (i = new ResizeObserver((d) => {
|
|
58
|
+
for (const u of d) {
|
|
59
|
+
const { width: a, height: w } = u.contentRect;
|
|
60
|
+
a > 0 && w > 0 && (E({ width: a, height: w }), k || W(!0));
|
|
61
|
+
}
|
|
62
|
+
}), i.observe(A.current), o()), window.addEventListener("resize", o), () => {
|
|
63
|
+
i && i.disconnect(), window.removeEventListener("resize", o);
|
|
64
|
+
};
|
|
65
|
+
}, [k]), te(() => {
|
|
66
|
+
if (!$ || $.length === 0 || !U.current || !k || N.width === 0 || (D(U.current).selectAll("*").remove(), !r?.xAxis || !r?.yAxis || !r?.series))
|
|
67
|
+
return;
|
|
68
|
+
const i = Array.isArray(r.xAxis) ? r.xAxis[0] : r.xAxis, o = Array.isArray(r.yAxis) ? r.yAxis[0] : r.yAxis, d = Array.isArray(r.series) ? r.series[0] : r.series, u = Array.isArray(r.sizeField) ? r.sizeField[0] : r.sizeField || o, a = Array.isArray(r.colorField) ? r.colorField[0] : r.colorField;
|
|
69
|
+
if (!i || !o || !d || !u)
|
|
70
|
+
return;
|
|
71
|
+
const w = Se(H, i), h = H?.timeDimensions?.some(
|
|
72
|
+
(e) => e.dimension === i
|
|
73
|
+
) || !1, n = $.map((e) => {
|
|
74
|
+
const t = e[i];
|
|
75
|
+
let l, m;
|
|
76
|
+
if (h && t) {
|
|
77
|
+
const c = String(t);
|
|
78
|
+
let f;
|
|
79
|
+
if (c.match(/^\d{4}-\d{2}-\d{2}[T ]/)) {
|
|
80
|
+
let b = c;
|
|
81
|
+
c.includes(" ") && (b = c.replace(" ", "T").replace("+00", "Z").replace(/\+\d{2}:\d{2}$/, "Z")), !b.endsWith("Z") && !b.includes("+") && (b = b + "Z"), f = new Date(b);
|
|
82
|
+
} else
|
|
83
|
+
f = new Date(c);
|
|
84
|
+
l = isNaN(f.getTime()) ? parseFloat(c) : f.getTime(), m = de(t, w);
|
|
85
|
+
} else {
|
|
86
|
+
const c = de(t, w) || t;
|
|
87
|
+
l = typeof c == "string" ? parseFloat(c) : c, m = String(c);
|
|
88
|
+
}
|
|
89
|
+
const x = ue(e[o]), z = ue(e[u]), R = e[d];
|
|
90
|
+
return {
|
|
91
|
+
x: l,
|
|
92
|
+
xLabel: m,
|
|
93
|
+
// Store formatted label for tooltip display
|
|
94
|
+
y: x,
|
|
95
|
+
// Type assertion: filter below ensures this is never null
|
|
96
|
+
size: z !== null ? Math.abs(z) : 0,
|
|
97
|
+
// Ensure positive size
|
|
98
|
+
color: a ? e[a] : R,
|
|
99
|
+
series: R,
|
|
100
|
+
label: `${R || "Unknown"}`,
|
|
101
|
+
isValid: ve(l) && x !== null && z !== null && z > 0
|
|
102
|
+
};
|
|
103
|
+
}).filter((e) => e.isValid && e.size > 0);
|
|
104
|
+
if (n.length === 0) return;
|
|
105
|
+
const V = {
|
|
106
|
+
...me,
|
|
107
|
+
left: me.left + 30,
|
|
108
|
+
// Add extra 30px left margin for Y-axis label
|
|
109
|
+
bottom: s.showLegend && a ? 100 : 40
|
|
110
|
+
// Add extra space for legend
|
|
111
|
+
}, B = N.width - V.left - V.right, S = N.height - V.top - V.bottom, ae = D(U.current).attr("width", N.width).attr("height", N.height), v = ae.append("g").attr("transform", `translate(${V.left},${V.top})`), _ = xe().domain(ye(n, (e) => e.x)).range([0, B]).nice(), I = xe().domain(ye(n, (e) => e.y)).range([S, 0]).nice(), j = ze().domain([0, Te(n, (e) => e.size)]).range([s.minBubbleSize, s.maxBubbleSize]);
|
|
112
|
+
let Y, G = !1, Z = [];
|
|
113
|
+
if (a && n.length > 0) {
|
|
114
|
+
const e = n.map((t) => {
|
|
115
|
+
const l = t.color;
|
|
116
|
+
return typeof l == "string" ? parseFloat(l) : l;
|
|
117
|
+
}).filter((t) => !isNaN(t));
|
|
118
|
+
if (G = e.length === n.length && e.every((t) => typeof t == "number"), G) {
|
|
119
|
+
const t = Math.min(...e), l = Math.max(...e);
|
|
120
|
+
Y = $e().domain([t, l]).range(L?.gradient || fe);
|
|
121
|
+
} else
|
|
122
|
+
Z = [...new Set(n.map((t) => String(t.color)))], Y = pe().domain(Z).range(L?.colors || se);
|
|
123
|
+
} else
|
|
124
|
+
Y = pe().domain(["default"]).range([se[0]]);
|
|
125
|
+
const X = (e, t) => getComputedStyle(document.documentElement).getPropertyValue(e).trim() || t, ne = le !== "light", g = ne ? X("--dc-text-muted", "#cbd5e1") : X("--dc-text-secondary", "#374151"), M = ne ? X("--dc-border", "#475569") : "#9ca3af";
|
|
126
|
+
if (s.showGrid) {
|
|
127
|
+
const e = v.append("g").attr("class", "grid").attr("transform", `translate(0,${S})`).call(
|
|
128
|
+
he(_).tickSize(-S).tickFormat(() => "")
|
|
129
|
+
);
|
|
130
|
+
e.selectAll("line").style("stroke", M).style("stroke-dasharray", "3,3").style("opacity", 0.3), e.select(".domain").style("stroke", "none");
|
|
131
|
+
const t = v.append("g").attr("class", "grid").call(
|
|
132
|
+
ge(I).tickSize(-B).tickFormat(() => "")
|
|
133
|
+
);
|
|
134
|
+
t.selectAll("line").style("stroke", M).style("stroke-dasharray", "3,3").style("opacity", 0.3), t.select(".domain").style("stroke", "none");
|
|
135
|
+
}
|
|
136
|
+
const Q = he(_);
|
|
137
|
+
h ? Q.tickFormat((e) => {
|
|
138
|
+
const t = new Date(e);
|
|
139
|
+
if (isNaN(t.getTime())) return String(e);
|
|
140
|
+
switch (w?.toLowerCase()) {
|
|
141
|
+
case "year":
|
|
142
|
+
return String(t.getUTCFullYear());
|
|
143
|
+
case "quarter": {
|
|
144
|
+
const l = Math.floor(t.getUTCMonth() / 3) + 1;
|
|
145
|
+
return `${t.getUTCFullYear()}-Q${l}`;
|
|
146
|
+
}
|
|
147
|
+
case "month":
|
|
148
|
+
return `${t.getUTCFullYear()}-${String(t.getUTCMonth() + 1).padStart(2, "0")}`;
|
|
149
|
+
case "week":
|
|
150
|
+
case "day":
|
|
151
|
+
return `${t.getUTCFullYear()}-${String(t.getUTCMonth() + 1).padStart(2, "0")}-${String(t.getUTCDate()).padStart(2, "0")}`;
|
|
152
|
+
case "hour":
|
|
153
|
+
return `${String(t.getUTCMonth() + 1).padStart(2, "0")}-${String(t.getUTCDate()).padStart(2, "0")} ${String(t.getUTCHours()).padStart(2, "0")}:00`;
|
|
154
|
+
default:
|
|
155
|
+
return `${t.getUTCFullYear()}-${String(t.getUTCMonth() + 1).padStart(2, "0")}`;
|
|
156
|
+
}
|
|
157
|
+
}) : s.xAxisFormat && Q.tickFormat((e) => T(e, s.xAxisFormat));
|
|
158
|
+
const J = v.append("g").attr("transform", `translate(0,${S})`).call(Q);
|
|
159
|
+
J.selectAll("text").style("fill", g), J.selectAll("line, path").style("stroke", M), J.append("text").attr("x", B / 2).attr("y", 35).attr("fill", g).style("text-anchor", "middle").style("font-size", "12px").text(s.xAxisFormat?.label || F(i));
|
|
160
|
+
const oe = ge(I);
|
|
161
|
+
s.leftYAxisFormat && oe.tickFormat((e) => T(e, s.leftYAxisFormat));
|
|
162
|
+
const K = v.append("g").call(oe);
|
|
163
|
+
K.selectAll("text").style("fill", g), K.selectAll("line, path").style("stroke", M), K.append("text").attr("transform", "rotate(-90)").attr("y", -35).attr("x", -S / 2).attr("fill", g).style("text-anchor", "middle").style("font-size", "12px").text(s.leftYAxisFormat?.label || F(o));
|
|
164
|
+
const O = D("body").append("div").attr("class", "bubble-chart-tooltip").style("position", "absolute").style("padding", "8px").style("background", "rgba(0, 0, 0, 0.8)").style("color", "white").style("border-radius", "4px").style("font-size", "12px").style("pointer-events", "none").style("opacity", 0).style("z-index", 1e3), P = v.selectAll(".bubble").data(n).enter().append("circle").attr("class", "bubble").attr("cx", (e) => _(e.x)).attr("cy", (e) => I(e.y)).attr("r", (e) => j(e.size)).style("fill", (e) => a && e.color !== void 0 ? Y(G ? e.color : String(e.color)) : se[0]).style("opacity", s.bubbleOpacity).style("stroke", "#fff").style("stroke-width", 1).style("cursor", "pointer");
|
|
165
|
+
if (s.showTooltip && P.on("mouseover", function(e, t) {
|
|
166
|
+
D(this).transition().duration(200).style("opacity", 1).attr("r", j(t.size) * 1.1);
|
|
167
|
+
const l = [
|
|
168
|
+
`<strong>${t.series || "Unknown"}</strong>`,
|
|
169
|
+
`${F(i)}: ${t.xLabel || (s.xAxisFormat ? T(t.x, s.xAxisFormat) : t.x)}`,
|
|
170
|
+
`${F(o)}: ${s.leftYAxisFormat ? T(t.y, s.leftYAxisFormat) : t.y}`,
|
|
171
|
+
`${F(u)}: ${s.leftYAxisFormat ? T(t.size, s.leftYAxisFormat) : t.size}`,
|
|
172
|
+
a && t.color ? `${F(a)}: ${t.color}` : ""
|
|
173
|
+
].filter(Boolean).join("<br>");
|
|
174
|
+
O.html(l).style("left", e.pageX + 10 + "px").style("top", e.pageY - 10 + "px").transition().duration(200).style("opacity", 1), re(t.label);
|
|
175
|
+
}).on("mousemove", function(e) {
|
|
176
|
+
O.style("left", e.pageX + 10 + "px").style("top", e.pageY - 10 + "px");
|
|
177
|
+
}).on("mouseout", function(e, t) {
|
|
178
|
+
D(this).transition().duration(200).style("opacity", s.bubbleOpacity).attr("r", j(t.size)), O.transition().duration(200).style("opacity", 0), re(null);
|
|
179
|
+
}), s.showLegend && a)
|
|
180
|
+
if (G) {
|
|
181
|
+
const l = Math.min(...n.map((f) => f.color)), m = Math.max(...n.map((f) => f.color)), x = v.append("g").attr("class", "color-legend").attr("transform", `translate(${B / 2 - 200 / 2}, ${S + 60})`), R = ae.append("defs").append("linearGradient").attr("id", "color-scale-gradient").attr("x1", "0%").attr("y1", "0%").attr("x2", "100%").attr("y2", "0%"), c = L?.gradient || fe;
|
|
182
|
+
c.forEach((f, b) => {
|
|
183
|
+
R.append("stop").attr("offset", `${b / (c.length - 1) * 100}%`).attr("stop-color", f);
|
|
184
|
+
}), x.append("rect").attr("width", 200).attr("height", 20).style("fill", "url(#color-scale-gradient)").style("stroke", "#ccc").style("stroke-width", 1), x.append("text").attr("x", 0).attr("y", 35).attr("text-anchor", "start").style("font-size", "11px").style("fill", g).text(s.leftYAxisFormat ? T(l, s.leftYAxisFormat) : l.toFixed(2)), x.append("text").attr("x", 200).attr("y", 35).attr("text-anchor", "end").style("font-size", "11px").style("fill", g).text(s.leftYAxisFormat ? T(m, s.leftYAxisFormat) : m.toFixed(2)), x.append("text").attr("x", 200 / 2).attr("y", -5).attr("text-anchor", "middle").style("font-size", "12px").style("font-weight", "bold").style("fill", g).text(F(a));
|
|
185
|
+
} else {
|
|
186
|
+
const e = Z;
|
|
187
|
+
if (e.length > 0) {
|
|
188
|
+
const l = v.append("g").attr("class", "legend").attr("transform", `translate(${B / 2 - e.length * 80 / 2}, ${S + 60})`).selectAll(".legend-item").data(e).enter().append("g").attr("class", "legend-item").attr("transform", (m, x) => `translate(${x * 80}, 0)`).style("cursor", "pointer");
|
|
189
|
+
l.append("circle").attr("cx", 5).attr("cy", 5).attr("r", 5).style("fill", (m) => Y(m)).style("opacity", s.bubbleOpacity), l.append("text").attr("x", 15).attr("y", 5).attr("dy", ".35em").style("font-size", "11px").style("fill", g).text((m) => String(m)), l.on("mouseover", function(m, x) {
|
|
190
|
+
P.transition().duration(200).style("opacity", (z) => a && String(z.color) === x ? 1 : 0.2);
|
|
191
|
+
}).on("mouseout", function() {
|
|
192
|
+
P.transition().duration(200).style("opacity", s.bubbleOpacity);
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return () => {
|
|
197
|
+
O.remove();
|
|
198
|
+
};
|
|
199
|
+
}, [$, r, p, H, N, k, s.showLegend, s.showGrid, s.showTooltip, s.minBubbleSize, s.maxBubbleSize, s.bubbleOpacity, L, le]), !$ || $.length === 0 ? /* @__PURE__ */ y("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: q }, children: /* @__PURE__ */ ee("div", { className: "text-center", children: [
|
|
200
|
+
/* @__PURE__ */ y("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
|
|
201
|
+
/* @__PURE__ */ y("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display in bubble chart" })
|
|
202
|
+
] }) }) : r?.xAxis && r?.yAxis && r?.series ? /* @__PURE__ */ y("div", { className: "w-full flex-1 flex flex-col relative", style: { height: q, minHeight: "250px", overflow: "hidden" }, children: /* @__PURE__ */ ee("div", { ref: A, className: "w-full h-full relative", children: [
|
|
203
|
+
/* @__PURE__ */ y("svg", { ref: U, className: "w-full h-full" }),
|
|
204
|
+
!k && /* @__PURE__ */ y("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ y("div", { className: "text-dc-text-muted text-sm", children: "Measuring chart dimensions..." }) })
|
|
205
|
+
] }) }) : /* @__PURE__ */ y("div", { className: "flex items-center justify-center w-full text-dc-warning", style: { height: q }, children: /* @__PURE__ */ ee("div", { className: "text-center", children: [
|
|
206
|
+
/* @__PURE__ */ y("div", { className: "text-sm font-semibold mb-1", children: "Configuration Required" }),
|
|
207
|
+
/* @__PURE__ */ y("div", { className: "text-xs", children: "Bubble chart requires xAxis, yAxis, series, and sizeField dimensions" }),
|
|
208
|
+
/* @__PURE__ */ y("div", { className: "text-xs mt-1", children: "Optional: colorField for bubble coloring" })
|
|
209
|
+
] }) });
|
|
210
|
+
}
|
|
211
|
+
export {
|
|
212
|
+
Re as default
|
|
213
|
+
};
|
|
214
|
+
//# sourceMappingURL=chart-bubblechart-BsaIXUbS.js.map
|