@qrvey/utils 1.11.0 → 1.12.0-0-chart-v2-0

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.
Files changed (37) hide show
  1. package/dist/charts/adapters/chartBuilderAdapter.d.ts +35 -0
  2. package/dist/charts/adapters/chartBuilderAdapter.js +647 -0
  3. package/dist/charts/adapters/chartBuilderDefinitions.d.ts +568 -0
  4. package/dist/charts/adapters/chartBuilderDefinitions.js +31 -0
  5. package/dist/charts/adapters/chartBuilderParse.d.ts +9 -0
  6. package/dist/charts/adapters/chartBuilderParse.js +416 -0
  7. package/dist/charts/adapters/index.d.ts +1 -0
  8. package/dist/charts/adapters/index.js +1 -0
  9. package/dist/charts/helpers/chartBuilder.d.ts +53 -0
  10. package/dist/charts/helpers/chartBuilder.js +190 -0
  11. package/dist/cjs/charts/adapters/chartBuilderAdapter.d.ts +35 -0
  12. package/dist/cjs/charts/adapters/chartBuilderAdapter.js +654 -0
  13. package/dist/cjs/charts/adapters/chartBuilderDefinitions.d.ts +568 -0
  14. package/dist/cjs/charts/adapters/chartBuilderDefinitions.js +34 -0
  15. package/dist/cjs/charts/adapters/chartBuilderParse.d.ts +9 -0
  16. package/dist/cjs/charts/adapters/chartBuilderParse.js +421 -0
  17. package/dist/cjs/charts/adapters/index.d.ts +1 -0
  18. package/dist/cjs/charts/adapters/index.js +1 -0
  19. package/dist/cjs/charts/helpers/chartBuilder.d.ts +53 -0
  20. package/dist/cjs/charts/helpers/chartBuilder.js +212 -0
  21. package/dist/cjs/globalization/interfaces/chart_builder/II18nChartBuilderAxisStyle.d.ts +4 -0
  22. package/dist/cjs/globalization/interfaces/common/II18nRelativeDates.d.ts +8 -0
  23. package/dist/cjs/globalization/interfaces/common/II18nRelativeDates.js +2 -0
  24. package/dist/cjs/globalization/interfaces/common/II18nUnits.d.ts +6 -0
  25. package/dist/cjs/globalization/labels/chart_builder/I18N_CHART_BUILDER_STYLE_OPTIONS.js +4 -0
  26. package/dist/cjs/globalization/labels/common/I18N_COMMON.js +2 -10
  27. package/dist/cjs/globalization/labels/common/I18N_RELATIVE_DATES.d.ts +2 -0
  28. package/dist/cjs/globalization/labels/common/I18N_RELATIVE_DATES.js +11 -0
  29. package/dist/globalization/interfaces/chart_builder/II18nChartBuilderAxisStyle.d.ts +4 -0
  30. package/dist/globalization/interfaces/common/II18nRelativeDates.d.ts +8 -0
  31. package/dist/globalization/interfaces/common/II18nRelativeDates.js +1 -0
  32. package/dist/globalization/interfaces/common/II18nUnits.d.ts +6 -0
  33. package/dist/globalization/labels/chart_builder/I18N_CHART_BUILDER_STYLE_OPTIONS.js +4 -0
  34. package/dist/globalization/labels/common/I18N_COMMON.js +2 -10
  35. package/dist/globalization/labels/common/I18N_RELATIVE_DATES.d.ts +2 -0
  36. package/dist/globalization/labels/common/I18N_RELATIVE_DATES.js +8 -0
  37. package/package.json +1 -1
