@embeddable.com/remarkable-ui 1.0.1 → 1.0.3
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/BarChartDefaultHorizontalPro.js +1 -1
- package/dist/BarChartDefaultPro.js +1 -1
- package/dist/BarChartGroupedHorizontalPro.js +1 -1
- package/dist/BarChartGroupedPro.js +1 -1
- package/dist/BarChartStackedHorizontalPro.js +1 -1
- package/dist/BarChartStackedPro.js +1 -1
- package/dist/DonutChartPro.js +1 -1
- package/dist/DonutLabelChartPro.js +1 -1
- package/dist/LineChartGroupedPro.js +55 -55
- package/dist/LineChartGroupedPro.js.map +1 -1
- package/dist/PieChartPro.js +1 -1
- package/dist/bars.utils-CfUdtqtZ.js +146 -0
- package/dist/bars.utils-CfUdtqtZ.js.map +1 -0
- package/dist/{charts.utils-eHB_o46Z.js → charts.utils-DnzWuMfl.js} +817 -815
- package/dist/charts.utils-DnzWuMfl.js.map +1 -0
- package/dist/embeddable-components.json +10 -10
- package/dist/embeddable-theme-2b917.js +817 -815
- package/dist/{index-CGRZXASn.js → index-DDmT6wnq.js} +12 -9
- package/dist/index-DDmT6wnq.js.map +1 -0
- package/dist/{index-CwCkuHzT.js → index-GHJlcYHx.js} +15 -12
- package/dist/index-GHJlcYHx.js.map +1 -0
- package/dist/{index-DfsOzpdV.js → index-cQhXpSWY.js} +28 -25
- package/dist/index-cQhXpSWY.js.map +1 -0
- package/dist/index.js +37 -34
- package/dist/index.js.map +1 -1
- package/dist/{pies.utils-BvSC2qnJ.js → pies.utils-C3VeiEKh.js} +6 -6
- package/dist/pies.utils-C3VeiEKh.js.map +1 -0
- package/dist/remarkable-pro/components/charts/pies/DonutChartPro/index.d.ts.map +1 -1
- package/dist/remarkable-pro/components/charts/pies/DonutLabelChartPro/index.d.ts.map +1 -1
- package/dist/remarkable-pro/components/charts/pies/PieChartPro/index.d.ts.map +1 -1
- package/dist/remarkable-pro/components/charts/pies/pies.utils.d.ts +2 -2
- package/dist/remarkable-pro/components/charts/pies/pies.utils.d.ts.map +1 -1
- package/dist/remarkable-pro/index.d.ts +1 -0
- package/dist/remarkable-pro/index.d.ts.map +1 -1
- package/dist/remarkable-ui/styles/styles.tokensCore.constants.d.ts +3 -3
- package/dist/remarkable-ui/styles/styles.tokensCore.constants.d.ts.map +1 -1
- package/dist/remarkable-ui.css +3 -3
- package/package.json +1 -1
- package/dist/bars.utils-wy9RMO2F.js +0 -146
- package/dist/bars.utils-wy9RMO2F.js.map +0 -1
- package/dist/charts.utils-eHB_o46Z.js.map +0 -1
- package/dist/index-CGRZXASn.js.map +0 -1
- package/dist/index-CwCkuHzT.js.map +0 -1
- package/dist/index-DfsOzpdV.js.map +0 -1
- package/dist/pies.utils-BvSC2qnJ.js.map +0 -1
|
@@ -2,7 +2,7 @@ import { i as L, r as w, m as M, j as l, B as V, d as y, a as z, b as P, t as k,
|
|
|
2
2
|
import { useTheme as _, defineComponent as q } from "@embeddable.com/react";
|
|
3
3
|
import { C as J } from "./ChartCard-CyemTSay.js";
|
|
4
4
|
import "react";
|
|
5
|
-
import { g as K, a as N } from "./bars.utils-
|
|
5
|
+
import { g as K, a as N } from "./bars.utils-CfUdtqtZ.js";
|
|
6
6
|
import { u as Q } from "./charts.fillGaps.hooks-5WclK2CD.js";
|
|
7
7
|
const U = (a) => {
|
|
8
8
|
var i, n;
|
|
@@ -2,7 +2,7 @@ import { i as L, r as y, m as w, j as l, B as M, d as V, a as P, b as v, t as k,
|
|
|
2
2
|
import { useTheme as _, defineComponent as H } from "@embeddable.com/react";
|
|
3
3
|
import { C as J } from "./ChartCard-CyemTSay.js";
|
|
4
4
|
import "react";
|
|
5
|
-
import { g as K, a as N } from "./bars.utils-
|
|
5
|
+
import { g as K, a as N } from "./bars.utils-CfUdtqtZ.js";
|
|
6
6
|
import { u as Q } from "./charts.fillGaps.hooks-5WclK2CD.js";
|
|
7
7
|
const U = (a) => {
|
|
8
8
|
var o, n;
|
|
@@ -2,7 +2,7 @@ import { i as L, r as w, m as k, j as m, B as z, d as G, w as P, b as R, z as M,
|
|
|
2
2
|
import { useTheme as J, defineComponent as K } from "@embeddable.com/react";
|
|
3
3
|
import { C as N } from "./ChartCard-CyemTSay.js";
|
|
4
4
|
import "react";
|
|
5
|
-
import { b as Q, a as U } from "./bars.utils-
|
|
5
|
+
import { b as Q, a as U } from "./bars.utils-CfUdtqtZ.js";
|
|
6
6
|
import { u as X } from "./charts.fillGaps.hooks-5WclK2CD.js";
|
|
7
7
|
const Z = (e) => {
|
|
8
8
|
var n, l;
|
|
@@ -2,7 +2,7 @@ import { i as L, r as w, m as G, j as m, B as k, d as P, w as R, b as M, z as j,
|
|
|
2
2
|
import { useTheme as J, defineComponent as K } from "@embeddable.com/react";
|
|
3
3
|
import { C as N } from "./ChartCard-CyemTSay.js";
|
|
4
4
|
import "react";
|
|
5
|
-
import { b as Q, a as U } from "./bars.utils-
|
|
5
|
+
import { b as Q, a as U } from "./bars.utils-CfUdtqtZ.js";
|
|
6
6
|
import { u as Y } from "./charts.fillGaps.hooks-5WclK2CD.js";
|
|
7
7
|
const Z = (e) => {
|
|
8
8
|
var n, l;
|
|
@@ -2,7 +2,7 @@ import { i as L, r as f, m as w, j as m, B as S, d as z, w as P, b as R, z as M,
|
|
|
2
2
|
import { useTheme as K, defineComponent as N } from "@embeddable.com/react";
|
|
3
3
|
import { C as Q } from "./ChartCard-CyemTSay.js";
|
|
4
4
|
import "react";
|
|
5
|
-
import { b as U, a as X } from "./bars.utils-
|
|
5
|
+
import { b as U, a as X } from "./bars.utils-CfUdtqtZ.js";
|
|
6
6
|
import { u as Z } from "./charts.fillGaps.hooks-5WclK2CD.js";
|
|
7
7
|
const $ = (a) => {
|
|
8
8
|
var n, l;
|
|
@@ -2,7 +2,7 @@ import { i as D, r as L, m as w, j as m, B as S, d as P, w as R, b as M, z as T,
|
|
|
2
2
|
import { useTheme as K, defineComponent as N } from "@embeddable.com/react";
|
|
3
3
|
import { C as Q } from "./ChartCard-CyemTSay.js";
|
|
4
4
|
import "react";
|
|
5
|
-
import { b as U, a as Y } from "./bars.utils-
|
|
5
|
+
import { b as U, a as Y } from "./bars.utils-CfUdtqtZ.js";
|
|
6
6
|
import { u as Z } from "./charts.fillGaps.hooks-5WclK2CD.js";
|
|
7
7
|
const $ = (e) => {
|
|
8
8
|
var n, l;
|
package/dist/DonutChartPro.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { d as a, w as s, z as t, t as o, c as n, s as r, Q as i, e as m, f as l, V as d, o as u } from "./component.constants-CYS5-3qd.js";
|
|
2
2
|
import { defineComponent as c } from "@embeddable.com/react";
|
|
3
|
-
import { D as p } from "./index-
|
|
3
|
+
import { D as p } from "./index-GHJlcYHx.js";
|
|
4
4
|
const C = {
|
|
5
5
|
name: "DonutChartPro",
|
|
6
6
|
label: "Donut Chart",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as n } from "./index-
|
|
1
|
+
import { D as n } from "./index-cQhXpSWY.js";
|
|
2
2
|
import { d as s, w as a, z as r, t as o, c as l, s as i, Q as m, e as d, f as u, V as b, o as t } from "./component.constants-CYS5-3qd.js";
|
|
3
3
|
import { defineComponent as c } from "@embeddable.com/react";
|
|
4
4
|
const p = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useTheme as R, defineComponent as P } from "@embeddable.com/react";
|
|
2
|
-
import { E as k, m as $, i as F, r as v, j as w, N as
|
|
2
|
+
import { E as k, m as $, i as F, r as v, j as w, N as S, d as j, w as y, I as V, b as B, z as O, t as T, c as X, A as E, s as K, e as N, f as U, g as Y, x as q, y as z, p as W, q as _, u as H, V as D, o as J } from "./component.constants-CYS5-3qd.js";
|
|
3
3
|
import { C as Q } from "./ChartCard-CyemTSay.js";
|
|
4
4
|
import { g as M } from "./formatter.utils-CaFr8SlX.js";
|
|
5
5
|
import { g as Z, a as G } from "./object.utils-D_Zzon-H.js";
|
|
@@ -7,62 +7,62 @@ import { s as I } from "./color.utils-CVyp-fGP.js";
|
|
|
7
7
|
import "react";
|
|
8
8
|
import { g as ee } from "./lines.utils-CFEUUo4k.js";
|
|
9
9
|
import { u as ae } from "./charts.fillGaps.hooks-5WclK2CD.js";
|
|
10
|
-
const se = (e,
|
|
11
|
-
const c = M(
|
|
10
|
+
const se = (e, t) => {
|
|
11
|
+
const c = M(t), { data: o = [], dimension: l, groupDimension: r, measure: n, hasMinMaxYAxisRange: m } = e, u = [...new Set(o.map((a) => a[l.name]).filter((a) => a != null))].sort(), d = [...new Set(o.map((a) => a[r.name]))].filter((a) => a != null), s = Z(t), i = d.map((a, x) => {
|
|
12
12
|
var p;
|
|
13
13
|
const b = G(
|
|
14
|
-
`${
|
|
15
|
-
`${r.name}.${
|
|
16
|
-
|
|
14
|
+
`${s}.charts.backgroundColors`,
|
|
15
|
+
`${r.name}.${a}`,
|
|
16
|
+
t.charts.backgroundColors ?? k,
|
|
17
17
|
x
|
|
18
18
|
), h = G(
|
|
19
|
-
`${
|
|
20
|
-
`${r.name}.${
|
|
21
|
-
|
|
19
|
+
`${s}.charts.borderColors`,
|
|
20
|
+
`${r.name}.${a}`,
|
|
21
|
+
t.charts.borderColors ?? k,
|
|
22
22
|
x
|
|
23
23
|
);
|
|
24
24
|
return {
|
|
25
|
-
clip:
|
|
26
|
-
label: c.data(r,
|
|
27
|
-
rawLabel:
|
|
25
|
+
clip: m,
|
|
26
|
+
label: c.data(r, a),
|
|
27
|
+
rawLabel: a,
|
|
28
28
|
backgroundColor: I(b, 0.5),
|
|
29
29
|
pointBackgroundColor: b,
|
|
30
30
|
fill: (p = n.inputs) == null ? void 0 : p.fillUnderLine,
|
|
31
31
|
borderColor: h,
|
|
32
|
-
data:
|
|
32
|
+
data: u.map((C) => {
|
|
33
33
|
var f;
|
|
34
|
-
const g =
|
|
35
|
-
(A) => A[r.name] ===
|
|
34
|
+
const g = o.find(
|
|
35
|
+
(A) => A[r.name] === a && A[l.name] === C
|
|
36
36
|
);
|
|
37
37
|
return (g == null ? void 0 : g[n.name]) ?? ((f = n.inputs) != null && f.connectGaps ? 0 : null);
|
|
38
38
|
})
|
|
39
39
|
};
|
|
40
40
|
});
|
|
41
41
|
return {
|
|
42
|
-
labels:
|
|
42
|
+
labels: u,
|
|
43
43
|
datasets: i
|
|
44
44
|
};
|
|
45
|
-
}, ne = (e,
|
|
46
|
-
var
|
|
47
|
-
const { dimension: c, data:
|
|
45
|
+
}, ne = (e, t) => {
|
|
46
|
+
var u, d;
|
|
47
|
+
const { dimension: c, data: o, measure: l, onLineClicked: r } = e, n = M(t), m = {
|
|
48
48
|
plugins: {
|
|
49
49
|
datalabels: {
|
|
50
50
|
labels: {
|
|
51
51
|
value: {
|
|
52
|
-
formatter: (
|
|
52
|
+
formatter: (s) => n.data(l, s)
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
56
|
tooltip: {
|
|
57
57
|
callbacks: {
|
|
58
|
-
title: (
|
|
59
|
-
var
|
|
60
|
-
const i = (
|
|
58
|
+
title: (s) => {
|
|
59
|
+
var a;
|
|
60
|
+
const i = (a = s[0]) == null ? void 0 : a.label;
|
|
61
61
|
return n.data(c, i);
|
|
62
62
|
},
|
|
63
|
-
label: (
|
|
64
|
-
const i =
|
|
65
|
-
return `${
|
|
63
|
+
label: (s) => {
|
|
64
|
+
const i = s.raw;
|
|
65
|
+
return `${s.dataset.label}: ${n.data(l, i)}`;
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
}
|
|
@@ -70,36 +70,36 @@ const se = (e, o) => {
|
|
|
70
70
|
scales: {
|
|
71
71
|
x: {
|
|
72
72
|
ticks: {
|
|
73
|
-
callback: (
|
|
74
|
-
if (!
|
|
75
|
-
const i =
|
|
73
|
+
callback: (s) => {
|
|
74
|
+
if (!o || !o.labels) return;
|
|
75
|
+
const i = o.labels[Number(s)];
|
|
76
76
|
return n.data(c, i);
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
},
|
|
80
80
|
y: {
|
|
81
81
|
ticks: {
|
|
82
|
-
callback: (
|
|
82
|
+
callback: (s) => n.data(l, s)
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
};
|
|
87
87
|
return $(
|
|
88
88
|
ee({ onLineClicked: r }),
|
|
89
|
-
|
|
90
|
-
((d = (
|
|
89
|
+
m,
|
|
90
|
+
((d = (u = t.charts) == null ? void 0 : u.lineChartGroupedPro) == null ? void 0 : d.options) || {}
|
|
91
91
|
);
|
|
92
|
-
},
|
|
93
|
-
const
|
|
94
|
-
F(
|
|
95
|
-
const { title: c, description:
|
|
92
|
+
}, te = (e) => {
|
|
93
|
+
const t = R();
|
|
94
|
+
F(t);
|
|
95
|
+
const { title: c, description: o, xAxisLabel: l, yAxisLabel: r } = v(e), {
|
|
96
96
|
measure: n,
|
|
97
|
-
xAxis:
|
|
98
|
-
groupBy:
|
|
97
|
+
xAxis: m,
|
|
98
|
+
groupBy: u,
|
|
99
99
|
reverseXAxis: d,
|
|
100
|
-
showLegend:
|
|
100
|
+
showLegend: s,
|
|
101
101
|
showLogarithmicScale: i,
|
|
102
|
-
showTooltips:
|
|
102
|
+
showTooltips: a,
|
|
103
103
|
showValueLabels: x,
|
|
104
104
|
yAxisRangeMax: b,
|
|
105
105
|
yAxisRangeMin: h,
|
|
@@ -110,32 +110,32 @@ const se = (e, o) => {
|
|
|
110
110
|
}), C = se(
|
|
111
111
|
{
|
|
112
112
|
data: p.data,
|
|
113
|
-
dimension:
|
|
114
|
-
groupDimension:
|
|
113
|
+
dimension: m,
|
|
114
|
+
groupDimension: u,
|
|
115
115
|
measure: n,
|
|
116
116
|
hasMinMaxYAxisRange: h != null || b != null
|
|
117
117
|
},
|
|
118
|
-
|
|
118
|
+
t
|
|
119
119
|
), g = ne(
|
|
120
|
-
{ data: C, dimension:
|
|
121
|
-
|
|
120
|
+
{ data: C, dimension: m, measure: n, onLineClicked: L },
|
|
121
|
+
t
|
|
122
122
|
);
|
|
123
123
|
return /* @__PURE__ */ w.jsx(
|
|
124
124
|
Q,
|
|
125
125
|
{
|
|
126
126
|
data: p,
|
|
127
|
-
dimensionsAndMeasures: [n,
|
|
127
|
+
dimensionsAndMeasures: [n, m, u],
|
|
128
128
|
errorMessage: p.error,
|
|
129
|
-
subtitle:
|
|
129
|
+
subtitle: o,
|
|
130
130
|
title: c,
|
|
131
131
|
children: /* @__PURE__ */ w.jsx(
|
|
132
|
-
|
|
132
|
+
S,
|
|
133
133
|
{
|
|
134
134
|
data: C,
|
|
135
135
|
reverseXAxis: d,
|
|
136
|
-
showLegend:
|
|
136
|
+
showLegend: s,
|
|
137
137
|
showLogarithmicScale: i,
|
|
138
|
-
showTooltips:
|
|
138
|
+
showTooltips: a,
|
|
139
139
|
showValueLabels: x,
|
|
140
140
|
xAxisLabel: l,
|
|
141
141
|
yAxisLabel: r,
|
|
@@ -146,12 +146,12 @@ const se = (e, o) => {
|
|
|
146
146
|
)
|
|
147
147
|
}
|
|
148
148
|
);
|
|
149
|
-
},
|
|
149
|
+
}, oe = {
|
|
150
150
|
name: "LineChartGroupedPro",
|
|
151
151
|
label: "Line Chart - Grouped",
|
|
152
152
|
category: "Line Charts",
|
|
153
153
|
inputs: [
|
|
154
|
-
|
|
154
|
+
j,
|
|
155
155
|
{
|
|
156
156
|
...y,
|
|
157
157
|
inputs: [
|
|
@@ -160,7 +160,7 @@ const se = (e, o) => {
|
|
|
160
160
|
{ ...V, name: "connectGaps", label: "Connect gaps", defaultValue: !0 }
|
|
161
161
|
]
|
|
162
162
|
},
|
|
163
|
-
{ ...
|
|
163
|
+
{ ...B, name: "xAxis", label: "X-axis" },
|
|
164
164
|
{ ...O, name: "groupBy", label: "Group by" },
|
|
165
165
|
T,
|
|
166
166
|
X,
|
|
@@ -193,7 +193,7 @@ const se = (e, o) => {
|
|
|
193
193
|
]
|
|
194
194
|
}
|
|
195
195
|
]
|
|
196
|
-
}, ge = P(
|
|
196
|
+
}, ge = P(te, oe, {
|
|
197
197
|
props: (e) => ({
|
|
198
198
|
...e,
|
|
199
199
|
results: J({
|
|
@@ -211,6 +211,6 @@ const se = (e, o) => {
|
|
|
211
211
|
});
|
|
212
212
|
export {
|
|
213
213
|
ge as default,
|
|
214
|
-
|
|
214
|
+
oe as meta
|
|
215
215
|
};
|
|
216
216
|
//# sourceMappingURL=LineChartGroupedPro.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineChartGroupedPro.js","sources":["../src/remarkable-pro/components/charts/lines/LineChartGroupedPro/LineChartGroupedPro.utils.ts","../src/remarkable-pro/components/charts/lines/LineChartGroupedPro/index.tsx","../src/remarkable-pro/components/charts/lines/LineChartGroupedPro/LineChartGroupedPro.emb.ts"],"sourcesContent":["import { DataResponse, Dimension, Measure } from '@embeddable.com/core';\nimport { Theme } from '../../../../theme/theme.types';\nimport { ChartData, ChartOptions } from 'chart.js';\nimport { getThemeFormatter } from '../../../../theme/formatter/formatter.utils';\nimport { mergician } from 'mergician';\nimport { getObjectStableKey } from '../../../../utils.ts/object.utils';\nimport { getColor } from '../../../../theme/styles/styles.utils';\nimport { setColorAlpha } from '../../../../utils.ts/color.utils';\nimport { chartContrastColors } from '../../../../../remarkable-ui';\nimport { getLineChartProOptions, LineChartProOptionsClick } from '../lines.utils';\n\nexport const getLineChartGroupedProData = (\n props: {\n data: DataResponse['data'];\n dimension: Dimension;\n groupDimension: Dimension;\n measure: Measure;\n hasMinMaxYAxisRange: boolean;\n },\n theme: Theme,\n): ChartData<'line'> => {\n const themeFormatter = getThemeFormatter(theme);\n const { data = [], dimension, groupDimension, measure, hasMinMaxYAxisRange } = props;\n\n const axis = [...new Set(data.map((d) => d[dimension.name]).filter(Boolean))].sort();\n const groupBy = [...new Set(data.map((d) => d[groupDimension.name]))].filter(Boolean);\n\n const themeKey = getObjectStableKey(theme);\n\n const datasets: ChartData<'line'>['datasets'] = groupBy.map((groupByItem, index) => {\n const backgroundColor = getColor(\n `${themeKey}.charts.backgroundColors`,\n `${groupDimension.name}.${groupByItem}`,\n theme.charts.backgroundColors ?? chartContrastColors,\n index,\n );\n\n const borderColor = getColor(\n `${themeKey}.charts.borderColors`,\n `${groupDimension.name}.${groupByItem}`,\n theme.charts.borderColors ?? chartContrastColors,\n index,\n );\n\n const dataset = {\n clip: hasMinMaxYAxisRange,\n label: themeFormatter.data(groupDimension, groupByItem),\n rawLabel: groupByItem,\n backgroundColor: setColorAlpha(backgroundColor, 0.5),\n pointBackgroundColor: backgroundColor,\n fill: measure.inputs?.['fillUnderLine'],\n borderColor,\n data: axis.map((axisItem) => {\n const record = data.find(\n (d) => d[groupDimension.name] === groupByItem && d[dimension.name] === axisItem,\n );\n return record?.[measure.name] ?? (measure.inputs?.['connectGaps'] ? 0 : null);\n }),\n } as ChartData<'line'>['datasets'][number];\n\n return dataset;\n });\n\n return {\n labels: axis,\n datasets,\n };\n};\n\nexport const getLineChartGroupedProOptions = (\n options: {\n dimension: Dimension;\n measure: Measure;\n data: ChartData<'line'>;\n onLineClicked: LineChartProOptionsClick;\n },\n theme: Theme,\n): ChartOptions<'line'> => {\n const { dimension, data, measure, onLineClicked } = options;\n const themeFormatter = getThemeFormatter(theme);\n\n const lineChartOptions: ChartOptions<'line'> = {\n plugins: {\n datalabels: {\n labels: {\n value: {\n formatter: (value: string | number) => {\n return themeFormatter.data(measure, value);\n },\n },\n },\n },\n tooltip: {\n callbacks: {\n title: (context) => {\n const label = context[0]?.label;\n return themeFormatter.data(dimension, label);\n },\n label: (context) => {\n const raw = context.raw as number;\n return `${context.dataset.label}: ${themeFormatter.data(measure, raw)}`;\n },\n },\n },\n },\n scales: {\n x: {\n ticks: {\n callback: (value) => {\n if (!data || !data.labels) return undefined;\n\n const label = data.labels[Number(value)] as string;\n return themeFormatter.data(dimension, label);\n },\n },\n },\n y: {\n ticks: {\n callback: (value) => {\n return themeFormatter.data(measure, value);\n },\n },\n },\n },\n };\n\n return mergician(\n getLineChartProOptions({ onLineClicked }),\n lineChartOptions,\n theme.charts?.lineChartGroupedPro?.options || {},\n );\n};\n","import { useTheme } from '@embeddable.com/react';\nimport { Theme } from '../../../../theme/theme.types';\nimport { DataResponse, Dimension, Measure } from '@embeddable.com/core';\nimport { i18nSetup } from '../../../../theme/i18n/i18n';\nimport { resolveI18nProps } from '../../../component.utils';\nimport { ChartCard } from '../../shared/ChartCard/ChartCard';\nimport {\n getLineChartGroupedProData,\n getLineChartGroupedProOptions,\n} from './LineChartGroupedPro.utils';\nimport { useFillGaps } from '../../charts.fillGaps.hooks';\nimport { LineChartProOptionsClick } from '../lines.utils';\nimport { LineChart } from '../../../../../remarkable-ui';\n\nexport type LineChartGroupedProPropsOnLineClicked = {\n axisDimensionValue: string | null;\n groupingDimensionValue: string | null;\n};\n\ntype LineChartGroupedProProp = {\n description: string;\n xAxis: Dimension;\n groupBy: Dimension;\n measure: Measure;\n results: DataResponse;\n reverseXAxis: boolean;\n showLegend: boolean;\n showLogarithmicScale: boolean;\n showTooltips: boolean;\n showValueLabels: boolean;\n title: string;\n xAxisLabel: string;\n yAxisLabel: string;\n yAxisRangeMax?: number;\n yAxisRangeMin?: number;\n onLineClicked: LineChartProOptionsClick;\n};\n\nconst LineChartGroupedPro = (props: LineChartGroupedProProp) => {\n const theme: Theme = useTheme() as Theme;\n i18nSetup(theme);\n\n const { title, description, xAxisLabel, yAxisLabel } = resolveI18nProps(props);\n const {\n measure,\n xAxis,\n groupBy,\n reverseXAxis,\n showLegend,\n showLogarithmicScale,\n showTooltips,\n showValueLabels,\n yAxisRangeMax,\n yAxisRangeMin,\n onLineClicked,\n } = props;\n\n const results = useFillGaps({\n results: props.results,\n dimension: props.xAxis,\n });\n\n const data = getLineChartGroupedProData(\n {\n data: results.data,\n dimension: xAxis,\n groupDimension: groupBy,\n measure,\n hasMinMaxYAxisRange: Boolean(yAxisRangeMin != null || yAxisRangeMax != null),\n },\n\n theme,\n );\n const options = getLineChartGroupedProOptions(\n { data, dimension: xAxis, measure, onLineClicked },\n theme,\n );\n\n return (\n <ChartCard\n data={results}\n dimensionsAndMeasures={[measure, xAxis, groupBy]}\n errorMessage={results.error}\n subtitle={description}\n title={title}\n >\n <LineChart\n data={data}\n reverseXAxis={reverseXAxis}\n showLegend={showLegend}\n showLogarithmicScale={showLogarithmicScale}\n showTooltips={showTooltips}\n showValueLabels={showValueLabels}\n xAxisLabel={xAxisLabel}\n yAxisLabel={yAxisLabel}\n yAxisRangeMax={yAxisRangeMax}\n yAxisRangeMin={yAxisRangeMin}\n options={options}\n />\n </ChartCard>\n );\n};\n\nexport default LineChartGroupedPro;\n","import { defineComponent, EmbeddedComponentMeta, Inputs } from '@embeddable.com/react';\nimport {\n dataset,\n description,\n dimension,\n dimensionWithDateBounds,\n genericBoolean,\n maxResults,\n measure,\n reverseXAxis,\n showLegend,\n showLogarithmicScale,\n showTooltips,\n showValueLabels,\n title,\n xAxisLabel,\n yAxisLabel,\n yAxisRangeMax,\n yAxisRangeMin,\n} from '../../../component.constants';\nimport LineChartGroupedPro from './index';\nimport { loadData, Value } from '@embeddable.com/core';\nimport { LineChartProOptionsClickArg } from '../lines.utils';\n\nexport const meta = {\n name: 'LineChartGroupedPro',\n label: 'Line Chart - Grouped',\n category: 'Line Charts',\n inputs: [\n dataset,\n {\n ...measure,\n inputs: [\n ...measure.inputs,\n { ...genericBoolean, name: 'fillUnderLine', label: 'Fill under line' },\n { ...genericBoolean, name: 'connectGaps', label: 'Connect gaps', defaultValue: true },\n ],\n },\n { ...dimensionWithDateBounds, name: 'xAxis', label: 'X-axis' },\n { ...dimension, name: 'groupBy', label: 'Group by' },\n title,\n description,\n maxResults,\n showLegend,\n showTooltips,\n showValueLabels,\n showLogarithmicScale,\n xAxisLabel,\n yAxisLabel,\n reverseXAxis,\n yAxisRangeMin,\n yAxisRangeMax,\n ],\n events: [\n {\n name: 'onLineClicked',\n label: 'A line is clicked',\n properties: [\n {\n name: 'axisDimensionValue',\n label: 'Clicked Axis Dimension Value',\n type: 'string',\n },\n {\n name: 'groupingDimensionValue',\n label: 'Clicked Grouping Dimension Value',\n type: 'string',\n },\n ],\n },\n ],\n} as const satisfies EmbeddedComponentMeta;\n\nexport default defineComponent(LineChartGroupedPro, meta, {\n props: (inputs: Inputs<typeof meta>) => {\n return {\n ...inputs,\n results: loadData({\n limit: inputs.maxResults,\n from: inputs.dataset,\n select: [inputs.xAxis, inputs.groupBy, inputs.measure],\n }),\n };\n },\n events: {\n onLineClicked: (value: LineChartProOptionsClickArg) => {\n return {\n axisDimensionValue: value.dimensionValue || Value.noFilter(),\n groupingDimensionValue: value.groupingDimensionValue || Value.noFilter(),\n };\n },\n },\n});\n"],"names":["getLineChartGroupedProData","props","theme","themeFormatter","getThemeFormatter","data","dimension","groupDimension","measure","hasMinMaxYAxisRange","axis","d","groupBy","themeKey","getObjectStableKey","datasets","groupByItem","index","backgroundColor","getColor","chartContrastColors","borderColor","setColorAlpha","_a","axisItem","record","getLineChartGroupedProOptions","options","onLineClicked","lineChartOptions","value","context","label","raw","mergician","getLineChartProOptions","_b","LineChartGroupedPro","useTheme","i18nSetup","title","description","xAxisLabel","yAxisLabel","resolveI18nProps","xAxis","reverseXAxis","showLegend","showLogarithmicScale","showTooltips","showValueLabels","yAxisRangeMax","yAxisRangeMin","results","useFillGaps","jsx","ChartCard","LineChart","meta","dataset","genericBoolean","dimensionWithDateBounds","maxResults","LineChartGroupedPro_emb","defineComponent","inputs","loadData","Value"],"mappings":";;;;;;;;;AAWO,MAAMA,KAA6B,CACxCC,GAOAC,MACsB;AACtB,QAAMC,IAAiBC,EAAkBF,CAAK,GACxC,EAAE,MAAAG,IAAO,IAAI,WAAAC,GAAW,gBAAAC,GAAgB,SAAAC,GAAS,qBAAAC,MAAwBR,GAEzES,IAAO,CAAC,GAAG,IAAI,IAAIL,EAAK,IAAI,CAACM,MAAMA,EAAEL,EAAU,IAAI,CAAC,EAAE,OAAO,OAAO,CAAC,CAAC,EAAE,KAAA,GACxEM,IAAU,CAAC,GAAG,IAAI,IAAIP,EAAK,IAAI,CAACM,MAAMA,EA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AAA,EAE3E;AAEJ,CAAC;"}
|
|
1
|
+
{"version":3,"file":"LineChartGroupedPro.js","sources":["../src/remarkable-pro/components/charts/lines/LineChartGroupedPro/LineChartGroupedPro.utils.ts","../src/remarkable-pro/components/charts/lines/LineChartGroupedPro/index.tsx","../src/remarkable-pro/components/charts/lines/LineChartGroupedPro/LineChartGroupedPro.emb.ts"],"sourcesContent":["import { DataResponse, Dimension, Measure } from '@embeddable.com/core';\nimport { Theme } from '../../../../theme/theme.types';\nimport { ChartData, ChartOptions } from 'chart.js';\nimport { getThemeFormatter } from '../../../../theme/formatter/formatter.utils';\nimport { mergician } from 'mergician';\nimport { getObjectStableKey } from '../../../../utils.ts/object.utils';\nimport { getColor } from '../../../../theme/styles/styles.utils';\nimport { setColorAlpha } from '../../../../utils.ts/color.utils';\nimport { chartContrastColors } from '../../../../../remarkable-ui';\nimport { getLineChartProOptions, LineChartProOptionsClick } from '../lines.utils';\n\nexport const getLineChartGroupedProData = (\n props: {\n data: DataResponse['data'];\n dimension: Dimension;\n groupDimension: Dimension;\n measure: Measure;\n hasMinMaxYAxisRange: boolean;\n },\n theme: Theme,\n): ChartData<'line'> => {\n const themeFormatter = getThemeFormatter(theme);\n const { data = [], dimension, groupDimension, measure, hasMinMaxYAxisRange } = props;\n\n const axis = [...new Set(data.map((d) => d[dimension.name]).filter((d) => d != null))].sort();\n const groupBy = [...new Set(data.map((d) => d[groupDimension.name]))].filter((d) => d != null);\n\n const themeKey = getObjectStableKey(theme);\n\n const datasets: ChartData<'line'>['datasets'] = groupBy.map((groupByItem, index) => {\n const backgroundColor = getColor(\n `${themeKey}.charts.backgroundColors`,\n `${groupDimension.name}.${groupByItem}`,\n theme.charts.backgroundColors ?? chartContrastColors,\n index,\n );\n\n const borderColor = getColor(\n `${themeKey}.charts.borderColors`,\n `${groupDimension.name}.${groupByItem}`,\n theme.charts.borderColors ?? chartContrastColors,\n index,\n );\n\n const dataset = {\n clip: hasMinMaxYAxisRange,\n label: themeFormatter.data(groupDimension, groupByItem),\n rawLabel: groupByItem,\n backgroundColor: setColorAlpha(backgroundColor, 0.5),\n pointBackgroundColor: backgroundColor,\n fill: measure.inputs?.['fillUnderLine'],\n borderColor,\n data: axis.map((axisItem) => {\n const record = data.find(\n (d) => d[groupDimension.name] === groupByItem && d[dimension.name] === axisItem,\n );\n return record?.[measure.name] ?? (measure.inputs?.['connectGaps'] ? 0 : null);\n }),\n } as ChartData<'line'>['datasets'][number];\n\n return dataset;\n });\n\n return {\n labels: axis,\n datasets,\n };\n};\n\nexport const getLineChartGroupedProOptions = (\n options: {\n dimension: Dimension;\n measure: Measure;\n data: ChartData<'line'>;\n onLineClicked: LineChartProOptionsClick;\n },\n theme: Theme,\n): ChartOptions<'line'> => {\n const { dimension, data, measure, onLineClicked } = options;\n const themeFormatter = getThemeFormatter(theme);\n\n const lineChartOptions: ChartOptions<'line'> = {\n plugins: {\n datalabels: {\n labels: {\n value: {\n formatter: (value: string | number) => {\n return themeFormatter.data(measure, value);\n },\n },\n },\n },\n tooltip: {\n callbacks: {\n title: (context) => {\n const label = context[0]?.label;\n return themeFormatter.data(dimension, label);\n },\n label: (context) => {\n const raw = context.raw as number;\n return `${context.dataset.label}: ${themeFormatter.data(measure, raw)}`;\n },\n },\n },\n },\n scales: {\n x: {\n ticks: {\n callback: (value) => {\n if (!data || !data.labels) return undefined;\n\n const label = data.labels[Number(value)] as string;\n return themeFormatter.data(dimension, label);\n },\n },\n },\n y: {\n ticks: {\n callback: (value) => {\n return themeFormatter.data(measure, value);\n },\n },\n },\n },\n };\n\n return mergician(\n getLineChartProOptions({ onLineClicked }),\n lineChartOptions,\n theme.charts?.lineChartGroupedPro?.options || {},\n );\n};\n","import { useTheme } from '@embeddable.com/react';\nimport { Theme } from '../../../../theme/theme.types';\nimport { DataResponse, Dimension, Measure } from '@embeddable.com/core';\nimport { i18nSetup } from '../../../../theme/i18n/i18n';\nimport { resolveI18nProps } from '../../../component.utils';\nimport { ChartCard } from '../../shared/ChartCard/ChartCard';\nimport {\n getLineChartGroupedProData,\n getLineChartGroupedProOptions,\n} from './LineChartGroupedPro.utils';\nimport { useFillGaps } from '../../charts.fillGaps.hooks';\nimport { LineChartProOptionsClick } from '../lines.utils';\nimport { LineChart } from '../../../../../remarkable-ui';\n\nexport type LineChartGroupedProPropsOnLineClicked = {\n axisDimensionValue: string | null;\n groupingDimensionValue: string | null;\n};\n\ntype LineChartGroupedProProp = {\n description: string;\n xAxis: Dimension;\n groupBy: Dimension;\n measure: Measure;\n results: DataResponse;\n reverseXAxis: boolean;\n showLegend: boolean;\n showLogarithmicScale: boolean;\n showTooltips: boolean;\n showValueLabels: boolean;\n title: string;\n xAxisLabel: string;\n yAxisLabel: string;\n yAxisRangeMax?: number;\n yAxisRangeMin?: number;\n onLineClicked: LineChartProOptionsClick;\n};\n\nconst LineChartGroupedPro = (props: LineChartGroupedProProp) => {\n const theme: Theme = useTheme() as Theme;\n i18nSetup(theme);\n\n const { title, description, xAxisLabel, yAxisLabel } = resolveI18nProps(props);\n const {\n measure,\n xAxis,\n groupBy,\n reverseXAxis,\n showLegend,\n showLogarithmicScale,\n showTooltips,\n showValueLabels,\n yAxisRangeMax,\n yAxisRangeMin,\n onLineClicked,\n } = props;\n\n const results = useFillGaps({\n results: props.results,\n dimension: props.xAxis,\n });\n\n const data = getLineChartGroupedProData(\n {\n data: results.data,\n dimension: xAxis,\n groupDimension: groupBy,\n measure,\n hasMinMaxYAxisRange: Boolean(yAxisRangeMin != null || yAxisRangeMax != null),\n },\n\n theme,\n );\n const options = getLineChartGroupedProOptions(\n { data, dimension: xAxis, measure, onLineClicked },\n theme,\n );\n\n return (\n <ChartCard\n data={results}\n dimensionsAndMeasures={[measure, xAxis, groupBy]}\n errorMessage={results.error}\n subtitle={description}\n title={title}\n >\n <LineChart\n data={data}\n reverseXAxis={reverseXAxis}\n showLegend={showLegend}\n showLogarithmicScale={showLogarithmicScale}\n showTooltips={showTooltips}\n showValueLabels={showValueLabels}\n xAxisLabel={xAxisLabel}\n yAxisLabel={yAxisLabel}\n yAxisRangeMax={yAxisRangeMax}\n yAxisRangeMin={yAxisRangeMin}\n options={options}\n />\n </ChartCard>\n );\n};\n\nexport default LineChartGroupedPro;\n","import { defineComponent, EmbeddedComponentMeta, Inputs } from '@embeddable.com/react';\nimport {\n dataset,\n description,\n dimension,\n dimensionWithDateBounds,\n genericBoolean,\n maxResults,\n measure,\n reverseXAxis,\n showLegend,\n showLogarithmicScale,\n showTooltips,\n showValueLabels,\n title,\n xAxisLabel,\n yAxisLabel,\n yAxisRangeMax,\n yAxisRangeMin,\n} from '../../../component.constants';\nimport LineChartGroupedPro from './index';\nimport { loadData, Value } from '@embeddable.com/core';\nimport { LineChartProOptionsClickArg } from '../lines.utils';\n\nexport const meta = {\n name: 'LineChartGroupedPro',\n label: 'Line Chart - Grouped',\n category: 'Line Charts',\n inputs: [\n dataset,\n {\n ...measure,\n inputs: [\n ...measure.inputs,\n { ...genericBoolean, name: 'fillUnderLine', label: 'Fill under line' },\n { ...genericBoolean, name: 'connectGaps', label: 'Connect gaps', defaultValue: true },\n ],\n },\n { ...dimensionWithDateBounds, name: 'xAxis', label: 'X-axis' },\n { ...dimension, name: 'groupBy', label: 'Group by' },\n title,\n description,\n maxResults,\n showLegend,\n showTooltips,\n showValueLabels,\n showLogarithmicScale,\n xAxisLabel,\n yAxisLabel,\n reverseXAxis,\n yAxisRangeMin,\n yAxisRangeMax,\n ],\n events: [\n {\n name: 'onLineClicked',\n label: 'A line is clicked',\n properties: [\n {\n name: 'axisDimensionValue',\n label: 'Clicked Axis Dimension Value',\n type: 'string',\n },\n {\n name: 'groupingDimensionValue',\n label: 'Clicked Grouping Dimension Value',\n type: 'string',\n },\n ],\n },\n ],\n} as const satisfies EmbeddedComponentMeta;\n\nexport default defineComponent(LineChartGroupedPro, meta, {\n props: (inputs: Inputs<typeof meta>) => {\n return {\n ...inputs,\n results: loadData({\n limit: inputs.maxResults,\n from: inputs.dataset,\n select: [inputs.xAxis, inputs.groupBy, inputs.measure],\n }),\n };\n },\n events: {\n onLineClicked: (value: LineChartProOptionsClickArg) => {\n return {\n axisDimensionValue: value.dimensionValue || Value.noFilter(),\n groupingDimensionValue: value.groupingDimensionValue || Value.noFilter(),\n };\n },\n },\n});\n"],"names":["getLineChartGroupedProData","props","theme","themeFormatter","getThemeFormatter","data","dimension","groupDimension","measure","hasMinMaxYAxisRange","axis","d","groupBy","themeKey","getObjectStableKey","datasets","groupByItem","index","backgroundColor","getColor","chartContrastColors","borderColor","setColorAlpha","_a","axisItem","record","getLineChartGroupedProOptions","options","onLineClicked","lineChartOptions","value","context","label","raw","mergician","getLineChartProOptions","_b","LineChartGroupedPro","useTheme","i18nSetup","title","description","xAxisLabel","yAxisLabel","resolveI18nProps","xAxis","reverseXAxis","showLegend","showLogarithmicScale","showTooltips","showValueLabels","yAxisRangeMax","yAxisRangeMin","results","useFillGaps","jsx","ChartCard","LineChart","meta","dataset","genericBoolean","dimensionWithDateBounds","maxResults","LineChartGroupedPro_emb","defineComponent","inputs","loadData","Value"],"mappings":";;;;;;;;;AAWO,MAAMA,KAA6B,CACxCC,GAOAC,MACsB;AACtB,QAAMC,IAAiBC,EAAkBF,CAAK,GACxC,EAAE,MAAAG,IAAO,IAAI,WAAAC,GAAW,gBAAAC,GAAgB,SAAAC,GAAS,qBAAAC,MAAwBR,GAEzES,IAAO,CAAC,GAAG,IAAI,IAAIL,EAAK,IAAI,CAACM,MAAMA,EAAEL,EAAU,IAAI,CAAC,EAAE,OAAO,CAACK,MAAMA,KAAK,IAAI,CAAC,CAAC,EAAE,KAAA,GACjFC,IAAU,CAAC,GAAG,IAAI,IAAIP,EAAK,IAAI,CAACM,MAAMA,EAAEJ,EAAe,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,CAACI,MAAMA,KAAK,IAAI,GAEvFE,IAAWC,EAAmBZ,CAAK,GAEnCa,IAA0CH,EAAQ,IAAI,CAACI,GAAaC,MAAU;;AAClF,UAAMC,IAAkBC;AAAA,M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AAiB,OAAO,kBAAA;AAAA,QACnD,EAAE,GAAGA,GAAgB,MAAM,eAAe,OAAO,gBAAgB,cAAc,GAAA;AAAA,MAAK;AAAA,IACtF;AAAA,IAEF,EAAE,GAAGC,GAAyB,MAAM,SAAS,OAAO,SAAA;AAAA,IACpD,EAAE,GAAGvD,GAAW,MAAM,WAAW,OAAO,WAAA;AAAA,IACxCkC;AAAA,IACAC;AAAA,IACAqB;AAAA,IACAf;AAAA,IACAE;AAAA,IACAC;AAAA,IACAF;AAAA,IACAN;AAAA,IACAC;AAAA,IACAG;AAAA,IACAM;AAAA,IACAD;AAAA,EAAA;AAAA,EAEF,QAAQ;AAAA,IACN;AAAA,MACE,MAAM;AAAA,MACN,OAAO;AAAA,MACP,YAAY;AAAA,QACV;AAAA,UACE,MAAM;AAAA,UACN,OAAO;AAAA,UACP,MAAM;AAAA,QAAA;AAAA,QAER;AAAA,UACE,MAAM;AAAA,UACN,OAAO;AAAA,UACP,MAAM;AAAA,QAAA;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEJ,GAEAY,KAAeC,EAAgB3B,IAAqBqB,IAAM;AAAA,EACxD,OAAO,CAACO,OACC;AAAA,IACL,GAAGA;AAAA,IACH,SAASC,EAAS;AAAA,MAChB,OAAOD,EAAO;AAAA,MACd,MAAMA,EAAO;AAAA,MACb,QAAQ,CAACA,EAAO,OAAOA,EAAO,SAASA,EAAO,OAAO;AAAA,IAAA,CACtD;AAAA,EAAA;AAAA,EAGL,QAAQ;AAAA,IACN,eAAe,CAACnC,OACP;AAAA,MACL,oBAAoBA,EAAM,kBAAkBqC,EAAM,SAAA;AAAA,MAClD,wBAAwBrC,EAAM,0BAA0BqC,EAAM,SAAA;AAAA,IAAS;AAAA,EAE3E;AAEJ,CAAC;"}
|
package/dist/PieChartPro.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { d as a, w as s, z as t, t as o, c as n, s as i, Q as r, e as m, f as l, V as d, o as c } from "./component.constants-CYS5-3qd.js";
|
|
2
2
|
import { defineComponent as p } from "@embeddable.com/react";
|
|
3
|
-
import { P as u } from "./index-
|
|
3
|
+
import { P as u } from "./index-DDmT6wnq.js";
|
|
4
4
|
const C = {
|
|
5
5
|
name: "PieChartPro",
|
|
6
6
|
label: "Pie Chart",
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { r as P, g as T } from "./charts.utils-DnzWuMfl.js";
|
|
2
|
+
import { g as h } from "./formatter.utils-CaFr8SlX.js";
|
|
3
|
+
import { g as D, a as C } from "./object.utils-D_Zzon-H.js";
|
|
4
|
+
import { D as $, E as p } from "./component.constants-CYS5-3qd.js";
|
|
5
|
+
import "react";
|
|
6
|
+
const B = (n, l) => {
|
|
7
|
+
var g;
|
|
8
|
+
const m = h(l), { data: e = [], dimension: i, groupDimension: t, measure: d } = n, o = [...new Set(e.map((s) => s[i.name]).filter((s) => s != null))].sort(), a = `${t.name}${(g = t.inputs) != null && g.granularity ? `.${t.inputs.granularity}` : ""}`, r = [...new Set(e.map((s) => s[a]))].filter((s) => s != null), c = D(l), u = r.map((s, b) => {
|
|
9
|
+
const w = C(
|
|
10
|
+
`${c}.charts.backgroundColors`,
|
|
11
|
+
`${t.name}.${s}`,
|
|
12
|
+
l.charts.backgroundColors ?? p,
|
|
13
|
+
b
|
|
14
|
+
), x = C(
|
|
15
|
+
`${c}.charts.borderColors`,
|
|
16
|
+
`${t.name}.${s}`,
|
|
17
|
+
l.charts.borderColors ?? p,
|
|
18
|
+
b
|
|
19
|
+
);
|
|
20
|
+
return {
|
|
21
|
+
label: m.data(t, s),
|
|
22
|
+
rawLabel: s,
|
|
23
|
+
backgroundColor: w,
|
|
24
|
+
borderColor: x,
|
|
25
|
+
data: o.map((F) => {
|
|
26
|
+
const k = e.find(
|
|
27
|
+
(f) => f[a] === s && f[i.name] === F
|
|
28
|
+
);
|
|
29
|
+
return k ? Number(k[d.name]) : 0;
|
|
30
|
+
})
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
return {
|
|
34
|
+
labels: o,
|
|
35
|
+
datasets: u
|
|
36
|
+
};
|
|
37
|
+
}, L = (n, l = P) => {
|
|
38
|
+
if (!n.data)
|
|
39
|
+
return {
|
|
40
|
+
labels: [],
|
|
41
|
+
datasets: [{ data: [] }]
|
|
42
|
+
};
|
|
43
|
+
const m = h(l), e = D(l), i = T(n.data, n.dimension, n.measures, n.maxItems);
|
|
44
|
+
return {
|
|
45
|
+
labels: i.map((t) => t[n.dimension.name]),
|
|
46
|
+
datasets: n.measures.map((t, d) => {
|
|
47
|
+
const o = C(
|
|
48
|
+
`${e}.charts.backgroundColors`,
|
|
49
|
+
t.name,
|
|
50
|
+
l.charts.backgroundColors ?? $,
|
|
51
|
+
d
|
|
52
|
+
), a = C(
|
|
53
|
+
`${e}.charts.borderColors`,
|
|
54
|
+
t.name,
|
|
55
|
+
l.charts.borderColors ?? $,
|
|
56
|
+
d
|
|
57
|
+
);
|
|
58
|
+
return {
|
|
59
|
+
label: m.dimensionOrMeasureTitle(t),
|
|
60
|
+
data: i.map((r) => r[t.name] ?? 0),
|
|
61
|
+
backgroundColor: o,
|
|
62
|
+
borderColor: a
|
|
63
|
+
};
|
|
64
|
+
})
|
|
65
|
+
};
|
|
66
|
+
}, v = (n, l) => {
|
|
67
|
+
const { datasets: m } = n.chart.data, e = n.dataIndex, i = m.reduce((t, d) => {
|
|
68
|
+
const o = d.data[e];
|
|
69
|
+
return t + (o || 0);
|
|
70
|
+
}, 0);
|
|
71
|
+
return l(i);
|
|
72
|
+
}, V = (n, l) => {
|
|
73
|
+
const { onBarClicked: m, measures: e, dimension: i, horizontal: t, data: d } = n, o = h(l);
|
|
74
|
+
return {
|
|
75
|
+
plugins: {
|
|
76
|
+
legend: { position: l.charts.legendPosition ?? "bottom" },
|
|
77
|
+
datalabels: {
|
|
78
|
+
labels: {
|
|
79
|
+
total: {
|
|
80
|
+
formatter: (a, r) => v(
|
|
81
|
+
r,
|
|
82
|
+
(c) => o.data(e[0], c)
|
|
83
|
+
)
|
|
84
|
+
},
|
|
85
|
+
value: {
|
|
86
|
+
formatter: (a, r) => {
|
|
87
|
+
const c = e[r.datasetIndex % e.length];
|
|
88
|
+
return o.data(c, a);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
tooltip: {
|
|
94
|
+
callbacks: {
|
|
95
|
+
title: (a) => {
|
|
96
|
+
var c;
|
|
97
|
+
const r = (c = a[0]) == null ? void 0 : c.label;
|
|
98
|
+
return o.data(i, r);
|
|
99
|
+
},
|
|
100
|
+
label: (a) => {
|
|
101
|
+
const r = e[a.datasetIndex % e.length], c = a.raw;
|
|
102
|
+
return `${o.data(i, a.dataset.label) || ""}: ${o.data(r, c)}`;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
scales: {
|
|
108
|
+
x: {
|
|
109
|
+
ticks: {
|
|
110
|
+
callback: (a) => {
|
|
111
|
+
if (t)
|
|
112
|
+
return o.data(e[0], a);
|
|
113
|
+
if (!d || !d.labels) return;
|
|
114
|
+
const r = d.labels[Number(a)];
|
|
115
|
+
return o.data(i, r);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
y: {
|
|
120
|
+
ticks: {
|
|
121
|
+
callback: (a) => {
|
|
122
|
+
if (!t)
|
|
123
|
+
return o.data(e[0], a);
|
|
124
|
+
if (!d || !d.labels) return;
|
|
125
|
+
const r = d.labels[Number(a)];
|
|
126
|
+
return o.data(i, r);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
onClick: (a, r, c) => {
|
|
132
|
+
var b;
|
|
133
|
+
const u = r[0], g = u ? c.data.labels[u.index] : null, s = u ? (b = c.data.datasets[u.datasetIndex]) == null ? void 0 : b.rawLabel : null;
|
|
134
|
+
m({
|
|
135
|
+
axisDimensionValue: g,
|
|
136
|
+
groupingDimensionValue: s
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
export {
|
|
142
|
+
V as a,
|
|
143
|
+
B as b,
|
|
144
|
+
L as g
|
|
145
|
+
};
|
|
146
|
+
//# sourceMappingURL=bars.utils-CfUdtqtZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bars.utils-CfUdtqtZ.js","sources":["../src/remarkable-pro/components/charts/bars/bars.utils.ts"],"sourcesContent":["import { DataResponse, Dimension, Measure } from '@embeddable.com/core';\nimport { Theme } from '../../../theme/theme.types';\nimport { remarkableTheme } from '../../../theme/theme.constants';\nimport { ChartData, ChartOptions } from 'chart.js';\nimport { getThemeFormatter } from '../../../theme/formatter/formatter.utils';\nimport { groupTailAsOther } from '../charts.utils';\nimport { getColor } from '../../../theme/styles/styles.utils';\nimport { chartColors, chartContrastColors } from '../../../../remarkable-ui';\nimport { getObjectStableKey } from '../../../utils.ts/object.utils';\nimport { Context } from 'chartjs-plugin-datalabels';\n\nexport const getBarStackedChartProData = (\n props: {\n data: DataResponse['data'];\n dimension: Dimension;\n groupDimension: Dimension;\n measure: Measure;\n },\n theme: Theme,\n): ChartData<'bar'> => {\n const themeFormatter = getThemeFormatter(theme);\n const { data = [], dimension, groupDimension, measure } = props;\n\n const axis = [...new Set(data.map((d) => d[dimension.name]).filter((d) => d != null))].sort();\n const groupDimensionName = `${groupDimension.name}${groupDimension.inputs?.granularity ? `.${groupDimension.inputs.granularity}` : ''}`;\n const groupBy = [...new Set(data.map((d) => d[groupDimensionName]))].filter((d) => d != null);\n\n const themeKey = getObjectStableKey(theme);\n\n const datasets = groupBy.map((groupByItem, index) => {\n const backgroundColor = getColor(\n `${themeKey}.charts.backgroundColors`,\n `${groupDimension.name}.${groupByItem}`,\n theme.charts.backgroundColors ?? chartContrastColors,\n index,\n );\n\n const borderColor = getColor(\n `${themeKey}.charts.borderColors`,\n `${groupDimension.name}.${groupByItem}`,\n theme.charts.borderColors ?? chartContrastColors,\n index,\n );\n\n return {\n label: themeFormatter.data(groupDimension, groupByItem),\n rawLabel: groupByItem,\n backgroundColor,\n borderColor,\n data: axis.map((axisItem) => {\n const record = data.find(\n (d) => d[groupDimensionName] === groupByItem && d[dimension.name] === axisItem,\n );\n return record ? Number(record[measure.name]) : 0;\n }),\n };\n });\n\n return {\n labels: axis,\n datasets,\n };\n};\n\nexport const getBarChartProData = (\n props: {\n data: DataResponse['data'];\n dimension: Dimension;\n measures: Measure[];\n maxItems?: number;\n },\n theme: Theme = remarkableTheme,\n): ChartData<'bar'> => {\n if (!props.data) {\n return {\n labels: [],\n datasets: [{ data: [] }],\n };\n }\n\n const themeFormatter = getThemeFormatter(theme);\n const themeKey = getObjectStableKey(theme);\n const groupedData = groupTailAsOther(props.data, props.dimension, props.measures, props.maxItems);\n\n return {\n labels: groupedData.map((item) => {\n return item[props.dimension.name];\n }),\n datasets: props.measures.map((measure, index) => {\n const backgroundColor = getColor(\n `${themeKey}.charts.backgroundColors`,\n measure.name,\n theme.charts.backgroundColors ?? chartColors,\n index,\n );\n\n const borderColor = getColor(\n `${themeKey}.charts.borderColors`,\n measure.name,\n theme.charts.borderColors ?? chartColors,\n index,\n );\n\n return {\n label: themeFormatter.dimensionOrMeasureTitle(measure),\n data: groupedData.map((item) => item[measure.name] ?? 0),\n backgroundColor,\n borderColor,\n };\n }),\n };\n};\n\nconst getBarChartProDatalabelTotalFormatter = (\n context: Context,\n formatter: (value: number) => string,\n) => {\n const { datasets } = context.chart.data;\n const i = context.dataIndex;\n\n const total = datasets.reduce((sum, ds) => {\n const val = ds.data[i] as number;\n return sum + (val || 0);\n }, 0);\n\n return formatter(total);\n};\n\nexport const getBarChartProOptions = (\n options: {\n onBarClicked: (args: {\n axisDimensionValue: string | null;\n groupingDimensionValue: string | null;\n }) => void;\n measures: Measure[];\n dimension: Dimension;\n horizontal: boolean;\n data: ChartData<'bar'>;\n },\n theme: Theme,\n): Partial<ChartOptions<'bar'>> => {\n const { onBarClicked, measures, dimension, horizontal, data } = options;\n\n const themeFormatter = getThemeFormatter(theme);\n return {\n plugins: {\n legend: { position: theme.charts.legendPosition ?? 'bottom' },\n datalabels: {\n labels: {\n total: {\n formatter: (_value: string | number, context: Context) =>\n getBarChartProDatalabelTotalFormatter(context, (value: number) =>\n themeFormatter.data(measures[0]!, value),\n ),\n },\n value: {\n formatter: (value: string | number, context) => {\n const measure = measures[context.datasetIndex % measures.length]!;\n return themeFormatter.data(measure, value);\n },\n },\n },\n },\n tooltip: {\n callbacks: {\n title: (context) => {\n const label = context[0]?.label;\n return themeFormatter.data(dimension, label);\n },\n label: (context) => {\n const measure = measures[context.datasetIndex % measures.length]!;\n const raw = context.raw as number;\n return `${themeFormatter.data(dimension, context.dataset.label) || ''}: ${themeFormatter.data(measure, raw)}`;\n },\n },\n },\n },\n scales: {\n x: {\n ticks: {\n callback: (value) => {\n if (horizontal) {\n return themeFormatter.data(measures[0]!, value);\n }\n\n if (!data || !data.labels) return undefined;\n\n const label = data.labels[Number(value)] as string;\n\n return themeFormatter.data(dimension, label);\n },\n },\n },\n y: {\n ticks: {\n callback: (value) => {\n if (!horizontal) {\n return themeFormatter.data(measures[0]!, value);\n }\n if (!data || !data.labels) return undefined;\n const label = data.labels[Number(value)] as string;\n return themeFormatter.data(dimension, label);\n },\n },\n },\n },\n onClick: (_event, elements, chart) => {\n const element = elements[0];\n const axisDimensionValue = (element ? chart.data.labels![element.index] : null) as\n | string\n | null;\n const groupingDimensionValue = (\n element\n ? (chart.data.datasets[element.datasetIndex] as { rawLabel?: string | null })?.rawLabel\n : null\n ) as string | null;\n\n onBarClicked({\n axisDimensionValue,\n groupingDimensionValue,\n });\n },\n };\n};\n"],"names":["getBarStackedChartProData","props","theme","themeFormatter","getThemeFormatter","data","dimension","groupDimension","measure","axis","d","groupDimensionName","_a","groupBy","themeKey","getObjectStableKey","datasets","groupByItem","index","backgroundColor","getColor","chartContrastColors","borderColor","axisItem","record","getBarChartProData","remarkableTheme","groupedData","groupTailAsOther","item","chartColors","getBarChartProDatalabelTotalFormatter","context","formatter","i","total","sum","ds","val","getBarChartProOptions","options","onBarClicked","measures","horizontal","_value","value","label","raw","_event","elements","chart","element","axisDimensionValue","groupingDimensionValue"],"mappings":";;;;;AAWO,MAAMA,IAA4B,CACvCC,GAMAC,MACqB;;AACrB,QAAMC,IAAiBC,EAAkBF,CAAK,GACxC,EAAE,MAAAG,IAAO,CAAA,GAAI,WAAAC,GAAW,gBAAAC,GAAgB,SAAAC,MAAYP,GAEpDQ,IAAO,CAAC,GAAG,IAAI,IAAIJ,EAAK,IAAI,CAACK,MAAMA,EAAEJ,EAAU,IAAI,CAAC,EAAE,OAAO,CAACI,MAAMA,KAAK,IAAI,CAAC,CAAC,EAAE,KAAA,GACjFC,IAAqB,GAAGJ,EAAe,IAAI,IAAGK,IAAAL,EAAe,WAAf,QAAAK,EAAuB,cAAc,IAAIL,EAAe,OAAO,WAAW,KAAK,EAAE,IAC/HM,IAAU,CAAC,GAAG,IAAI,IAAIR,EAAK,IAAI,CAACK,MAAMA,EAAEC,CAAkB,CAAC,CAAC,CAAC,EAAE,OAAO,CAACD,MAAMA,KAAK,IAAI,GAEtFI,IAAWC,EAAmBb,CAAK,GAEnCc,IAAWH,EAAQ,IAAI,CAACI,GAAaC,MAAU;AACnD,UAAMC,IAAkBC;AAAA,MACtB,GAAGN,CAAQ;AAAA,MACX,GAAGP,EAAe,IAAI,IAAIU,CAAW;AAAA,MACrCf,EAAM,OAAO,oBAAoBmB;AAAA,MACjCH;AAAA,IAAA,GAGII,IAAcF;AAAA,MAClB,GAAGN,CAAQ;AAAA,MACX,GAAGP,EAAe,IAAI,IAAIU,CAAW;AAAA,MACrCf,EAAM,OAAO,gBAAgBmB;AAAA,MAC7BH;AAAA,IAAA;AAGF,WAAO;AAAA,MACL,OAAOf,EAAe,KAAKI,GAAgBU,CAAW;AAAA,MACtD,UAAUA;AAAA,MACV,iBAAAE;AAAA,MACA,aAAAG;AAAA,M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