@gooddata/sdk-ui 9.6.0-alpha.2 → 9.6.0-alpha.21
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/esm/base/errors/GoodDataSdkError.js +3 -0
- package/esm/base/errors/GoodDataSdkError.js.map +1 -1
- package/esm/base/headerMatching/MappingHeader.d.ts.map +1 -1
- package/esm/base/headerMatching/MappingHeader.js +4 -3
- package/esm/base/headerMatching/MappingHeader.js.map +1 -1
- package/esm/base/localization/IntlStore.js +2 -1
- package/esm/base/localization/IntlStore.js.map +1 -1
- package/esm/base/localization/TranslationsCustomizationProvider/Context.js +2 -2
- package/esm/base/localization/TranslationsCustomizationProvider/Context.js.map +1 -1
- package/esm/base/localization/TranslationsCustomizationProvider/utils.js +10 -4
- package/esm/base/localization/TranslationsCustomizationProvider/utils.js.map +1 -1
- package/esm/base/localization/bundles/de-DE.json +1 -0
- package/esm/base/localization/bundles/es-ES.json +1 -0
- package/esm/base/localization/bundles/fr-FR.json +1 -0
- package/esm/base/localization/bundles/ja-JP.json +1 -0
- package/esm/base/localization/bundles/nl-NL.json +1 -0
- package/esm/base/localization/bundles/pt-BR.json +1 -0
- package/esm/base/localization/bundles/pt-PT.json +1 -0
- package/esm/base/localization/bundles/zh-Hans.json +1 -0
- package/esm/base/localization/intlUtils.js +5 -2
- package/esm/base/localization/intlUtils.js.map +1 -1
- package/esm/base/measureTitles/ArithmeticMeasureTitleFactory.js +1 -0
- package/esm/base/measureTitles/ArithmeticMeasureTitleFactory.js.map +1 -1
- package/esm/base/measureTitles/DerivedMeasureTitleSuffixFactory.js +1 -0
- package/esm/base/measureTitles/DerivedMeasureTitleSuffixFactory.js.map +1 -1
- package/esm/base/measureTitles/ignoreTitlesForSimpleMeasures.js +1 -1
- package/esm/base/measureTitles/ignoreTitlesForSimpleMeasures.js.map +1 -1
- package/esm/base/react/BackendContext.js +3 -3
- package/esm/base/react/BackendContext.js.map +1 -1
- package/esm/base/react/CancelablePromise.js +1 -0
- package/esm/base/react/CancelablePromise.js.map +1 -1
- package/esm/base/react/ClientWorkspaceContext/ClientWorkspaceContext.js +3 -5
- package/esm/base/react/ClientWorkspaceContext/ClientWorkspaceContext.js.map +1 -1
- package/esm/base/react/ClientWorkspaceContext/resolveLCMWorkspaceIdentifiers.js +7 -11
- package/esm/base/react/ClientWorkspaceContext/resolveLCMWorkspaceIdentifiers.js.map +1 -1
- package/esm/base/react/ErrorComponent.js +21 -18
- package/esm/base/react/ErrorComponent.js.map +1 -1
- package/esm/base/react/LoadingComponent.js +20 -12
- package/esm/base/react/LoadingComponent.js.map +1 -1
- package/esm/base/react/PromiseCache.d.ts.map +1 -1
- package/esm/base/react/PromiseCache.js +48 -45
- package/esm/base/react/PromiseCache.js.map +1 -1
- package/esm/base/react/WorkspaceContext.js +3 -3
- package/esm/base/react/WorkspaceContext.js.map +1 -1
- package/esm/base/react/legacy/withEntireDataView.js +13 -14
- package/esm/base/react/legacy/withEntireDataView.js.map +1 -1
- package/esm/base/react/placeholders/context.js +6 -4
- package/esm/base/react/placeholders/context.js.map +1 -1
- package/esm/base/react/placeholders/factory.js +1 -1
- package/esm/base/react/placeholders/factory.js.map +1 -1
- package/esm/base/react/placeholders/hooks.js +4 -5
- package/esm/base/react/placeholders/hooks.js.map +1 -1
- package/esm/base/react/placeholders/resolve.js +11 -3
- package/esm/base/react/placeholders/resolve.js.map +1 -1
- package/esm/base/react/safeSerialize.js +1 -1
- package/esm/base/react/safeSerialize.js.map +1 -1
- package/esm/base/react/useCancelablePromise.js +2 -2
- package/esm/base/react/useCancelablePromise.js.map +1 -1
- package/esm/base/react/useCancelablePromiseUtils.js +1 -2
- package/esm/base/react/useCancelablePromiseUtils.js.map +1 -1
- package/esm/base/react/usePromiseCache.js +4 -4
- package/esm/base/react/usePromiseCache.js.map +1 -1
- package/esm/base/results/facade.js +9 -4
- package/esm/base/results/facade.js.map +1 -1
- package/esm/base/results/internal/dataAccessDigest.js +5 -6
- package/esm/base/results/internal/dataAccessDigest.js.map +1 -1
- package/esm/base/results/internal/dataAccessImpl.js +300 -270
- package/esm/base/results/internal/dataAccessImpl.js.map +1 -1
- package/esm/base/results/internal/dataAccessMethods.js +65 -61
- package/esm/base/results/internal/dataAccessMethods.js.map +1 -1
- package/esm/base/results/internal/definitionMethods.js +5 -0
- package/esm/base/results/internal/definitionMethods.js.map +1 -1
- package/esm/base/results/internal/lazyInitArray.js +30 -30
- package/esm/base/results/internal/lazyInitArray.js.map +1 -1
- package/esm/base/results/internal/resultDataMethods.js +5 -8
- package/esm/base/results/internal/resultDataMethods.js.map +1 -1
- package/esm/base/results/internal/resultMetaMethods.d.ts.map +1 -1
- package/esm/base/results/internal/resultMetaMethods.js +63 -51
- package/esm/base/results/internal/resultMetaMethods.js.map +1 -1
- package/esm/base/results/internal/utils.js +1 -2
- package/esm/base/results/internal/utils.js.map +1 -1
- package/esm/base/vis/drilling.js +12 -5
- package/esm/base/vis/drilling.js.map +1 -1
- package/esm/base/vis/export.js +1 -1
- package/esm/base/vis/export.js.map +1 -1
- package/esm/execution/DataViewLoader.js +81 -72
- package/esm/execution/DataViewLoader.js.map +1 -1
- package/esm/execution/Execute.js +12 -4
- package/esm/execution/Execute.js.map +1 -1
- package/esm/execution/ExecuteInsight.js +1 -1
- package/esm/execution/ExecuteInsight.js.map +1 -1
- package/esm/execution/useExecutionDataView.js +11 -8
- package/esm/execution/useExecutionDataView.js.map +1 -1
- package/esm/execution/useInsight.js +1 -1
- package/esm/execution/useInsight.js.map +1 -1
- package/esm/execution/useInsightDataView.js +1 -1
- package/esm/execution/useInsightDataView.js.map +1 -1
- package/esm/execution/withExecutionLoading.js +27 -11
- package/esm/execution/withExecutionLoading.js.map +1 -1
- package/esm/kpi/Kpi.js +4 -5
- package/esm/kpi/Kpi.js.map +1 -1
- package/package.json +11 -14
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// (C) 2019-2023 GoodData Corporation
|
|
2
|
-
var _a, _b;
|
|
3
2
|
import { isResultTotalHeader, resultHeaderName, } from "@gooddata/sdk-model";
|
|
4
3
|
import { createDataAccessDigest } from "./dataAccessDigest.js";
|
|
5
4
|
import { LazyInitArray } from "./lazyInitArray.js";
|
|
@@ -11,85 +10,63 @@ import isArray from "lodash/isArray.js";
|
|
|
11
10
|
* Iterates over single-dimensional result and returns values as data points.
|
|
12
11
|
*/
|
|
13
12
|
class SingleDimIterator {
|
|
13
|
+
seriesIdx;
|
|
14
|
+
accessors;
|
|
15
|
+
config;
|
|
16
|
+
returned;
|
|
14
17
|
constructor(seriesIdx, accessors, config) {
|
|
15
18
|
this.seriesIdx = seriesIdx;
|
|
16
19
|
this.accessors = accessors;
|
|
17
20
|
this.config = config;
|
|
18
|
-
this.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
value: undefined,
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
/*
|
|
26
|
-
* Set series and slices indexes accordingly. If iterator is over series, then base
|
|
27
|
-
* is index of series and offset is index of slice. Similar for slice..
|
|
28
|
-
*/
|
|
29
|
-
const { rawValue, coordinates } = this.accessors.dataAt(this.seriesIdx);
|
|
30
|
-
const { valueFormatter } = this.config;
|
|
31
|
-
const seriesDesc = this.accessors.seriesDescriptors(this.seriesIdx);
|
|
32
|
-
const measureFormat = seriesDesc.measureFormat();
|
|
33
|
-
this.returned = true;
|
|
21
|
+
this.returned = false;
|
|
22
|
+
}
|
|
23
|
+
next = () => {
|
|
24
|
+
if (this.returned) {
|
|
34
25
|
return {
|
|
35
|
-
done:
|
|
36
|
-
value:
|
|
37
|
-
rawValue,
|
|
38
|
-
seriesDesc,
|
|
39
|
-
coordinates,
|
|
40
|
-
total: false,
|
|
41
|
-
formattedValue() {
|
|
42
|
-
return valueFormatter(rawValue, measureFormat);
|
|
43
|
-
},
|
|
44
|
-
},
|
|
26
|
+
done: true,
|
|
27
|
+
value: undefined,
|
|
45
28
|
};
|
|
29
|
+
}
|
|
30
|
+
/*
|
|
31
|
+
* Set series and slices indexes accordingly. If iterator is over series, then base
|
|
32
|
+
* is index of series and offset is index of slice. Similar for slice..
|
|
33
|
+
*/
|
|
34
|
+
const { rawValue, coordinates } = this.accessors.dataAt(this.seriesIdx);
|
|
35
|
+
const { valueFormatter } = this.config;
|
|
36
|
+
const seriesDesc = this.accessors.seriesDescriptors(this.seriesIdx);
|
|
37
|
+
const measureFormat = seriesDesc.measureFormat();
|
|
38
|
+
this.returned = true;
|
|
39
|
+
return {
|
|
40
|
+
done: false,
|
|
41
|
+
value: {
|
|
42
|
+
rawValue,
|
|
43
|
+
seriesDesc,
|
|
44
|
+
coordinates,
|
|
45
|
+
total: false,
|
|
46
|
+
formattedValue() {
|
|
47
|
+
return valueFormatter(rawValue, measureFormat);
|
|
48
|
+
},
|
|
49
|
+
},
|
|
46
50
|
};
|
|
47
|
-
|
|
48
|
-
}
|
|
51
|
+
};
|
|
49
52
|
}
|
|
50
53
|
/**
|
|
51
54
|
* Iterates over two-dimensional data and returns values as data points.
|
|
52
55
|
*/
|
|
53
56
|
class TwoDimIterator {
|
|
57
|
+
type;
|
|
58
|
+
baseIdx;
|
|
59
|
+
digest;
|
|
60
|
+
accessors;
|
|
61
|
+
config;
|
|
62
|
+
offset;
|
|
63
|
+
offsetEnd;
|
|
54
64
|
constructor(type, baseIdx, digest, accessors, config) {
|
|
55
65
|
this.type = type;
|
|
56
66
|
this.baseIdx = baseIdx;
|
|
57
67
|
this.digest = digest;
|
|
58
68
|
this.accessors = accessors;
|
|
59
69
|
this.config = config;
|
|
60
|
-
this.next = () => {
|
|
61
|
-
if (this.offset >= this.offsetEnd) {
|
|
62
|
-
return {
|
|
63
|
-
done: true,
|
|
64
|
-
value: undefined,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
/*
|
|
68
|
-
* Set series and slices indexes accordingly. If iterator is over series, then base
|
|
69
|
-
* is index of series and offset is index of slice. Similar for type "slice".
|
|
70
|
-
*/
|
|
71
|
-
const seriesIdx = this.type === "series" ? this.baseIdx : this.offset;
|
|
72
|
-
const sliceIdx = this.type === "slice" ? this.baseIdx : this.offset;
|
|
73
|
-
const { rawValue, coordinates } = this.accessors.dataAt(this.baseIdx, this.offset);
|
|
74
|
-
const { valueFormatter } = this.config;
|
|
75
|
-
const seriesDesc = this.accessors.seriesDescriptors(seriesIdx);
|
|
76
|
-
const sliceDesc = this.accessors.sliceDescriptors(sliceIdx);
|
|
77
|
-
const measureFormat = seriesDesc.measureFormat();
|
|
78
|
-
this.offset += 1;
|
|
79
|
-
return {
|
|
80
|
-
done: false,
|
|
81
|
-
value: {
|
|
82
|
-
rawValue,
|
|
83
|
-
seriesDesc,
|
|
84
|
-
sliceDesc,
|
|
85
|
-
coordinates,
|
|
86
|
-
total: sliceDesc.isTotal,
|
|
87
|
-
formattedValue() {
|
|
88
|
-
return valueFormatter(rawValue, measureFormat);
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
};
|
|
92
|
-
};
|
|
93
70
|
this.offset = 0;
|
|
94
71
|
if (this.type === "series") {
|
|
95
72
|
this.offsetEnd = this.digest.slices.count;
|
|
@@ -98,91 +75,138 @@ class TwoDimIterator {
|
|
|
98
75
|
this.offsetEnd = this.digest.series.count;
|
|
99
76
|
}
|
|
100
77
|
}
|
|
78
|
+
next = () => {
|
|
79
|
+
if (this.offset >= this.offsetEnd) {
|
|
80
|
+
return {
|
|
81
|
+
done: true,
|
|
82
|
+
value: undefined,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/*
|
|
86
|
+
* Set series and slices indexes accordingly. If iterator is over series, then base
|
|
87
|
+
* is index of series and offset is index of slice. Similar for type "slice".
|
|
88
|
+
*/
|
|
89
|
+
const seriesIdx = this.type === "series" ? this.baseIdx : this.offset;
|
|
90
|
+
const sliceIdx = this.type === "slice" ? this.baseIdx : this.offset;
|
|
91
|
+
const { rawValue, coordinates } = this.accessors.dataAt(this.baseIdx, this.offset);
|
|
92
|
+
const { valueFormatter } = this.config;
|
|
93
|
+
const seriesDesc = this.accessors.seriesDescriptors(seriesIdx);
|
|
94
|
+
const sliceDesc = this.accessors.sliceDescriptors(sliceIdx);
|
|
95
|
+
const measureFormat = seriesDesc.measureFormat();
|
|
96
|
+
this.offset += 1;
|
|
97
|
+
return {
|
|
98
|
+
done: false,
|
|
99
|
+
value: {
|
|
100
|
+
rawValue,
|
|
101
|
+
seriesDesc,
|
|
102
|
+
sliceDesc,
|
|
103
|
+
coordinates,
|
|
104
|
+
total: sliceDesc.isTotal,
|
|
105
|
+
formattedValue() {
|
|
106
|
+
return valueFormatter(rawValue, measureFormat);
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
};
|
|
101
111
|
}
|
|
102
112
|
class DataSeries {
|
|
113
|
+
seriesIdx;
|
|
114
|
+
digest;
|
|
115
|
+
accessors;
|
|
116
|
+
config;
|
|
117
|
+
id;
|
|
118
|
+
descriptor;
|
|
119
|
+
rawDataValues;
|
|
120
|
+
dataPointsArray;
|
|
103
121
|
constructor(seriesIdx, digest, accessors, config) {
|
|
104
122
|
this.seriesIdx = seriesIdx;
|
|
105
123
|
this.digest = digest;
|
|
106
124
|
this.accessors = accessors;
|
|
107
125
|
this.config = config;
|
|
108
|
-
this.measureFormat = () => {
|
|
109
|
-
return this.descriptor.measureFormat();
|
|
110
|
-
};
|
|
111
|
-
this.measureTitle = () => {
|
|
112
|
-
return this.descriptor.measureTitle();
|
|
113
|
-
};
|
|
114
|
-
this.scopeTitles = () => {
|
|
115
|
-
return this.descriptor.scopeTitles();
|
|
116
|
-
};
|
|
117
|
-
this.rawData = () => {
|
|
118
|
-
if (!this.rawDataValues) {
|
|
119
|
-
this.rawDataValues = this.accessors.rawData(this.seriesIdx);
|
|
120
|
-
}
|
|
121
|
-
return this.rawDataValues;
|
|
122
|
-
};
|
|
123
|
-
this.dataPoints = () => {
|
|
124
|
-
if (!this.dataPointsArray) {
|
|
125
|
-
this.dataPointsArray = Array.from(this);
|
|
126
|
-
}
|
|
127
|
-
return this.dataPointsArray;
|
|
128
|
-
};
|
|
129
|
-
this[_a] = () => {
|
|
130
|
-
const { slices } = this.digest;
|
|
131
|
-
/*
|
|
132
|
-
* Note here: code accounts for two invariants:
|
|
133
|
-
*
|
|
134
|
-
* 1. truly a single-dim result - data is array of values
|
|
135
|
-
* 2. weird single-dim result - the slices dimension is empty, contains no attributes to slice by. in that case
|
|
136
|
-
* the data view is an array-in-array. the result is essentially single-dimensional however is wrapped
|
|
137
|
-
* in another array. the dataAt accessor impl can handle this
|
|
138
|
-
*/
|
|
139
|
-
if (slices === undefined || (slices.dimIdx >= 0 && slices.count === 0)) {
|
|
140
|
-
return new SingleDimIterator(this.seriesIdx, this.accessors, this.config);
|
|
141
|
-
}
|
|
142
|
-
return new TwoDimIterator("series", this.seriesIdx, this.digest, this.accessors, this.config);
|
|
143
|
-
};
|
|
144
126
|
this.descriptor = this.accessors.seriesDescriptors(this.seriesIdx);
|
|
145
127
|
this.id = this.descriptor.id;
|
|
146
128
|
}
|
|
129
|
+
measureFormat = () => {
|
|
130
|
+
return this.descriptor.measureFormat();
|
|
131
|
+
};
|
|
132
|
+
measureTitle = () => {
|
|
133
|
+
return this.descriptor.measureTitle();
|
|
134
|
+
};
|
|
135
|
+
scopeTitles = () => {
|
|
136
|
+
return this.descriptor.scopeTitles();
|
|
137
|
+
};
|
|
138
|
+
rawData = () => {
|
|
139
|
+
if (!this.rawDataValues) {
|
|
140
|
+
this.rawDataValues = this.accessors.rawData(this.seriesIdx);
|
|
141
|
+
}
|
|
142
|
+
return this.rawDataValues;
|
|
143
|
+
};
|
|
144
|
+
dataPoints = () => {
|
|
145
|
+
if (!this.dataPointsArray) {
|
|
146
|
+
this.dataPointsArray = Array.from(this);
|
|
147
|
+
}
|
|
148
|
+
return this.dataPointsArray;
|
|
149
|
+
};
|
|
150
|
+
[Symbol.iterator] = () => {
|
|
151
|
+
const { slices } = this.digest;
|
|
152
|
+
/*
|
|
153
|
+
* Note here: code accounts for two invariants:
|
|
154
|
+
*
|
|
155
|
+
* 1. truly a single-dim result - data is array of values
|
|
156
|
+
* 2. weird single-dim result - the slices dimension is empty, contains no attributes to slice by. in that case
|
|
157
|
+
* the data view is an array-in-array. the result is essentially single-dimensional however is wrapped
|
|
158
|
+
* in another array. the dataAt accessor impl can handle this
|
|
159
|
+
*/
|
|
160
|
+
if (slices === undefined || (slices.dimIdx >= 0 && slices.count === 0)) {
|
|
161
|
+
return new SingleDimIterator(this.seriesIdx, this.accessors, this.config);
|
|
162
|
+
}
|
|
163
|
+
return new TwoDimIterator("series", this.seriesIdx, this.digest, this.accessors, this.config);
|
|
164
|
+
};
|
|
147
165
|
}
|
|
148
|
-
_a = Symbol.iterator;
|
|
149
166
|
class DataSlice {
|
|
167
|
+
sliceIdx;
|
|
168
|
+
digest;
|
|
169
|
+
accessors;
|
|
170
|
+
config;
|
|
171
|
+
id;
|
|
172
|
+
descriptor;
|
|
173
|
+
rawDataValues;
|
|
174
|
+
dataPointsArray;
|
|
150
175
|
constructor(sliceIdx, digest, accessors, config) {
|
|
151
176
|
this.sliceIdx = sliceIdx;
|
|
152
177
|
this.digest = digest;
|
|
153
178
|
this.accessors = accessors;
|
|
154
179
|
this.config = config;
|
|
155
|
-
this.sliceTitles = () => {
|
|
156
|
-
return this.descriptor.sliceTitles();
|
|
157
|
-
};
|
|
158
|
-
this.rawData = () => {
|
|
159
|
-
if (!this.rawDataValues) {
|
|
160
|
-
this.rawDataValues = this.accessors.rawData(this.sliceIdx);
|
|
161
|
-
}
|
|
162
|
-
return this.rawDataValues;
|
|
163
|
-
};
|
|
164
|
-
// eslint-disable-next-line sonarjs/no-identical-functions
|
|
165
|
-
this.dataPoints = () => {
|
|
166
|
-
if (!this.dataPointsArray) {
|
|
167
|
-
this.dataPointsArray = Array.from(this);
|
|
168
|
-
}
|
|
169
|
-
return this.dataPointsArray;
|
|
170
|
-
};
|
|
171
|
-
this[_b] = () => {
|
|
172
|
-
if (!this.digest.series) {
|
|
173
|
-
/*
|
|
174
|
-
* If there are no data series, there are no measures and therefore there
|
|
175
|
-
* are no data points to iterate over.
|
|
176
|
-
*/
|
|
177
|
-
return [][Symbol.iterator]();
|
|
178
|
-
}
|
|
179
|
-
return new TwoDimIterator("slice", this.sliceIdx, this.digest, this.accessors, this.config);
|
|
180
|
-
};
|
|
181
180
|
this.descriptor = this.accessors.sliceDescriptors(this.sliceIdx);
|
|
182
181
|
this.id = this.descriptor.id;
|
|
183
182
|
}
|
|
183
|
+
sliceTitles = () => {
|
|
184
|
+
return this.descriptor.sliceTitles();
|
|
185
|
+
};
|
|
186
|
+
rawData = () => {
|
|
187
|
+
if (!this.rawDataValues) {
|
|
188
|
+
this.rawDataValues = this.accessors.rawData(this.sliceIdx);
|
|
189
|
+
}
|
|
190
|
+
return this.rawDataValues;
|
|
191
|
+
};
|
|
192
|
+
// eslint-disable-next-line sonarjs/no-identical-functions
|
|
193
|
+
dataPoints = () => {
|
|
194
|
+
if (!this.dataPointsArray) {
|
|
195
|
+
this.dataPointsArray = Array.from(this);
|
|
196
|
+
}
|
|
197
|
+
return this.dataPointsArray;
|
|
198
|
+
};
|
|
199
|
+
[Symbol.iterator] = () => {
|
|
200
|
+
if (!this.digest.series) {
|
|
201
|
+
/*
|
|
202
|
+
* If there are no data series, there are no measures and therefore there
|
|
203
|
+
* are no data points to iterate over.
|
|
204
|
+
*/
|
|
205
|
+
return [][Symbol.iterator]();
|
|
206
|
+
}
|
|
207
|
+
return new TwoDimIterator("slice", this.sliceIdx, this.digest, this.accessors, this.config);
|
|
208
|
+
};
|
|
184
209
|
}
|
|
185
|
-
_b = Symbol.iterator;
|
|
186
210
|
function illegalState(message) {
|
|
187
211
|
return () => {
|
|
188
212
|
throw new InvariantError(message);
|
|
@@ -199,155 +223,21 @@ function illegalState(message) {
|
|
|
199
223
|
* data organized in row→col or col→row.
|
|
200
224
|
*/
|
|
201
225
|
export class DataAccessImpl {
|
|
226
|
+
dataView;
|
|
227
|
+
config;
|
|
228
|
+
digest;
|
|
229
|
+
seriesDescriptors;
|
|
230
|
+
slicesDescriptors;
|
|
231
|
+
series;
|
|
232
|
+
slices;
|
|
233
|
+
accessors;
|
|
202
234
|
constructor(dataView, config) {
|
|
203
|
-
var _c, _d;
|
|
204
|
-
this.getDataAccessPointers = () => {
|
|
205
|
-
return this.digest;
|
|
206
|
-
};
|
|
207
|
-
this.getDataSeriesIterator = () => {
|
|
208
|
-
return this.series[Symbol.iterator]();
|
|
209
|
-
};
|
|
210
|
-
this.getDataSlicesIterator = () => {
|
|
211
|
-
return this.slices[Symbol.iterator]();
|
|
212
|
-
};
|
|
213
|
-
this.getDataSeries = (idx) => {
|
|
214
|
-
return this.series.get(idx);
|
|
215
|
-
};
|
|
216
|
-
this.findDataSeriesIndexes = (localId) => {
|
|
217
|
-
const { series: seriesDigest } = this.digest;
|
|
218
|
-
if (!seriesDigest) {
|
|
219
|
-
return [];
|
|
220
|
-
}
|
|
221
|
-
return seriesDigest.measureIndexes[localId] || [];
|
|
222
|
-
};
|
|
223
|
-
this.getRawData = (fromDimIdx, idx) => {
|
|
224
|
-
if (fromDimIdx === 1) {
|
|
225
|
-
/*
|
|
226
|
-
* Need to extract data from particular columns of two-dim data. Go through all rows, from
|
|
227
|
-
* each row take value at the desired column's index.
|
|
228
|
-
*/
|
|
229
|
-
return this.dataView.data.map((row) => {
|
|
230
|
-
return row[idx];
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
else {
|
|
234
|
-
/*
|
|
235
|
-
* Either extracting row from two-dim result or extracting single value from one-dim result
|
|
236
|
-
*/
|
|
237
|
-
const value = this.dataView.data[idx];
|
|
238
|
-
if (isArray(value)) {
|
|
239
|
-
/*
|
|
240
|
-
* Two-dim result, return as-is
|
|
241
|
-
*/
|
|
242
|
-
return value;
|
|
243
|
-
}
|
|
244
|
-
else {
|
|
245
|
-
/*
|
|
246
|
-
* Single-dim result, return wrapped
|
|
247
|
-
*/
|
|
248
|
-
return [value];
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
this.getDataAt = (fromDimIdx, idx, seq = 0) => {
|
|
253
|
-
if (fromDimIdx === 1) {
|
|
254
|
-
/*
|
|
255
|
-
* Want data from column. Get `idx` column value in of `seq` row
|
|
256
|
-
*/
|
|
257
|
-
const twoDimData = this.dataView.data;
|
|
258
|
-
return { rawValue: twoDimData[seq][idx], coordinates: [seq, idx] };
|
|
259
|
-
}
|
|
260
|
-
else {
|
|
261
|
-
const value = this.dataView.data[idx];
|
|
262
|
-
if (isArray(value)) {
|
|
263
|
-
return { rawValue: value[seq], coordinates: [idx, seq] };
|
|
264
|
-
}
|
|
265
|
-
else {
|
|
266
|
-
invariant(seq === 0, "trying to get row-col from single dim result");
|
|
267
|
-
return { rawValue: value, coordinates: [idx] };
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
};
|
|
271
|
-
this.createDataSeriesDescriptor = (seriesIdx) => {
|
|
272
|
-
var _c, _d;
|
|
273
|
-
const { series: seriesDigest } = this.digest;
|
|
274
|
-
invariant(seriesDigest, "trying to create data series descriptor when there are no data series");
|
|
275
|
-
const { fromMeasures, fromMeasuresDef, measureHeaders, allAttributeHeaders, scopingAttributes, scopingAttributesDef, } = seriesDigest;
|
|
276
|
-
const measureHeader = measureHeaders[seriesIdx];
|
|
277
|
-
let measureIndex = ((_c = measureHeader === null || measureHeader === void 0 ? void 0 : measureHeader.measureHeaderItem) === null || _c === void 0 ? void 0 : _c.order) || 0;
|
|
278
|
-
if (isResultTotalHeader(measureHeader)) {
|
|
279
|
-
// total headers are mixed with measure headers, linking to measure index
|
|
280
|
-
measureIndex = ((_d = measureHeader === null || measureHeader === void 0 ? void 0 : measureHeader.totalHeaderItem) === null || _d === void 0 ? void 0 : _d.measureIndex) || 0;
|
|
281
|
-
}
|
|
282
|
-
const attributeHeaders = allAttributeHeaders.map((headers) => headers[seriesIdx]);
|
|
283
|
-
const measureDescriptor = fromMeasures[measureIndex];
|
|
284
|
-
const measureDefinition = fromMeasuresDef[measureIndex];
|
|
285
|
-
const { headerTranslator } = this.config;
|
|
286
|
-
const { isTotal, isSubtotal } = getTotalInfo(attributeHeaders);
|
|
287
|
-
return {
|
|
288
|
-
id: `${seriesIdx}`,
|
|
289
|
-
measureDescriptor,
|
|
290
|
-
measureDefinition,
|
|
291
|
-
attributeDescriptors: scopingAttributes,
|
|
292
|
-
attributeDefinitions: scopingAttributesDef,
|
|
293
|
-
measureHeader,
|
|
294
|
-
attributeHeaders,
|
|
295
|
-
isTotal,
|
|
296
|
-
isSubtotal,
|
|
297
|
-
measureFormat: () => {
|
|
298
|
-
return measureFormat(measureDescriptor);
|
|
299
|
-
},
|
|
300
|
-
measureTitle: () => {
|
|
301
|
-
return measureName(measureDescriptor);
|
|
302
|
-
},
|
|
303
|
-
scopeTitles: () => {
|
|
304
|
-
if (!headerTranslator) {
|
|
305
|
-
return attributeHeaders.map(resultHeaderName);
|
|
306
|
-
}
|
|
307
|
-
return attributeHeaders.map((h) => headerTranslator(resultHeaderName(h)));
|
|
308
|
-
},
|
|
309
|
-
};
|
|
310
|
-
};
|
|
311
|
-
this.createDataSliceDescriptor = (sliceIdx) => {
|
|
312
|
-
const { slices: slicesDigest } = this.digest;
|
|
313
|
-
invariant(slicesDigest, "trying to create data slice descriptor when there are no data slices");
|
|
314
|
-
const { descriptors, headerItems, descriptorsDef } = slicesDigest;
|
|
315
|
-
const headers = [];
|
|
316
|
-
const { headerTranslator } = this.config;
|
|
317
|
-
let total = false;
|
|
318
|
-
headerItems.forEach((h) => {
|
|
319
|
-
const header = h[sliceIdx];
|
|
320
|
-
headers.push(header);
|
|
321
|
-
if (isResultTotalHeader(header)) {
|
|
322
|
-
total = true;
|
|
323
|
-
}
|
|
324
|
-
});
|
|
325
|
-
return {
|
|
326
|
-
id: `${sliceIdx}`,
|
|
327
|
-
descriptors,
|
|
328
|
-
definitions: descriptorsDef,
|
|
329
|
-
headers,
|
|
330
|
-
isTotal: total,
|
|
331
|
-
sliceTitles: () => {
|
|
332
|
-
if (!headerTranslator) {
|
|
333
|
-
return headers.map(resultHeaderName);
|
|
334
|
-
}
|
|
335
|
-
return headers.map((h) => headerTranslator(resultHeaderName(h)));
|
|
336
|
-
},
|
|
337
|
-
};
|
|
338
|
-
};
|
|
339
|
-
this.createDataSeries = (seriesIdx) => {
|
|
340
|
-
return new DataSeries(seriesIdx, this.digest, this.accessors[0], this.config);
|
|
341
|
-
};
|
|
342
|
-
this.createDataSlice = (sliceIdx) => {
|
|
343
|
-
return new DataSlice(sliceIdx, this.digest, this.accessors[1], this.config);
|
|
344
|
-
};
|
|
345
235
|
this.dataView = dataView;
|
|
346
236
|
this.config = config;
|
|
347
237
|
this.digest = createDataAccessDigest(this.dataView);
|
|
348
238
|
const { series, slices } = this.digest;
|
|
349
|
-
const seriesCount =
|
|
350
|
-
const slicesCount =
|
|
239
|
+
const seriesCount = series?.count ?? 0;
|
|
240
|
+
const slicesCount = slices?.count ?? 0;
|
|
351
241
|
this.seriesDescriptors = new LazyInitArray(seriesCount, this.createDataSeriesDescriptor);
|
|
352
242
|
this.series = new LazyInitArray(seriesCount, this.createDataSeries);
|
|
353
243
|
this.slicesDescriptors = new LazyInitArray(slicesCount, this.createDataSliceDescriptor);
|
|
@@ -375,5 +265,145 @@ export class DataAccessImpl {
|
|
|
375
265
|
},
|
|
376
266
|
];
|
|
377
267
|
}
|
|
268
|
+
getDataAccessPointers = () => {
|
|
269
|
+
return this.digest;
|
|
270
|
+
};
|
|
271
|
+
getDataSeriesIterator = () => {
|
|
272
|
+
return this.series[Symbol.iterator]();
|
|
273
|
+
};
|
|
274
|
+
getDataSlicesIterator = () => {
|
|
275
|
+
return this.slices[Symbol.iterator]();
|
|
276
|
+
};
|
|
277
|
+
getDataSeries = (idx) => {
|
|
278
|
+
return this.series.get(idx);
|
|
279
|
+
};
|
|
280
|
+
findDataSeriesIndexes = (localId) => {
|
|
281
|
+
const { series: seriesDigest } = this.digest;
|
|
282
|
+
if (!seriesDigest) {
|
|
283
|
+
return [];
|
|
284
|
+
}
|
|
285
|
+
return seriesDigest.measureIndexes[localId] || [];
|
|
286
|
+
};
|
|
287
|
+
getRawData = (fromDimIdx, idx) => {
|
|
288
|
+
if (fromDimIdx === 1) {
|
|
289
|
+
/*
|
|
290
|
+
* Need to extract data from particular columns of two-dim data. Go through all rows, from
|
|
291
|
+
* each row take value at the desired column's index.
|
|
292
|
+
*/
|
|
293
|
+
return this.dataView.data.map((row) => {
|
|
294
|
+
return row[idx];
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
else {
|
|
298
|
+
/*
|
|
299
|
+
* Either extracting row from two-dim result or extracting single value from one-dim result
|
|
300
|
+
*/
|
|
301
|
+
const value = this.dataView.data[idx];
|
|
302
|
+
if (isArray(value)) {
|
|
303
|
+
/*
|
|
304
|
+
* Two-dim result, return as-is
|
|
305
|
+
*/
|
|
306
|
+
return value;
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
/*
|
|
310
|
+
* Single-dim result, return wrapped
|
|
311
|
+
*/
|
|
312
|
+
return [value];
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
getDataAt = (fromDimIdx, idx, seq = 0) => {
|
|
317
|
+
if (fromDimIdx === 1) {
|
|
318
|
+
/*
|
|
319
|
+
* Want data from column. Get `idx` column value in of `seq` row
|
|
320
|
+
*/
|
|
321
|
+
const twoDimData = this.dataView.data;
|
|
322
|
+
return { rawValue: twoDimData[seq][idx], coordinates: [seq, idx] };
|
|
323
|
+
}
|
|
324
|
+
else {
|
|
325
|
+
const value = this.dataView.data[idx];
|
|
326
|
+
if (isArray(value)) {
|
|
327
|
+
return { rawValue: value[seq], coordinates: [idx, seq] };
|
|
328
|
+
}
|
|
329
|
+
else {
|
|
330
|
+
invariant(seq === 0, "trying to get row-col from single dim result");
|
|
331
|
+
return { rawValue: value, coordinates: [idx] };
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
createDataSeriesDescriptor = (seriesIdx) => {
|
|
336
|
+
const { series: seriesDigest } = this.digest;
|
|
337
|
+
invariant(seriesDigest, "trying to create data series descriptor when there are no data series");
|
|
338
|
+
const { fromMeasures, fromMeasuresDef, measureHeaders, allAttributeHeaders, scopingAttributes, scopingAttributesDef, } = seriesDigest;
|
|
339
|
+
const measureHeader = measureHeaders[seriesIdx];
|
|
340
|
+
let measureIndex = measureHeader?.measureHeaderItem?.order || 0;
|
|
341
|
+
if (isResultTotalHeader(measureHeader)) {
|
|
342
|
+
// total headers are mixed with measure headers, linking to measure index
|
|
343
|
+
measureIndex = measureHeader?.totalHeaderItem?.measureIndex || 0;
|
|
344
|
+
}
|
|
345
|
+
const attributeHeaders = allAttributeHeaders.map((headers) => headers[seriesIdx]);
|
|
346
|
+
const measureDescriptor = fromMeasures[measureIndex];
|
|
347
|
+
const measureDefinition = fromMeasuresDef[measureIndex];
|
|
348
|
+
const { headerTranslator } = this.config;
|
|
349
|
+
const { isTotal, isSubtotal } = getTotalInfo(attributeHeaders);
|
|
350
|
+
return {
|
|
351
|
+
id: `${seriesIdx}`,
|
|
352
|
+
measureDescriptor,
|
|
353
|
+
measureDefinition,
|
|
354
|
+
attributeDescriptors: scopingAttributes,
|
|
355
|
+
attributeDefinitions: scopingAttributesDef,
|
|
356
|
+
measureHeader,
|
|
357
|
+
attributeHeaders,
|
|
358
|
+
isTotal,
|
|
359
|
+
isSubtotal,
|
|
360
|
+
measureFormat: () => {
|
|
361
|
+
return measureFormat(measureDescriptor);
|
|
362
|
+
},
|
|
363
|
+
measureTitle: () => {
|
|
364
|
+
return measureName(measureDescriptor);
|
|
365
|
+
},
|
|
366
|
+
scopeTitles: () => {
|
|
367
|
+
if (!headerTranslator) {
|
|
368
|
+
return attributeHeaders.map(resultHeaderName);
|
|
369
|
+
}
|
|
370
|
+
return attributeHeaders.map((h) => headerTranslator(resultHeaderName(h)));
|
|
371
|
+
},
|
|
372
|
+
};
|
|
373
|
+
};
|
|
374
|
+
createDataSliceDescriptor = (sliceIdx) => {
|
|
375
|
+
const { slices: slicesDigest } = this.digest;
|
|
376
|
+
invariant(slicesDigest, "trying to create data slice descriptor when there are no data slices");
|
|
377
|
+
const { descriptors, headerItems, descriptorsDef } = slicesDigest;
|
|
378
|
+
const headers = [];
|
|
379
|
+
const { headerTranslator } = this.config;
|
|
380
|
+
let total = false;
|
|
381
|
+
headerItems.forEach((h) => {
|
|
382
|
+
const header = h[sliceIdx];
|
|
383
|
+
headers.push(header);
|
|
384
|
+
if (isResultTotalHeader(header)) {
|
|
385
|
+
total = true;
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
return {
|
|
389
|
+
id: `${sliceIdx}`,
|
|
390
|
+
descriptors,
|
|
391
|
+
definitions: descriptorsDef,
|
|
392
|
+
headers,
|
|
393
|
+
isTotal: total,
|
|
394
|
+
sliceTitles: () => {
|
|
395
|
+
if (!headerTranslator) {
|
|
396
|
+
return headers.map(resultHeaderName);
|
|
397
|
+
}
|
|
398
|
+
return headers.map((h) => headerTranslator(resultHeaderName(h)));
|
|
399
|
+
},
|
|
400
|
+
};
|
|
401
|
+
};
|
|
402
|
+
createDataSeries = (seriesIdx) => {
|
|
403
|
+
return new DataSeries(seriesIdx, this.digest, this.accessors[0], this.config);
|
|
404
|
+
};
|
|
405
|
+
createDataSlice = (sliceIdx) => {
|
|
406
|
+
return new DataSlice(sliceIdx, this.digest, this.accessors[1], this.config);
|
|
407
|
+
};
|
|
378
408
|
}
|
|
379
409
|
//# sourceMappingURL=dataAccessImpl.js.map
|