@acorex-platform/module-dashboard-management-client 0.0.37 → 0.0.46
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/fesm2022/{acorex-platform-module-dashboard-management-client-acorex-platform-module-dashboard-management-client-BUmHWNqL.mjs → acorex-platform-module-dashboard-management-client-acorex-platform-module-dashboard-management-client-Ey27MqFo.mjs} +976 -2957
- package/fesm2022/acorex-platform-module-dashboard-management-client-acorex-platform-module-dashboard-management-client-Ey27MqFo.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-dashboard-management-client-bar-chart-widget.component-5c4X-lEC.mjs +151 -0
- package/fesm2022/acorex-platform-module-dashboard-management-client-bar-chart-widget.component-5c4X-lEC.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-dashboard-management-client-chart-card-widget.component-BYdlIBv9.mjs +126 -0
- package/fesm2022/acorex-platform-module-dashboard-management-client-chart-card-widget.component-BYdlIBv9.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-dashboard-management-client-chart-configurator-widget-column.component-DxNKy3bB.mjs +76 -0
- package/fesm2022/acorex-platform-module-dashboard-management-client-chart-configurator-widget-column.component-DxNKy3bB.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-dashboard-management-client-chart-configurator-widget-edit.component-FhtkU52L.mjs +559 -0
- package/fesm2022/acorex-platform-module-dashboard-management-client-chart-configurator-widget-edit.component-FhtkU52L.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-dashboard-management-client-chart-legend.util-C1zqTQEf.mjs +31 -0
- package/fesm2022/acorex-platform-module-dashboard-management-client-chart-legend.util-C1zqTQEf.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-dashboard-management-client-chart-widget-data.util-DgCBHS1p.mjs +589 -0
- package/fesm2022/acorex-platform-module-dashboard-management-client-chart-widget-data.util-DgCBHS1p.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-dashboard-management-client-contracts-entities-dashboard.mjs +30 -1
- package/fesm2022/acorex-platform-module-dashboard-management-client-contracts-entities-dashboard.mjs.map +1 -1
- package/fesm2022/{acorex-platform-module-dashboard-management-client-contracts-entity-catalog-acorex-platform-module-dashboard-management-client-contracts-entity-catalog-CPDwiLWC.mjs → acorex-platform-module-dashboard-management-client-contracts-entity-catalog-acorex-platform-module-dashboard-management-client-contracts-entity-catalog-C3ZKIYgQ.mjs} +2 -2
- package/fesm2022/{acorex-platform-module-dashboard-management-client-contracts-entity-catalog-acorex-platform-module-dashboard-management-client-contracts-entity-catalog-CPDwiLWC.mjs.map → acorex-platform-module-dashboard-management-client-contracts-entity-catalog-acorex-platform-module-dashboard-management-client-contracts-entity-catalog-C3ZKIYgQ.mjs.map} +1 -1
- package/fesm2022/{acorex-platform-module-dashboard-management-client-contracts-entity-catalog-dashboard.entity-C1ju-BQM.mjs → acorex-platform-module-dashboard-management-client-contracts-entity-catalog-dashboard.entity-D2uqZMd4.mjs} +32 -3
- package/fesm2022/acorex-platform-module-dashboard-management-client-contracts-entity-catalog-dashboard.entity-D2uqZMd4.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-dashboard-management-client-contracts-entity-catalog.mjs +1 -1
- package/fesm2022/acorex-platform-module-dashboard-management-client-contracts.mjs +21 -1
- package/fesm2022/acorex-platform-module-dashboard-management-client-contracts.mjs.map +1 -1
- package/fesm2022/acorex-platform-module-dashboard-management-client-donut-chart-widget.component-DRiIRbhX.mjs +145 -0
- package/fesm2022/acorex-platform-module-dashboard-management-client-donut-chart-widget.component-DRiIRbhX.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-dashboard-management-client-funnel-chart-widget.component-BPY1NchM.mjs +135 -0
- package/fesm2022/acorex-platform-module-dashboard-management-client-funnel-chart-widget.component-BPY1NchM.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-dashboard-management-client-gauge-chart-widget.component-Cy6fgife.mjs +138 -0
- package/fesm2022/acorex-platform-module-dashboard-management-client-gauge-chart-widget.component-Cy6fgife.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-dashboard-management-client-heatmap-chart-widget.component-CTelqGbm.mjs +154 -0
- package/fesm2022/acorex-platform-module-dashboard-management-client-heatmap-chart-widget.component-CTelqGbm.mjs.map +1 -0
- package/fesm2022/{acorex-platform-module-dashboard-management-client-index-C1Te5cDf.mjs → acorex-platform-module-dashboard-management-client-index-P-PzUrbN.mjs} +3 -3
- package/fesm2022/{acorex-platform-module-dashboard-management-client-index-C1Te5cDf.mjs.map → acorex-platform-module-dashboard-management-client-index-P-PzUrbN.mjs.map} +1 -1
- package/fesm2022/acorex-platform-module-dashboard-management-client-line-chart-widget.component-B18VZb9t.mjs +158 -0
- package/fesm2022/acorex-platform-module-dashboard-management-client-line-chart-widget.component-B18VZb9t.mjs.map +1 -0
- package/fesm2022/acorex-platform-module-dashboard-management-client.mjs +1 -1
- package/package.json +1 -1
- package/types/acorex-platform-module-dashboard-management-client-contracts.d.ts +19 -5
- package/types/acorex-platform-module-dashboard-management-client.d.ts +49 -267
- package/fesm2022/acorex-platform-module-dashboard-management-client-acorex-platform-module-dashboard-management-client-BUmHWNqL.mjs.map +0 -1
- package/fesm2022/acorex-platform-module-dashboard-management-client-contracts-entity-catalog-dashboard.entity-C1ju-BQM.mjs.map +0 -1
package/fesm2022/acorex-platform-module-dashboard-management-client-chart-legend.util-C1zqTQEf.mjs
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared legend options for dashboard chart widgets (ax-chart-legend).
|
|
3
|
+
*/
|
|
4
|
+
//#region ----- Defaults -----
|
|
5
|
+
const AXP_CHART_LEGEND_OPTIONS_SERIES = {
|
|
6
|
+
mode: 'horizontal',
|
|
7
|
+
showValues: true,
|
|
8
|
+
showPercentage: false,
|
|
9
|
+
interactive: true,
|
|
10
|
+
};
|
|
11
|
+
const AXP_CHART_LEGEND_OPTIONS_DONUT = {
|
|
12
|
+
mode: 'horizontal',
|
|
13
|
+
showValues: true,
|
|
14
|
+
showPercentage: true,
|
|
15
|
+
interactive: true,
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region ----- Options helpers -----
|
|
19
|
+
/**
|
|
20
|
+
* Removes fixed width/height so @acorex/charts sizes from the container.
|
|
21
|
+
*/
|
|
22
|
+
function omitChartFixedSize(options) {
|
|
23
|
+
const next = { ...options };
|
|
24
|
+
delete next['width'];
|
|
25
|
+
delete next['height'];
|
|
26
|
+
return next;
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
|
|
30
|
+
export { AXP_CHART_LEGEND_OPTIONS_SERIES as A, AXP_CHART_LEGEND_OPTIONS_DONUT as a, omitChartFixedSize as o };
|
|
31
|
+
//# sourceMappingURL=acorex-platform-module-dashboard-management-client-chart-legend.util-C1zqTQEf.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acorex-platform-module-dashboard-management-client-chart-legend.util-C1zqTQEf.mjs","sources":["../../../../libs/modules/dashboard-management/client/src/lib/features/shared/widgets/chart/chart-legend.util.ts"],"sourcesContent":["/**\n * Shared legend options for dashboard chart widgets (ax-chart-legend).\n */\n\nimport type { AXChartLegendOptions } from '@acorex/charts/chart-legend';\n\n//#region ----- Defaults -----\n\nexport const AXP_CHART_LEGEND_OPTIONS_SERIES: AXChartLegendOptions = {\n mode: 'horizontal',\n showValues: true,\n showPercentage: false,\n interactive: true,\n};\n\nexport const AXP_CHART_LEGEND_OPTIONS_DONUT: AXChartLegendOptions = {\n mode: 'horizontal',\n showValues: true,\n showPercentage: true,\n interactive: true,\n};\n\n//#endregion\n\n//#region ----- Options helpers -----\n\n/**\n * Removes fixed width/height so @acorex/charts sizes from the container.\n */\nexport function omitChartFixedSize<T extends Record<string, unknown>>(options: T): T {\n const next = { ...options };\n delete next['width'];\n delete next['height'];\n return next;\n}\n\n//#endregion\n"],"names":[],"mappings":"AAAA;;AAEG;AAIH;AAEO,MAAM,+BAA+B,GAAyB;AACnE,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,UAAU,EAAE,IAAI;AAChB,IAAA,cAAc,EAAE,KAAK;AACrB,IAAA,WAAW,EAAE,IAAI;;AAGZ,MAAM,8BAA8B,GAAyB;AAClE,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,UAAU,EAAE,IAAI;AAChB,IAAA,cAAc,EAAE,IAAI;AACpB,IAAA,WAAW,EAAE,IAAI;;AAGnB;AAEA;AAEA;;AAEG;AACG,SAAU,kBAAkB,CAAoC,OAAU,EAAA;AAC9E,IAAA,MAAM,IAAI,GAAG,EAAE,GAAG,OAAO,EAAE;AAC3B,IAAA,OAAO,IAAI,CAAC,OAAO,CAAC;AACpB,IAAA,OAAO,IAAI,CAAC,QAAQ,CAAC;AACrB,IAAA,OAAO,IAAI;AACb;AAEA;;"}
|
|
@@ -0,0 +1,589 @@
|
|
|
1
|
+
import { runtimeQueryCollectionData } from '@acorex-platform/framework-shared/core';
|
|
2
|
+
import { isObjectLike, isNumber, isString } from 'lodash';
|
|
3
|
+
import { k as fetchChartQueryResult, l as applyChartColorRulesFromOptions } from './acorex-platform-module-dashboard-management-client-acorex-platform-module-dashboard-management-client-Ey27MqFo.mjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Normalizes AI / Chart Generator agent payloads into shapes dashboard chart widgets expect.
|
|
7
|
+
* Called before every `load*Chart*` resolver in {@link chart-widget-data.util.ts}.
|
|
8
|
+
*/
|
|
9
|
+
function asRecord$1(value) {
|
|
10
|
+
return isObjectLike(value) && !Array.isArray(value) ? value : undefined;
|
|
11
|
+
}
|
|
12
|
+
function toNumber$1(value) {
|
|
13
|
+
if (isNumber(value) && Number.isFinite(value)) {
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
if (isString(value) && value.trim()) {
|
|
17
|
+
const parsed = Number(value);
|
|
18
|
+
if (Number.isFinite(parsed)) {
|
|
19
|
+
return parsed;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
function promoteLabelsToAxisCategories(opts) {
|
|
25
|
+
const xAxis = asRecord$1(opts['xAxis']);
|
|
26
|
+
if (xAxis && Array.isArray(xAxis['labels']) && !Array.isArray(opts['labels'])) {
|
|
27
|
+
opts['labels'] = xAxis['labels'];
|
|
28
|
+
}
|
|
29
|
+
const labels = opts['labels'];
|
|
30
|
+
if (!Array.isArray(labels)) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const nextXAxis = xAxis ?? {};
|
|
34
|
+
if (!Array.isArray(nextXAxis['categories'])) {
|
|
35
|
+
opts['xAxis'] = { ...nextXAxis, categories: labels };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function materializeLabelValueRows(labels, values) {
|
|
39
|
+
const rows = [];
|
|
40
|
+
const length = Math.min(labels.length, values.length);
|
|
41
|
+
for (let index = 0; index < length; index++) {
|
|
42
|
+
const value = toNumber$1(values[index]);
|
|
43
|
+
const label = String(labels[index] ?? '').trim();
|
|
44
|
+
if (!label || value === undefined) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
rows.push({ label, value });
|
|
48
|
+
}
|
|
49
|
+
return rows;
|
|
50
|
+
}
|
|
51
|
+
function readCategoriesForExpand(opts) {
|
|
52
|
+
const xAxis = asRecord$1(opts['xAxis']);
|
|
53
|
+
const fromAxis = xAxis?.['categories'] ?? xAxis?.['labels'];
|
|
54
|
+
if (Array.isArray(fromAxis)) {
|
|
55
|
+
return fromAxis.map((entry) => String(entry ?? ''));
|
|
56
|
+
}
|
|
57
|
+
if (Array.isArray(opts['labels'])) {
|
|
58
|
+
return opts['labels'].map((entry) => String(entry ?? ''));
|
|
59
|
+
}
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
function materializeDataSourceFromLabelsAndSeries(opts) {
|
|
63
|
+
if (opts['dataSource'] != null || opts['items'] != null) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const labels = readCategoriesForExpand(opts);
|
|
67
|
+
if (labels.length === 0) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const values = opts['values'];
|
|
71
|
+
if (Array.isArray(values)) {
|
|
72
|
+
const rows = materializeLabelValueRows(labels, values);
|
|
73
|
+
if (rows.length > 0) {
|
|
74
|
+
opts['dataSource'] = rows;
|
|
75
|
+
}
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const rawSeries = opts['series'];
|
|
79
|
+
if (!Array.isArray(rawSeries) || rawSeries.length === 0) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const first = rawSeries[0];
|
|
83
|
+
if (!isObjectLike(first)) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const seriesData = first['data'];
|
|
87
|
+
if (!Array.isArray(seriesData)) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const rows = materializeLabelValueRows(labels, seriesData);
|
|
91
|
+
if (rows.length > 0) {
|
|
92
|
+
opts['dataSource'] = rows;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function unwrapNestedDataObject(opts) {
|
|
96
|
+
const data = opts['data'];
|
|
97
|
+
if (data == null || typeof data !== 'object' || Array.isArray(data)) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const dataObj = data;
|
|
101
|
+
if (Array.isArray(dataObj['labels']) && opts['labels'] == null) {
|
|
102
|
+
opts['labels'] = dataObj['labels'];
|
|
103
|
+
}
|
|
104
|
+
const xAxisObj = asRecord$1(dataObj['xAxis']);
|
|
105
|
+
if (xAxisObj && Array.isArray(xAxisObj['labels']) && opts['xAxis'] == null) {
|
|
106
|
+
opts['xAxis'] = xAxisObj;
|
|
107
|
+
}
|
|
108
|
+
if (Array.isArray(dataObj['values']) && opts['values'] == null) {
|
|
109
|
+
opts['values'] = dataObj['values'];
|
|
110
|
+
}
|
|
111
|
+
if (Array.isArray(dataObj['series']) && opts['series'] == null) {
|
|
112
|
+
opts['series'] = dataObj['series'];
|
|
113
|
+
}
|
|
114
|
+
if (Array.isArray(dataObj['items'])) {
|
|
115
|
+
if (opts['items'] == null) {
|
|
116
|
+
opts['items'] = dataObj['items'];
|
|
117
|
+
}
|
|
118
|
+
if (opts['dataSource'] == null) {
|
|
119
|
+
opts['dataSource'] = dataObj['items'];
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const scalarValue = toNumber$1(dataObj['value']);
|
|
123
|
+
if (scalarValue !== undefined && opts['value'] == null && opts['dataSource'] == null) {
|
|
124
|
+
opts['value'] = scalarValue;
|
|
125
|
+
opts['dataSource'] = scalarValue;
|
|
126
|
+
}
|
|
127
|
+
delete opts['data'];
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Expands common AI chart option shapes (`props`, `data`, `labels`+`series`, etc.)
|
|
131
|
+
* into `dataSource` / `xAxis.categories` / scalar gauge values understood by chart loaders.
|
|
132
|
+
*/
|
|
133
|
+
function expandAiChartWidgetOptions(opts) {
|
|
134
|
+
unwrapNestedDataObject(opts);
|
|
135
|
+
if (Array.isArray(opts['data']) && opts['dataSource'] == null && opts['items'] == null) {
|
|
136
|
+
opts['dataSource'] = opts['data'];
|
|
137
|
+
delete opts['data'];
|
|
138
|
+
}
|
|
139
|
+
if (Array.isArray(opts['items']) && opts['dataSource'] == null) {
|
|
140
|
+
opts['dataSource'] = opts['items'];
|
|
141
|
+
}
|
|
142
|
+
promoteLabelsToAxisCategories(opts);
|
|
143
|
+
materializeDataSourceFromLabelsAndSeries(opts);
|
|
144
|
+
if (opts['dataSource'] == null) {
|
|
145
|
+
const scalar = toNumber$1(opts['value']);
|
|
146
|
+
if (scalar !== undefined) {
|
|
147
|
+
opts['dataSource'] = scalar;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Resolves chart widget payloads from AXPQuery bindings, inline `options.dataSource`,
|
|
154
|
+
* or common AI-emitted shapes (`series` + `xAxis.categories`, etc.).
|
|
155
|
+
*/
|
|
156
|
+
//#region ----- Shared helpers -----
|
|
157
|
+
function asRecord(value) {
|
|
158
|
+
return isObjectLike(value) && !Array.isArray(value) ? value : undefined;
|
|
159
|
+
}
|
|
160
|
+
function readAxisTitle(axis) {
|
|
161
|
+
const row = asRecord(axis);
|
|
162
|
+
const title = row?.['title'];
|
|
163
|
+
return isString(title) && title.trim() ? title.trim() : undefined;
|
|
164
|
+
}
|
|
165
|
+
function readAxisCategoriesFromRecord(axis) {
|
|
166
|
+
if (!axis) {
|
|
167
|
+
return [];
|
|
168
|
+
}
|
|
169
|
+
const categories = axis['categories'] ?? axis['labels'];
|
|
170
|
+
if (!Array.isArray(categories)) {
|
|
171
|
+
return [];
|
|
172
|
+
}
|
|
173
|
+
return categories.map((entry) => String(entry ?? ''));
|
|
174
|
+
}
|
|
175
|
+
function readAxisCategories(opts) {
|
|
176
|
+
const fromXAxis = readAxisCategoriesFromRecord(asRecord(opts['xAxis']));
|
|
177
|
+
if (fromXAxis.length > 0) {
|
|
178
|
+
return fromXAxis;
|
|
179
|
+
}
|
|
180
|
+
const labels = opts['labels'];
|
|
181
|
+
if (Array.isArray(labels)) {
|
|
182
|
+
return labels.map((entry) => String(entry ?? ''));
|
|
183
|
+
}
|
|
184
|
+
return [];
|
|
185
|
+
}
|
|
186
|
+
function zipCategoryValues(categories, values) {
|
|
187
|
+
const points = [];
|
|
188
|
+
const length = Math.min(categories.length, values.length);
|
|
189
|
+
for (let index = 0; index < length; index++) {
|
|
190
|
+
const y = values[index];
|
|
191
|
+
if (!isNumber(y)) {
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
points.push({ x: categories[index], y });
|
|
195
|
+
}
|
|
196
|
+
return points;
|
|
197
|
+
}
|
|
198
|
+
function seriesLabel(raw) {
|
|
199
|
+
const label = raw['label'] ?? raw['name'];
|
|
200
|
+
return isString(label) && label.trim() ? label.trim() : undefined;
|
|
201
|
+
}
|
|
202
|
+
function toNumber(value) {
|
|
203
|
+
if (isNumber(value) && Number.isFinite(value)) {
|
|
204
|
+
return value;
|
|
205
|
+
}
|
|
206
|
+
if (isString(value) && value.trim()) {
|
|
207
|
+
const parsed = Number(value);
|
|
208
|
+
if (Number.isFinite(parsed)) {
|
|
209
|
+
return parsed;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return undefined;
|
|
213
|
+
}
|
|
214
|
+
function normalizeLinePoints(rawData, categories) {
|
|
215
|
+
if (!Array.isArray(rawData) || rawData.length === 0) {
|
|
216
|
+
return [];
|
|
217
|
+
}
|
|
218
|
+
const first = rawData[0];
|
|
219
|
+
if (isNumber(first)) {
|
|
220
|
+
return zipCategoryValues(categories, rawData);
|
|
221
|
+
}
|
|
222
|
+
const points = [];
|
|
223
|
+
for (const entry of rawData) {
|
|
224
|
+
if (!isObjectLike(entry)) {
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
const row = entry;
|
|
228
|
+
const y = toNumber(row['y'] ?? row['value'] ?? row['count'] ?? row['productCount']);
|
|
229
|
+
if (y === undefined) {
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
const x = row['x'] ??
|
|
233
|
+
row['label'] ??
|
|
234
|
+
row['name'] ??
|
|
235
|
+
row['brandLabel'] ??
|
|
236
|
+
row['brandTitle'] ??
|
|
237
|
+
row['brand'] ??
|
|
238
|
+
row['category'];
|
|
239
|
+
if (x == null || x === '') {
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
points.push({ x: x, y });
|
|
243
|
+
}
|
|
244
|
+
return points;
|
|
245
|
+
}
|
|
246
|
+
function toLineChartSeries(row, index, categories) {
|
|
247
|
+
const data = normalizeLinePoints(row['data'], categories);
|
|
248
|
+
if (data.length === 0) {
|
|
249
|
+
return undefined;
|
|
250
|
+
}
|
|
251
|
+
return {
|
|
252
|
+
id: isString(row['id']) ? row['id'] : `series-${index + 1}`,
|
|
253
|
+
label: seriesLabel(row),
|
|
254
|
+
lineColor: isString(row['lineColor']) ? row['lineColor'] : undefined,
|
|
255
|
+
fillColor: isString(row['fillColor']) ? row['fillColor'] : undefined,
|
|
256
|
+
data,
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
const LINE_CHART_LABEL_KEYS = ['label', 'name', 'brandLabel', 'brandTitle', 'brand', 'category'];
|
|
260
|
+
function isLineChartLabelValueRow(row) {
|
|
261
|
+
if (Array.isArray(row['data'])) {
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
const labelRaw = LINE_CHART_LABEL_KEYS.map((key) => row[key]).find((value) => value != null && value !== '');
|
|
265
|
+
const y = toNumber(row['value'] ?? row['y'] ?? row['count'] ?? row['productCount']);
|
|
266
|
+
return labelRaw != null && y !== undefined;
|
|
267
|
+
}
|
|
268
|
+
/** Bar/donut-style `{ label, value }[]` → one line series (common AI chart agent output). */
|
|
269
|
+
function normalizeLineSeriesFromLabelValueItems(rawItems) {
|
|
270
|
+
const points = [];
|
|
271
|
+
for (const entry of rawItems) {
|
|
272
|
+
if (!isObjectLike(entry)) {
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
const row = entry;
|
|
276
|
+
if (!isLineChartLabelValueRow(row)) {
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
const labelRaw = LINE_CHART_LABEL_KEYS.map((key) => row[key]).find((value) => value != null && value !== '');
|
|
280
|
+
const y = toNumber(row['value'] ?? row['y'] ?? row['count'] ?? row['productCount']);
|
|
281
|
+
if (labelRaw == null || y === undefined) {
|
|
282
|
+
continue;
|
|
283
|
+
}
|
|
284
|
+
points.push({ x: String(labelRaw), y });
|
|
285
|
+
}
|
|
286
|
+
if (points.length === 0) {
|
|
287
|
+
return [];
|
|
288
|
+
}
|
|
289
|
+
return [{ id: 'series-1', data: points }];
|
|
290
|
+
}
|
|
291
|
+
function tryNormalizeLineSeriesFromLabelValueRows(rawItems) {
|
|
292
|
+
if (!Array.isArray(rawItems) || rawItems.length === 0) {
|
|
293
|
+
return [];
|
|
294
|
+
}
|
|
295
|
+
const rows = rawItems.filter(isObjectLike);
|
|
296
|
+
if (rows.length === 0 || rows.length !== rawItems.length || !rows.every(isLineChartLabelValueRow)) {
|
|
297
|
+
return [];
|
|
298
|
+
}
|
|
299
|
+
return normalizeLineSeriesFromLabelValueItems(rawItems);
|
|
300
|
+
}
|
|
301
|
+
function normalizeLineSeriesFromOptions(opts) {
|
|
302
|
+
const categories = readAxisCategories(opts);
|
|
303
|
+
const series = [];
|
|
304
|
+
const fromDataSource = opts['dataSource'] ?? (Array.isArray(opts['data']) ? opts['data'] : undefined);
|
|
305
|
+
if (Array.isArray(fromDataSource) && fromDataSource.length > 0) {
|
|
306
|
+
fromDataSource.forEach((entry, index) => {
|
|
307
|
+
if (!isObjectLike(entry)) {
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
const normalized = toLineChartSeries(entry, index, categories);
|
|
311
|
+
if (normalized) {
|
|
312
|
+
series.push(normalized);
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
if (series.length > 0) {
|
|
316
|
+
return series;
|
|
317
|
+
}
|
|
318
|
+
const labelValueFromDataSource = tryNormalizeLineSeriesFromLabelValueRows(fromDataSource);
|
|
319
|
+
if (labelValueFromDataSource.length > 0) {
|
|
320
|
+
return labelValueFromDataSource;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
const inlineData = opts['data'];
|
|
324
|
+
if (Array.isArray(inlineData) && inlineData.length > 0) {
|
|
325
|
+
const points = normalizeLinePoints(inlineData, categories);
|
|
326
|
+
if (points.length > 0) {
|
|
327
|
+
return [{ id: 'series-1', data: points }];
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
if (inlineData != null && typeof inlineData === 'object' && !Array.isArray(inlineData)) {
|
|
331
|
+
const wrapped = inlineData;
|
|
332
|
+
const wrappedSeries = wrapped['series'];
|
|
333
|
+
if (Array.isArray(wrappedSeries) && wrappedSeries.length > 0) {
|
|
334
|
+
const points = normalizeLinePoints(wrappedSeries, categories);
|
|
335
|
+
if (points.length > 0) {
|
|
336
|
+
return [{ id: 'series-1', data: points }];
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
const rawSeries = opts['series'];
|
|
341
|
+
if (!Array.isArray(rawSeries) || rawSeries.length === 0) {
|
|
342
|
+
return [];
|
|
343
|
+
}
|
|
344
|
+
rawSeries.forEach((entry, index) => {
|
|
345
|
+
if (!isObjectLike(entry)) {
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
const normalized = toLineChartSeries(entry, index, categories);
|
|
349
|
+
if (normalized) {
|
|
350
|
+
series.push(normalized);
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
if (series.length > 0) {
|
|
354
|
+
return series;
|
|
355
|
+
}
|
|
356
|
+
return tryNormalizeLineSeriesFromLabelValueRows(rawSeries);
|
|
357
|
+
}
|
|
358
|
+
function normalizeLabelValueItems(opts, labelKeys) {
|
|
359
|
+
const categories = readAxisCategories(opts);
|
|
360
|
+
const rawItems = opts['items'] ?? opts['dataSource'] ?? opts['data'];
|
|
361
|
+
const items = [];
|
|
362
|
+
if (Array.isArray(rawItems) && rawItems.length > 0) {
|
|
363
|
+
rawItems.forEach((entry, index) => {
|
|
364
|
+
if (!isObjectLike(entry)) {
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
const row = entry;
|
|
368
|
+
const labelRaw = labelKeys.map((key) => row[key]).find((value) => value != null && value !== '');
|
|
369
|
+
const label = labelRaw != null ? String(labelRaw) : '';
|
|
370
|
+
const value = toNumber(row['value'] ?? row['y'] ?? row['count'] ?? row['productCount']);
|
|
371
|
+
if (!label || value === undefined) {
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
items.push({
|
|
375
|
+
id: isString(row['id']) ? row['id'] : `item-${index + 1}`,
|
|
376
|
+
label,
|
|
377
|
+
value,
|
|
378
|
+
color: isString(row['color']) ? row['color'] : undefined,
|
|
379
|
+
});
|
|
380
|
+
});
|
|
381
|
+
return items;
|
|
382
|
+
}
|
|
383
|
+
const rawSeries = opts['series'];
|
|
384
|
+
if (Array.isArray(rawSeries) && rawSeries.length > 0 && categories.length > 0) {
|
|
385
|
+
const first = rawSeries[0];
|
|
386
|
+
if (!isObjectLike(first)) {
|
|
387
|
+
return [];
|
|
388
|
+
}
|
|
389
|
+
const row = first;
|
|
390
|
+
const values = Array.isArray(row['data']) ? row['data'] : [];
|
|
391
|
+
return zipCategoryValues(categories, values).map((point, index) => ({
|
|
392
|
+
id: `item-${index + 1}`,
|
|
393
|
+
label: String(point.x),
|
|
394
|
+
value: point.y,
|
|
395
|
+
}));
|
|
396
|
+
}
|
|
397
|
+
return [];
|
|
398
|
+
}
|
|
399
|
+
/** Loads collection items when `options.dataSource` is a query key. */
|
|
400
|
+
async function loadQueryDataSourceItems(queryExecutor, queryKey) {
|
|
401
|
+
const key = queryKey.trim();
|
|
402
|
+
if (!key) {
|
|
403
|
+
return [];
|
|
404
|
+
}
|
|
405
|
+
try {
|
|
406
|
+
const result = await queryExecutor.fetch(key, { skip: 0, take: 10_000, sort: [] });
|
|
407
|
+
const page = runtimeQueryCollectionData(result);
|
|
408
|
+
return Array.isArray(page?.items) ? page.items : [];
|
|
409
|
+
}
|
|
410
|
+
catch {
|
|
411
|
+
return [];
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
/** Merges `xAxisLabel` / `yAxisLabel` with AI `xAxis.title` / `yAxis.title` fallbacks. */
|
|
415
|
+
function resolveChartAxisLabels(opts) {
|
|
416
|
+
const xAxisLabel = opts['xAxisLabel'] ?? readAxisTitle(opts['xAxis']);
|
|
417
|
+
const yAxisLabel = opts['yAxisLabel'] ?? readAxisTitle(opts['yAxis']);
|
|
418
|
+
return { xAxisLabel, yAxisLabel };
|
|
419
|
+
}
|
|
420
|
+
//#endregion
|
|
421
|
+
//#region ----- Line chart -----
|
|
422
|
+
async function loadLineChartSeries(opts, deps) {
|
|
423
|
+
expandAiChartWidgetOptions(opts);
|
|
424
|
+
if (deps.queryKey) {
|
|
425
|
+
const payload = await fetchChartQueryResult(deps.queryExecutor, deps.queryKey, deps.queryInput);
|
|
426
|
+
return applyChartColorRulesFromOptions(payload?.series ?? [], opts, 'lineColor');
|
|
427
|
+
}
|
|
428
|
+
const inline = normalizeLineSeriesFromOptions(opts);
|
|
429
|
+
if (inline.length > 0) {
|
|
430
|
+
return applyChartColorRulesFromOptions(inline, opts, 'lineColor');
|
|
431
|
+
}
|
|
432
|
+
const dataSource = opts['dataSource'];
|
|
433
|
+
if (isString(dataSource) && dataSource.trim()) {
|
|
434
|
+
const items = await loadQueryDataSourceItems(deps.queryExecutor, dataSource);
|
|
435
|
+
return applyChartColorRulesFromOptions(normalizeLineSeriesFromOptions({ ...opts, dataSource: items }), opts, 'lineColor');
|
|
436
|
+
}
|
|
437
|
+
return [];
|
|
438
|
+
}
|
|
439
|
+
//#endregion
|
|
440
|
+
//#region ----- Bar chart -----
|
|
441
|
+
async function loadBarChartItems(opts, deps) {
|
|
442
|
+
expandAiChartWidgetOptions(opts);
|
|
443
|
+
if (deps.queryKey) {
|
|
444
|
+
const payload = await fetchChartQueryResult(deps.queryExecutor, deps.queryKey, deps.queryInput);
|
|
445
|
+
return applyChartColorRulesFromOptions(payload?.items ?? [], opts);
|
|
446
|
+
}
|
|
447
|
+
const inline = normalizeLabelValueItems(opts, ['label', 'name', 'brand', 'brandLabel', 'brandTitle', 'category']);
|
|
448
|
+
if (inline.length > 0) {
|
|
449
|
+
return applyChartColorRulesFromOptions(inline.map((item) => ({
|
|
450
|
+
id: item.id ?? item.label,
|
|
451
|
+
label: item.label,
|
|
452
|
+
value: item.value,
|
|
453
|
+
color: item.color,
|
|
454
|
+
})), opts);
|
|
455
|
+
}
|
|
456
|
+
const dataSource = opts['dataSource'];
|
|
457
|
+
if (isString(dataSource) && dataSource.trim()) {
|
|
458
|
+
const items = await loadQueryDataSourceItems(deps.queryExecutor, dataSource);
|
|
459
|
+
return applyChartColorRulesFromOptions(normalizeLabelValueItems({ ...opts, dataSource: items }, ['label', 'name', 'brand', 'brandLabel', 'brandTitle', 'category']).map((item) => ({
|
|
460
|
+
id: item.id ?? item.label,
|
|
461
|
+
label: item.label,
|
|
462
|
+
value: item.value,
|
|
463
|
+
color: item.color,
|
|
464
|
+
})), opts);
|
|
465
|
+
}
|
|
466
|
+
return [];
|
|
467
|
+
}
|
|
468
|
+
//#endregion
|
|
469
|
+
//#region ----- Donut chart -----
|
|
470
|
+
async function loadDonutChartItems(opts, deps) {
|
|
471
|
+
expandAiChartWidgetOptions(opts);
|
|
472
|
+
if (deps.queryKey) {
|
|
473
|
+
const payload = await fetchChartQueryResult(deps.queryExecutor, deps.queryKey, deps.queryInput);
|
|
474
|
+
return applyChartColorRulesFromOptions(payload?.items ?? [], opts);
|
|
475
|
+
}
|
|
476
|
+
const inline = normalizeLabelValueItems(opts, ['label', 'name', 'brandLabel', 'brandTitle', 'brand', 'category']);
|
|
477
|
+
if (inline.length > 0) {
|
|
478
|
+
return applyChartColorRulesFromOptions(inline.map((item) => ({
|
|
479
|
+
id: item.id ?? item.label,
|
|
480
|
+
label: item.label,
|
|
481
|
+
value: item.value,
|
|
482
|
+
color: item.color,
|
|
483
|
+
})), opts);
|
|
484
|
+
}
|
|
485
|
+
const dataSource = opts['dataSource'];
|
|
486
|
+
if (isString(dataSource) && dataSource.trim()) {
|
|
487
|
+
const items = await loadQueryDataSourceItems(deps.queryExecutor, dataSource);
|
|
488
|
+
return applyChartColorRulesFromOptions(normalizeLabelValueItems({ ...opts, dataSource: items }, ['label', 'name', 'brandLabel', 'brandTitle', 'brand', 'category']).map((item) => ({
|
|
489
|
+
id: item.id ?? item.label,
|
|
490
|
+
label: item.label,
|
|
491
|
+
value: item.value,
|
|
492
|
+
color: item.color,
|
|
493
|
+
})), opts);
|
|
494
|
+
}
|
|
495
|
+
return [];
|
|
496
|
+
}
|
|
497
|
+
//#endregion
|
|
498
|
+
//#region ----- Funnel chart -----
|
|
499
|
+
async function loadFunnelChartItems(opts, deps) {
|
|
500
|
+
expandAiChartWidgetOptions(opts);
|
|
501
|
+
if (deps.queryKey) {
|
|
502
|
+
const payload = await fetchChartQueryResult(deps.queryExecutor, deps.queryKey, deps.queryInput);
|
|
503
|
+
return applyChartColorRulesFromOptions(payload?.items ?? [], opts);
|
|
504
|
+
}
|
|
505
|
+
const inline = normalizeLabelValueItems(opts, ['name', 'label', 'brandLabel', 'brandTitle', 'brand', 'category']);
|
|
506
|
+
if (inline.length > 0) {
|
|
507
|
+
return applyChartColorRulesFromOptions(inline.map((item) => ({
|
|
508
|
+
id: item.id ?? item.label,
|
|
509
|
+
name: item.label,
|
|
510
|
+
value: item.value,
|
|
511
|
+
color: item.color,
|
|
512
|
+
})), opts);
|
|
513
|
+
}
|
|
514
|
+
const dataSource = opts['dataSource'];
|
|
515
|
+
if (isString(dataSource) && dataSource.trim()) {
|
|
516
|
+
const items = await loadQueryDataSourceItems(deps.queryExecutor, dataSource);
|
|
517
|
+
return loadFunnelChartItems({ ...opts, dataSource: items }, { ...deps, queryKey: undefined });
|
|
518
|
+
}
|
|
519
|
+
return [];
|
|
520
|
+
}
|
|
521
|
+
//#endregion
|
|
522
|
+
//#region ----- Heatmap chart -----
|
|
523
|
+
async function loadHeatmapChartItems(opts, deps) {
|
|
524
|
+
expandAiChartWidgetOptions(opts);
|
|
525
|
+
if (deps.queryKey) {
|
|
526
|
+
const payload = await fetchChartQueryResult(deps.queryExecutor, deps.queryKey, deps.queryInput);
|
|
527
|
+
return payload?.items ?? [];
|
|
528
|
+
}
|
|
529
|
+
const rawItems = opts['items'] ?? opts['dataSource'] ?? opts['data'];
|
|
530
|
+
if (Array.isArray(rawItems) && rawItems.length > 0) {
|
|
531
|
+
const items = [];
|
|
532
|
+
rawItems.forEach((entry) => {
|
|
533
|
+
if (!isObjectLike(entry)) {
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
536
|
+
const row = entry;
|
|
537
|
+
const x = row['x'];
|
|
538
|
+
const y = row['y'];
|
|
539
|
+
const value = toNumber(row['value'] ?? row['v']);
|
|
540
|
+
if (x == null || y == null || value === undefined) {
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
const item = {
|
|
544
|
+
x: x,
|
|
545
|
+
y: y,
|
|
546
|
+
value,
|
|
547
|
+
};
|
|
548
|
+
if (row['label'] != null) {
|
|
549
|
+
item.label = String(row['label']);
|
|
550
|
+
}
|
|
551
|
+
items.push(item);
|
|
552
|
+
});
|
|
553
|
+
return items;
|
|
554
|
+
}
|
|
555
|
+
const dataSource = opts['dataSource'];
|
|
556
|
+
if (isString(dataSource) && dataSource.trim()) {
|
|
557
|
+
const items = await loadQueryDataSourceItems(deps.queryExecutor, dataSource);
|
|
558
|
+
return loadHeatmapChartItems({ ...opts, dataSource: items }, { ...deps, queryKey: undefined });
|
|
559
|
+
}
|
|
560
|
+
return [];
|
|
561
|
+
}
|
|
562
|
+
//#endregion
|
|
563
|
+
//#region ----- Gauge chart -----
|
|
564
|
+
async function loadGaugeChartValue(opts, deps) {
|
|
565
|
+
expandAiChartWidgetOptions(opts);
|
|
566
|
+
if (deps.queryKey) {
|
|
567
|
+
const payload = await fetchChartQueryResult(deps.queryExecutor, deps.queryKey, deps.queryInput);
|
|
568
|
+
return typeof payload?.value === 'number' ? payload.value : 0;
|
|
569
|
+
}
|
|
570
|
+
const dataSource = opts['dataSource'];
|
|
571
|
+
if (isNumber(dataSource)) {
|
|
572
|
+
return dataSource;
|
|
573
|
+
}
|
|
574
|
+
if (isString(dataSource) && dataSource.trim()) {
|
|
575
|
+
const payload = await fetchChartQueryResult(deps.queryExecutor, dataSource.trim());
|
|
576
|
+
if (isNumber(payload)) {
|
|
577
|
+
return payload;
|
|
578
|
+
}
|
|
579
|
+
if (payload && typeof payload === 'object' && isNumber(payload.value)) {
|
|
580
|
+
return payload.value;
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
const fallback = toNumber(opts['value']);
|
|
584
|
+
return fallback ?? 0;
|
|
585
|
+
}
|
|
586
|
+
//#endregion
|
|
587
|
+
|
|
588
|
+
export { loadDonutChartItems as a, loadFunnelChartItems as b, loadGaugeChartValue as c, loadHeatmapChartItems as d, loadLineChartSeries as e, loadBarChartItems as l, resolveChartAxisLabels as r };
|
|
589
|
+
//# sourceMappingURL=acorex-platform-module-dashboard-management-client-chart-widget-data.util-DgCBHS1p.mjs.map
|