@qrvey/utils 1.5.0-2 → 1.5.0-5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +19 -10
- package/dist/cjs/constants/Charts.Const.d.ts +1 -0
- package/dist/cjs/constants/Charts.Const.js +1 -0
- package/dist/cjs/dates/constants/DATETIME_COLUMN_FORMAT.js +1 -0
- package/dist/cjs/format/duration/durationFormatter.js +1 -1
- 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_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 +19 -10
- package/dist/constants/Charts.Const.d.ts +1 -0
- package/dist/constants/Charts.Const.js +1 -0
- package/dist/dates/constants/DATETIME_COLUMN_FORMAT.js +1 -0
- package/dist/format/duration/durationFormatter.js +1 -1
- 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_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,444 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSummariesBody = exports.setDateGroup = exports.getLayerBody = exports.getRefenceBodyU = exports.getTrendBody = exports.getRefenceBody = exports.getAggFiltersResults = exports.getSmallMultipleBody = exports.getComboBody = exports.getCategoryBody = exports.getValidSortingType = exports.getPivotBody = exports.getDrilldownId = void 0;
|
|
4
|
+
const columns_1 = require("../../columns");
|
|
5
|
+
const filters_1 = require("../../filters");
|
|
6
|
+
const general_1 = require("../../general");
|
|
7
|
+
const endpointDataValidators_1 = require("./endpointDataValidators");
|
|
8
|
+
function getDrilldownId(ctx, data) {
|
|
9
|
+
return !ctx.config.isFromAN
|
|
10
|
+
? ctx.config.id || data.chartid || data.chart_id
|
|
11
|
+
: data.chartid || data.chart_id;
|
|
12
|
+
}
|
|
13
|
+
exports.getDrilldownId = getDrilldownId;
|
|
14
|
+
function getPivotBody(layer, body) {
|
|
15
|
+
const value = (0, general_1._get)(layer, "value");
|
|
16
|
+
const pivot = (0, general_1._get)(layer, "pivot", (0, general_1._get)(layer, "multiserie.serie"));
|
|
17
|
+
const type = (0, general_1._get)(layer, "type", "");
|
|
18
|
+
let obj;
|
|
19
|
+
if ((type === "HEATMAP_CHART" || !(0, general_1._get)(body, "isDrillDown")) && pivot) {
|
|
20
|
+
const uSorting = (0, general_1._get)(pivot, "sorting");
|
|
21
|
+
const sorting = (0, general_1._get)(body, "globalSettings.sortX", {});
|
|
22
|
+
let pSortOption = {
|
|
23
|
+
sortBy: uSorting || getValidSortingType(body) === "Label"
|
|
24
|
+
? "CATEGORY"
|
|
25
|
+
: "VALUE",
|
|
26
|
+
sortDirection: ((uSorting && uSorting.order) ||
|
|
27
|
+
sorting.order ||
|
|
28
|
+
"ASC").toUpperCase(),
|
|
29
|
+
};
|
|
30
|
+
/** TODO: Remove line on implement universal sorting on Heatmap */
|
|
31
|
+
pSortOption =
|
|
32
|
+
value && value.calculation
|
|
33
|
+
? { sortBy: "CATEGORY", sortDirection: "ASC" }
|
|
34
|
+
: pSortOption;
|
|
35
|
+
const maxDataPoints = pivot.type !== "DATE"
|
|
36
|
+
? (0, general_1._get)(layer, "multiserie.maxDataPoints")
|
|
37
|
+
? (0, general_1._get)(layer, "multiserie.maxNumDataPoints", 50)
|
|
38
|
+
: undefined
|
|
39
|
+
: 50;
|
|
40
|
+
obj = {
|
|
41
|
+
linkid: pivot.linkid,
|
|
42
|
+
maxDataPoints: maxDataPoints,
|
|
43
|
+
property: pivot.property,
|
|
44
|
+
qrveyid: pivot.qrveyid || body.qrveyid,
|
|
45
|
+
questionid: pivot.id || pivot.bucketId,
|
|
46
|
+
sortOption: pSortOption,
|
|
47
|
+
type: pivot.type,
|
|
48
|
+
};
|
|
49
|
+
setDateGroup(pivot, pivot, obj);
|
|
50
|
+
}
|
|
51
|
+
return obj;
|
|
52
|
+
}
|
|
53
|
+
exports.getPivotBody = getPivotBody;
|
|
54
|
+
function getValidSortingType(body) {
|
|
55
|
+
const sorting = (0, general_1._get)(body, "globalSettings.sortX", {});
|
|
56
|
+
const type = (0, general_1._get)(body, "layerList[0].type");
|
|
57
|
+
const notAllowValue = type === "HEATMAP_CHART" && (0, general_1._get)(body, "layerList[0].pivot");
|
|
58
|
+
return !sorting.type || sorting.type == "Label" || notAllowValue
|
|
59
|
+
? "Label"
|
|
60
|
+
: "Value";
|
|
61
|
+
}
|
|
62
|
+
exports.getValidSortingType = getValidSortingType;
|
|
63
|
+
function getCategoryBody(layer, body) {
|
|
64
|
+
var _a;
|
|
65
|
+
const maxDataPoints = (0, general_1._get)(body, "globalSettings.maxNumDataPoints");
|
|
66
|
+
const category = (0, general_1._get)(layer, "category");
|
|
67
|
+
if (category && category.bucketId)
|
|
68
|
+
category.id = category.bucketId;
|
|
69
|
+
const categoryId = category ? category.id : null;
|
|
70
|
+
const sorting = (0, general_1._get)(body, "globalSettings.sortX", {});
|
|
71
|
+
const pSortOption = {
|
|
72
|
+
sortBy: ((_a = sorting === null || sorting === void 0 ? void 0 : sorting.column) === null || _a === void 0 ? void 0 : _a.isHidden)
|
|
73
|
+
? "VALUE"
|
|
74
|
+
: getValidSortingType(body) === "Label"
|
|
75
|
+
? "CATEGORY"
|
|
76
|
+
: "VALUE",
|
|
77
|
+
sortDirection: (sorting.order || "ASC").toUpperCase(),
|
|
78
|
+
order: getSortOrder(sorting, category, body),
|
|
79
|
+
};
|
|
80
|
+
let obj;
|
|
81
|
+
if (categoryId) {
|
|
82
|
+
obj = {
|
|
83
|
+
questionid: category.id,
|
|
84
|
+
linkid: category.linkid,
|
|
85
|
+
maxDataPoints,
|
|
86
|
+
property: category.property,
|
|
87
|
+
qrveyid: category.qrveyid || body.qrveyid,
|
|
88
|
+
type: category.type || body.type,
|
|
89
|
+
sortOption: (0, columns_1.isNumericalColumn)(category) &&
|
|
90
|
+
(0, general_1._get)(category, "scaleType.value") === "CONTINUOUS"
|
|
91
|
+
? undefined
|
|
92
|
+
: pSortOption,
|
|
93
|
+
};
|
|
94
|
+
setDateGroup(category, body, obj);
|
|
95
|
+
}
|
|
96
|
+
return obj;
|
|
97
|
+
}
|
|
98
|
+
exports.getCategoryBody = getCategoryBody;
|
|
99
|
+
function getComboBody(layer, body, filters, newModel = false) {
|
|
100
|
+
const obj = {};
|
|
101
|
+
try {
|
|
102
|
+
const category = getCategoryBody((0, general_1._get)(body, "layerList[0]"), body);
|
|
103
|
+
const pSmallMultiple = getSmallMultipleBody(body.layerList.find((ly) => (0, general_1._get)(ly, "combopt.label") === "SMALL_MULTIPLES"), body);
|
|
104
|
+
if (newModel) {
|
|
105
|
+
obj.dimensions = [];
|
|
106
|
+
if (pSmallMultiple)
|
|
107
|
+
obj.dimensions.push(pSmallMultiple);
|
|
108
|
+
obj.dimensions.push(category);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
obj.category = category;
|
|
112
|
+
}
|
|
113
|
+
obj.summaries = getSummariesBody(layer, body);
|
|
114
|
+
obj.aggFilters = getAggFiltersResults(filters, obj.summaries);
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
console.error(error);
|
|
118
|
+
}
|
|
119
|
+
return obj;
|
|
120
|
+
}
|
|
121
|
+
exports.getComboBody = getComboBody;
|
|
122
|
+
function getSmallMultipleBody(layer, body) {
|
|
123
|
+
if (!layer)
|
|
124
|
+
return null;
|
|
125
|
+
const category = (0, general_1._get)(layer, "smallMultiplesColumn");
|
|
126
|
+
const maxDataPoints = !(0, endpointDataValidators_1.isColumnDate)(category)
|
|
127
|
+
? (0, general_1._get)(layer, "visualization.maxMultiplePanels", undefined)
|
|
128
|
+
: undefined;
|
|
129
|
+
if (category && category.bucketId)
|
|
130
|
+
category.id = category.bucketId;
|
|
131
|
+
const categoryId = category ? category.id : null;
|
|
132
|
+
let obj;
|
|
133
|
+
if (categoryId) {
|
|
134
|
+
obj = {
|
|
135
|
+
questionid: category.id,
|
|
136
|
+
linkid: category.linkid,
|
|
137
|
+
maxDataPoints: maxDataPoints,
|
|
138
|
+
property: category.property,
|
|
139
|
+
qrveyid: category.qrveyid || body.qrveyid,
|
|
140
|
+
type: category.type || body.type,
|
|
141
|
+
};
|
|
142
|
+
if ((0, columns_1.isNumericalColumn)(category))
|
|
143
|
+
obj.numberAsRange = true;
|
|
144
|
+
setDateGroup(category, category, obj);
|
|
145
|
+
}
|
|
146
|
+
return obj;
|
|
147
|
+
}
|
|
148
|
+
exports.getSmallMultipleBody = getSmallMultipleBody;
|
|
149
|
+
function getAggFiltersResults(logics = [], summaries = []) {
|
|
150
|
+
function concatAggFilters(aggFilters, operator = filters_1.FILTER_OPERATOR.AND) {
|
|
151
|
+
const expressions = aggFilters.filter(Boolean);
|
|
152
|
+
if (!expressions.length)
|
|
153
|
+
return undefined;
|
|
154
|
+
else if (expressions.length === 1)
|
|
155
|
+
return expressions[0];
|
|
156
|
+
return {
|
|
157
|
+
operator,
|
|
158
|
+
expressions: aggFilters.filter(Boolean),
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
function getExpressionsInLogic(logicsData = []) {
|
|
162
|
+
return logicsData.reduce((expressions, logic) => {
|
|
163
|
+
logic.filters.forEach((filter) => {
|
|
164
|
+
expressions = expressions.concat(filter.expressions[0].expressions);
|
|
165
|
+
});
|
|
166
|
+
return expressions;
|
|
167
|
+
}, []);
|
|
168
|
+
}
|
|
169
|
+
function getAggregateFilters(logicsData = []) {
|
|
170
|
+
logicsData = (0, general_1.cloneDeep)(logicsData);
|
|
171
|
+
const aggregateLogics = logicsData.reduce((newLogics, logic) => {
|
|
172
|
+
if (!logic)
|
|
173
|
+
return newLogics;
|
|
174
|
+
// if ([FILTER_SCOPE.DEFAULT, FILTER_SCOPE.CHART].includes(logic.scope)) {
|
|
175
|
+
logic.filters.forEach((filter, index) => {
|
|
176
|
+
const expressions = (0, general_1._get)(filter, "expressions[0].expressions");
|
|
177
|
+
if (!(0, general_1.isEmpty)(expressions)) {
|
|
178
|
+
const aggregateFilters = filter.expressions[0].expressions.filter((expression) => !(0, general_1.isEmpty)(expression.uiExtras.column.aggregate));
|
|
179
|
+
logic.filters[index].expressions[0].expressions = aggregateFilters;
|
|
180
|
+
if (!filter.expressions[0].expressions.length)
|
|
181
|
+
logic.filters[index] = undefined;
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
logic.filters = logic.filters.filter((filter) => filter);
|
|
185
|
+
if (logic.filters.length)
|
|
186
|
+
newLogics.push(logic);
|
|
187
|
+
//}
|
|
188
|
+
return newLogics;
|
|
189
|
+
}, []);
|
|
190
|
+
return aggregateLogics;
|
|
191
|
+
}
|
|
192
|
+
const aggregateFilters = getAggregateFilters(logics);
|
|
193
|
+
const aggFilters = aggregateFilters
|
|
194
|
+
.map((aggFilter) => {
|
|
195
|
+
const expressions = getExpressionsInLogic([aggFilter]);
|
|
196
|
+
return (expressions &&
|
|
197
|
+
expressions.length && {
|
|
198
|
+
operator: filters_1.FILTER_OPERATOR.OR,
|
|
199
|
+
expressions: expressions
|
|
200
|
+
.map((expression) => {
|
|
201
|
+
const summaryIndex = summaries.findIndex((summary) => expression.questionid === summary.questionid &&
|
|
202
|
+
expression.qrveyid === summary.qrveyid &&
|
|
203
|
+
expression.linkid === summary.linkid &&
|
|
204
|
+
(0, general_1._get)(expression.uiExtras.column, "aggregate") ===
|
|
205
|
+
summary.aggregate);
|
|
206
|
+
if (summaryIndex > -1 ||
|
|
207
|
+
expression.questionType === columns_1.COLUMN.AGGREGATED_FORMULA) {
|
|
208
|
+
return {
|
|
209
|
+
enabled: expression.enabled,
|
|
210
|
+
summaryIndex,
|
|
211
|
+
validationType: expression.validationType,
|
|
212
|
+
value: expression.value,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
return;
|
|
216
|
+
})
|
|
217
|
+
.filter(Boolean),
|
|
218
|
+
});
|
|
219
|
+
})
|
|
220
|
+
.filter((aggFilter) => aggFilter && aggFilter.expressions && aggFilter.expressions.length);
|
|
221
|
+
return aggFilters && concatAggFilters(aggFilters);
|
|
222
|
+
}
|
|
223
|
+
exports.getAggFiltersResults = getAggFiltersResults;
|
|
224
|
+
function getRefenceBody(layer) {
|
|
225
|
+
let obj;
|
|
226
|
+
try {
|
|
227
|
+
obj = {
|
|
228
|
+
type: "REFERENCE_LINE",
|
|
229
|
+
referenceType: layer.valuetype,
|
|
230
|
+
referenceValue: layer.value,
|
|
231
|
+
valueId: (0, general_1._get)(layer, "axis.id"),
|
|
232
|
+
aggregate: (0, general_1._get)(layer, "aggregate.label"),
|
|
233
|
+
value: {
|
|
234
|
+
questionid: (0, general_1._get)(layer, "axis.id"),
|
|
235
|
+
qrveyid: (0, general_1._get)(layer, "axis.qrveyid"),
|
|
236
|
+
linkid: (0, general_1._get)(layer, "axis.linkid"),
|
|
237
|
+
property: (0, general_1._get)(layer, "axis.property"),
|
|
238
|
+
type: (0, general_1._get)(layer, "axis.type", (0, general_1._get)(layer, "axis.label")),
|
|
239
|
+
},
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
catch (e) {
|
|
243
|
+
console.error(e);
|
|
244
|
+
}
|
|
245
|
+
return obj;
|
|
246
|
+
}
|
|
247
|
+
exports.getRefenceBody = getRefenceBody;
|
|
248
|
+
function getTrendBody(layer) {
|
|
249
|
+
let obj;
|
|
250
|
+
try {
|
|
251
|
+
obj = {
|
|
252
|
+
type: "TREND_LINE",
|
|
253
|
+
trendType: layer.trendtype.label,
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
catch (e) {
|
|
257
|
+
console.error(e);
|
|
258
|
+
}
|
|
259
|
+
return obj;
|
|
260
|
+
}
|
|
261
|
+
exports.getTrendBody = getTrendBody;
|
|
262
|
+
function getRefenceBodyU(layer, body) {
|
|
263
|
+
let obj;
|
|
264
|
+
const layerType = layer.valuetype === "Fixed";
|
|
265
|
+
const pSmallMultiple = getSmallMultipleBody(body.layerList.find((ly) => (0, general_1._get)(ly, "combopt.label") === "SMALL_MULTIPLES"), body);
|
|
266
|
+
if (!layerType) {
|
|
267
|
+
obj = {
|
|
268
|
+
summaries: [
|
|
269
|
+
{
|
|
270
|
+
aggregate: (0, general_1._get)(layer, "aggregate.label"),
|
|
271
|
+
linkid: (0, general_1._get)(layer, "axis.linkid"),
|
|
272
|
+
property: (0, general_1._get)(layer, "axis.property"),
|
|
273
|
+
qrveyid: (0, general_1._get)(layer, "axis.qrveyid") || body.qrveyid,
|
|
274
|
+
questionid: (0, general_1._get)(layer, "axis.id"),
|
|
275
|
+
type: (0, general_1._get)(layer, "axis.type", (0, general_1._get)(layer, "axis.label")),
|
|
276
|
+
},
|
|
277
|
+
],
|
|
278
|
+
};
|
|
279
|
+
if (pSmallMultiple)
|
|
280
|
+
obj.dimensions = [pSmallMultiple];
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
obj = { type: "REFERENCE_LINE" };
|
|
284
|
+
}
|
|
285
|
+
return obj;
|
|
286
|
+
}
|
|
287
|
+
exports.getRefenceBodyU = getRefenceBodyU;
|
|
288
|
+
function getLayerBody(layer, dateGroup, qrveyid) {
|
|
289
|
+
let obj;
|
|
290
|
+
try {
|
|
291
|
+
if ((0, general_1._get)(layer, "mapType.label") == "DOT")
|
|
292
|
+
obj = {};
|
|
293
|
+
// eslint-disable-next-line no-extra-boolean-cast
|
|
294
|
+
else if (!!~["BOXWHISKER_CHART", "WORD_CLOUD"].indexOf(layer.type)) {
|
|
295
|
+
obj = {
|
|
296
|
+
valueId: (0, general_1._get)(layer, "value.id"),
|
|
297
|
+
aggregate: (0, general_1._get)(layer, "aggregate.label"),
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
else {
|
|
301
|
+
obj = {
|
|
302
|
+
valueId: layer.value.id,
|
|
303
|
+
aggregate: layer.aggregate.label,
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
obj.type =
|
|
307
|
+
layer.type || (0, general_1._get)(layer, "layer.label", (0, general_1._get)(layer, "combopt.label"));
|
|
308
|
+
obj.property = layer.property;
|
|
309
|
+
if (layer.value)
|
|
310
|
+
obj.value = {
|
|
311
|
+
questionid: layer.value.id,
|
|
312
|
+
type: layer.value.type,
|
|
313
|
+
qrveyid: layer.value.qrveyid,
|
|
314
|
+
linkid: layer.value.linkid,
|
|
315
|
+
property: layer.value.property,
|
|
316
|
+
};
|
|
317
|
+
if (layer.mapType)
|
|
318
|
+
obj.mapType = layer.mapType.label;
|
|
319
|
+
if (layer.multiserie && layer.multiserie.serie) {
|
|
320
|
+
if (layer.multiserie.serie.type === "BUCKET") {
|
|
321
|
+
obj.multiValueId = layer.multiserie.serie.bucketId; //required
|
|
322
|
+
obj.multiValueType = "BUCKET";
|
|
323
|
+
}
|
|
324
|
+
else {
|
|
325
|
+
obj.multiValueId = layer.multiserie.serie.id; //required
|
|
326
|
+
obj.multiValueType = undefined;
|
|
327
|
+
}
|
|
328
|
+
obj.isMulti = true;
|
|
329
|
+
obj.multiValueAxis = {
|
|
330
|
+
questionid: layer.multiserie.serie.id,
|
|
331
|
+
groupType: (0, general_1._get)(layer, "multiserie.type"),
|
|
332
|
+
questionType: (0, general_1._get)(layer, "multiserie.serie.type"),
|
|
333
|
+
type: (0, general_1._get)(layer, "multiserie.serie.type"),
|
|
334
|
+
groupValue: (0, general_1._get)(layer, "multiserie.dateGroup.label"),
|
|
335
|
+
property: (0, general_1._get)(layer, "multiserie.serie.property"),
|
|
336
|
+
qrveyid: (0, general_1._get)(layer, "multiserie.serie.qrveyid"),
|
|
337
|
+
linkid: (0, general_1._get)(layer, "multiserie.serie.linkid"),
|
|
338
|
+
};
|
|
339
|
+
if ((0, general_1._get)(layer, "multiserie.maxDataPoints", false))
|
|
340
|
+
obj.multiValueAxis.maxDataPoints = (0, general_1._get)(layer, "multiserie.maxNumDataPoints", 50);
|
|
341
|
+
}
|
|
342
|
+
if (dateGroup && dateGroup.label) {
|
|
343
|
+
obj.groupType = "DATE";
|
|
344
|
+
obj.groupValue = dateGroup.label;
|
|
345
|
+
}
|
|
346
|
+
if (layer.pivot) {
|
|
347
|
+
obj.pivot = {};
|
|
348
|
+
obj.pivot.qrveyid = (0, general_1._get)(layer, "pivot.qrveyid", qrveyid);
|
|
349
|
+
obj.pivot.linkid = (0, general_1._get)(layer, "pivot.linkid");
|
|
350
|
+
obj.pivot.groupType = (0, general_1._get)(layer, "pivot.type");
|
|
351
|
+
obj.pivot.type = (0, general_1._get)(layer, "pivot.type");
|
|
352
|
+
const labelBucketId = (0, general_1._get)(layer, "pivot.bucketId", null);
|
|
353
|
+
if (labelBucketId !== null) {
|
|
354
|
+
obj.pivot.labelBucketId = labelBucketId;
|
|
355
|
+
}
|
|
356
|
+
else {
|
|
357
|
+
obj.pivot.questionid = (0, general_1._get)(layer, "pivot.id");
|
|
358
|
+
}
|
|
359
|
+
obj.pivot.groupValue = (0, general_1._get)(layer, "pivot.dateGroup.label");
|
|
360
|
+
obj.pivot.property = (0, general_1._get)(layer, "pivot.property");
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
catch (error) {
|
|
364
|
+
console.error(error);
|
|
365
|
+
}
|
|
366
|
+
return obj;
|
|
367
|
+
}
|
|
368
|
+
exports.getLayerBody = getLayerBody;
|
|
369
|
+
function getSortOrder(sorting = {}, category = {}, body = {}) {
|
|
370
|
+
var _a;
|
|
371
|
+
const order = (sorting.order || "ASC").toUpperCase();
|
|
372
|
+
const column = sorting.column || {};
|
|
373
|
+
const aggregate = (_a = body.globalSettings) === null || _a === void 0 ? void 0 : _a.sortAggregation;
|
|
374
|
+
return column.isHidden
|
|
375
|
+
? [
|
|
376
|
+
{
|
|
377
|
+
hidden: true,
|
|
378
|
+
type: column.type,
|
|
379
|
+
sortDirection: order,
|
|
380
|
+
questionid: column.id,
|
|
381
|
+
qrveyid: column.qrveyid,
|
|
382
|
+
aggregate: aggregate === null || aggregate === void 0 ? void 0 : aggregate.label,
|
|
383
|
+
property: column.property || category.property,
|
|
384
|
+
},
|
|
385
|
+
]
|
|
386
|
+
: [
|
|
387
|
+
{
|
|
388
|
+
summaryIndex: 0,
|
|
389
|
+
sortDirection: order,
|
|
390
|
+
},
|
|
391
|
+
];
|
|
392
|
+
}
|
|
393
|
+
function setDateGroup(column, body, obj) {
|
|
394
|
+
if ((0, endpointDataValidators_1.isColumnDate)(column) && !(0, general_1.isEmpty)((0, general_1._get)(body, "dateGroup.label"))) {
|
|
395
|
+
obj["groupType"] = columns_1.COLUMN.DATE;
|
|
396
|
+
obj["groupValue"] = body.dateGroup.label;
|
|
397
|
+
if ((0, general_1._get)(body, "dateGroup.datePart", false)) {
|
|
398
|
+
obj["maxDataPoints"] = obj["maxDataPoints"] || 60;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
exports.setDateGroup = setDateGroup;
|
|
403
|
+
function getSummariesBody(layer, body) {
|
|
404
|
+
let value = (0, general_1._get)(layer, "value");
|
|
405
|
+
let aggregate = (0, general_1._get)(layer, "aggregate");
|
|
406
|
+
if (layer.type === "WORD_CLOUD" && !value)
|
|
407
|
+
value = (0, general_1._get)(layer, "category");
|
|
408
|
+
if (layer.type === "WORD_CLOUD" && !aggregate)
|
|
409
|
+
aggregate = { label: "COUNT", text: "Count" };
|
|
410
|
+
let obj;
|
|
411
|
+
if (layer.type === "MINMAX_CHART" && value) {
|
|
412
|
+
const min = aggregateGenerator("MIN", value.linkid, value.property, value.qrveyid || body.qrveyid, value.id, value.type);
|
|
413
|
+
const max = aggregateGenerator("MAX", value.linkid, value.property, value.qrveyid || body.qrveyid, value.id, value.type);
|
|
414
|
+
obj = [min, max];
|
|
415
|
+
if (body.globalSettings.average)
|
|
416
|
+
obj.push(aggregateGenerator("AVG", value.linkid, value.property, value.qrveyid || body.qrveyid, value.id, value.type));
|
|
417
|
+
}
|
|
418
|
+
else if (value) {
|
|
419
|
+
obj = [
|
|
420
|
+
{
|
|
421
|
+
aggregate: aggregate && aggregate.label,
|
|
422
|
+
linkid: value.linkid,
|
|
423
|
+
property: value.property,
|
|
424
|
+
qrveyid: value.qrveyid || body.qrveyid,
|
|
425
|
+
questionid: value.id,
|
|
426
|
+
type: value.type,
|
|
427
|
+
},
|
|
428
|
+
];
|
|
429
|
+
if (value.calculation)
|
|
430
|
+
obj[0].calculations = value.calculation;
|
|
431
|
+
}
|
|
432
|
+
return obj;
|
|
433
|
+
}
|
|
434
|
+
exports.getSummariesBody = getSummariesBody;
|
|
435
|
+
function aggregateGenerator(aggregate, linkid, property, qrveyid, questionid, type) {
|
|
436
|
+
return {
|
|
437
|
+
type,
|
|
438
|
+
linkid,
|
|
439
|
+
qrveyid,
|
|
440
|
+
property,
|
|
441
|
+
questionid,
|
|
442
|
+
aggregate: aggregate !== null && aggregate !== void 0 ? aggregate : "SUM",
|
|
443
|
+
};
|
|
444
|
+
}
|
|
@@ -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,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isColumnDate = exports.hasMinorVersion = exports.validChartTypeWithEndPoint = exports.isNotValid = void 0;
|
|
4
|
+
const columns_1 = require("../../columns");
|
|
5
|
+
const constants_1 = require("../../constants");
|
|
6
|
+
function isNotValid(mainLayer) {
|
|
7
|
+
if (!mainLayer)
|
|
8
|
+
return;
|
|
9
|
+
const chartType = mainLayer.type;
|
|
10
|
+
switch (chartType) {
|
|
11
|
+
case constants_1.CHART_TYPE.GEO_CHART:
|
|
12
|
+
if (mainLayer.mapType && mainLayer.mapType.label === "DOT")
|
|
13
|
+
return !mainLayer.category;
|
|
14
|
+
break;
|
|
15
|
+
case constants_1.CHART_TYPE.WORD_CLOUD:
|
|
16
|
+
return !mainLayer.category;
|
|
17
|
+
case constants_1.CHART_TYPE.BOXWHISKER_CHART:
|
|
18
|
+
return !mainLayer.value;
|
|
19
|
+
case constants_1.CHART_TYPE.MINMAX_CHART:
|
|
20
|
+
return !mainLayer.value;
|
|
21
|
+
case constants_1.CHART_TYPE.TABLE_CHART:
|
|
22
|
+
case constants_1.CHART_TYPE.CROSSTAB_CHART:
|
|
23
|
+
case constants_1.CHART_TYPE.EXPANDABLE_TABLE_CHART:
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
return (!mainLayer.category ||
|
|
27
|
+
!mainLayer.value ||
|
|
28
|
+
(chartType !== "SYMBOL_CHART" && !mainLayer.aggregate));
|
|
29
|
+
}
|
|
30
|
+
exports.isNotValid = isNotValid;
|
|
31
|
+
function validChartTypeWithEndPoint(chartType) {
|
|
32
|
+
return [
|
|
33
|
+
constants_1.CHART_TYPE.BAR_CHART,
|
|
34
|
+
constants_1.CHART_TYPE.LINE_CHART,
|
|
35
|
+
constants_1.CHART_TYPE.MINMAX_CHART,
|
|
36
|
+
constants_1.CHART_TYPE.SYMBOL_CHART,
|
|
37
|
+
constants_1.CHART_TYPE.PIE_CHART,
|
|
38
|
+
constants_1.CHART_TYPE.HEATMAP_CHART,
|
|
39
|
+
constants_1.CHART_TYPE.WORD_CLOUD,
|
|
40
|
+
constants_1.CHART_TYPE.FUNNEL_CHART,
|
|
41
|
+
].includes(chartType);
|
|
42
|
+
}
|
|
43
|
+
exports.validChartTypeWithEndPoint = validChartTypeWithEndPoint;
|
|
44
|
+
function hasMinorVersion(version, current) {
|
|
45
|
+
const splitVersion = (v) => v.split(".").map((t) => parseInt(t));
|
|
46
|
+
const currentVersion = splitVersion(current);
|
|
47
|
+
const chartVersion = splitVersion(version);
|
|
48
|
+
if (chartVersion[0] < currentVersion[0])
|
|
49
|
+
return true;
|
|
50
|
+
else if (chartVersion[1] < currentVersion[1])
|
|
51
|
+
return true;
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
exports.hasMinorVersion = hasMinorVersion;
|
|
55
|
+
function isColumnDate(column) {
|
|
56
|
+
if (column == null)
|
|
57
|
+
return;
|
|
58
|
+
return (column.type === columns_1.COLUMN.DATE ||
|
|
59
|
+
(column.type === columns_1.COLUMN.FORMULA && column.formulaType === "date"));
|
|
60
|
+
}
|
|
61
|
+
exports.isColumnDate = isColumnDate;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./endpointDataValidators"), exports);
|
|
18
|
+
__exportStar(require("./endpointDataGet"), exports);
|
|
19
|
+
__exportStar(require("./endpointData"), exports);
|
package/dist/cjs/charts/index.js
CHANGED
|
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./constants/index"), exports);
|
|
18
18
|
__exportStar(require("./interfaces/index"), exports);
|
|
19
|
+
__exportStar(require("./adapters/index"), exports);
|
|
@@ -10,6 +10,7 @@ const TABLE_TYPE_1 = require("../constants/TABLE_TYPE");
|
|
|
10
10
|
const columnTypeByChart_1 = require("./columnTypeByChart");
|
|
11
11
|
const CALCULATION_LABEL_1 = require("../../qrvey/constants/CALCULATION_LABEL");
|
|
12
12
|
const DATEGROUP_UNSUPPORT_FORMAT_1 = require("../constants/DATEGROUP_UNSUPPORT_FORMAT");
|
|
13
|
+
const DURATION_PARTS_LIST_1 = require("../constants/DURATION_PARTS_LIST");
|
|
13
14
|
/**
|
|
14
15
|
* It returns the format of a column based on the column type, the chart type, and the chart settings
|
|
15
16
|
* @param {IChartColumn} column - IChartColumn
|
|
@@ -60,17 +61,25 @@ const defineTableChartFormat = (column, settings) => {
|
|
|
60
61
|
case COLUMN_1.COLUMN.NUMERIC:
|
|
61
62
|
case COLUMN_1.COLUMN.RATING:
|
|
62
63
|
case COLUMN_1.COLUMN.SLIDEBAR: {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return defaultPercentage;
|
|
67
|
-
if (hasDefaultFormat) {
|
|
68
|
-
if ((aggregate === null || aggregate === void 0 ? void 0 : aggregate.label) === AGGREGATE_1.AGGREGATE.COUNT ||
|
|
69
|
-
(aggregate === null || aggregate === void 0 ? void 0 : aggregate.label) === AGGREGATE_1.AGGREGATE.DISTINCTCOUNT)
|
|
70
|
-
return defaultNumeric;
|
|
71
|
-
return defaultFormat || defaultNumeric;
|
|
64
|
+
let output;
|
|
65
|
+
if (selectedFormat && selectedFormat.format !== "Default") {
|
|
66
|
+
output = selectedFormat;
|
|
72
67
|
}
|
|
73
|
-
|
|
68
|
+
else if ((calculation === null || calculation === void 0 ? void 0 : calculation.value) === CALCULATION_LABEL_1.CALCULATION_LABEL.PDIFF) {
|
|
69
|
+
output = defaultPercentage;
|
|
70
|
+
}
|
|
71
|
+
else if (isGroupedTable &&
|
|
72
|
+
((aggregate === null || aggregate === void 0 ? void 0 : aggregate.label) === AGGREGATE_1.AGGREGATE.COUNT ||
|
|
73
|
+
(aggregate === null || aggregate === void 0 ? void 0 : aggregate.label) === AGGREGATE_1.AGGREGATE.DISTINCTCOUNT)) {
|
|
74
|
+
output = defaultNumeric;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
output = defaultFormat || defaultNumeric;
|
|
78
|
+
}
|
|
79
|
+
if (DURATION_PARTS_LIST_1.DURATION_PARTS_LIST.includes(output === null || output === void 0 ? void 0 : output.format)) {
|
|
80
|
+
output = Object.assign(Object.assign({}, output), { template: output.format, format: "Duration" });
|
|
81
|
+
}
|
|
82
|
+
return output;
|
|
74
83
|
}
|
|
75
84
|
}
|
|
76
85
|
};
|
|
@@ -4,6 +4,7 @@ exports.CHART_DIMENSION = exports.CHART_TYPE = void 0;
|
|
|
4
4
|
var CHART_TYPE;
|
|
5
5
|
(function (CHART_TYPE) {
|
|
6
6
|
CHART_TYPE["BAR_CHART"] = "BAR_CHART";
|
|
7
|
+
CHART_TYPE["FUNNEL_CHART"] = "FUNNEL_CHART";
|
|
7
8
|
CHART_TYPE["BAR_CHART_MS"] = "BAR_CHART_MS";
|
|
8
9
|
CHART_TYPE["EXPANDABLE_TABLE_CHART"] = "EXPANDABLE_TABLE_CHART";
|
|
9
10
|
CHART_TYPE["SYMBOL_CHART"] = "SYMBOL_CHART";
|
|
@@ -129,7 +129,7 @@ class DurationFormatter {
|
|
|
129
129
|
return "";
|
|
130
130
|
number *= this.numberFactor;
|
|
131
131
|
const durationParts = this.parts.reduce((store, part) => {
|
|
132
|
-
store[part.symbol] = number / part.ms;
|
|
132
|
+
store[part.symbol] = Math.floor(number / part.ms);
|
|
133
133
|
number %= part.ms;
|
|
134
134
|
return store;
|
|
135
135
|
}, {});
|
|
@@ -7,6 +7,7 @@ import { II18nDayNames } from "./II18nDayNames";
|
|
|
7
7
|
import { II18nUnits } from "./II18nUnits";
|
|
8
8
|
import { II18nCalendar } from "../calendar/II18nCalendar";
|
|
9
9
|
export interface II18nCommon {
|
|
10
|
+
aggregates: string;
|
|
10
11
|
aggregate_labels: II18nAgreggateLabels;
|
|
11
12
|
calendar: II18nCalendar;
|
|
12
13
|
column_types: II18nColumnTypes;
|
|
@@ -218,8 +218,8 @@ exports.I18N_CHART_BUILDER_STYLE_OPTIONS = {
|
|
|
218
218
|
border_outer: "Outer Borders",
|
|
219
219
|
expandable_color: "Header Color",
|
|
220
220
|
expandable_font_color: "Header Font Color",
|
|
221
|
-
crosstab_color: "
|
|
222
|
-
crosstab_font_color: "
|
|
221
|
+
crosstab_color: "BG Color",
|
|
222
|
+
crosstab_font_color: "Font Color",
|
|
223
223
|
},
|
|
224
224
|
table_body: {
|
|
225
225
|
title: "Body",
|
|
@@ -9,6 +9,7 @@ const I18N_COLUMN_PROPERTY_LABEL_1 = require("./I18N_COLUMN_PROPERTY_LABEL");
|
|
|
9
9
|
const I18N_DATE_GROUPING_1 = require("./I18N_DATE_GROUPING");
|
|
10
10
|
const I18N_DAY_NAMES_1 = require("./I18N_DAY_NAMES");
|
|
11
11
|
exports.I18N_COMMON = {
|
|
12
|
+
aggregates: "Aggregates",
|
|
12
13
|
aggregate_labels: I18N_AGGREGATE_LABEL_1.I18N_AGGREGATE_LABEL,
|
|
13
14
|
calendar: calendar_1.I18N_CALENDAR,
|
|
14
15
|
column_types: I18N_COLUMN_LABEL_1.I18N_COLUMN_LABEL,
|