@burdenoff/microfe-bigconsole 2026.1103.4 → 2026.1103.5
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/bigconsole/components/widgets/chart/charts/FunnelChart.d.ts +1 -1
- package/dist/bigconsole/components/widgets/chart/charts/FunnelChart.js +69 -54
- package/dist/bigconsole/components/widgets/chart/charts/funnelData.d.ts +8 -0
- package/dist/bigconsole/components/widgets/chart/charts/funnelData.js +17 -0
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
import { ChartConfig, ChartData } from './types';
|
|
3
3
|
export interface FunnelChartProps {
|
|
4
|
-
/** Chart data
|
|
4
|
+
/** Chart data in funnel stage order */
|
|
5
5
|
data: ChartData[];
|
|
6
6
|
/** Chart configuration */
|
|
7
7
|
config: ChartConfig;
|
|
@@ -1,68 +1,83 @@
|
|
|
1
1
|
import { ChartTooltip as e } from "../ChartTooltip.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { funnelStages as t } from "./funnelData.js";
|
|
3
|
+
import { memo as n } from "react";
|
|
4
|
+
import { useI18n as r } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
5
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
6
|
+
import { Cell as o, Funnel as s, FunnelChart as c, LabelList as l, ResponsiveContainer as u, Tooltip as d } from "recharts";
|
|
5
7
|
//#region src/bigconsole/components/widgets/chart/charts/FunnelChart.tsx
|
|
6
|
-
var
|
|
8
|
+
var f = [
|
|
7
9
|
"var(--color-chart-1)",
|
|
8
10
|
"var(--color-chart-2)",
|
|
9
11
|
"var(--color-chart-3)",
|
|
10
12
|
"var(--color-chart-4)",
|
|
11
13
|
"var(--color-chart-5)"
|
|
12
|
-
],
|
|
13
|
-
let h = (e) => typeof e == "number" ? new Intl.NumberFormat("en-US", {
|
|
14
|
+
], p = n(function({ data: n = [], config: p, dataKey: m = "value", nameKey: h = "name", onDataClick: g }) {
|
|
15
|
+
let { t: _, locale: v } = r(), y = t(n, m, h), b = (e) => typeof e == "number" ? new Intl.NumberFormat("en-US", {
|
|
14
16
|
notation: e >= 1e4 ? "compact" : "standard",
|
|
15
17
|
maximumFractionDigits: 2
|
|
16
18
|
}).format(e) : String(e);
|
|
17
|
-
if (!
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return {
|
|
25
|
-
...e,
|
|
26
|
-
rate: a
|
|
27
|
-
};
|
|
19
|
+
if (!y || !y.length || y.every((e) => e.value === 0)) return /* @__PURE__ */ i("div", {
|
|
20
|
+
role: "status",
|
|
21
|
+
className: "flex items-center justify-center h-full text-text-secondary text-sm p-4",
|
|
22
|
+
children: y ? _("bigconsole.widgets.funnel.noCounts", "No funnel counts to display. Connect data with at least one count greater than zero.") : _("bigconsole.widgets.funnel.invalidFields", "Each funnel row needs a label in \"{{labelField}}\" and a non-negative number in \"{{valueField}}\". Choose the label and value fields in Style.", {
|
|
23
|
+
labelField: h,
|
|
24
|
+
valueField: m
|
|
25
|
+
})
|
|
28
26
|
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
children:
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
27
|
+
let x = new Intl.NumberFormat(v, {
|
|
28
|
+
style: "percent",
|
|
29
|
+
maximumFractionDigits: 1
|
|
30
|
+
}), S = y.map((e) => ({
|
|
31
|
+
...e.row,
|
|
32
|
+
__conversionLabel: `${e.label} (${e.conversion === void 0 ? "—" : x.format(e.conversion)})`
|
|
33
|
+
}));
|
|
34
|
+
return /* @__PURE__ */ a("div", {
|
|
35
|
+
className: "flex flex-col h-full",
|
|
36
|
+
children: [/* @__PURE__ */ i("p", {
|
|
37
|
+
className: "text-xs text-text-secondary mb-2",
|
|
38
|
+
children: _("bigconsole.widgets.funnel.conversionBasis", "Conversion from previous stage; first stage is the baseline.")
|
|
39
|
+
}), /* @__PURE__ */ i("div", {
|
|
40
|
+
className: "flex-1 min-h-0",
|
|
41
|
+
children: /* @__PURE__ */ i(u, {
|
|
42
|
+
width: "100%",
|
|
43
|
+
height: "100%",
|
|
44
|
+
children: /* @__PURE__ */ a(c, { children: [/* @__PURE__ */ i(d, { content: /* @__PURE__ */ i(e, {
|
|
45
|
+
valueFormatter: b,
|
|
46
|
+
labelFormatter: (e) => String(e)
|
|
47
|
+
}) }), /* @__PURE__ */ a(s, {
|
|
48
|
+
dataKey: m,
|
|
49
|
+
nameKey: h,
|
|
50
|
+
data: S,
|
|
51
|
+
isAnimationActive: !0,
|
|
52
|
+
onClick: (e, t) => {
|
|
53
|
+
t !== void 0 && n[t] && g?.(n[t], t);
|
|
54
|
+
},
|
|
55
|
+
children: [
|
|
56
|
+
/* @__PURE__ */ i(l, {
|
|
57
|
+
position: "right",
|
|
58
|
+
fill: "var(--color-text-primary)",
|
|
59
|
+
stroke: "none",
|
|
60
|
+
dataKey: "__conversionLabel",
|
|
61
|
+
fontSize: 12
|
|
62
|
+
}),
|
|
63
|
+
/* @__PURE__ */ i(l, {
|
|
64
|
+
position: "center",
|
|
65
|
+
fill: "var(--color-text-on-primary, #ffffff)",
|
|
66
|
+
stroke: "none",
|
|
67
|
+
dataKey: m,
|
|
68
|
+
formatter: (e) => b(e),
|
|
69
|
+
fontSize: 14,
|
|
70
|
+
fontWeight: 600
|
|
71
|
+
}),
|
|
72
|
+
S.map((e, t) => /* @__PURE__ */ i(o, {
|
|
73
|
+
fill: p.colors?.[t] || f[t % f.length],
|
|
74
|
+
style: { cursor: g ? "pointer" : "default" }
|
|
75
|
+
}, `cell-${t}`))
|
|
76
|
+
]
|
|
77
|
+
})] })
|
|
78
|
+
})
|
|
79
|
+
})]
|
|
65
80
|
});
|
|
66
81
|
});
|
|
67
82
|
//#endregion
|
|
68
|
-
export {
|
|
83
|
+
export { p as FunnelChart, p as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ChartData } from './types';
|
|
2
|
+
/** Keep the caller's stage order; conversions compare adjacent stages. */
|
|
3
|
+
export declare function funnelStages(data: ChartData[], valueField: string, labelField: string): {
|
|
4
|
+
row: ChartData;
|
|
5
|
+
value: number;
|
|
6
|
+
label: string;
|
|
7
|
+
conversion: number | undefined;
|
|
8
|
+
}[] | null;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/bigconsole/components/widgets/chart/charts/funnelData.ts
|
|
2
|
+
function e(e, t, n) {
|
|
3
|
+
return !Array.isArray(e) || e.some((e) => {
|
|
4
|
+
let r = e?.[t], i = e?.[n];
|
|
5
|
+
return typeof r != "number" || !Number.isFinite(r) || r < 0 || !["string", "number"].includes(typeof i) || String(i).trim() === "";
|
|
6
|
+
}) ? null : e.map((r, i) => {
|
|
7
|
+
let a = r[t], o = e[Math.max(0, i - 1)][t];
|
|
8
|
+
return {
|
|
9
|
+
row: r,
|
|
10
|
+
value: a,
|
|
11
|
+
label: String(r[n]),
|
|
12
|
+
conversion: o > 0 ? a / o : void 0
|
|
13
|
+
};
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { e as funnelStages };
|