@sisense/sdk-data 0.16.0 → 1.1.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.
@@ -0,0 +1,47 @@
1
+ import type { Attribute, Measure } from '../interfaces.js';
2
+ /** @internal */
3
+ export declare const BOX_WHISKER: {
4
+ BOX_MIN_VALUE_NAME: string;
5
+ BOX_MEDIAN_VALUE_NAME: string;
6
+ BOX_MAX_VALUE_NAME: string;
7
+ WHISKER_MIN_VALUE_NAME: string;
8
+ WHISKER_MAX_VALUE_NAME: string;
9
+ OUTLIER_COUNT_VALUE_NAME: string;
10
+ OUTLIER_MIN_VALUE_NAME: string;
11
+ OUTLIER_MAX_VALUE_NAME: string;
12
+ };
13
+ /**
14
+ * Returns an array of values for box whisker plot using interquartile range (IQR) calculations.
15
+ *
16
+ * @param {Attribute} target - The target attribute for calculations.
17
+ * @returns {Measure[]} An array of measures representing IQR values for box whisker plots.
18
+ */
19
+ export declare function boxWhiskerIqrValues(target: Attribute): Measure[];
20
+ /**
21
+ * Returns an array of extremum values for box whisker plot.
22
+ *
23
+ * @param {Attribute} target - The target attribute for calculations.
24
+ * @returns {Measure[]} An array of measures representing extremum values for box whisker plots.
25
+ */
26
+ export declare function boxWhiskerExtremumsValues(target: Attribute): Measure[];
27
+ /**
28
+ * Returns an array of values for box whisker plot using standard deviation calculations.
29
+ *
30
+ * @param {Attribute} target - The target attribute for calculations.
31
+ * @returns {Measure[]} An array of measures representing standard deviation values for box whisker plots.
32
+ */
33
+ export declare function boxWhiskerStdDevValues(target: Attribute): Measure[];
34
+ /**
35
+ * Returns an attribute representing outlier points based on interquartile range (IQR) calculations.
36
+ *
37
+ * @param {Attribute} target - The target attribute for calculations.
38
+ * @returns {Attribute} An attribute representing outliers for box whisker plots using IQR.
39
+ */
40
+ export declare const boxWhiskerIqrOutliers: (target: Attribute) => Attribute;
41
+ /**
42
+ * Returns an attribute representing outlier points based on standard deviation calculations.
43
+ *
44
+ * @param {Attribute} target - The target attribute for calculations.
45
+ * @returns {Attribute} An attribute representing outliers for box whisker plots using standard deviation.
46
+ */
47
+ export declare const boxWhiskerStdDevOutliers: (target: Attribute) => Attribute;
@@ -0,0 +1,140 @@
1
+ import cloneDeep from 'lodash/cloneDeep.js';
2
+ import { customFormula } from '../measures/factory.js';
3
+ /** @internal */
4
+ export const BOX_WHISKER = {
5
+ BOX_MIN_VALUE_NAME: 'Box Min',
6
+ BOX_MEDIAN_VALUE_NAME: 'Box Median',
7
+ BOX_MAX_VALUE_NAME: 'Box Max',
8
+ WHISKER_MIN_VALUE_NAME: 'Whisker Min',
9
+ WHISKER_MAX_VALUE_NAME: 'Whisker Max',
10
+ OUTLIER_COUNT_VALUE_NAME: 'Outlier Count',
11
+ OUTLIER_MIN_VALUE_NAME: 'Outlier Min',
12
+ OUTLIER_MAX_VALUE_NAME: 'Outlier Max',
13
+ };
14
+ function boxWhiskerCommonValues(target) {
15
+ return [
16
+ customFormula(BOX_WHISKER.BOX_MIN_VALUE_NAME, 'QUARTILE([Attr], 1)', {
17
+ Attr: target,
18
+ }),
19
+ customFormula(BOX_WHISKER.BOX_MEDIAN_VALUE_NAME, 'MEDIAN([Attr])', {
20
+ Attr: target,
21
+ }),
22
+ customFormula(BOX_WHISKER.BOX_MAX_VALUE_NAME, 'QUARTILE([Attr], 3)', {
23
+ Attr: target,
24
+ }),
25
+ ];
26
+ }
27
+ /**
28
+ * Returns an array of values for box whisker plot using interquartile range (IQR) calculations.
29
+ *
30
+ * @param {Attribute} target - The target attribute for calculations.
31
+ * @returns {Measure[]} An array of measures representing IQR values for box whisker plots.
32
+ */
33
+ export function boxWhiskerIqrValues(target) {
34
+ return [
35
+ ...boxWhiskerCommonValues(target),
36
+ customFormula(BOX_WHISKER.WHISKER_MIN_VALUE_NAME, 'LOWERWHISKERMAX_IQR([Attr])', {
37
+ Attr: target,
38
+ }),
39
+ customFormula(BOX_WHISKER.WHISKER_MAX_VALUE_NAME, 'UPPERWHISKERMIN_IQR([Attr])', {
40
+ Attr: target,
41
+ }),
42
+ customFormula(BOX_WHISKER.OUTLIER_COUNT_VALUE_NAME, 'OUTLIERSCOUNT_IQR([Attr])', {
43
+ Attr: target,
44
+ }),
45
+ ];
46
+ }
47
+ /**
48
+ * Returns an array of extremum values for box whisker plot.
49
+ *
50
+ * @param {Attribute} target - The target attribute for calculations.
51
+ * @returns {Measure[]} An array of measures representing extremum values for box whisker plots.
52
+ */
53
+ export function boxWhiskerExtremumsValues(target) {
54
+ return [
55
+ ...boxWhiskerCommonValues(target),
56
+ customFormula(BOX_WHISKER.WHISKER_MIN_VALUE_NAME, 'MIN([Attr])', {
57
+ Attr: target,
58
+ }),
59
+ customFormula(BOX_WHISKER.WHISKER_MAX_VALUE_NAME, 'MAX([Attr])', {
60
+ Attr: target,
61
+ }),
62
+ ];
63
+ }
64
+ /**
65
+ * Returns an array of values for box whisker plot using standard deviation calculations.
66
+ *
67
+ * @param {Attribute} target - The target attribute for calculations.
68
+ * @returns {Measure[]} An array of measures representing standard deviation values for box whisker plots.
69
+ */
70
+ export function boxWhiskerStdDevValues(target) {
71
+ return [
72
+ ...boxWhiskerCommonValues(target),
73
+ customFormula(BOX_WHISKER.WHISKER_MIN_VALUE_NAME, 'LOWERWHISKERMAX_STDEVP([Attr])', {
74
+ Attr: target,
75
+ }),
76
+ customFormula(BOX_WHISKER.WHISKER_MAX_VALUE_NAME, 'UPPERWHISKERMIN_STDEVP([Attr])', {
77
+ Attr: target,
78
+ }),
79
+ customFormula(BOX_WHISKER.OUTLIER_COUNT_VALUE_NAME, 'OUTLIERSCOUNT_STDEVP([Attr])', {
80
+ Attr: target,
81
+ }),
82
+ ];
83
+ }
84
+ /**
85
+ * Returns an attribute representing outlier points based on interquartile range (IQR) calculations.
86
+ *
87
+ * @param {Attribute} target - The target attribute for calculations.
88
+ * @returns {Attribute} An attribute representing outliers for box whisker plots using IQR.
89
+ */
90
+ export const boxWhiskerIqrOutliers = (target) => {
91
+ const outliersAttrWithInnerFilter = cloneDeep(target);
92
+ const outliersMax = customFormula(BOX_WHISKER.OUTLIER_MAX_VALUE_NAME, '(UPPERWHISKERMIN_IQR([Attr]), all([Attr]))', {
93
+ Attr: target,
94
+ });
95
+ const outliersMin = customFormula(BOX_WHISKER.OUTLIER_MIN_VALUE_NAME, '(LOWERWHISKERMAX_IQR([Attr]), all([Attr]))', {
96
+ Attr: target,
97
+ });
98
+ outliersAttrWithInnerFilter.name = `${outliersAttrWithInnerFilter.name} (Outliers)`;
99
+ outliersAttrWithInnerFilter.jaql = () => {
100
+ return Object.assign(Object.assign({}, target.jaql()), { filter: {
101
+ or: [
102
+ {
103
+ fromNotEqual: outliersMax.jaql(true),
104
+ },
105
+ {
106
+ toNotEqual: outliersMin.jaql(true),
107
+ },
108
+ ],
109
+ } });
110
+ };
111
+ return outliersAttrWithInnerFilter;
112
+ };
113
+ /**
114
+ * Returns an attribute representing outlier points based on standard deviation calculations.
115
+ *
116
+ * @param {Attribute} target - The target attribute for calculations.
117
+ * @returns {Attribute} An attribute representing outliers for box whisker plots using standard deviation.
118
+ */
119
+ export const boxWhiskerStdDevOutliers = (target) => {
120
+ const outliersAttrWithInnerFilter = cloneDeep(target);
121
+ const outliersMax = customFormula(BOX_WHISKER.OUTLIER_MAX_VALUE_NAME, '(UPPERWHISKERMIN_STDEVP([Attr]), all([Attr]))', {
122
+ Attr: target,
123
+ });
124
+ const outliersMin = customFormula(BOX_WHISKER.OUTLIER_MIN_VALUE_NAME, '(LOWERWHISKERMAX_STDEVP([Attr]), all([Attr]))', {
125
+ Attr: target,
126
+ });
127
+ outliersAttrWithInnerFilter.jaql = () => {
128
+ return Object.assign(Object.assign({}, target.jaql()), { filter: {
129
+ or: [
130
+ {
131
+ fromNotEqual: outliersMax.jaql(true),
132
+ },
133
+ {
134
+ toNotEqual: outliersMin.jaql(true),
135
+ },
136
+ ],
137
+ } });
138
+ };
139
+ return outliersAttrWithInnerFilter;
140
+ };
@@ -46,5 +46,5 @@ export function create(item) {
46
46
  item.dimtype) {
47
47
  return createDimension(item);
48
48
  }
49
- throw new TranslatableError('errors.unsupportedDimesionalElement');
49
+ throw new TranslatableError('errors.unsupportedDimensionalElement');
50
50
  }