@@ -0,0 +1,421 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseGlobalSettingByType = exports.parseStyleSettingByType = void 0;
4
+ const chartBuilder_1 = require("../helpers/chartBuilder");
5
+ function parseStyleSettingByType(type, { stylesSettings, globalSettings, isGrouped }, optsCombo = {}) {
6
+ var _a, _b, _c, _d;
7
+ const { theme, color, thickness, line_style: style, line_type: straight, y_axis, data_labels, symbol_type: symbol, symbol_fill: fill, opacity, } = stylesSettings;
8
+ const y_axis_format = (0, chartBuilder_1._get)(y_axis, "format.value") === "General" /* FORMATS.GENERAL */
9
+ ? "Default" /* FORMATS.DEFAULT */
10
+ : (0, chartBuilder_1._get)(y_axis, "format.value");
11
+ const pie_labels = (0, chartBuilder_1._get)(data_labels, "pie_labels.format.value") === "General" /* FORMATS.GENERAL */
12
+ ? "Default" /* FORMATS.DEFAULT */
13
+ : (0, chartBuilder_1._get)(data_labels, "pie_labels.format.value");
14
+ const heat_map_labels = (0, chartBuilder_1._get)(data_labels, "heat_map_labels.format.value") === "General" /* FORMATS.GENERAL */
15
+ ? "Default" /* FORMATS.DEFAULT */
16
+ : (0, chartBuilder_1._get)(data_labels, "heat_map_labels.format.value");
17
+ const format = {
18
+ y_axis: y_axis_format,
19
+ data_labels: type === "PIE_CHART" /* CHART_TYPE.PIE_CHART */ ? pie_labels : heat_map_labels,
20
+ };
21
+ return ({
22
+ ["BAR_CHART" /* CHART_TYPE.BAR_CHART */]: {
23
+ color,
24
+ theme,
25
+ orientation: stylesSettings.orientation,
26
+ format,
27
+ },
28
+ ["BAR_CHART_MS" /* CHART_TYPE.BAR_CHART_MS */]: {
29
+ color,
30
+ theme,
31
+ orientation: "VERTICAL" /* CHART_ORIENTATION.VERTICAL */,
32
+ format,
33
+ },
34
+ ["SYMBOL_CHART" /* CHART_TYPE.SYMBOL_CHART */]: { color, theme, fill, symbol, format },
35
+ ["SYMBOL_CHART_MS" /* CHART_TYPE.SYMBOL_CHART_MS */]: { color, theme, format, fill, symbol },
36
+ ["LINE_CHART" /* CHART_TYPE.LINE_CHART */]: {
37
+ color,
38
+ theme,
39
+ thickness,
40
+ straight,
41
+ style,
42
+ format,
43
+ },
44
+ ["LINE_CHART_MS" /* CHART_TYPE.LINE_CHART_MS */]: {
45
+ color,
46
+ theme,
47
+ thickness,
48
+ straight,
49
+ style,
50
+ format,
51
+ },
52
+ ["COMBO_CHART" /* CHART_TYPE.COMBO_CHART */]: {
53
+ custom_color: optsCombo.custom_color,
54
+ custom_theme: optsCombo.custom_theme,
55
+ match_colors: optsCombo.match_colors,
56
+ color_type: optsCombo.color_type,
57
+ color: [optsCombo.color],
58
+ theme: optsCombo.theme,
59
+ thickness: optsCombo.thickness,
60
+ straight: optsCombo.line_type,
61
+ style: optsCombo.line_style,
62
+ format: Object.assign(Object.assign({}, format), { y_axis: optsCombo.format || (0, chartBuilder_1._get)(optsCombo, "y_axis.format.value") }),
63
+ symbol: optsCombo.symbol_type,
64
+ fill: optsCombo.symbol_fill,
65
+ axis_scale: (0, chartBuilder_1._get)(optsCombo, "y_axis.scale"),
66
+ },
67
+ ["HEATMAP_CHART" /* CHART_TYPE.HEATMAP_CHART */]: {
68
+ orientation: "VERTICAL" /* CHART_ORIENTATION.VERTICAL */,
69
+ format,
70
+ },
71
+ ["WORD_CLOUD" /* CHART_TYPE.WORD_CLOUD */]: {},
72
+ ["PIE_CHART" /* CHART_TYPE.PIE_CHART */]: {
73
+ color,
74
+ theme,
75
+ format,
76
+ pielabel: ((_a = stylesSettings.data_labels) === null || _a === void 0 ? void 0 : _a.pie_labels)
77
+ ? (_b = stylesSettings.data_labels.pie_labels) === null || _b === void 0 ? void 0 : _b.position
78
+ : "outside" /* PIE_LABEL_POSITION.OUTSIDE */,
79
+ donut: stylesSettings.pie_type === "donut" /* PIE_TYPE.DONUT */,
80
+ data_labels: (_c = stylesSettings.data_labels) === null || _c === void 0 ? void 0 : _c.value,
81
+ percent_labels: stylesSettings.percent_labels,
82
+ visible_labels: (_d = stylesSettings.data_labels) === null || _d === void 0 ? void 0 : _d.visible,
83
+ },
84
+ ["MINMAX_CHART" /* CHART_TYPE.MINMAX_CHART */]: {
85
+ color,
86
+ theme,
87
+ symbol,
88
+ fill,
89
+ thickness,
90
+ straight,
91
+ style,
92
+ orientation: stylesSettings.orientation,
93
+ format,
94
+ opacity,
95
+ },
96
+ ["REFERENCE" /* CHART_TYPE.REFERENCE */]: {
97
+ color,
98
+ theme,
99
+ fill: "None",
100
+ thickness,
101
+ style: "Solid",
102
+ opacity: 20,
103
+ },
104
+ ["TREND" /* CHART_TYPE.TREND */]: { color, theme, style: "Solid", thickness },
105
+ ["SMALL_MULTIPLES" /* CHART_TYPE.SMALL_MULTIPLES */]: {
106
+ maxMultiplePanels: 4,
107
+ displayMultiplePanels: false,
108
+ displayBorder: false,
109
+ labels: { axis: true },
110
+ },
111
+ ["BOXWHISKER_CHART" /* CHART_TYPE.BOXWHISKER_CHART */]: {
112
+ thickness,
113
+ opacity: (100 - opacity) / 10,
114
+ displaySymbol: (0, chartBuilder_1._get)(stylesSettings, "outliers.value"),
115
+ symbol: (0, chartBuilder_1._get)(stylesSettings, "outliers.symbol_type"),
116
+ fill: (0, chartBuilder_1._get)(stylesSettings, "outliers.symbol_fill"),
117
+ orientation: stylesSettings.orientation,
118
+ },
119
+ ["GEO_CHART" /* CHART_TYPE.GEO_CHART */]: {
120
+ baseMap: { text: "Streets", label: "mapbox://styles/mapbox/streets-v11" /* BASE_MAPS.STREET */ },
121
+ symbol: "circle",
122
+ opacity: 5,
123
+ mapborder: true,
124
+ mapRegion: { text: "Default", label: "DEFAULT" },
125
+ },
126
+ ["GEO_CHART_BUBBLE" /* CHART_TYPE.GEO_CHART_BUBBLE */]: Object.assign({}, parseMaps(stylesSettings)),
127
+ ["GEO_CHART_DOT" /* CHART_TYPE.GEO_CHART_DOT */]: Object.assign(Object.assign({}, parseMaps(stylesSettings)), { symbol, symbolfill: fill === "Filled" /* SYMBOL_FILL.FILLED */ }),
128
+ ["GEO_CHART_CHOROPLETH" /* CHART_TYPE.GEO_CHART_CHOROPLETH */]: Object.assign({}, parseMaps(stylesSettings)),
129
+ ["CROSSTAB_CHART" /* CHART_TYPE.CROSSTAB_CHART */]: {
130
+ format: (0, chartBuilder_1._get)(stylesSettings, "format.value"),
131
+ groupedTotals: {
132
+ label: (0, chartBuilder_1._get)(globalSettings, "crosstab_totals.value", false)
133
+ ? (0, chartBuilder_1._get)(globalSettings, "crosstab_totals.option", "SHOW" /* CROSSTAB_TOTALS_VISUAL.SHOW */)
134
+ : "DONTSHOW" /* CROSSTAB_TOTALS_VISUAL.DONTSHOW */,
135
+ },
136
+ groupedSubtotals: {
137
+ label: (0, chartBuilder_1._get)(globalSettings, "crosstab_subtotals", false)
138
+ ? "SHOW" /* CROSSTAB_TOTALS_VISUAL.SHOW */
139
+ : "DONTSHOW" /* CROSSTAB_TOTALS_VISUAL.DONTSHOW */,
140
+ },
141
+ rowsMaxDataPoints: (0, chartBuilder_1._get)(globalSettings, "max_rows.value", true),
142
+ columnsMaxDataPoints: (0, chartBuilder_1._get)(globalSettings, "max_groups.value", true),
143
+ maxRowNumDataPoints: (0, chartBuilder_1._get)(globalSettings, "max_rows.option", true),
144
+ maxColumnsNumDataPoints: (0, chartBuilder_1._get)(globalSettings, "max_groups.option", true),
145
+ },
146
+ ["TABLE_CHART" /* CHART_TYPE.TABLE_CHART */]: {
147
+ sorting: (0, chartBuilder_1._get)(globalSettings, "table_menu.sorting"),
148
+ value_view: (0, chartBuilder_1._get)(globalSettings, "table_menu.value_view"),
149
+ totals: (0, chartBuilder_1._get)(globalSettings, "table_menu.totals"),
150
+ pagination: isGrouped
151
+ ? {
152
+ enabled: false,
153
+ recordsPage: 30,
154
+ }
155
+ : (0, chartBuilder_1._get)(globalSettings, "table_menu.pagination"),
156
+ },
157
+ ["EXPANDABLE_TABLE_CHART" /* CHART_TYPE.EXPANDABLE_TABLE_CHART */]: {
158
+ sorting: (0, chartBuilder_1._get)(globalSettings, "table_menu.sorting"),
159
+ value_view: (0, chartBuilder_1._get)(globalSettings, "table_menu.value_view"),
160
+ totals: (0, chartBuilder_1._get)(globalSettings, "table_menu.totals"),
161
+ },
162
+ ["INDICATOR" /* CHART_TYPE.INDICATOR_METRIC */]: {
163
+ iconPosition: { label: (0, chartBuilder_1._get)(stylesSettings, "indicator_position") },
164
+ },
165
+ ["DIAL" /* CHART_TYPE.DIAL_METRIC */]: {
166
+ color,
167
+ theme,
168
+ thresholdOpacity: opacity,
169
+ showComparison: (0, chartBuilder_1._get)(stylesSettings, "metric_comparison.value"),
170
+ comparisonColor: (0, chartBuilder_1._get)(stylesSettings, "metric_comparison.color"),
171
+ gaugeStyle: { label: (0, chartBuilder_1._get)(stylesSettings, "gauge") },
172
+ circleSize: { label: (0, chartBuilder_1._get)(stylesSettings, "dial_size") },
173
+ },
174
+ ["BULLET" /* CHART_TYPE.BULLET_METRIC */]: {
175
+ color,
176
+ theme,
177
+ thresholdOpacity: opacity,
178
+ targetLabel: (0, chartBuilder_1._get)(stylesSettings, "bullet_target.label"),
179
+ targetColor: (0, chartBuilder_1._get)(stylesSettings, "bullet_target.color"),
180
+ targetIndicator: (0, chartBuilder_1._get)(stylesSettings, "bullet_target.indicator"),
181
+ targetValue: (0, chartBuilder_1._get)(stylesSettings, "bullet_target.value"),
182
+ },
183
+ ["FUNNEL_CHART" /* CHART_TYPE.FUNNEL_CHART */]: Object.assign(Object.assign({}, stylesSettings), { orientation: stylesSettings.orientation }),
184
+ }[type] || {});
185
+ }
186
+ exports.parseStyleSettingByType = parseStyleSettingByType;
187
+ function parseMaps(stylesSettings) {
188
+ const { value, steps, min_value, max_value } = stylesSettings.custom_scale || {};
189
+ return {
190
+ baseMap: { label: (0, chartBuilder_1._get)(stylesSettings, "base_map") },
191
+ mapRegion: { label: (0, chartBuilder_1._get)(stylesSettings, "map_region") },
192
+ mapborder: (0, chartBuilder_1._get)(stylesSettings, "map_borders"),
193
+ opacity: (0, chartBuilder_1._get)(stylesSettings, "opacity", 10) / 10,
194
+ mapClustering: (0, chartBuilder_1._get)(stylesSettings, "map_clustering"),
195
+ mapDataLabels: (0, chartBuilder_1._get)(stylesSettings, "data_labels.value"),
196
+ color: {
197
+ values: (stylesSettings.theme || []).slice(0, 5),
198
+ },
199
+ custom: {
200
+ steps,
201
+ min: min_value,
202
+ max: max_value,
203
+ },
204
+ scale: {
205
+ type: value ? "Custom" : "Auto",
206
+ order: stylesSettings.reverse_color ? "Reverse" : "Default",
207
+ },
208
+ };
209
+ }
210
+ function parseLabels(type, stylesSettings) {
211
+ var _a, _b, _c, _d, _e;
212
+ const noLabelCharts = [
213
+ "CROSSTAB_CHART" /* CHART_TYPE.CROSSTAB_CHART */,
214
+ "TABLE_CHART" /* CHART_TYPE.TABLE_CHART */,
215
+ "EXPANDABLE_TABLE_CHART" /* CHART_TYPE.EXPANDABLE_TABLE_CHART */,
216
+ "INDICATOR" /* CHART_TYPE.INDICATOR_METRIC */,
217
+ "DIAL" /* CHART_TYPE.DIAL_METRIC */,
218
+ "BULLET" /* CHART_TYPE.BULLET_METRIC */,
219
+ ];
220
+ if (noLabelCharts.includes(type))
221
+ return false;
222
+ if (type === "PIE_CHART" /* CHART_TYPE.PIE_CHART */)
223
+ return stylesSettings.data_labels.value;
224
+ const labels = {
225
+ axis: {
226
+ x: {
227
+ enabled: stylesSettings.x_axis.showAxisTitle,
228
+ fontColor: stylesSettings.x_axis.fontColor,
229
+ fontSize: stylesSettings.x_axis.fontSize,
230
+ fontType: stylesSettings.x_axis.fontType,
231
+ fontWeight: stylesSettings.x_axis.fontWeight,
232
+ },
233
+ y: {
234
+ enabled: stylesSettings.y_axis.showAxisTitle,
235
+ fontColor: stylesSettings.y_axis.fontColor,
236
+ fontSize: stylesSettings.y_axis.fontSize,
237
+ fontType: stylesSettings.y_axis.fontType,
238
+ fontWeight: stylesSettings.y_axis.fontWeight,
239
+ },
240
+ pivot: {
241
+ enabled: (_a = stylesSettings === null || stylesSettings === void 0 ? void 0 : stylesSettings.pivot_axis) === null || _a === void 0 ? void 0 : _a.showAxisTitle,
242
+ fontColor: (_b = stylesSettings === null || stylesSettings === void 0 ? void 0 : stylesSettings.pivot_axis) === null || _b === void 0 ? void 0 : _b.fontColor,
243
+ fontSize: (_c = stylesSettings === null || stylesSettings === void 0 ? void 0 : stylesSettings.pivot_axis) === null || _c === void 0 ? void 0 : _c.fontSize,
244
+ fontType: (_d = stylesSettings === null || stylesSettings === void 0 ? void 0 : stylesSettings.pivot_axis) === null || _d === void 0 ? void 0 : _d.fontType,
245
+ fontWeight: (_e = stylesSettings === null || stylesSettings === void 0 ? void 0 : stylesSettings.pivot_axis) === null || _e === void 0 ? void 0 : _e.fontWeight,
246
+ },
247
+ },
248
+ value: {
249
+ x: {
250
+ enabled: stylesSettings.x_axis.values,
251
+ rotation: stylesSettings.x_axis.rotation,
252
+ fontColor: stylesSettings.x_axis.fontColorValues,
253
+ fontSize: stylesSettings.x_axis.fontSizeValues,
254
+ fontType: stylesSettings.x_axis.fontTypeValues,
255
+ fontWeight: stylesSettings.x_axis.fontWeightValues,
256
+ },
257
+ y: {
258
+ enabled: stylesSettings.y_axis.values,
259
+ rotation: stylesSettings.y_axis.rotation,
260
+ fontColor: stylesSettings.y_axis.fontColorValues,
261
+ fontSize: stylesSettings.y_axis.fontSizeValues,
262
+ fontType: stylesSettings.y_axis.fontTypeValues,
263
+ fontWeight: stylesSettings.y_axis.fontWeightValues,
264
+ },
265
+ },
266
+ data: {
267
+ enabled: stylesSettings.data_labels.value,
268
+ border: (0, chartBuilder_1._get)(stylesSettings, "data_labels.simple_labels.border", true),
269
+ },
270
+ scale: {
271
+ x: stylesSettings.x_axis.scale,
272
+ y: stylesSettings.y_axis.scale,
273
+ },
274
+ };
275
+ if (type === "HEATMAP_CHART" /* CHART_TYPE.HEATMAP_CHART */)
276
+ delete labels.data;
277
+ return labels;
278
+ }
279
+ function parseHeatMap(stylesSettings) {
280
+ return {
281
+ celltext: (0, chartBuilder_1._get)(stylesSettings, "data_labels.value"),
282
+ color: {
283
+ values: (stylesSettings.theme || []).slice(0, 5),
284
+ },
285
+ custom: {
286
+ steps: (0, chartBuilder_1._get)(stylesSettings, "custom_scale.steps"),
287
+ min: (0, chartBuilder_1._get)(stylesSettings, "custom_scale.min_value"),
288
+ max: (0, chartBuilder_1._get)(stylesSettings, "custom_scale.max_value"),
289
+ },
290
+ gap: Object.assign({}, stylesSettings.gaps),
291
+ yAxisRotation: (0, chartBuilder_1._get)(stylesSettings, "y_axis.rotation"),
292
+ labelRotation: (0, chartBuilder_1._get)(stylesSettings, "pivot_axis.rotation"),
293
+ scale: {
294
+ type: (0, chartBuilder_1._get)(stylesSettings, "custom_scale.value") ? "Custom" : "Auto",
295
+ order: stylesSettings.reverse_color ? "Reverse" : "Default",
296
+ },
297
+ };
298
+ }
299
+ function parseTableChart({ stylesSettings, globalSettings }) {
300
+ return {
301
+ size: globalSettings.size,
302
+ maxNumGroups: (0, chartBuilder_1._get)(globalSettings, "max_groups.option"),
303
+ theme: {
304
+ name: "Theme 1",
305
+ values: stylesSettings.color,
306
+ },
307
+ maxNumRows: (0, chartBuilder_1._get)(globalSettings, "max_rows.option"),
308
+ sort_by_column: (0, chartBuilder_1._get)(globalSettings, "sort_by_column"),
309
+ sort_by_multi_columns: (0, chartBuilder_1._get)(globalSettings, "sort_by_multi_columns"),
310
+ };
311
+ }
312
+ function parseCrosstabChart({ stylesSettings, globalSettings }) {
313
+ return {
314
+ size: globalSettings.size,
315
+ theme: {
316
+ name: "Theme 1",
317
+ values: stylesSettings.color,
318
+ },
319
+ labels: (0, chartBuilder_1._get)(globalSettings, "crosstab_labels.value"),
320
+ sortX: (0, chartBuilder_1._get)(globalSettings, "crosstab_labels.option.sorting"),
321
+ };
322
+ }
323
+ function parseMetricGlobal({ globalSettings, stylesSettings, }) {
324
+ let format = (0, chartBuilder_1._get)(stylesSettings, "format.value", "Default" /* FORMATS.DEFAULT */);
325
+ const templateFormat = (0, chartBuilder_1._get)(stylesSettings, "format.template") ||
326
+ (0, chartBuilder_1._get)(stylesSettings, "y_axis.format.template");
327
+ if ((0, chartBuilder_1._get)(stylesSettings, "format.value", "") === "Numeric" /* FORMATS.NUMERIC */)
328
+ format = "Decimal" /* FORMATS.DECIMAL */;
329
+ return {
330
+ numberFormat: format,
331
+ templateFormat,
332
+ comparisonType: "CHANGE",
333
+ desctription: false,
334
+ animation: (0, chartBuilder_1._get)(stylesSettings, "animation", {}),
335
+ indicator_font: (0, chartBuilder_1._get)(stylesSettings, "indicator_font", {}),
336
+ indicator_symbol: (0, chartBuilder_1._get)(stylesSettings, "indicator_symbol", {}),
337
+ comparison_font: (0, chartBuilder_1._get)(stylesSettings, "comparison_font", {}),
338
+ decimals: (0, chartBuilder_1._get)(stylesSettings, "format.decimals", 2),
339
+ currency: { label: (0, chartBuilder_1._get)(stylesSettings, "format.currency", "$") },
340
+ fixedScale: {
341
+ min: (0, chartBuilder_1._get)(globalSettings, "metric_scale.value", false)
342
+ ? (0, chartBuilder_1._get)(globalSettings, "metric_scale.min_value")
343
+ : null,
344
+ max: (0, chartBuilder_1._get)(globalSettings, "metric_scale.value", false)
345
+ ? (0, chartBuilder_1._get)(globalSettings, "metric_scale.max_value")
346
+ : null,
347
+ },
348
+ };
349
+ }
350
+ function parseGlobalSettingByType(type, { stylesSettings, globalSettings, dimensions }) {
351
+ const theme = { values: stylesSettings.theme };
352
+ const typeCategory = (0, chartBuilder_1._get)(dimensions === null || dimensions === void 0 ? void 0 : dimensions.categories, "[0].type");
353
+ const typeValue = (0, chartBuilder_1._get)(dimensions === null || dimensions === void 0 ? void 0 : dimensions.values, "[0].type");
354
+ const trueTypeCategory = typeCategory || typeValue;
355
+ const base = {
356
+ color_type: (0, chartBuilder_1._get)(stylesSettings, "color_type"),
357
+ match_colors: (0, chartBuilder_1._get)(stylesSettings, "match_colors"),
358
+ custom_color: (0, chartBuilder_1._get)(stylesSettings, "custom_color"),
359
+ custom_theme: (0, chartBuilder_1._get)(stylesSettings, "custom_theme"),
360
+ theme,
361
+ size: globalSettings.size,
362
+ labels: parseLabels(type, stylesSettings),
363
+ legends: globalSettings.legend
364
+ ? globalSettings.legend !== "NONE" /* LEGEND_STATE.NONE */
365
+ : false,
366
+ tooltips: (0, chartBuilder_1._get)(globalSettings, "tooltips.value"),
367
+ custom_tooltips: (0, chartBuilder_1._get)(globalSettings, "tooltips.advanced"),
368
+ scale: {
369
+ type: (0, chartBuilder_1._get)(stylesSettings, "custom_scale.value") ? "Custom" : "Auto",
370
+ order: stylesSettings.reverse_color ? "Reverse" : "Default",
371
+ },
372
+ // size: 3,
373
+ sortX: (0, chartBuilder_1.getSortByType)(globalSettings, type),
374
+ sortAggregation: globalSettings.aggregation_sort,
375
+ sortCalculation: globalSettings.table_calculation_sort,
376
+ calculation_direction: globalSettings.calculation_direction,
377
+ maxNumValuePoints: (0, chartBuilder_1._get)(globalSettings, "max_value_point.option", 500),
378
+ maxNumDataPoints: (0, chartBuilder_1._get)(globalSettings, "max_data_point.option"),
379
+ maxDataPoints: trueTypeCategory === "DATE"
380
+ ? false
381
+ : (0, chartBuilder_1._get)(globalSettings, "max_data_point.value"),
382
+ average: globalSettings.average,
383
+ startDate: globalSettings.startDate,
384
+ endDate: globalSettings.endDate,
385
+ startTime: globalSettings.startTime,
386
+ endTime: globalSettings.endTime,
387
+ startNumeric: globalSettings.startNumeric,
388
+ endNumeric: globalSettings.endNumeric,
389
+ chartVersion: (0, chartBuilder_1._get)(globalSettings, "chartVersion"),
390
+ };
391
+ return ({
392
+ ["BAR_CHART" /* CHART_TYPE.BAR_CHART */]: Object.assign(Object.assign({}, base), { hideShading: !stylesSettings.shadding, fit_panel: (0, chartBuilder_1._get)(globalSettings, "fit_panel", false) }),
393
+ ["BAR_CHART_MS" /* CHART_TYPE.BAR_CHART_MS */]: Object.assign(Object.assign({}, base), { hideShading: true, fit_panel: (0, chartBuilder_1._get)(globalSettings, "fit_panel", false) }),
394
+ ["SYMBOL_CHART" /* CHART_TYPE.SYMBOL_CHART */]: Object.assign(Object.assign({}, base), { fit_panel: (0, chartBuilder_1._get)(globalSettings, "fit_panel", false) }),
395
+ ["SYMBOL_CHART_MS" /* CHART_TYPE.SYMBOL_CHART_MS */]: Object.assign(Object.assign({}, base), { fit_panel: (0, chartBuilder_1._get)(globalSettings, "fit_panel", false) }),
396
+ ["LINE_CHART" /* CHART_TYPE.LINE_CHART */]: Object.assign(Object.assign({}, base), { fit_panel: (0, chartBuilder_1._get)(globalSettings, "fit_panel", false) }),
397
+ ["LINE_CHART_MS" /* CHART_TYPE.LINE_CHART_MS */]: Object.assign(Object.assign({}, base), { fit_panel: (0, chartBuilder_1._get)(globalSettings, "fit_panel", false) }),
398
+ ["COMBO_CHART" /* CHART_TYPE.COMBO_CHART */]: Object.assign(Object.assign({}, base), { hideShading: true, fit_panel: (0, chartBuilder_1._get)(globalSettings, "fit_panel", false) }),
399
+ ["HEATMAP_CHART" /* CHART_TYPE.HEATMAP_CHART */]: Object.assign(Object.assign({}, base), parseHeatMap(stylesSettings)),
400
+ ["WORD_CLOUD" /* CHART_TYPE.WORD_CLOUD */]: Object.assign({}, base),
401
+ ["MINMAX_CHART" /* CHART_TYPE.MINMAX_CHART */]: Object.assign(Object.assign({}, base), { fit_panel: (0, chartBuilder_1._get)(globalSettings, "fit_panel", false) }),
402
+ ["PIE_CHART" /* CHART_TYPE.PIE_CHART */]: Object.assign({}, base),
403
+ ["REFERENCE" /* CHART_TYPE.REFERENCE */]: Object.assign(Object.assign({}, base), { fit_panel: (0, chartBuilder_1._get)(globalSettings, "fit_panel", false) }),
404
+ ["TREND" /* CHART_TYPE.TREND */]: Object.assign(Object.assign({}, base), { fit_panel: (0, chartBuilder_1._get)(globalSettings, "fit_panel", false) }),
405
+ ["SMALL_MULTIPLES" /* CHART_TYPE.SMALL_MULTIPLES */]: Object.assign(Object.assign({}, base), { fit_panel: (0, chartBuilder_1._get)(globalSettings, "fit_panel", false) }),
406
+ ["BOXWHISKER_CHART" /* CHART_TYPE.BOXWHISKER_CHART */]: Object.assign(Object.assign({}, base), { enableDataLabels: true, labelRotation: (0, chartBuilder_1._get)(stylesSettings, "x_axis.rotation"), orientation: (0, chartBuilder_1.capitalize)((stylesSettings.orientation || "").toString()), hasPivot: globalSettings.hasPivot }),
407
+ ["GEO_CHART_BUBBLE" /* CHART_TYPE.GEO_CHART_BUBBLE */]: Object.assign(Object.assign({}, base), { theme: { values: [stylesSettings.color] } }),
408
+ ["GEO_CHART_DOT" /* CHART_TYPE.GEO_CHART_DOT */]: Object.assign(Object.assign({}, base), { theme: { values: [stylesSettings.color] }, legends: false }),
409
+ ["GEO_CHART_CHOROPLETH" /* CHART_TYPE.GEO_CHART_CHOROPLETH */]: Object.assign(Object.assign({}, base), { theme: { values: [stylesSettings.color] } }),
410
+ ["GEO_CHART" /* CHART_TYPE.GEO_CHART */]: Object.assign({}, base),
411
+ ["CROSSTAB_CHART" /* CHART_TYPE.CROSSTAB_CHART */]: Object.assign({}, parseCrosstabChart({ globalSettings, stylesSettings })),
412
+ ["TABLE_CHART" /* CHART_TYPE.TABLE_CHART */]: Object.assign({}, parseTableChart({ globalSettings, stylesSettings })),
413
+ ["EXPANDABLE_TABLE_CHART" /* CHART_TYPE.EXPANDABLE_TABLE_CHART */]: Object.assign({}, parseTableChart({ globalSettings, stylesSettings })),
414
+ ["INDICATOR" /* CHART_TYPE.INDICATOR_METRIC */]: Object.assign(Object.assign({}, parseMetricGlobal({ globalSettings, stylesSettings })), { tooltips: base.tooltips, custom_tooltips: base.custom_tooltips }),
415
+ ["DIAL" /* CHART_TYPE.DIAL_METRIC */]: Object.assign(Object.assign({}, parseMetricGlobal({ globalSettings, stylesSettings })), { legend: base.legends, tooltips: base.tooltips, custom_tooltips: base.custom_tooltips }),
416
+ ["BULLET" /* CHART_TYPE.BULLET_METRIC */]: Object.assign(Object.assign({}, parseMetricGlobal({ globalSettings, stylesSettings })), { legend: base.legends, tooltips: base.tooltips, custom_tooltips: base.custom_tooltips }),
417
+ ["FUNNEL_CHART" /* CHART_TYPE.FUNNEL_CHART */]: Object.assign(Object.assign({}, base), { fit_panel: (0, chartBuilder_1._get)(globalSettings, "fit_panel", false) }),
418
+ ["COMBINED_CHART" /* CHART_TYPE.COMBINED_CHART */]: Object.assign(Object.assign({}, base), { hideShading: true, fit_panel: (0, chartBuilder_1._get)(globalSettings, "fit_panel", false) }),
419
+ }[type] || {});
420
+ }
421
+ exports.parseGlobalSettingByType = parseGlobalSettingByType;
@@ -2,3 +2,4 @@ export * from "./endpointDataValidators";
2
2
  export * from "./endpointDataGet";
