@qrvey/utils 1.16.0-9 → 1.16.1-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/charts/adapters/RequestAdapterMetric.d.ts +2 -1
- package/dist/charts/adapters/RequestAdapterMetric.js +14 -1
- package/dist/charts/adapters/convertChartObjectFromV2toV1.d.ts +2 -0
- package/dist/charts/adapters/convertChartObjectFromV2toV1.js +63 -0
- package/dist/charts/adapters/getPanelBodyByChart.d.ts +2 -0
- package/dist/charts/adapters/getPanelBodyByChart.js +289 -0
- package/dist/charts/adapters/index.d.ts +2 -0
- package/dist/charts/adapters/index.js +2 -0
- package/dist/charts/constants/AGGREGATE.d.ts +3 -1
- package/dist/charts/constants/AGGREGATE.js +2 -0
- package/dist/charts/constants/AGGREGATE_ABBREVIATION.d.ts +3 -1
- package/dist/charts/constants/AGGREGATE_ABBREVIATION.js +2 -0
- package/dist/charts/constants/AGGREGATE_INFO.js +16 -0
- package/dist/charts/constants/AGGREGATE_LABEL.d.ts +3 -1
- package/dist/charts/constants/AGGREGATE_LABEL.js +2 -0
- package/dist/charts/constants/CHART_OBJECT.d.ts +564 -0
- package/dist/charts/constants/CHART_OBJECT.js +53 -0
- package/dist/charts/constants/QUESTION_TYPES.d.ts +241 -0
- package/dist/charts/constants/QUESTION_TYPES.js +410 -0
- package/dist/charts/constants/TIME_PERIOD.d.ts +10 -0
- package/dist/charts/constants/TIME_PERIOD.js +25 -0
- package/dist/charts/constants/index.d.ts +3 -0
- package/dist/charts/constants/index.js +3 -0
- package/dist/charts/helpers/chartTypes.d.ts +24 -0
- package/dist/charts/helpers/chartTypes.js +118 -0
- package/dist/charts/helpers/defaultColumnBuilder.d.ts +56 -0
- package/dist/charts/helpers/defaultColumnBuilder.js +322 -0
- package/dist/charts/helpers/getChartDimensions.d.ts +2 -0
- package/dist/charts/helpers/getChartDimensions.js +263 -0
- package/dist/charts/helpers/index.d.ts +4 -0
- package/dist/charts/helpers/index.js +4 -0
- package/dist/charts/helpers/styleSettingsByChartType.d.ts +60 -0
- package/dist/charts/helpers/styleSettingsByChartType.js +532 -0
- package/dist/charts/interfaces/IChartV2.d.ts +537 -0
- package/dist/charts/interfaces/IChartV2.js +33 -0
- package/dist/charts/interfaces/IRequestAdapterMetric.d.ts +3 -1
- package/dist/charts/interfaces/index.d.ts +1 -0
- package/dist/charts/interfaces/index.js +1 -0
- package/dist/cjs/charts/adapters/RequestAdapterMetric.d.ts +2 -1
- package/dist/cjs/charts/adapters/RequestAdapterMetric.js +16 -2
- package/dist/cjs/charts/adapters/convertChartObjectFromV2toV1.d.ts +2 -0
- package/dist/cjs/charts/adapters/convertChartObjectFromV2toV1.js +67 -0
- package/dist/cjs/charts/adapters/getPanelBodyByChart.d.ts +2 -0
- package/dist/cjs/charts/adapters/getPanelBodyByChart.js +294 -0
- package/dist/cjs/charts/adapters/index.d.ts +2 -0
- package/dist/cjs/charts/adapters/index.js +2 -0
- package/dist/cjs/charts/constants/AGGREGATE.d.ts +3 -1
- package/dist/cjs/charts/constants/AGGREGATE.js +2 -0
- package/dist/cjs/charts/constants/AGGREGATE_ABBREVIATION.d.ts +3 -1
- package/dist/cjs/charts/constants/AGGREGATE_ABBREVIATION.js +2 -0
- package/dist/cjs/charts/constants/AGGREGATE_INFO.js +16 -0
- package/dist/cjs/charts/constants/AGGREGATE_LABEL.d.ts +3 -1
- package/dist/cjs/charts/constants/AGGREGATE_LABEL.js +2 -0
- package/dist/cjs/charts/constants/CHART_OBJECT.d.ts +564 -0
- package/dist/cjs/charts/constants/CHART_OBJECT.js +56 -0
- package/dist/cjs/charts/constants/QUESTION_TYPES.d.ts +241 -0
- package/dist/cjs/charts/constants/QUESTION_TYPES.js +413 -0
- package/dist/cjs/charts/constants/TIME_PERIOD.d.ts +10 -0
- package/dist/cjs/charts/constants/TIME_PERIOD.js +28 -0
- package/dist/cjs/charts/constants/index.d.ts +3 -0
- package/dist/cjs/charts/constants/index.js +3 -0
- package/dist/cjs/charts/helpers/chartTypes.d.ts +24 -0
- package/dist/cjs/charts/helpers/chartTypes.js +138 -0
- package/dist/cjs/charts/helpers/defaultColumnBuilder.d.ts +56 -0
- package/dist/cjs/charts/helpers/defaultColumnBuilder.js +326 -0
- package/dist/cjs/charts/helpers/getChartDimensions.d.ts +2 -0
- package/dist/cjs/charts/helpers/getChartDimensions.js +267 -0
- package/dist/cjs/charts/helpers/index.d.ts +4 -0
- package/dist/cjs/charts/helpers/index.js +4 -0
- package/dist/cjs/charts/helpers/styleSettingsByChartType.d.ts +60 -0
- package/dist/cjs/charts/helpers/styleSettingsByChartType.js +541 -0
- package/dist/cjs/charts/interfaces/IChartV2.d.ts +537 -0
- package/dist/cjs/charts/interfaces/IChartV2.js +36 -0
- package/dist/cjs/charts/interfaces/IRequestAdapterMetric.d.ts +3 -1
- package/dist/cjs/charts/interfaces/index.d.ts +1 -0
- package/dist/cjs/charts/interfaces/index.js +1 -0
- package/dist/cjs/column_format/helpers/columnTypeByChart.js +3 -1
- package/dist/cjs/column_format/helpers/defineTableChartFormat.js +5 -1
- package/dist/cjs/column_format/helpers/defineXYChartFormat.js +5 -1
- package/dist/cjs/columns/interfaces/IColunmCalculation.d.ts +5 -0
- package/dist/cjs/constants/Charts.Const.d.ts +2 -1
- package/dist/cjs/constants/Charts.Const.js +1 -0
- package/dist/cjs/elements/helpers/fixed.d.ts +3 -2
- package/dist/cjs/elements/helpers/fixed.js +18 -12
- package/dist/cjs/elements/helpers/gridStrategy.d.ts +2 -1
- package/dist/cjs/elements/helpers/gridStrategy.js +11 -7
- package/dist/cjs/elements/helpers/index.d.ts +1 -1
- package/dist/cjs/elements/helpers/index.js +2 -1
- package/dist/cjs/elements/helpers/responsive.d.ts +11 -1
- package/dist/cjs/elements/helpers/responsive.js +31 -1
- package/dist/cjs/filters/constants/common/FILTER_SCOPE.d.ts +1 -0
- package/dist/cjs/filters/constants/common/FILTER_SCOPE.js +1 -0
- package/dist/cjs/filters/constants/common/FILTER_SCOPES.js +1 -0
- package/dist/cjs/filters/constants/common/FILTER_SCOPE_INFO.js +8 -0
- package/dist/cjs/filters/constants/common/FILTER_SCOPE_LABEL.d.ts +1 -0
- package/dist/cjs/filters/constants/common/FILTER_SCOPE_LABEL.js +1 -0
- package/dist/cjs/filters/constants/settings/FILTER_SETTINGS_DEFAULT.js +29 -6
- package/dist/cjs/filters/helpers/common/excludeFiltersByDatasetsColumns.d.ts +10 -0
- package/dist/cjs/filters/helpers/common/excludeFiltersByDatasetsColumns.js +64 -0
- package/dist/cjs/filters/helpers/common/index.d.ts +1 -0
- package/dist/cjs/filters/helpers/common/index.js +1 -0
- package/dist/cjs/filters/services/UChartPaginationApi.js +8 -1
- package/dist/cjs/format/duration/durationFormatter.js +18 -12
- package/dist/cjs/format/format.js +13 -2
- package/dist/cjs/format/helpers/getCurrencySymbolByCode.d.ts +6 -0
- package/dist/cjs/format/helpers/getCurrencySymbolByCode.js +28 -0
- package/dist/cjs/format/helpers/index.d.ts +2 -0
- package/dist/cjs/format/helpers/index.js +2 -0
- package/dist/cjs/format/helpers/isDefaultCurrent.d.ts +7 -0
- package/dist/cjs/format/helpers/isDefaultCurrent.js +13 -0
- package/dist/cjs/format/localization.js +8 -1
- package/dist/cjs/general/string/strategies/XSSEstrictedSanitizer.js +6 -1
- package/dist/cjs/general/string/strategies/XSSSanitizer.js +1 -1
- package/dist/cjs/globalization/interfaces/II18nConfig.d.ts +13 -0
- package/dist/cjs/globalization/interfaces/chart_builder/II18nChartBuilderGeneralOptions.d.ts +9 -0
- package/dist/cjs/globalization/interfaces/chart_builder/II18nChartBuilderMessagesDefault.d.ts +1 -0
- package/dist/cjs/globalization/interfaces/chart_builder/II18nChartBuilderMessagesGeneral.d.ts +1 -0
- package/dist/cjs/globalization/interfaces/chart_builder/II18nChartBuilderStyleOptions.d.ts +7 -0
- package/dist/cjs/globalization/interfaces/dashboard/II18nDashboardAddChart.d.ts +1 -0
- package/dist/cjs/globalization/interfaces/export/II18nExportingModal.d.ts +2 -0
- package/dist/cjs/globalization/interfaces/filters/II18nFilterPanel.d.ts +2 -0
- package/dist/cjs/globalization/interfaces/filters/II18nFilterPanelScopeTitle.d.ts +1 -0
- package/dist/cjs/globalization/interfaces/filters/II18nFilterScopes.d.ts +1 -0
- package/dist/cjs/globalization/labels/chart_builder/I18N_CHART_BUILDER_GENERAL.js +2 -0
- package/dist/cjs/globalization/labels/chart_builder/I18N_CHART_BUILDER_GENERAL_OPTIONS.js +9 -0
- package/dist/cjs/globalization/labels/chart_builder/I18N_CHART_BUILDER_STYLE_OPTIONS.js +7 -0
- package/dist/cjs/globalization/labels/dashboard/I18N_DASHBOARD.js +1 -0
- package/dist/cjs/globalization/labels/export/I18N_EXPORT_MODAL.d.ts +1 -1
- package/dist/cjs/globalization/labels/export/I18N_EXPORT_MODAL.js +76 -43
- package/dist/cjs/globalization/labels/filters/I18N_FILTER.js +1 -0
- package/dist/cjs/globalization/labels/filters/I18N_FILTER_PANEL.js +2 -0
- package/dist/cjs/globalization/labels/filters/I18N_FILTER_SCOPE.js +1 -0
- package/dist/cjs/interfaces/format/IFormatConfig.Interface.d.ts +1 -0
- package/dist/cjs/interfaces/format/IFormatCurrency.Interface.d.ts +1 -0
- package/dist/cjs/themes/helpers/index.d.ts +1 -0
- package/dist/cjs/themes/helpers/index.js +1 -0
- package/dist/cjs/themes/helpers/loadDefaultQrveyFonts.d.ts +11 -0
- package/dist/cjs/themes/helpers/loadDefaultQrveyFonts.js +32 -0
- package/dist/column_format/helpers/columnTypeByChart.js +4 -2
- package/dist/column_format/helpers/defineTableChartFormat.js +5 -1
- package/dist/column_format/helpers/defineXYChartFormat.js +5 -1
- package/dist/columns/interfaces/IColunmCalculation.d.ts +5 -0
- package/dist/constants/Charts.Const.d.ts +2 -1
- package/dist/constants/Charts.Const.js +1 -0
- package/dist/elements/helpers/fixed.d.ts +3 -2
- package/dist/elements/helpers/fixed.js +15 -9
- package/dist/elements/helpers/gridStrategy.d.ts +2 -1
- package/dist/elements/helpers/gridStrategy.js +10 -6
- package/dist/elements/helpers/index.d.ts +1 -1
- package/dist/elements/helpers/index.js +1 -1
- package/dist/elements/helpers/responsive.d.ts +11 -1
- package/dist/elements/helpers/responsive.js +29 -0
- package/dist/filters/constants/common/FILTER_SCOPE.d.ts +1 -0
- package/dist/filters/constants/common/FILTER_SCOPE.js +1 -0
- package/dist/filters/constants/common/FILTER_SCOPES.js +1 -0
- package/dist/filters/constants/common/FILTER_SCOPE_INFO.js +8 -0
- package/dist/filters/constants/common/FILTER_SCOPE_LABEL.d.ts +1 -0
- package/dist/filters/constants/common/FILTER_SCOPE_LABEL.js +1 -0
- package/dist/filters/constants/settings/FILTER_SETTINGS_DEFAULT.js +29 -6
- package/dist/filters/helpers/common/excludeFiltersByDatasetsColumns.d.ts +10 -0
- package/dist/filters/helpers/common/excludeFiltersByDatasetsColumns.js +60 -0
- package/dist/filters/helpers/common/index.d.ts +1 -0
- package/dist/filters/helpers/common/index.js +1 -0
- package/dist/filters/services/UChartPaginationApi.js +8 -1
- package/dist/format/duration/durationFormatter.js +18 -12
- package/dist/format/format.js +13 -2
- package/dist/format/helpers/getCurrencySymbolByCode.d.ts +6 -0
- package/dist/format/helpers/getCurrencySymbolByCode.js +24 -0
- package/dist/format/helpers/index.d.ts +2 -0
- package/dist/format/helpers/index.js +2 -0
- package/dist/format/helpers/isDefaultCurrent.d.ts +7 -0
- package/dist/format/helpers/isDefaultCurrent.js +9 -0
- package/dist/format/localization.js +8 -1
- package/dist/general/string/strategies/XSSEstrictedSanitizer.js +6 -1
- package/dist/general/string/strategies/XSSSanitizer.js +1 -1
- package/dist/globalization/interfaces/II18nConfig.d.ts +13 -0
- package/dist/globalization/interfaces/chart_builder/II18nChartBuilderGeneralOptions.d.ts +9 -0
- package/dist/globalization/interfaces/chart_builder/II18nChartBuilderMessagesDefault.d.ts +1 -0
- package/dist/globalization/interfaces/chart_builder/II18nChartBuilderMessagesGeneral.d.ts +1 -0
- package/dist/globalization/interfaces/chart_builder/II18nChartBuilderStyleOptions.d.ts +7 -0
- package/dist/globalization/interfaces/dashboard/II18nDashboardAddChart.d.ts +1 -0
- package/dist/globalization/interfaces/export/II18nExportingModal.d.ts +2 -0
- package/dist/globalization/interfaces/filters/II18nFilterPanel.d.ts +2 -0
- package/dist/globalization/interfaces/filters/II18nFilterPanelScopeTitle.d.ts +1 -0
- package/dist/globalization/interfaces/filters/II18nFilterScopes.d.ts +1 -0
- package/dist/globalization/labels/chart_builder/I18N_CHART_BUILDER_GENERAL.js +2 -0
- package/dist/globalization/labels/chart_builder/I18N_CHART_BUILDER_GENERAL_OPTIONS.js +9 -0
- package/dist/globalization/labels/chart_builder/I18N_CHART_BUILDER_STYLE_OPTIONS.js +7 -0
- package/dist/globalization/labels/dashboard/I18N_DASHBOARD.js +1 -0
- package/dist/globalization/labels/export/I18N_EXPORT_MODAL.d.ts +1 -1
- package/dist/globalization/labels/export/I18N_EXPORT_MODAL.js +76 -43
- package/dist/globalization/labels/filters/I18N_FILTER.js +1 -0
- package/dist/globalization/labels/filters/I18N_FILTER_PANEL.js +2 -0
- package/dist/globalization/labels/filters/I18N_FILTER_SCOPE.js +1 -0
- package/dist/interfaces/format/IFormatConfig.Interface.d.ts +1 -0
- package/dist/interfaces/format/IFormatCurrency.Interface.d.ts +1 -0
- package/dist/themes/helpers/index.d.ts +1 -0
- package/dist/themes/helpers/index.js +1 -0
- package/dist/themes/helpers/loadDefaultQrveyFonts.d.ts +11 -0
- package/dist/themes/helpers/loadDefaultQrveyFonts.js +28 -0
- package/package.json +4 -4
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { IBColumn } from "../../columns";
|
|
2
|
-
import { CustomRangeConfig, MetricConfig, MetricCustomRange, MetricPeriod, MetricRequestPayload, MetricTimeInfo } from "../interfaces/IRequestAdapterMetric";
|
|
2
|
+
import { CustomRangeConfig, MetricConfig, MetricConfigData, MetricCustomRange, MetricPeriod, MetricRequestPayload, MetricTimeInfo } from "../interfaces/IRequestAdapterMetric";
|
|
3
3
|
/**
|
|
4
4
|
* It takes a metric object and returns a metric request object
|
|
5
5
|
* @param {MetricConfig} metricObj - MetricConfigData
|
|
6
6
|
* @returns A function that takes in a metricObj and returns a partial metricRequest
|
|
7
7
|
*/
|
|
8
8
|
export declare const makeBodyRequestMetrics: (metricObj: MetricConfig) => Partial<MetricRequestPayload>;
|
|
9
|
+
export declare const isDateAsText: (data: Partial<MetricConfigData>) => boolean;
|
|
9
10
|
/**
|
|
10
11
|
* It takes a date column, time data, and a custom range config and returns a metric period or metric
|
|
11
12
|
* custom range
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AGGREGATE_FORMULA } from "../../formulas";
|
|
2
2
|
import { isEmpty } from "../../general";
|
|
3
3
|
import { TIME_PERIOD, TP_CUSTOM_RANGE } from "../../interfaces";
|
|
4
|
+
import { AGGREGATE } from "../constants";
|
|
4
5
|
import { RELATIVE_OBJECT_BY_TIME_LABEL } from "../constants/REQUEST_ADAPTER";
|
|
5
6
|
/**
|
|
6
7
|
* It takes a metric object and returns a metric request object
|
|
@@ -14,7 +15,7 @@ export const makeBodyRequestMetrics = (metricObj) => {
|
|
|
14
15
|
body.value = metricMakeValue(data);
|
|
15
16
|
/* Checking if the data object has a dateColumn property. If it does, it will add a period and
|
|
16
17
|
comparison property to the body object. */
|
|
17
|
-
if (isComparison(data)) {
|
|
18
|
+
if (isComparison(data) && !isDateAsText(data)) {
|
|
18
19
|
body.period = metricMakeTimeData(data.dateColumn, data.timePeriod, getRangeDataPeriod(data));
|
|
19
20
|
body.comparison = metricMakeTimeData(data.dateColumn, data.comparison, getRangeDataComparison(data));
|
|
20
21
|
}
|
|
@@ -23,6 +24,7 @@ export const makeBodyRequestMetrics = (metricObj) => {
|
|
|
23
24
|
/**
|
|
24
25
|
* If data is truthy, return data.logic, otherwise return an empty array.
|
|
25
26
|
* @param filters - The data object that is passed to the component.
|
|
27
|
+
* @returns An array of IFBLogic objects.
|
|
26
28
|
*/
|
|
27
29
|
const getFilterLogic = (filters) => (filters === null || filters === void 0 ? void 0 : filters.logic) || [];
|
|
28
30
|
/**
|
|
@@ -36,14 +38,25 @@ const metricMakeValue = (data) => {
|
|
|
36
38
|
const metricValue = {
|
|
37
39
|
questionid: (_b = data === null || data === void 0 ? void 0 : data.value) === null || _b === void 0 ? void 0 : _b.id,
|
|
38
40
|
property: ((_c = data === null || data === void 0 ? void 0 : data.value) === null || _c === void 0 ? void 0 : _c.property) || null,
|
|
41
|
+
dateAsText: isDateAsText(data),
|
|
39
42
|
};
|
|
40
43
|
if (!isAggregateFormula)
|
|
41
44
|
metricValue.aggregate = (_d = data === null || data === void 0 ? void 0 : data.valueAggregate) === null || _d === void 0 ? void 0 : _d.label;
|
|
42
45
|
return metricValue;
|
|
43
46
|
};
|
|
47
|
+
export const isDateAsText = (data) => {
|
|
48
|
+
var _a;
|
|
49
|
+
return [
|
|
50
|
+
AGGREGATE.MIN,
|
|
51
|
+
AGGREGATE.MAX,
|
|
52
|
+
AGGREGATE.FIRST,
|
|
53
|
+
AGGREGATE.LAST,
|
|
54
|
+
].includes((_a = data === null || data === void 0 ? void 0 : data.valueAggregate) === null || _a === void 0 ? void 0 : _a.id);
|
|
55
|
+
};
|
|
44
56
|
/**
|
|
45
57
|
* If data is truthy and data.dateColumn is truthy, return true, otherwise return false.
|
|
46
58
|
* @param data - The data object that is passed to the component.
|
|
59
|
+
* @returns A boolean.
|
|
47
60
|
*/
|
|
48
61
|
const isComparison = (data) => Boolean(data === null || data === void 0 ? void 0 : data.dateColumn);
|
|
49
62
|
/**
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { CHART_TYPE } from "../../constants";
|
|
2
|
+
import { isEmpty, objectCopy } from "../../general";
|
|
3
|
+
import { hasReferenceLayer, hasSmallMultiple, hasTrendLayer, isChartMetric, isChartMinMax, isChartMultiserie, } from "../helpers/chartTypes";
|
|
4
|
+
import { getChartLayerList } from "../helpers/getChartDimensions";
|
|
5
|
+
import { getPanelBodyByChart } from "./getPanelBodyByChart";
|
|
6
|
+
export const convertChartObjectFromV2toV1 = (v2Model, inPreviewMode = true) => {
|
|
7
|
+
if (!(v2Model === null || v2Model === void 0 ? void 0 : v2Model.stylesSettings) ||
|
|
8
|
+
((isChartMetric(v2Model.type) || isChartMinMax(v2Model.type)) &&
|
|
9
|
+
isEmpty(v2Model.dimensions.values))) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const objCopy = objectCopy(v2Model);
|
|
13
|
+
const chart_ms = [
|
|
14
|
+
CHART_TYPE.BAR_CHART_MS,
|
|
15
|
+
CHART_TYPE.LINE_CHART_MS,
|
|
16
|
+
CHART_TYPE.SYMBOL_CHART_MS,
|
|
17
|
+
CHART_TYPE.AREA_CHART_MS,
|
|
18
|
+
];
|
|
19
|
+
const chart_cb = [...chart_ms, CHART_TYPE.COMBO_CHART];
|
|
20
|
+
const chart_base = [
|
|
21
|
+
CHART_TYPE.BAR_CHART,
|
|
22
|
+
CHART_TYPE.LINE_CHART,
|
|
23
|
+
CHART_TYPE.SYMBOL_CHART,
|
|
24
|
+
CHART_TYPE.MINMAX_CHART,
|
|
25
|
+
CHART_TYPE.FUNNEL_CHART,
|
|
26
|
+
CHART_TYPE.AREA_CHART,
|
|
27
|
+
];
|
|
28
|
+
const bar_type = objCopy.stylesSettings.bar_type;
|
|
29
|
+
objCopy.bar_width = objCopy.stylesSettings.bar_width;
|
|
30
|
+
objCopy.isMulti = isChartMultiserie(objCopy.type);
|
|
31
|
+
objCopy.isChartOptions = [...chart_base, ...chart_cb].includes(objCopy.type);
|
|
32
|
+
objCopy.isCombolayer = [
|
|
33
|
+
CHART_TYPE.COMBO_CHART,
|
|
34
|
+
CHART_TYPE.COMBINED_CHART,
|
|
35
|
+
CHART_TYPE.RADAR_CHART,
|
|
36
|
+
].includes(objCopy.type);
|
|
37
|
+
objCopy.isReference = hasReferenceLayer(v2Model.dimensions.reference);
|
|
38
|
+
objCopy.isTrend =
|
|
39
|
+
objCopy.type !== CHART_TYPE.MINMAX_CHART &&
|
|
40
|
+
hasTrendLayer(v2Model.dimensions.trend);
|
|
41
|
+
const isBarMs = objCopy.isMulti && objCopy.type === CHART_TYPE.BAR_CHART_MS;
|
|
42
|
+
objCopy.is100 = isBarMs && bar_type === "h100";
|
|
43
|
+
objCopy.isCombo =
|
|
44
|
+
objCopy.isTrend ||
|
|
45
|
+
objCopy.isMulti ||
|
|
46
|
+
objCopy.isCombolayer ||
|
|
47
|
+
objCopy.isReference;
|
|
48
|
+
objCopy.isComboCalc = objCopy.isCombolayer;
|
|
49
|
+
objCopy.isStakedBar =
|
|
50
|
+
(isBarMs || objCopy.isCombo) &&
|
|
51
|
+
(objCopy.is100 || bar_type === "Stacked") &&
|
|
52
|
+
objCopy.type !== CHART_TYPE.BAR_CHART;
|
|
53
|
+
objCopy.isSmallMultiples =
|
|
54
|
+
[...chart_base, ...chart_cb].includes(objCopy.type) &&
|
|
55
|
+
objCopy.type !== CHART_TYPE.FUNNEL_CHART &&
|
|
56
|
+
hasSmallMultiple(v2Model.dimensions.smallmultiple);
|
|
57
|
+
const layerList = getChartLayerList(objCopy);
|
|
58
|
+
if (!layerList)
|
|
59
|
+
return;
|
|
60
|
+
const data = getPanelBodyByChart(objCopy.type, objCopy, layerList, inPreviewMode);
|
|
61
|
+
data.v2 = v2Model;
|
|
62
|
+
return data;
|
|
63
|
+
};
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { CHART_TYPE } from "../../constants";
|
|
2
|
+
import { _get, objectCopy, pick } from "../../general";
|
|
3
|
+
import { timePeriod, timePeriodCustomRange } from "../constants/TIME_PERIOD";
|
|
4
|
+
import { parseCalculation } from "../helpers/chartTypes";
|
|
5
|
+
import { parseGlobalSettingByType, parseStyleSettingByType, } from "../helpers/styleSettingsByChartType";
|
|
6
|
+
const parsePropertyComplexData = (column) => {
|
|
7
|
+
return _get(column, "property.value", null);
|
|
8
|
+
};
|
|
9
|
+
export const randomKey = () => {
|
|
10
|
+
return (Date.now() + Math.random() * 1e17).toString(36);
|
|
11
|
+
};
|
|
12
|
+
const setTotalAggregateInPreview = (totalAggregate, _inPreviewMode) => {
|
|
13
|
+
if (!totalAggregate)
|
|
14
|
+
return;
|
|
15
|
+
return totalAggregate;
|
|
16
|
+
};
|
|
17
|
+
const columnKey = (id, type, prop = "", index = 0) => {
|
|
18
|
+
const fixedProp = prop !== null ? prop["value"] || prop || "" : "";
|
|
19
|
+
const idx = index === void 0 ? "" : `|${index}`;
|
|
20
|
+
return `${id}|${type}|${fixedProp}${idx}`;
|
|
21
|
+
};
|
|
22
|
+
const parseSortOrder = (chartType, column) => {
|
|
23
|
+
const sortDirection = column.sortOrder || typeof column.sorting !== "string"
|
|
24
|
+
? _get(column, "sorting.order")
|
|
25
|
+
: column.sorting;
|
|
26
|
+
if (chartType === CHART_TYPE.CROSSTAB_CHART) {
|
|
27
|
+
const isDategroupSortOpt = typeof sortDirection === "string" && column.dateGroup;
|
|
28
|
+
return Object.assign(Object.assign({}, (typeof column.sorting !== "string" ? column.sorting : {})), { order: isDategroupSortOpt
|
|
29
|
+
? {
|
|
30
|
+
[column.dateGroup.text]: sortDirection || "asc",
|
|
31
|
+
}
|
|
32
|
+
: sortDirection });
|
|
33
|
+
}
|
|
34
|
+
const isDategroupSortOpt = column.dateGroup && typeof sortDirection !== "string";
|
|
35
|
+
return Object.assign(Object.assign({}, (typeof column.sorting !== "string" ? column.sorting : {})), { order: isDategroupSortOpt
|
|
36
|
+
? sortDirection &&
|
|
37
|
+
_get(column, `sorting.order.${column.dateGroup.text}`)
|
|
38
|
+
: sortDirection });
|
|
39
|
+
};
|
|
40
|
+
const getTableConfig = (chart, inPreviewMode, isTrendChart = false) => {
|
|
41
|
+
const fields = {
|
|
42
|
+
groupsList: [],
|
|
43
|
+
columnsList: [],
|
|
44
|
+
};
|
|
45
|
+
const params = [
|
|
46
|
+
{ objKey: "categories", fieldKey: "groupsList", type: "group" },
|
|
47
|
+
{ objKey: "values", fieldKey: "columnsList", type: "column" },
|
|
48
|
+
];
|
|
49
|
+
let count = 0;
|
|
50
|
+
params.forEach((param) => {
|
|
51
|
+
var _a;
|
|
52
|
+
if ((_a = chart.dimensions[param.objKey]) === null || _a === void 0 ? void 0 : _a.length) {
|
|
53
|
+
fields[param.fieldKey] = chart.dimensions[param.objKey].map((item) => {
|
|
54
|
+
const column = {
|
|
55
|
+
data: Object.assign(Object.assign({}, item), { property: parsePropertyComplexData(item) }),
|
|
56
|
+
index: new Date().getTime() + randomKey(),
|
|
57
|
+
type: param.type,
|
|
58
|
+
label: item.label || item.text,
|
|
59
|
+
visualization: item.visualization || "Values",
|
|
60
|
+
aggregate: setTotalAggregateInPreview(item.totalAggregate, inPreviewMode),
|
|
61
|
+
calculation: chart.dimensions["categories"].length
|
|
62
|
+
? parseCalculation(item, chart)
|
|
63
|
+
: null,
|
|
64
|
+
dataField: columnKey(item.id, item.type, item.property, count + 1),
|
|
65
|
+
qrveyid: item.qrveyid,
|
|
66
|
+
dateGroup: item.dateGroup,
|
|
67
|
+
sorting: parseSortOrder(chart.type, item),
|
|
68
|
+
sortIndex: item.sortIndex,
|
|
69
|
+
width: item.width,
|
|
70
|
+
groupAggregate: undefined,
|
|
71
|
+
};
|
|
72
|
+
if (item.aggregate)
|
|
73
|
+
column.groupAggregate = Object.assign({}, item.aggregate);
|
|
74
|
+
count += 1;
|
|
75
|
+
return column;
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
if (isTrendChart)
|
|
80
|
+
return { fields };
|
|
81
|
+
const isGrouped = fields.groupsList && !!fields.groupsList.length;
|
|
82
|
+
return {
|
|
83
|
+
fields,
|
|
84
|
+
isGrouped,
|
|
85
|
+
conditions: chart.conditions,
|
|
86
|
+
visualization: parseStyleSettingByType(CHART_TYPE.TABLE_CHART, Object.assign(Object.assign({}, chart), { isGrouped })),
|
|
87
|
+
totals: chart.dimensions.tableTotals,
|
|
88
|
+
isMultipleSorted: chart.isMultipleSorted,
|
|
89
|
+
trendsChart: chart.trendsCharts || [],
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
const getCrosstabConfig = (opts) => {
|
|
93
|
+
const fields = {};
|
|
94
|
+
const params = [
|
|
95
|
+
{ objKey: "pivots", fieldKey: "columnsList", type: "column" },
|
|
96
|
+
{ objKey: "categories", fieldKey: "rowsList", type: "row" },
|
|
97
|
+
{ objKey: "values", fieldKey: "valuesList", type: "data" },
|
|
98
|
+
];
|
|
99
|
+
params.forEach((param) => {
|
|
100
|
+
var _a;
|
|
101
|
+
const dimension = param.objKey === "values" && !((_a = opts.dimensions[param.objKey]) === null || _a === void 0 ? void 0 : _a.length)
|
|
102
|
+
? [opts.dimensions.categories[0] || opts.dimensions.pivots[0]]
|
|
103
|
+
: opts.dimensions[param.objKey];
|
|
104
|
+
fields[param.fieldKey] = dimension.map((item) => {
|
|
105
|
+
const column = {
|
|
106
|
+
data: Object.assign(Object.assign({}, item), { property: parsePropertyComplexData(item) }),
|
|
107
|
+
index: new Date().getTime() + randomKey(),
|
|
108
|
+
type: param.type,
|
|
109
|
+
qrveyid: item.qrveyid,
|
|
110
|
+
label: item.label || item.text,
|
|
111
|
+
sorting: parseSortOrder(opts.type, item),
|
|
112
|
+
dateGroup: undefined,
|
|
113
|
+
aggregate: undefined,
|
|
114
|
+
};
|
|
115
|
+
if (item.dateGroup) {
|
|
116
|
+
column.dateGroup = item.dateGroup;
|
|
117
|
+
}
|
|
118
|
+
if (item.aggregate && param.type === "data") {
|
|
119
|
+
column.aggregate = Object.assign({}, item.aggregate);
|
|
120
|
+
}
|
|
121
|
+
return column;
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
const rowGrandTotals = ["SHOW", "ROWSONLY"].includes(opts.globalSettings.crosstab_totals.option);
|
|
125
|
+
const columnGrandTotals = ["SHOW", "COLUMNSONLY"].includes(opts.globalSettings.crosstab_totals.option);
|
|
126
|
+
return {
|
|
127
|
+
fields,
|
|
128
|
+
visualization: parseStyleSettingByType(CHART_TYPE.CROSSTAB_CHART, opts),
|
|
129
|
+
config: {
|
|
130
|
+
showBorders: false,
|
|
131
|
+
width: 442,
|
|
132
|
+
height: 361,
|
|
133
|
+
fieldChooser: { enabled: false },
|
|
134
|
+
fieldPanel: {
|
|
135
|
+
visible: opts.globalSettings.crosstab_labels.value,
|
|
136
|
+
showFilterFields: false,
|
|
137
|
+
allowFieldDragging: false,
|
|
138
|
+
showColumnFields: true,
|
|
139
|
+
showRowFields: true,
|
|
140
|
+
showDataFields: false,
|
|
141
|
+
texts: { columnFieldArea: "", rowFieldArea: "" },
|
|
142
|
+
},
|
|
143
|
+
rowHeaderLayout: "tree",
|
|
144
|
+
showRowGrandTotals: opts.globalSettings.crosstab_totals.value && rowGrandTotals,
|
|
145
|
+
showColumnGrandTotals: opts.globalSettings.crosstab_totals.value && columnGrandTotals,
|
|
146
|
+
showRowTotals: opts.globalSettings.crosstab_subtotals,
|
|
147
|
+
showColumnTotals: opts.globalSettings.crosstab_subtotals,
|
|
148
|
+
allowSorting: opts.globalSettings.crosstab_labels.options.sorting,
|
|
149
|
+
allowSortingBySummary: false,
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
const getGeoMapConfig = (opts) => {
|
|
154
|
+
const fields = {};
|
|
155
|
+
const params = [
|
|
156
|
+
{ objKey: "categories", fieldKey: "categories", type: "column" },
|
|
157
|
+
{ objKey: "values", fieldKey: "values", type: "column" },
|
|
158
|
+
];
|
|
159
|
+
params.forEach((param) => {
|
|
160
|
+
var _a;
|
|
161
|
+
if ((_a = opts.dimensions[param.objKey]) === null || _a === void 0 ? void 0 : _a.length) {
|
|
162
|
+
fields[param.fieldKey] = opts.dimensions[param.objKey].map((item) => {
|
|
163
|
+
const column = {
|
|
164
|
+
data: Object.assign(Object.assign({}, item), { property: parsePropertyComplexData(item) }),
|
|
165
|
+
index: new Date().getTime() + randomKey(),
|
|
166
|
+
type: param.type,
|
|
167
|
+
qrveyid: item.qrveyid,
|
|
168
|
+
aggregate: undefined,
|
|
169
|
+
};
|
|
170
|
+
if (item.aggregate && param.type === "data") {
|
|
171
|
+
column.aggregate = Object.assign({}, item.aggregate);
|
|
172
|
+
}
|
|
173
|
+
return column;
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
return {
|
|
178
|
+
fields,
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
const getMetricConfigData = (chart, obj) => {
|
|
182
|
+
const { values, thresholds, comparison } = objectCopy(obj.dimensions);
|
|
183
|
+
let data = {
|
|
184
|
+
value: Object.assign(Object.assign({}, values[0]), { property: parsePropertyComplexData(values[0]) }),
|
|
185
|
+
dataSet: {},
|
|
186
|
+
valueAggregate: values[0] && values[0].aggregate,
|
|
187
|
+
dateColumn: undefined,
|
|
188
|
+
timePeriod: undefined,
|
|
189
|
+
comparison: undefined,
|
|
190
|
+
timePeriodCustomRange: undefined,
|
|
191
|
+
timePeriodDate: undefined,
|
|
192
|
+
timePeriodEndDate: undefined,
|
|
193
|
+
comparisonCustomRange: undefined,
|
|
194
|
+
comparisonDate: undefined,
|
|
195
|
+
comparisonEndDate: undefined,
|
|
196
|
+
};
|
|
197
|
+
if (comparison[0]) {
|
|
198
|
+
const dateColumn = Object.assign({}, comparison[0]);
|
|
199
|
+
const config = dateColumn.comparison;
|
|
200
|
+
delete dateColumn.comparison;
|
|
201
|
+
data = Object.assign(Object.assign({}, data), { dateColumn, timePeriod: timePeriod.find((tp) => tp.label === config.time_period.value), comparison: timePeriod.find((tp) => tp.label === config.time_comparison.value) });
|
|
202
|
+
if (config.time_period.value === "CUSTOM_RANGE" /* CUSTOM_RANGE */) {
|
|
203
|
+
data = Object.assign(Object.assign({}, data), { timePeriodCustomRange: timePeriodCustomRange.find((tpc) => tpc.label === config.time_period.range), timePeriodDate: config.time_period.start, timePeriodEndDate: config.time_period.end });
|
|
204
|
+
}
|
|
205
|
+
if (config.time_comparison.value === "CUSTOM_RANGE" /* CUSTOM_RANGE */) {
|
|
206
|
+
data = Object.assign(Object.assign({}, data), { comparisonCustomRange: timePeriodCustomRange.find((tpc) => tpc.label === config.time_comparison.range), comparisonDate: config.time_comparison.start, comparisonEndDate: config.time_comparison.end });
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return {
|
|
210
|
+
appid: obj.appid,
|
|
211
|
+
type: { label: chart },
|
|
212
|
+
thresholdsList: thresholds.map((thr) => ({
|
|
213
|
+
label: thr.custom_label || thr.label,
|
|
214
|
+
color: thr.color,
|
|
215
|
+
operator: { label: thr.operator },
|
|
216
|
+
value: thr.value,
|
|
217
|
+
initValue: thr.value,
|
|
218
|
+
endValue: thr.max_value,
|
|
219
|
+
type: thr === null || thr === void 0 ? void 0 : thr.type,
|
|
220
|
+
column: thr === null || thr === void 0 ? void 0 : thr.column,
|
|
221
|
+
aggregate: thr === null || thr === void 0 ? void 0 : thr.aggregate,
|
|
222
|
+
endColumn: thr === null || thr === void 0 ? void 0 : thr.endColumn,
|
|
223
|
+
endAggregate: thr === null || thr === void 0 ? void 0 : thr.endAggregate,
|
|
224
|
+
})),
|
|
225
|
+
data,
|
|
226
|
+
individualSettings: parseStyleSettingByType(chart, obj),
|
|
227
|
+
dataset: data.dataSet,
|
|
228
|
+
};
|
|
229
|
+
};
|
|
230
|
+
export const getPanelBodyByChart = (chart, obj, layerList, inPreviewMode) => {
|
|
231
|
+
let panelBody = Object.assign(Object.assign({}, pick(obj, [
|
|
232
|
+
"title",
|
|
233
|
+
"name",
|
|
234
|
+
"metricid",
|
|
235
|
+
"chartid",
|
|
236
|
+
"type",
|
|
237
|
+
"position",
|
|
238
|
+
"createDate",
|
|
239
|
+
"modifyDate",
|
|
240
|
+
"dataSet",
|
|
241
|
+
"isOldChart",
|
|
242
|
+
"isMulti",
|
|
243
|
+
"bar_width",
|
|
244
|
+
"isComboCalc",
|
|
245
|
+
])), { globalSettings: parseGlobalSettingByType(obj.type, obj), preFilters: obj.preFilters || [], defaultFilters: obj.defaultFilters || {}, oldInternalFilters: obj.oldInternalFilters, dateGroup: _get(layerList[0], "dateGroup"),
|
|
246
|
+
// retro-compatibility
|
|
247
|
+
timeGroup: _get(layerList[0], "timeGroup"), layerList });
|
|
248
|
+
panelBody.name = obj.name || obj.title;
|
|
249
|
+
panelBody.dataset = obj.dataset;
|
|
250
|
+
switch (chart) {
|
|
251
|
+
case CHART_TYPE.BOXWHISKER_CHART:
|
|
252
|
+
panelBody.globalSettings.sortX = {
|
|
253
|
+
type: "Label",
|
|
254
|
+
order: "Asc",
|
|
255
|
+
};
|
|
256
|
+
break;
|
|
257
|
+
case CHART_TYPE.CROSSTAB_CHART:
|
|
258
|
+
panelBody = Object.assign(Object.assign({}, panelBody), { chart: getCrosstabConfig(obj) });
|
|
259
|
+
break;
|
|
260
|
+
case CHART_TYPE.EXPANDABLE_TABLE_CHART:
|
|
261
|
+
case CHART_TYPE.TABLE_CHART: {
|
|
262
|
+
const isSimpleTable = !obj.dimensions["categories"].length;
|
|
263
|
+
const attrMax = isSimpleTable
|
|
264
|
+
? "globalSettings.max_rows.value"
|
|
265
|
+
: "globalSettings.max_groups.value";
|
|
266
|
+
const maxRecords = _get(obj, attrMax);
|
|
267
|
+
panelBody = Object.assign(Object.assign({}, panelBody), { globalSettings: Object.assign(Object.assign({}, panelBody.globalSettings), { maxRecords }), chart: getTableConfig(obj, inPreviewMode) });
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
case CHART_TYPE.INDICATOR_METRIC:
|
|
271
|
+
case CHART_TYPE.DIAL_METRIC:
|
|
272
|
+
case CHART_TYPE.BULLET_METRIC: {
|
|
273
|
+
const { comparison } = objectCopy(obj.dimensions);
|
|
274
|
+
panelBody = Object.assign(Object.assign(Object.assign({}, panelBody), { globalSettings: Object.assign(Object.assign({}, panelBody.globalSettings), {
|
|
275
|
+
// TODO: Rebase this implementation to refactor
|
|
276
|
+
comparisonType: _get(comparison[0], "comparison.type", "CHANGE") }) }), getMetricConfigData(chart, obj));
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
case CHART_TYPE.GEO_CHART_DOT:
|
|
280
|
+
case CHART_TYPE.GEO_CHART_BUBBLE:
|
|
281
|
+
case CHART_TYPE.GEO_CHART_CHOROPLETH:
|
|
282
|
+
panelBody = Object.assign(Object.assign({}, panelBody), { isSmallMultiples: obj.isSmallMultiples, chart: getGeoMapConfig(obj) });
|
|
283
|
+
break;
|
|
284
|
+
default:
|
|
285
|
+
panelBody = Object.assign(Object.assign({}, panelBody), { isChartOptions: true, isCombolayer: obj.isCombolayer, isReference: obj.isReference, isMulti: obj.isMulti, isCombo: obj.isCombo, isSmallMultiples: obj.isSmallMultiples, isTrend: obj.isTrend, is100: obj.is100, isStakedBar: obj.isStakedBar, isSplit: false });
|
|
286
|
+
break;
|
|
287
|
+
}
|
|
288
|
+
return panelBody;
|
|
289
|
+
};
|
|
@@ -9,4 +9,6 @@ export var AGGREGATE_ABBREVIATION;
|
|
|
9
9
|
AGGREGATE_ABBREVIATION["STDEV"] = "STDEV";
|
|
10
10
|
AGGREGATE_ABBREVIATION["COUNT"] = "CNT";
|
|
11
11
|
AGGREGATE_ABBREVIATION["DISTINCTCOUNT"] = "CNTD";
|
|
12
|
+
AGGREGATE_ABBREVIATION["FIRST"] = "FIRST";
|
|
13
|
+
AGGREGATE_ABBREVIATION["LAST"] = "LAST";
|
|
12
14
|
})(AGGREGATE_ABBREVIATION || (AGGREGATE_ABBREVIATION = {}));
|
|
@@ -74,4 +74,20 @@ export const AGGREGATE_INFO = {
|
|
|
74
74
|
abbrLabel: AGGREGATE_ABBREVIATION.DISTINCTCOUNT,
|
|
75
75
|
i18nLabelPath: "common.aggregate_labels.distinct_count",
|
|
76
76
|
},
|
|
77
|
+
[AGGREGATE.FIRST]: {
|
|
78
|
+
value: AGGREGATE.FIRST,
|
|
79
|
+
displayed: false,
|
|
80
|
+
label: AGGREGATE_LABEL.LAST,
|
|
81
|
+
shortLabel: AGGREGATE_LABEL.FIRST,
|
|
82
|
+
abbrLabel: AGGREGATE_ABBREVIATION.FIRST,
|
|
83
|
+
i18nLabelPath: "common.aggregate_labels.first",
|
|
84
|
+
},
|
|
85
|
+
[AGGREGATE.LAST]: {
|
|
86
|
+
value: AGGREGATE.LAST,
|
|
87
|
+
displayed: false,
|
|
88
|
+
label: AGGREGATE_LABEL.LAST,
|
|
89
|
+
shortLabel: AGGREGATE_LABEL.LAST,
|
|
90
|
+
abbrLabel: AGGREGATE_ABBREVIATION.LAST,
|
|
91
|
+
i18nLabelPath: "common.aggregate_labels.last",
|
|
92
|
+
},
|
|
77
93
|
};
|
|
@@ -9,4 +9,6 @@ export var AGGREGATE_LABEL;
|
|
|
9
9
|
AGGREGATE_LABEL["STDEV"] = "Standard deviation";
|
|
10
10
|
AGGREGATE_LABEL["COUNT"] = "Count";
|
|
11
11
|
AGGREGATE_LABEL["DISTINCTCOUNT"] = "Distinct Count";
|
|
12
|
+
AGGREGATE_LABEL["FIRST"] = "First";
|
|
13
|
+
AGGREGATE_LABEL["LAST"] = "Last";
|
|
12
14
|
})(AGGREGATE_LABEL || (AGGREGATE_LABEL = {}));
|