@qrvey/utils 1.18.8 → 1.18.10
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/cjs/column_format/constants/COUNT_SUPPORTED_FORMATS.js +7 -0
- package/dist/cjs/column_format/constants/index.js +1 -0
- package/dist/cjs/column_format/helpers/defineTableChartFormat.js +10 -4
- package/dist/cjs/column_format/helpers/defineXYChartFormat.js +7 -2
- package/dist/cjs/comparativeAnalysis/index.js +7 -3
- package/dist/column_format/constants/COUNT_SUPPORTED_FORMATS.d.ts +1 -0
- package/dist/column_format/constants/COUNT_SUPPORTED_FORMATS.js +4 -0
- package/dist/column_format/constants/index.d.ts +1 -0
- package/dist/column_format/constants/index.js +1 -0
- package/dist/column_format/helpers/defineTableChartFormat.js +10 -4
- package/dist/column_format/helpers/defineXYChartFormat.js +7 -2
- package/dist/comparativeAnalysis/index.js +7 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./CHART_GROUP"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./COUNT_SUPPORTED_FORMATS"), exports);
|
|
5
6
|
tslib_1.__exportStar(require("./DATEGROUP_UNSUPPORT_FORMAT"), exports);
|
|
6
7
|
tslib_1.__exportStar(require("./DATEGROUP_WITHOUT_FORMAT"), exports);
|
|
7
8
|
tslib_1.__exportStar(require("./SHELF_TYPE"), exports);
|
|
@@ -5,6 +5,7 @@ const AGGREGATE_1 = require("../../charts/constants/AGGREGATE");
|
|
|
5
5
|
const COLUMN_1 = require("../../columns/constants/COLUMN");
|
|
6
6
|
const isEmpty_1 = require("../../general/mix/isEmpty");
|
|
7
7
|
const CHART_GROUP_1 = require("../constants/CHART_GROUP");
|
|
8
|
+
const COUNT_SUPPORTED_FORMATS_1 = require("../constants/COUNT_SUPPORTED_FORMATS");
|
|
8
9
|
const STRING_FORMAT_1 = require("../constants/STRING_FORMAT");
|
|
9
10
|
const TABLE_TYPE_1 = require("../constants/TABLE_TYPE");
|
|
10
11
|
const columnTypeByChart_1 = require("./columnTypeByChart");
|
|
@@ -85,11 +86,16 @@ const defineTableChartFormat = (column, settings) => {
|
|
|
85
86
|
return defaultPercentage;
|
|
86
87
|
if (selectedFormat && selectedFormat.format !== defaultText)
|
|
87
88
|
return selectedFormat;
|
|
89
|
+
const isCountAggregate = aggregate?.label === AGGREGATE_1.AGGREGATE.COUNT ||
|
|
90
|
+
aggregate?.label === AGGREGATE_1.AGGREGATE.DISTINCTCOUNT;
|
|
88
91
|
let output;
|
|
89
|
-
if (isGroupedTable &&
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
92
|
+
if (isGroupedTable && isCountAggregate) {
|
|
93
|
+
output = COUNT_SUPPORTED_FORMATS_1.COUNT_SUPPORTED_FORMATS.includes(outputFormat?.format)
|
|
94
|
+
? { ...outputFormat }
|
|
95
|
+
: defaultNumeric;
|
|
96
|
+
}
|
|
97
|
+
else if (definition_1.STANDARD_NUMERIC_FORMATS.includes(outputFormat?.format)) {
|
|
98
|
+
output = { ...outputFormat };
|
|
93
99
|
}
|
|
94
100
|
else {
|
|
95
101
|
output = defaultFormat || defaultNumeric;
|
|
@@ -8,6 +8,7 @@ const isEmpty_1 = require("../../general/mix/isEmpty");
|
|
|
8
8
|
const CALCULATION_LABEL_1 = require("../../qrvey/constants/CALCULATION_LABEL");
|
|
9
9
|
const constants_1 = require("../constants");
|
|
10
10
|
const CHART_GROUP_1 = require("../constants/CHART_GROUP");
|
|
11
|
+
const COUNT_SUPPORTED_FORMATS_1 = require("../constants/COUNT_SUPPORTED_FORMATS");
|
|
11
12
|
const DATEGROUP_UNSUPPORT_FORMAT_1 = require("../constants/DATEGROUP_UNSUPPORT_FORMAT");
|
|
12
13
|
const STRING_FORMAT_1 = require("../constants/STRING_FORMAT");
|
|
13
14
|
const columnTypeByChart_1 = require("./columnTypeByChart");
|
|
@@ -78,8 +79,11 @@ const defineXYChartFormat = (column, settings) => {
|
|
|
78
79
|
return defaultPercentage;
|
|
79
80
|
if ((aggregate?.label === AGGREGATE_1.AGGREGATE.COUNT ||
|
|
80
81
|
aggregate?.label === AGGREGATE_1.AGGREGATE.DISTINCTCOUNT) &&
|
|
81
|
-
hasDefaultFormat)
|
|
82
|
+
hasDefaultFormat) {
|
|
83
|
+
if (COUNT_SUPPORTED_FORMATS_1.COUNT_SUPPORTED_FORMATS.includes(outputFormat?.format))
|
|
84
|
+
return { ...outputFormat };
|
|
82
85
|
return defaultDecimal;
|
|
86
|
+
}
|
|
83
87
|
if (isUsedAsNumericColumn) {
|
|
84
88
|
if (columnCurrentFormat?.type !== COLUMN_1.COLUMN.NUMERIC || withoutFormat)
|
|
85
89
|
return defaultAbb;
|
|
@@ -91,7 +95,8 @@ const defineXYChartFormat = (column, settings) => {
|
|
|
91
95
|
else if (hasDefaultFormat) {
|
|
92
96
|
if (!outputFormat?.format)
|
|
93
97
|
return defaultDecimal;
|
|
94
|
-
if (!definition_1.STANDARD_NUMERIC_FORMATS.includes(outputFormat?.format) ||
|
|
98
|
+
if (!definition_1.STANDARD_NUMERIC_FORMATS.includes(outputFormat?.format) ||
|
|
99
|
+
constants_1.DURATION_PARTS_LIST.includes(outputFormat?.format)) {
|
|
95
100
|
return {
|
|
96
101
|
...outputFormat,
|
|
97
102
|
template: outputFormat?.format,
|
|
@@ -104,7 +104,9 @@ function formatDeltaDefaultCaption(referencePeriod, compareTo, allDatesText, col
|
|
|
104
104
|
const ref = fmtPeriodFn(referencePeriod);
|
|
105
105
|
const cmp = fmtPeriodFn(compareTo);
|
|
106
106
|
const comparison = ref && cmp ? `${ref} vs ${cmp}` : ref || cmp;
|
|
107
|
-
const prefix = colLabel
|
|
107
|
+
const prefix = colLabel
|
|
108
|
+
? `${exports.DELTA_COLUMN_PREFIX} ${colLabel}`
|
|
109
|
+
: exports.DELTA_COLUMN_PREFIX;
|
|
108
110
|
return comparison ? `${prefix} - ${comparison}` : prefix;
|
|
109
111
|
}
|
|
110
112
|
function computeComparativeVirtualColumns(isGrouped, myBus, chart, getChartColumns) {
|
|
@@ -342,7 +344,7 @@ function buildComparativeChartComparison(myBus, chart, groups) {
|
|
|
342
344
|
return null;
|
|
343
345
|
const validationType = mapOperatorToValidationType(operatorLabel);
|
|
344
346
|
const expression = {
|
|
345
|
-
groupValue: "day",
|
|
347
|
+
groupValue: periodData.groupValue || "day",
|
|
346
348
|
questionid: dateColumn,
|
|
347
349
|
qrveyid,
|
|
348
350
|
questionType,
|
|
@@ -443,7 +445,9 @@ function computeDeltaCellContent(comparativeAnalisis, columnKey, rawValue, optio
|
|
|
443
445
|
const compValueProvided = options != null &&
|
|
444
446
|
Object.prototype.hasOwnProperty.call(options, "comparisonValue");
|
|
445
447
|
const compVal = options?.comparisonValue;
|
|
446
|
-
if (compValueProvided &&
|
|
448
|
+
if (compValueProvided &&
|
|
449
|
+
(compVal == null || (typeof compVal === "number" && isNaN(compVal))) &&
|
|
450
|
+
origNum != null) {
|
|
447
451
|
parts.push(options?.missingLabel ?? "Missing");
|
|
448
452
|
}
|
|
449
453
|
else if (origNum != null &&
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const COUNT_SUPPORTED_FORMATS: string[];
|
|
@@ -2,6 +2,7 @@ import { AGGREGATE } from "../../charts/constants/AGGREGATE";
|
|
|
2
2
|
import { COLUMN } from "../../columns/constants/COLUMN";
|
|
3
3
|
import { isEmpty } from "../../general/mix/isEmpty";
|
|
4
4
|
import { CHART_GROUPS } from "../constants/CHART_GROUP";
|
|
5
|
+
import { COUNT_SUPPORTED_FORMATS } from "../constants/COUNT_SUPPORTED_FORMATS";
|
|
5
6
|
import { STRING_FORMAT } from "../constants/STRING_FORMAT";
|
|
6
7
|
import { TABLE_TYPE } from "../constants/TABLE_TYPE";
|
|
7
8
|
import { columnTypeByChart } from "./columnTypeByChart";
|
|
@@ -82,11 +83,16 @@ export const defineTableChartFormat = (column, settings) => {
|
|
|
82
83
|
return defaultPercentage;
|
|
83
84
|
if (selectedFormat && selectedFormat.format !== defaultText)
|
|
84
85
|
return selectedFormat;
|
|
86
|
+
const isCountAggregate = aggregate?.label === AGGREGATE.COUNT ||
|
|
87
|
+
aggregate?.label === AGGREGATE.DISTINCTCOUNT;
|
|
85
88
|
let output;
|
|
86
|
-
if (isGroupedTable &&
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
if (isGroupedTable && isCountAggregate) {
|
|
90
|
+
output = COUNT_SUPPORTED_FORMATS.includes(outputFormat?.format)
|
|
91
|
+
? { ...outputFormat }
|
|
92
|
+
: defaultNumeric;
|
|
93
|
+
}
|
|
94
|
+
else if (STANDARD_NUMERIC_FORMATS.includes(outputFormat?.format)) {
|
|
95
|
+
output = { ...outputFormat };
|
|
90
96
|
}
|
|
91
97
|
else {
|
|
92
98
|
output = defaultFormat || defaultNumeric;
|
|
@@ -5,6 +5,7 @@ import { isEmpty } from "../../general/mix/isEmpty";
|
|
|
5
5
|
import { CALCULATION_LABEL } from "../../qrvey/constants/CALCULATION_LABEL";
|
|
6
6
|
import { DURATION_PARTS_LIST, SHELF_TYPE } from "../constants";
|
|
7
7
|
import { CHART_GROUPS } from "../constants/CHART_GROUP";
|
|
8
|
+
import { COUNT_SUPPORTED_FORMATS } from "../constants/COUNT_SUPPORTED_FORMATS";
|
|
8
9
|
import { DATEGROUP_UNSUPPORT_FORMAT } from "../constants/DATEGROUP_UNSUPPORT_FORMAT";
|
|
9
10
|
import { STRING_FORMAT } from "../constants/STRING_FORMAT";
|
|
10
11
|
import { columnTypeByChart } from "./columnTypeByChart";
|
|
@@ -75,8 +76,11 @@ export const defineXYChartFormat = (column, settings) => {
|
|
|
75
76
|
return defaultPercentage;
|
|
76
77
|
if ((aggregate?.label === AGGREGATE.COUNT ||
|
|
77
78
|
aggregate?.label === AGGREGATE.DISTINCTCOUNT) &&
|
|
78
|
-
hasDefaultFormat)
|
|
79
|
+
hasDefaultFormat) {
|
|
80
|
+
if (COUNT_SUPPORTED_FORMATS.includes(outputFormat?.format))
|
|
81
|
+
return { ...outputFormat };
|
|
79
82
|
return defaultDecimal;
|
|
83
|
+
}
|
|
80
84
|
if (isUsedAsNumericColumn) {
|
|
81
85
|
if (columnCurrentFormat?.type !== COLUMN.NUMERIC || withoutFormat)
|
|
82
86
|
return defaultAbb;
|
|
@@ -88,7 +92,8 @@ export const defineXYChartFormat = (column, settings) => {
|
|
|
88
92
|
else if (hasDefaultFormat) {
|
|
89
93
|
if (!outputFormat?.format)
|
|
90
94
|
return defaultDecimal;
|
|
91
|
-
if (!STANDARD_NUMERIC_FORMATS.includes(outputFormat?.format) ||
|
|
95
|
+
if (!STANDARD_NUMERIC_FORMATS.includes(outputFormat?.format) ||
|
|
96
|
+
DURATION_PARTS_LIST.includes(outputFormat?.format)) {
|
|
92
97
|
return {
|
|
93
98
|
...outputFormat,
|
|
94
99
|
template: outputFormat?.format,
|
|
@@ -86,7 +86,9 @@ export function formatDeltaDefaultCaption(referencePeriod, compareTo, allDatesTe
|
|
|
86
86
|
const ref = fmtPeriodFn(referencePeriod);
|
|
87
87
|
const cmp = fmtPeriodFn(compareTo);
|
|
88
88
|
const comparison = ref && cmp ? `${ref} vs ${cmp}` : ref || cmp;
|
|
89
|
-
const prefix = colLabel
|
|
89
|
+
const prefix = colLabel
|
|
90
|
+
? `${DELTA_COLUMN_PREFIX} ${colLabel}`
|
|
91
|
+
: DELTA_COLUMN_PREFIX;
|
|
90
92
|
return comparison ? `${prefix} - ${comparison}` : prefix;
|
|
91
93
|
}
|
|
92
94
|
export function computeComparativeVirtualColumns(isGrouped, myBus, chart, getChartColumns) {
|
|
@@ -324,7 +326,7 @@ export function buildComparativeChartComparison(myBus, chart, groups) {
|
|
|
324
326
|
return null;
|
|
325
327
|
const validationType = mapOperatorToValidationType(operatorLabel);
|
|
326
328
|
const expression = {
|
|
327
|
-
groupValue: "day",
|
|
329
|
+
groupValue: periodData.groupValue || "day",
|
|
328
330
|
questionid: dateColumn,
|
|
329
331
|
qrveyid,
|
|
330
332
|
questionType,
|
|
@@ -425,7 +427,9 @@ export function computeDeltaCellContent(comparativeAnalisis, columnKey, rawValue
|
|
|
425
427
|
const compValueProvided = options != null &&
|
|
426
428
|
Object.prototype.hasOwnProperty.call(options, "comparisonValue");
|
|
427
429
|
const compVal = options?.comparisonValue;
|
|
428
|
-
if (compValueProvided &&
|
|
430
|
+
if (compValueProvided &&
|
|
431
|
+
(compVal == null || (typeof compVal === "number" && isNaN(compVal))) &&
|
|
432
|
+
origNum != null) {
|
|
429
433
|
parts.push(options?.missingLabel ?? "Missing");
|
|
430
434
|
}
|
|
431
435
|
else if (origNum != null &&
|