@qrvey/utils 1.5.0-3 → 1.5.0-6
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/README.md +1 -1
- package/dist/charts/adapters/endpointData.d.ts +90 -0
- package/dist/charts/adapters/endpointData.js +511 -0
- package/dist/charts/adapters/endpointDataGet.d.ts +14 -0
- package/dist/charts/adapters/endpointDataGet.js +428 -0
- package/dist/charts/adapters/endpointDataValidators.d.ts +4 -0
- package/dist/charts/adapters/endpointDataValidators.js +54 -0
- package/dist/charts/adapters/index.d.ts +3 -0
- package/dist/charts/adapters/index.js +3 -0
- package/dist/charts/index.d.ts +1 -0
- package/dist/charts/index.js +1 -0
- package/dist/cjs/charts/adapters/endpointData.d.ts +90 -0
- package/dist/cjs/charts/adapters/endpointData.js +517 -0
- package/dist/cjs/charts/adapters/endpointDataGet.d.ts +14 -0
- package/dist/cjs/charts/adapters/endpointDataGet.js +444 -0
- package/dist/cjs/charts/adapters/endpointDataValidators.d.ts +4 -0
- package/dist/cjs/charts/adapters/endpointDataValidators.js +61 -0
- package/dist/cjs/charts/adapters/index.d.ts +3 -0
- package/dist/cjs/charts/adapters/index.js +19 -0
- package/dist/cjs/charts/index.d.ts +1 -0
- package/dist/cjs/charts/index.js +1 -0
- package/dist/cjs/column_format/helpers/defineTableChartFormat.js +2 -2
- package/dist/cjs/column_format/helpers/defineXYChartFormat.js +4 -3
- package/dist/cjs/constants/Charts.Const.d.ts +1 -0
- package/dist/cjs/constants/Charts.Const.js +1 -0
- package/dist/cjs/format/definition.d.ts +1 -0
- package/dist/cjs/format/definition.js +8 -1
- package/dist/cjs/format/duration/durationFormatter.js +1 -5
- package/dist/cjs/globalization/interfaces/chart_builder/II18nChartBuilder.d.ts +2 -0
- package/dist/cjs/globalization/interfaces/chart_builder/II18nChartBuilderDurationParts.d.ts +9 -0
- package/dist/cjs/globalization/interfaces/chart_builder/II18nChartBuilderDurationParts.js +2 -0
- package/dist/cjs/globalization/interfaces/chart_builder/index.d.ts +1 -0
- package/dist/cjs/globalization/interfaces/chart_builder/index.js +1 -0
- package/dist/cjs/globalization/interfaces/common/II18nCommon.d.ts +1 -0
- package/dist/cjs/globalization/interfaces/panel/II18nPanelMenu.d.ts +1 -0
- package/dist/cjs/globalization/interfaces/style_themes/II18nStyleThemesTheme.d.ts +1 -0
- package/dist/cjs/globalization/labels/chart_builder/I18N_CHART_BUILDER.js +8 -0
- package/dist/cjs/globalization/labels/chart_builder/I18N_CHART_BUILDER_STYLE_OPTIONS.js +2 -2
- package/dist/cjs/globalization/labels/common/I18N_COMMON.js +1 -0
- package/dist/cjs/globalization/labels/panel/I18N_PANEL.js +1 -0
- package/dist/cjs/globalization/labels/style_themes/I18N_STYLE_THEMES.js +1 -0
- package/dist/column_format/helpers/defineTableChartFormat.js +2 -2
- package/dist/column_format/helpers/defineXYChartFormat.js +4 -3
- package/dist/constants/Charts.Const.d.ts +1 -0
- package/dist/constants/Charts.Const.js +1 -0
- package/dist/format/definition.d.ts +1 -0
- package/dist/format/definition.js +7 -0
- package/dist/format/duration/durationFormatter.js +1 -5
- package/dist/globalization/interfaces/chart_builder/II18nChartBuilder.d.ts +2 -0
- package/dist/globalization/interfaces/chart_builder/II18nChartBuilderDurationParts.d.ts +9 -0
- package/dist/globalization/interfaces/chart_builder/II18nChartBuilderDurationParts.js +1 -0
- package/dist/globalization/interfaces/chart_builder/index.d.ts +1 -0
- package/dist/globalization/interfaces/chart_builder/index.js +1 -0
- package/dist/globalization/interfaces/common/II18nCommon.d.ts +1 -0
- package/dist/globalization/interfaces/panel/II18nPanelMenu.d.ts +1 -0
- package/dist/globalization/interfaces/style_themes/II18nStyleThemesTheme.d.ts +1 -0
- package/dist/globalization/labels/chart_builder/I18N_CHART_BUILDER.js +8 -0
- package/dist/globalization/labels/chart_builder/I18N_CHART_BUILDER_STYLE_OPTIONS.js +2 -2
- package/dist/globalization/labels/common/I18N_COMMON.js +1 -0
- package/dist/globalization/labels/panel/I18N_PANEL.js +1 -0
- package/dist/globalization/labels/style_themes/I18N_STYLE_THEMES.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
import { COLUMN, isNumericalColumn } from "../../columns";
|
|
2
|
+
import { FILTER_OPERATOR, } from "../../filters";
|
|
3
|
+
import { cloneDeep, isEmpty, _get } from "../../general";
|
|
4
|
+
import { isColumnDate } from "./endpointDataValidators";
|
|
5
|
+
export function getDrilldownId(ctx, data) {
|
|
6
|
+
return !ctx.config.isFromAN
|
|
7
|
+
? ctx.config.id || data.chartid || data.chart_id
|
|
8
|
+
: data.chartid || data.chart_id;
|
|
9
|
+
}
|
|
10
|
+
export function getPivotBody(layer, body) {
|
|
11
|
+
const value = _get(layer, "value");
|
|
12
|
+
const pivot = _get(layer, "pivot", _get(layer, "multiserie.serie"));
|
|
13
|
+
const type = _get(layer, "type", "");
|
|
14
|
+
let obj;
|
|
15
|
+
if ((type === "HEATMAP_CHART" || !_get(body, "isDrillDown")) && pivot) {
|
|
16
|
+
const uSorting = _get(pivot, "sorting");
|
|
17
|
+
const sorting = _get(body, "globalSettings.sortX", {});
|
|
18
|
+
let pSortOption = {
|
|
19
|
+
sortBy: uSorting || getValidSortingType(body) === "Label"
|
|
20
|
+
? "CATEGORY"
|
|
21
|
+
: "VALUE",
|
|
22
|
+
sortDirection: ((uSorting && uSorting.order) ||
|
|
23
|
+
sorting.order ||
|
|
24
|
+
"ASC").toUpperCase(),
|
|
25
|
+
};
|
|
26
|
+
/** TODO: Remove line on implement universal sorting on Heatmap */
|
|
27
|
+
pSortOption =
|
|
28
|
+
value && value.calculation
|
|
29
|
+
? { sortBy: "CATEGORY", sortDirection: "ASC" }
|
|
30
|
+
: pSortOption;
|
|
31
|
+
const maxDataPoints = pivot.type !== "DATE"
|
|
32
|
+
? _get(layer, "multiserie.maxDataPoints")
|
|
33
|
+
? _get(layer, "multiserie.maxNumDataPoints", 50)
|
|
34
|
+
: undefined
|
|
35
|
+
: 50;
|
|
36
|
+
obj = {
|
|
37
|
+
linkid: pivot.linkid,
|
|
38
|
+
maxDataPoints: maxDataPoints,
|
|
39
|
+
property: pivot.property,
|
|
40
|
+
qrveyid: pivot.qrveyid || body.qrveyid,
|
|
41
|
+
questionid: pivot.id || pivot.bucketId,
|
|
42
|
+
sortOption: pSortOption,
|
|
43
|
+
type: pivot.type,
|
|
44
|
+
};
|
|
45
|
+
setDateGroup(pivot, pivot, obj);
|
|
46
|
+
}
|
|
47
|
+
return obj;
|
|
48
|
+
}
|
|
49
|
+
export function getValidSortingType(body) {
|
|
50
|
+
const sorting = _get(body, "globalSettings.sortX", {});
|
|
51
|
+
const type = _get(body, "layerList[0].type");
|
|
52
|
+
const notAllowValue = type === "HEATMAP_CHART" && _get(body, "layerList[0].pivot");
|
|
53
|
+
return !sorting.type || sorting.type == "Label" || notAllowValue
|
|
54
|
+
? "Label"
|
|
55
|
+
: "Value";
|
|
56
|
+
}
|
|
57
|
+
export function getCategoryBody(layer, body) {
|
|
58
|
+
var _a;
|
|
59
|
+
const maxDataPoints = _get(body, "globalSettings.maxNumDataPoints");
|
|
60
|
+
const category = _get(layer, "category");
|
|
61
|
+
if (category && category.bucketId)
|
|
62
|
+
category.id = category.bucketId;
|
|
63
|
+
const categoryId = category ? category.id : null;
|
|
64
|
+
const sorting = _get(body, "globalSettings.sortX", {});
|
|
65
|
+
const pSortOption = {
|
|
66
|
+
sortBy: ((_a = sorting === null || sorting === void 0 ? void 0 : sorting.column) === null || _a === void 0 ? void 0 : _a.isHidden)
|
|
67
|
+
? "VALUE"
|
|
68
|
+
: getValidSortingType(body) === "Label"
|
|
69
|
+
? "CATEGORY"
|
|
70
|
+
: "VALUE",
|
|
71
|
+
sortDirection: (sorting.order || "ASC").toUpperCase(),
|
|
72
|
+
order: getSortOrder(sorting, category, body),
|
|
73
|
+
};
|
|
74
|
+
let obj;
|
|
75
|
+
if (categoryId) {
|
|
76
|
+
obj = {
|
|
77
|
+
questionid: category.id,
|
|
78
|
+
linkid: category.linkid,
|
|
79
|
+
maxDataPoints,
|
|
80
|
+
property: category.property,
|
|
81
|
+
qrveyid: category.qrveyid || body.qrveyid,
|
|
82
|
+
type: category.type || body.type,
|
|
83
|
+
sortOption: isNumericalColumn(category) &&
|
|
84
|
+
_get(category, "scaleType.value") === "CONTINUOUS"
|
|
85
|
+
? undefined
|
|
86
|
+
: pSortOption,
|
|
87
|
+
};
|
|
88
|
+
setDateGroup(category, body, obj);
|
|
89
|
+
}
|
|
90
|
+
return obj;
|
|
91
|
+
}
|
|
92
|
+
export function getComboBody(layer, body, filters, newModel = false) {
|
|
93
|
+
const obj = {};
|
|
94
|
+
try {
|
|
95
|
+
const category = getCategoryBody(_get(body, "layerList[0]"), body);
|
|
96
|
+
const pSmallMultiple = getSmallMultipleBody(body.layerList.find((ly) => _get(ly, "combopt.label") === "SMALL_MULTIPLES"), body);
|
|
97
|
+
if (newModel) {
|
|
98
|
+
obj.dimensions = [];
|
|
99
|
+
if (pSmallMultiple)
|
|
100
|
+
obj.dimensions.push(pSmallMultiple);
|
|
101
|
+
obj.dimensions.push(category);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
obj.category = category;
|
|
105
|
+
}
|
|
106
|
+
obj.summaries = getSummariesBody(layer, body);
|
|
107
|
+
obj.aggFilters = getAggFiltersResults(filters, obj.summaries);
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
console.error(error);
|
|
111
|
+
}
|
|
112
|
+
return obj;
|
|
113
|
+
}
|
|
114
|
+
export function getSmallMultipleBody(layer, body) {
|
|
115
|
+
if (!layer)
|
|
116
|
+
return null;
|
|
117
|
+
const category = _get(layer, "smallMultiplesColumn");
|
|
118
|
+
const maxDataPoints = !isColumnDate(category)
|
|
119
|
+
? _get(layer, "visualization.maxMultiplePanels", undefined)
|
|
120
|
+
: undefined;
|
|
121
|
+
if (category && category.bucketId)
|
|
122
|
+
category.id = category.bucketId;
|
|
123
|
+
const categoryId = category ? category.id : null;
|
|
124
|
+
let obj;
|
|
125
|
+
if (categoryId) {
|
|
126
|
+
obj = {
|
|
127
|
+
questionid: category.id,
|
|
128
|
+
linkid: category.linkid,
|
|
129
|
+
maxDataPoints: maxDataPoints,
|
|
130
|
+
property: category.property,
|
|
131
|
+
qrveyid: category.qrveyid || body.qrveyid,
|
|
132
|
+
type: category.type || body.type,
|
|
133
|
+
};
|
|
134
|
+
if (isNumericalColumn(category))
|
|
135
|
+
obj.numberAsRange = true;
|
|
136
|
+
setDateGroup(category, category, obj);
|
|
137
|
+
}
|
|
138
|
+
return obj;
|
|
139
|
+
}
|
|
140
|
+
export function getAggFiltersResults(logics = [], summaries = []) {
|
|
141
|
+
function concatAggFilters(aggFilters, operator = FILTER_OPERATOR.AND) {
|
|
142
|
+
const expressions = aggFilters.filter(Boolean);
|
|
143
|
+
if (!expressions.length)
|
|
144
|
+
return undefined;
|
|
145
|
+
else if (expressions.length === 1)
|
|
146
|
+
return expressions[0];
|
|
147
|
+
return {
|
|
148
|
+
operator,
|
|
149
|
+
expressions: aggFilters.filter(Boolean),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
function getExpressionsInLogic(logicsData = []) {
|
|
153
|
+
return logicsData.reduce((expressions, logic) => {
|
|
154
|
+
logic.filters.forEach((filter) => {
|
|
155
|
+
expressions = expressions.concat(filter.expressions[0].expressions);
|
|
156
|
+
});
|
|
157
|
+
return expressions;
|
|
158
|
+
}, []);
|
|
159
|
+
}
|
|
160
|
+
function getAggregateFilters(logicsData = []) {
|
|
161
|
+
logicsData = cloneDeep(logicsData);
|
|
162
|
+
const aggregateLogics = logicsData.reduce((newLogics, logic) => {
|
|
163
|
+
if (!logic)
|
|
164
|
+
return newLogics;
|
|
165
|
+
// if ([FILTER_SCOPE.DEFAULT, FILTER_SCOPE.CHART].includes(logic.scope)) {
|
|
166
|
+
logic.filters.forEach((filter, index) => {
|
|
167
|
+
const expressions = _get(filter, "expressions[0].expressions");
|
|
168
|
+
if (!isEmpty(expressions)) {
|
|
169
|
+
const aggregateFilters = filter.expressions[0].expressions.filter((expression) => !isEmpty(expression.uiExtras.column.aggregate));
|
|
170
|
+
logic.filters[index].expressions[0].expressions = aggregateFilters;
|
|
171
|
+
if (!filter.expressions[0].expressions.length)
|
|
172
|
+
logic.filters[index] = undefined;
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
logic.filters = logic.filters.filter((filter) => filter);
|
|
176
|
+
if (logic.filters.length)
|
|
177
|
+
newLogics.push(logic);
|
|
178
|
+
//}
|
|
179
|
+
return newLogics;
|
|
180
|
+
}, []);
|
|
181
|
+
return aggregateLogics;
|
|
182
|
+
}
|
|
183
|
+
const aggregateFilters = getAggregateFilters(logics);
|
|
184
|
+
const aggFilters = aggregateFilters
|
|
185
|
+
.map((aggFilter) => {
|
|
186
|
+
const expressions = getExpressionsInLogic([aggFilter]);
|
|
187
|
+
return (expressions &&
|
|
188
|
+
expressions.length && {
|
|
189
|
+
operator: FILTER_OPERATOR.OR,
|
|
190
|
+
expressions: expressions
|
|
191
|
+
.map((expression) => {
|
|
192
|
+
const summaryIndex = summaries.findIndex((summary) => expression.questionid === summary.questionid &&
|
|
193
|
+
expression.qrveyid === summary.qrveyid &&
|
|
194
|
+
expression.linkid === summary.linkid &&
|
|
195
|
+
_get(expression.uiExtras.column, "aggregate") ===
|
|
196
|
+
summary.aggregate);
|
|
197
|
+
if (summaryIndex > -1 ||
|
|
198
|
+
expression.questionType === COLUMN.AGGREGATED_FORMULA) {
|
|
199
|
+
return {
|
|
200
|
+
enabled: expression.enabled,
|
|
201
|
+
summaryIndex,
|
|
202
|
+
validationType: expression.validationType,
|
|
203
|
+
value: expression.value,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
return;
|
|
207
|
+
})
|
|
208
|
+
.filter(Boolean),
|
|
209
|
+
});
|
|
210
|
+
})
|
|
211
|
+
.filter((aggFilter) => aggFilter && aggFilter.expressions && aggFilter.expressions.length);
|
|
212
|
+
return aggFilters && concatAggFilters(aggFilters);
|
|
213
|
+
}
|
|
214
|
+
export function getRefenceBody(layer) {
|
|
215
|
+
let obj;
|
|
216
|
+
try {
|
|
217
|
+
obj = {
|
|
218
|
+
type: "REFERENCE_LINE",
|
|
219
|
+
referenceType: layer.valuetype,
|
|
220
|
+
referenceValue: layer.value,
|
|
221
|
+
valueId: _get(layer, "axis.id"),
|
|
222
|
+
aggregate: _get(layer, "aggregate.label"),
|
|
223
|
+
value: {
|
|
224
|
+
questionid: _get(layer, "axis.id"),
|
|
225
|
+
qrveyid: _get(layer, "axis.qrveyid"),
|
|
226
|
+
linkid: _get(layer, "axis.linkid"),
|
|
227
|
+
property: _get(layer, "axis.property"),
|
|
228
|
+
type: _get(layer, "axis.type", _get(layer, "axis.label")),
|
|
229
|
+
},
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
catch (e) {
|
|
233
|
+
console.error(e);
|
|
234
|
+
}
|
|
235
|
+
return obj;
|
|
236
|
+
}
|
|
237
|
+
export function getTrendBody(layer) {
|
|
238
|
+
let obj;
|
|
239
|
+
try {
|
|
240
|
+
obj = {
|
|
241
|
+
type: "TREND_LINE",
|
|
242
|
+
trendType: layer.trendtype.label,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
catch (e) {
|
|
246
|
+
console.error(e);
|
|
247
|
+
}
|
|
248
|
+
return obj;
|
|
249
|
+
}
|
|
250
|
+
export function getRefenceBodyU(layer, body) {
|
|
251
|
+
let obj;
|
|
252
|
+
const layerType = layer.valuetype === "Fixed";
|
|
253
|
+
const pSmallMultiple = getSmallMultipleBody(body.layerList.find((ly) => _get(ly, "combopt.label") === "SMALL_MULTIPLES"), body);
|
|
254
|
+
if (!layerType) {
|
|
255
|
+
obj = {
|
|
256
|
+
summaries: [
|
|
257
|
+
{
|
|
258
|
+
aggregate: _get(layer, "aggregate.label"),
|
|
259
|
+
linkid: _get(layer, "axis.linkid"),
|
|
260
|
+
property: _get(layer, "axis.property"),
|
|
261
|
+
qrveyid: _get(layer, "axis.qrveyid") || body.qrveyid,
|
|
262
|
+
questionid: _get(layer, "axis.id"),
|
|
263
|
+
type: _get(layer, "axis.type", _get(layer, "axis.label")),
|
|
264
|
+
},
|
|
265
|
+
],
|
|
266
|
+
};
|
|
267
|
+
if (pSmallMultiple)
|
|
268
|
+
obj.dimensions = [pSmallMultiple];
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
obj = { type: "REFERENCE_LINE" };
|
|
272
|
+
}
|
|
273
|
+
return obj;
|
|
274
|
+
}
|
|
275
|
+
export function getLayerBody(layer, dateGroup, qrveyid) {
|
|
276
|
+
let obj;
|
|
277
|
+
try {
|
|
278
|
+
if (_get(layer, "mapType.label") == "DOT")
|
|
279
|
+
obj = {};
|
|
280
|
+
// eslint-disable-next-line no-extra-boolean-cast
|
|
281
|
+
else if (!!~["BOXWHISKER_CHART", "WORD_CLOUD"].indexOf(layer.type)) {
|
|
282
|
+
obj = {
|
|
283
|
+
valueId: _get(layer, "value.id"),
|
|
284
|
+
aggregate: _get(layer, "aggregate.label"),
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
obj = {
|
|
289
|
+
valueId: layer.value.id,
|
|
290
|
+
aggregate: layer.aggregate.label,
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
obj.type =
|
|
294
|
+
layer.type || _get(layer, "layer.label", _get(layer, "combopt.label"));
|
|
295
|
+
obj.property = layer.property;
|
|
296
|
+
if (layer.value)
|
|
297
|
+
obj.value = {
|
|
298
|
+
questionid: layer.value.id,
|
|
299
|
+
type: layer.value.type,
|
|
300
|
+
qrveyid: layer.value.qrveyid,
|
|
301
|
+
linkid: layer.value.linkid,
|
|
302
|
+
property: layer.value.property,
|
|
303
|
+
};
|
|
304
|
+
if (layer.mapType)
|
|
305
|
+
obj.mapType = layer.mapType.label;
|
|
306
|
+
if (layer.multiserie && layer.multiserie.serie) {
|
|
307
|
+
if (layer.multiserie.serie.type === "BUCKET") {
|
|
308
|
+
obj.multiValueId = layer.multiserie.serie.bucketId; //required
|
|
309
|
+
obj.multiValueType = "BUCKET";
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
obj.multiValueId = layer.multiserie.serie.id; //required
|
|
313
|
+
obj.multiValueType = undefined;
|
|
314
|
+
}
|
|
315
|
+
obj.isMulti = true;
|
|
316
|
+
obj.multiValueAxis = {
|
|
317
|
+
questionid: layer.multiserie.serie.id,
|
|
318
|
+
groupType: _get(layer, "multiserie.type"),
|
|
319
|
+
questionType: _get(layer, "multiserie.serie.type"),
|
|
320
|
+
type: _get(layer, "multiserie.serie.type"),
|
|
321
|
+
groupValue: _get(layer, "multiserie.dateGroup.label"),
|
|
322
|
+
property: _get(layer, "multiserie.serie.property"),
|
|
323
|
+
qrveyid: _get(layer, "multiserie.serie.qrveyid"),
|
|
324
|
+
linkid: _get(layer, "multiserie.serie.linkid"),
|
|
325
|
+
};
|
|
326
|
+
if (_get(layer, "multiserie.maxDataPoints", false))
|
|
327
|
+
obj.multiValueAxis.maxDataPoints = _get(layer, "multiserie.maxNumDataPoints", 50);
|
|
328
|
+
}
|
|
329
|
+
if (dateGroup && dateGroup.label) {
|
|
330
|
+
obj.groupType = "DATE";
|
|
331
|
+
obj.groupValue = dateGroup.label;
|
|
332
|
+
}
|
|
333
|
+
if (layer.pivot) {
|
|
334
|
+
obj.pivot = {};
|
|
335
|
+
obj.pivot.qrveyid = _get(layer, "pivot.qrveyid", qrveyid);
|
|
336
|
+
obj.pivot.linkid = _get(layer, "pivot.linkid");
|
|
337
|
+
obj.pivot.groupType = _get(layer, "pivot.type");
|
|
338
|
+
obj.pivot.type = _get(layer, "pivot.type");
|
|
339
|
+
const labelBucketId = _get(layer, "pivot.bucketId", null);
|
|
340
|
+
if (labelBucketId !== null) {
|
|
341
|
+
obj.pivot.labelBucketId = labelBucketId;
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
obj.pivot.questionid = _get(layer, "pivot.id");
|
|
345
|
+
}
|
|
346
|
+
obj.pivot.groupValue = _get(layer, "pivot.dateGroup.label");
|
|
347
|
+
obj.pivot.property = _get(layer, "pivot.property");
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
catch (error) {
|
|
351
|
+
console.error(error);
|
|
352
|
+
}
|
|
353
|
+
return obj;
|
|
354
|
+
}
|
|
355
|
+
function getSortOrder(sorting = {}, category = {}, body = {}) {
|
|
356
|
+
var _a;
|
|
357
|
+
const order = (sorting.order || "ASC").toUpperCase();
|
|
358
|
+
const column = sorting.column || {};
|
|
359
|
+
const aggregate = (_a = body.globalSettings) === null || _a === void 0 ? void 0 : _a.sortAggregation;
|
|
360
|
+
return column.isHidden
|
|
361
|
+
? [
|
|
362
|
+
{
|
|
363
|
+
hidden: true,
|
|
364
|
+
type: column.type,
|
|
365
|
+
sortDirection: order,
|
|
366
|
+
questionid: column.id,
|
|
367
|
+
qrveyid: column.qrveyid,
|
|
368
|
+
aggregate: aggregate === null || aggregate === void 0 ? void 0 : aggregate.label,
|
|
369
|
+
property: column.property || category.property,
|
|
370
|
+
},
|
|
371
|
+
]
|
|
372
|
+
: [
|
|
373
|
+
{
|
|
374
|
+
summaryIndex: 0,
|
|
375
|
+
sortDirection: order,
|
|
376
|
+
},
|
|
377
|
+
];
|
|
378
|
+
}
|
|
379
|
+
export function setDateGroup(column, body, obj) {
|
|
380
|
+
if (isColumnDate(column) && !isEmpty(_get(body, "dateGroup.label"))) {
|
|
381
|
+
obj["groupType"] = COLUMN.DATE;
|
|
382
|
+
obj["groupValue"] = body.dateGroup.label;
|
|
383
|
+
if (_get(body, "dateGroup.datePart", false)) {
|
|
384
|
+
obj["maxDataPoints"] = obj["maxDataPoints"] || 60;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
export function getSummariesBody(layer, body) {
|
|
389
|
+
let value = _get(layer, "value");
|
|
390
|
+
let aggregate = _get(layer, "aggregate");
|
|
391
|
+
if (layer.type === "WORD_CLOUD" && !value)
|
|
392
|
+
value = _get(layer, "category");
|
|
393
|
+
if (layer.type === "WORD_CLOUD" && !aggregate)
|
|
394
|
+
aggregate = { label: "COUNT", text: "Count" };
|
|
395
|
+
let obj;
|
|
396
|
+
if (layer.type === "MINMAX_CHART" && value) {
|
|
397
|
+
const min = aggregateGenerator("MIN", value.linkid, value.property, value.qrveyid || body.qrveyid, value.id, value.type);
|
|
398
|
+
const max = aggregateGenerator("MAX", value.linkid, value.property, value.qrveyid || body.qrveyid, value.id, value.type);
|
|
399
|
+
obj = [min, max];
|
|
400
|
+
if (body.globalSettings.average)
|
|
401
|
+
obj.push(aggregateGenerator("AVG", value.linkid, value.property, value.qrveyid || body.qrveyid, value.id, value.type));
|
|
402
|
+
}
|
|
403
|
+
else if (value) {
|
|
404
|
+
obj = [
|
|
405
|
+
{
|
|
406
|
+
aggregate: aggregate && aggregate.label,
|
|
407
|
+
linkid: value.linkid,
|
|
408
|
+
property: value.property,
|
|
409
|
+
qrveyid: value.qrveyid || body.qrveyid,
|
|
410
|
+
questionid: value.id,
|
|
411
|
+
type: value.type,
|
|
412
|
+
},
|
|
413
|
+
];
|
|
414
|
+
if (value.calculation)
|
|
415
|
+
obj[0].calculations = value.calculation;
|
|
416
|
+
}
|
|
417
|
+
return obj;
|
|
418
|
+
}
|
|
419
|
+
function aggregateGenerator(aggregate, linkid, property, qrveyid, questionid, type) {
|
|
420
|
+
return {
|
|
421
|
+
type,
|
|
422
|
+
linkid,
|
|
423
|
+
qrveyid,
|
|
424
|
+
property,
|
|
425
|
+
questionid,
|
|
426
|
+
aggregate: aggregate !== null && aggregate !== void 0 ? aggregate : "SUM",
|
|
427
|
+
};
|
|
428
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function isNotValid(mainLayer: any): boolean;
|
|
2
|
+
export declare function validChartTypeWithEndPoint(chartType: any): boolean;
|
|
3
|
+
export declare function hasMinorVersion(version: any, current: any): boolean;
|
|
4
|
+
export declare function isColumnDate(column: any): boolean;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { COLUMN } from "../../columns";
|
|
2
|
+
import { CHART_TYPE } from "../../constants";
|
|
3
|
+
export function isNotValid(mainLayer) {
|
|
4
|
+
if (!mainLayer)
|
|
5
|
+
return;
|
|
6
|
+
const chartType = mainLayer.type;
|
|
7
|
+
switch (chartType) {
|
|
8
|
+
case CHART_TYPE.GEO_CHART:
|
|
9
|
+
if (mainLayer.mapType && mainLayer.mapType.label === "DOT")
|
|
10
|
+
return !mainLayer.category;
|
|
11
|
+
break;
|
|
12
|
+
case CHART_TYPE.WORD_CLOUD:
|
|
13
|
+
return !mainLayer.category;
|
|
14
|
+
case CHART_TYPE.BOXWHISKER_CHART:
|
|
15
|
+
return !mainLayer.value;
|
|
16
|
+
case CHART_TYPE.MINMAX_CHART:
|
|
17
|
+
return !mainLayer.value;
|
|
18
|
+
case CHART_TYPE.TABLE_CHART:
|
|
19
|
+
case CHART_TYPE.CROSSTAB_CHART:
|
|
20
|
+
case CHART_TYPE.EXPANDABLE_TABLE_CHART:
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
return (!mainLayer.category ||
|
|
24
|
+
!mainLayer.value ||
|
|
25
|
+
(chartType !== "SYMBOL_CHART" && !mainLayer.aggregate));
|
|
26
|
+
}
|
|
27
|
+
export function validChartTypeWithEndPoint(chartType) {
|
|
28
|
+
return [
|
|
29
|
+
CHART_TYPE.BAR_CHART,
|
|
30
|
+
CHART_TYPE.LINE_CHART,
|
|
31
|
+
CHART_TYPE.MINMAX_CHART,
|
|
32
|
+
CHART_TYPE.SYMBOL_CHART,
|
|
33
|
+
CHART_TYPE.PIE_CHART,
|
|
34
|
+
CHART_TYPE.HEATMAP_CHART,
|
|
35
|
+
CHART_TYPE.WORD_CLOUD,
|
|
36
|
+
CHART_TYPE.FUNNEL_CHART,
|
|
37
|
+
].includes(chartType);
|
|
38
|
+
}
|
|
39
|
+
export function hasMinorVersion(version, current) {
|
|
40
|
+
const splitVersion = (v) => v.split(".").map((t) => parseInt(t));
|
|
41
|
+
const currentVersion = splitVersion(current);
|
|
42
|
+
const chartVersion = splitVersion(version);
|
|
43
|
+
if (chartVersion[0] < currentVersion[0])
|
|
44
|
+
return true;
|
|
45
|
+
else if (chartVersion[1] < currentVersion[1])
|
|
46
|
+
return true;
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
export function isColumnDate(column) {
|
|
50
|
+
if (column == null)
|
|
51
|
+
return;
|
|
52
|
+
return (column.type === COLUMN.DATE ||
|
|
53
|
+
(column.type === COLUMN.FORMULA && column.formulaType === "date"));
|
|
54
|
+
}
|
package/dist/charts/index.d.ts
CHANGED
package/dist/charts/index.js
CHANGED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { IFUData } from "../../filters";
|
|
2
|
+
export declare function configSetup(config?: any): {
|
|
3
|
+
config: {
|
|
4
|
+
id: any;
|
|
5
|
+
data: any;
|
|
6
|
+
type: any;
|
|
7
|
+
domain: any;
|
|
8
|
+
model: any;
|
|
9
|
+
tab_id: any;
|
|
10
|
+
app_id: any;
|
|
11
|
+
api_key: any;
|
|
12
|
+
user_id: any;
|
|
13
|
+
view_id: any;
|
|
14
|
+
page_id: any;
|
|
15
|
+
chart_id: any;
|
|
16
|
+
qv_token: any;
|
|
17
|
+
qrvey_id: any;
|
|
18
|
+
question: any;
|
|
19
|
+
metric_id: any;
|
|
20
|
+
summary_id: any;
|
|
21
|
+
formulaType: any;
|
|
22
|
+
summary_type: any;
|
|
23
|
+
custom_tokens: any;
|
|
24
|
+
section: any;
|
|
25
|
+
panel_view: any;
|
|
26
|
+
previewFilters: any;
|
|
27
|
+
filterData: any;
|
|
28
|
+
i18n: any;
|
|
29
|
+
visibleFilters: IFUData;
|
|
30
|
+
appliedFilters: IFUData;
|
|
31
|
+
customDrillLogic: any[];
|
|
32
|
+
isFromAN: any;
|
|
33
|
+
editable: any;
|
|
34
|
+
inBuilder: any;
|
|
35
|
+
clickable: any;
|
|
36
|
+
userFilters: any;
|
|
37
|
+
customdrill: any;
|
|
38
|
+
widgetConfig: any;
|
|
39
|
+
drilldowns: any;
|
|
40
|
+
filterPermissions: any;
|
|
41
|
+
chartBuilderConfig: any;
|
|
42
|
+
other_config: any;
|
|
43
|
+
predefined_filters: any;
|
|
44
|
+
locale: any;
|
|
45
|
+
lang: string;
|
|
46
|
+
panel: {
|
|
47
|
+
header: {
|
|
48
|
+
menu: any;
|
|
49
|
+
filter: any;
|
|
50
|
+
draggable: any;
|
|
51
|
+
title_prefix: any;
|
|
52
|
+
fit_panel: any;
|
|
53
|
+
visible: any;
|
|
54
|
+
ui: {
|
|
55
|
+
isFiltered: boolean;
|
|
56
|
+
isDisplayReady: boolean;
|
|
57
|
+
isScrollableXY: boolean;
|
|
58
|
+
};
|
|
59
|
+
externalDownload: any;
|
|
60
|
+
};
|
|
61
|
+
body: {
|
|
62
|
+
popup: any;
|
|
63
|
+
tooltip: any;
|
|
64
|
+
hasTimeout: boolean;
|
|
65
|
+
hasOverlay: any;
|
|
66
|
+
stylesTheme: {
|
|
67
|
+
original_match_color: any;
|
|
68
|
+
match_color: any;
|
|
69
|
+
};
|
|
70
|
+
ui: {
|
|
71
|
+
isLoading: boolean;
|
|
72
|
+
settingsStyle: any;
|
|
73
|
+
timeoutMessage: string;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
footer: {
|
|
77
|
+
visible: any;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
data: {};
|
|
82
|
+
scopes: {};
|
|
83
|
+
baseConfig: {};
|
|
84
|
+
customdrills: any[];
|
|
85
|
+
};
|
|
86
|
+
export declare function configMetricData(metricObj?: any): any;
|
|
87
|
+
export declare function configChartData(chartData: any, model: any, setup?: any): {
|
|
88
|
+
charts: any;
|
|
89
|
+
logic: import("../../filters").IFBLogic[];
|
|
90
|
+
};
|