3
3
  export * from "./endpointData";
4
4
  export * from "./RequestAdapterMetric";
5
+ export * from "./chartBuilderAdapter";
@@ -18,3 +18,4 @@ __exportStar(require("./endpointDataValidators"), exports);
18
18
  __exportStar(require("./endpointDataGet"), exports);
19
19
  __exportStar(require("./endpointData"), exports);
20
20
  __exportStar(require("./RequestAdapterMetric"), exports);
21
+ __exportStar(require("./chartBuilderAdapter"), exports);
@@ -0,0 +1,53 @@
1
+ import { ChartType, TIME_PERIOD, TP_CUSTOM_RANGE } from "../adapters/chartBuilderDefinitions";
2
+ /**
3
+ * simple deepclone
4
+ */
5
+ export declare const jsonCopy: <T = any>(obj?: string | T) => T;
6
+ export declare const _cloneDeep: <T = any>(obj?: string | T) => T;
7
+ /**
8
+ * Like lodash _.get
9
+ */
10
+ export declare const _get: (baseObject: any, key: string, fallback?: any) => any;
11
+ export declare const _isEmpty: (obj: any) => boolean;
12
+ export declare const _pick: (baseObject: any, keys: string[]) => {};
13
+ export declare const randomKey: () => string;
14
+ /**
15
+ * Capitalize string
16
+ */
17
+ export declare const capitalize: (text: string) => string;
18
+ export declare function getSortByType(globalSettings: any, type: ChartType): any;
19
+ /**
20
+ * Returns True or false when column type property is a date column.
21
+ * In cases when column type is a Formula, validate if formulaType property is a date one.
22
+ * @param column Webforms or Dataset Column object
23
+ * @return True if the column is a date column otherwise is not.
24
+ */
25
+ export declare const isColumnDate: (column: any) => boolean;
26
+ /**
27
+ * Column Key Indetifier Generator
28
+ * @param id QuestionId
29
+ * @param type Question Type
30
+ * @param prop Extra property for compound or complex data type
31
+ * @param index column index in table (to support the same column multiple times)
32
+ */
33
+ export declare const columnKey: (id: any, type: any, prop?: any, index?: any) => string;
34
+ export declare const timePeriod: {
35
+ text: string;
36
+ label: TIME_PERIOD;
37
+ key: string;
38
+ }[];
39
+ export declare const timePeriodCustomRange: {
40
+ text: string;
41
+ label: TP_CUSTOM_RANGE;
42
+ key: string;
43
+ }[];
44
+ export declare const isTimeColumn: (column?: any) => boolean;
45
+ export declare function allowTableCalculation(chartType: ChartType): boolean;
46
+ export declare function hasReferenceLayer(references: any): boolean;
47
+ export declare function hasSmallMultiple(list: any[]): boolean;
48
+ export declare function hasTrendLayer(trend: any): boolean;
49
+ export declare function isChartBasic(type: ChartType): boolean;
50
+ export declare function isChartMap(type: any): boolean;
51
+ export declare function isChartMetric(type: any): boolean;
52
+ export declare function isChartMultiserie(type: any): boolean;
53
+ export declare function isChartMinMax(type: any): boolean;