@datarailsshared/dr_renderer 1.2.3 → 1.2.4
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/.circleci/config.yml +4 -4
- package/README.md +0 -5
- package/package.json +2 -3
- package/src/dataformatter.js +2 -44
- package/src/dr_pivottable.js +157 -89
- package/src/highcharts_renderer.js +1727 -2418
- package/src/novix_renderer.js +11 -13
- package/src/pivottable.js +9 -35
- package/src/published_items_renderer.js +51 -29
- package/tests/highcharts_renderer.test.js +14 -9355
- package/src/charts/dr_gauge_chart.js +0 -566
- package/src/dataformatter.d.ts +0 -13
- package/src/dr-renderer-helpers.js +0 -58
- package/src/dr_chart_tooltip.js +0 -277
- package/src/graph-table-renderer.js +0 -147
- package/src/seriesPointStyles-helper.js +0 -43
- package/tests/dr-renderer-helpers.test.js +0 -150
- package/tests/dr_chart_tooltip.test.js +0 -739
- package/tests/dr_gauge_chart.test.js +0 -1931
- package/tests/mock/add-in-dynamic-ranges.json +0 -127
- package/tests/mock/add-in-functions.json +0 -410
- package/tests/mock/add-in-tables.json +0 -347
- package/tests/mock/tables.json +0 -2258
- package/tests/mock/widgets.json +0 -403
- package/tests/seriesPointStyles-helper.test.js +0 -114
- package/tsconfig.json +0 -15
- package/types/graph-table-renderer.d.ts +0 -79
- package/types/index.d.ts +0 -1
package/.circleci/config.yml
CHANGED
|
@@ -15,9 +15,9 @@ jobs:
|
|
|
15
15
|
at: ~/repo
|
|
16
16
|
- run:
|
|
17
17
|
name: Prepare publish version
|
|
18
|
-
command: "postfix=\"\"\nif [[ \"${CIRCLE_BRANCH}\" !=
|
|
19
|
-
|
|
20
|
-
\
|
|
18
|
+
command: "postfix=\"\"\nif [[ \"${CIRCLE_BRANCH}\" != prod ]] ; then\n postfix=\"\
|
|
19
|
+
-$CIRCLE_BRANCH\"\nfi\n\nVERSION=\"1.2.$CIRCLE_BUILD_NUM$postfix\"\nsed\
|
|
20
|
+
\ -i s/{{cicd_version}}/$VERSION/g ./package.json\ncat ./package.json\n"
|
|
21
21
|
- run:
|
|
22
22
|
name: Authenticate with registry
|
|
23
23
|
command: echo "//registry.npmjs.org/:_authToken=$npm_TOKEN" > ~/repo/.npmrc
|
|
@@ -57,7 +57,7 @@ workflows:
|
|
|
57
57
|
filters:
|
|
58
58
|
branches:
|
|
59
59
|
only:
|
|
60
|
-
- /
|
|
60
|
+
- /prod.*/
|
|
61
61
|
- /tigers/
|
|
62
62
|
- /bratans/
|
|
63
63
|
- /dragons/
|
package/README.md
CHANGED
|
@@ -13,11 +13,6 @@ This project was generated by amazing Datarails R&D team
|
|
|
13
13
|
let default_colors = ["#106bd0", "#00cee8", "#95c8d8", "#89cff0", "#FE746D", "#6ADC4C", "#9B9AD9", "#ff8000", "#C11B12", "#5a41f9"];
|
|
14
14
|
let hr = dr_renderer.getInitHighchartsRenderer($, document, default_colors, Highcharts);
|
|
15
15
|
|
|
16
|
-
## Development
|
|
17
|
-
### Types
|
|
18
|
-
To be able to compile types with `npm run build:types` you need to install typescript globally:
|
|
19
|
-
|
|
20
|
-
```npm i -g typescript```
|
|
21
16
|
|
|
22
17
|
## Publish to npm
|
|
23
18
|
Just merge to prod branch
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datarailsshared/dr_renderer",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"description": "DataRails charts and tables renderer",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"datarails",
|
|
@@ -10,8 +10,7 @@
|
|
|
10
10
|
],
|
|
11
11
|
"scripts": {
|
|
12
12
|
"login": "npm login",
|
|
13
|
-
"test": "jest --coverage"
|
|
14
|
-
"build:types": "tsc --build --verbose"
|
|
13
|
+
"test": "jest --coverage"
|
|
15
14
|
},
|
|
16
15
|
"author": "Sergey Spivakov",
|
|
17
16
|
"repository": {
|
package/src/dataformatter.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
const _ = require('lodash');
|
|
2
|
-
|
|
3
1
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
4
2
|
|
|
5
3
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -352,7 +350,7 @@ var DataFormatterImpl = function () {
|
|
|
352
350
|
|
|
353
351
|
n = this.roundDecimals(n, decimals).toString().split('.');
|
|
354
352
|
var integerPart = n[0];
|
|
355
|
-
var decimalPart =
|
|
353
|
+
var decimalPart = n[1] || 0;
|
|
356
354
|
|
|
357
355
|
return this.applyNumberPattern(integerPart, patternIntegerPart) + this.locale.decimalSeparator + this.applyNumberPattern(decimalPart, patternDecimalPart, n[1] && n[1][0] == '0' ? '' : 'right');
|
|
358
356
|
}
|
|
@@ -1028,49 +1026,9 @@ var DataFormatterImpl = function () {
|
|
|
1028
1026
|
|
|
1029
1027
|
return result;
|
|
1030
1028
|
}
|
|
1031
|
-
}, {
|
|
1032
|
-
key: 'formatValue',
|
|
1033
|
-
value: function formatValue(data_type, number_format, value, override_values_format) {
|
|
1034
|
-
if (!number_format) {
|
|
1035
|
-
number_format = 'General';
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
|
-
if (Number.isNaN(value)) {
|
|
1039
|
-
return { value: "#Error" };
|
|
1040
|
-
}
|
|
1041
|
-
|
|
1042
|
-
if (data_type === 'n' && value != null) {
|
|
1043
|
-
if (override_values_format) {
|
|
1044
|
-
number_format = override_values_format;
|
|
1045
|
-
}
|
|
1046
|
-
|
|
1047
|
-
if (number_format.indexOf('[kilo]') >= 0) {
|
|
1048
|
-
value = value / 1000;
|
|
1049
|
-
number_format = number_format.replace('[kilo]', '');
|
|
1050
|
-
} else if (number_format.indexOf('[mega]') >= 0) {
|
|
1051
|
-
value = value / 1000000;
|
|
1052
|
-
number_format = number_format.replace('[mega]', '');
|
|
1053
|
-
} else if (number_format.indexOf('[kilomega]') >= 0) {
|
|
1054
|
-
number_format = number_format.replace('[kilomega]', '');
|
|
1055
|
-
}
|
|
1056
|
-
|
|
1057
|
-
return this.format(value, 'Number', number_format);
|
|
1058
|
-
} else if (data_type === 'd') {
|
|
1059
|
-
number_format = number_format.split(';')[0];
|
|
1060
|
-
let d;
|
|
1061
|
-
if (value instanceof Date || typeof value === 'string') {
|
|
1062
|
-
d = new Date(value);
|
|
1063
|
-
} else {
|
|
1064
|
-
d = new Date(value * 1000);
|
|
1065
|
-
}
|
|
1066
|
-
return this.format(d.toString(), 'DateTime', number_format);
|
|
1067
|
-
} else {
|
|
1068
|
-
return value;
|
|
1069
|
-
}
|
|
1070
|
-
}
|
|
1071
1029
|
}]);
|
|
1072
1030
|
|
|
1073
1031
|
return DataFormatterImpl;
|
|
1074
1032
|
}();
|
|
1075
1033
|
|
|
1076
|
-
module.exports = new DataFormatterImpl();
|
|
1034
|
+
module.exports = new DataFormatterImpl();
|
package/src/dr_pivottable.js
CHANGED
|
@@ -12,10 +12,6 @@ let initDRPivotTable = function($, window, document) {
|
|
|
12
12
|
document.ReportHippo.user.organization.settings && document.ReportHippo.user.organization.settings.use_new_ux;
|
|
13
13
|
// const numberOfRows = 500; // change to activate the handsontable when num of rows bigger then this.
|
|
14
14
|
|
|
15
|
-
const isFlatKeyInPivotKeys = function(keys, flatKey) {
|
|
16
|
-
return keys.some(key => key.join(delim) === flatKey);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
15
|
DRPivotData = (function(superClass) {
|
|
20
16
|
extend(DRPivotData, superClass);
|
|
21
17
|
|
|
@@ -95,7 +91,6 @@ let initDRPivotTable = function($, window, document) {
|
|
|
95
91
|
|
|
96
92
|
DRPivotData.prototype.arrSort = function(attrs) {
|
|
97
93
|
var a, sortersArr;
|
|
98
|
-
const sortByValueAttrs = this.sortByValueAttrs;
|
|
99
94
|
sortersArr = (function() {
|
|
100
95
|
var l, len1, results;
|
|
101
96
|
results = [];
|
|
@@ -105,21 +100,11 @@ let initDRPivotTable = function($, window, document) {
|
|
|
105
100
|
}
|
|
106
101
|
return results;
|
|
107
102
|
}).call(this);
|
|
108
|
-
|
|
109
103
|
return function(a, b) {
|
|
110
104
|
var comparison, i, sorter;
|
|
111
105
|
for (i in sortersArr) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
if (sortByValueAttrs.indexOf(attrs[index]) !== -1) {
|
|
115
|
-
|
|
116
|
-
// For case current Field attrs[index] is sorted by value we are concatenating values passed to sorter function
|
|
117
|
-
// Concatenation is done from first field in a block (first axis or first series) until current field index.
|
|
118
|
-
// Cause for this case sorting will be as list of these concatenated strings (which is prepared in getSortingByValueOrderList)
|
|
119
|
-
comparison = sorter(a.slice(0, index + 1).join(','), b.slice(0, index + 1).join(','));
|
|
120
|
-
} else {
|
|
121
|
-
comparison = sorter(a[index], b[index]);
|
|
122
|
-
}
|
|
106
|
+
sorter = sortersArr[i];
|
|
107
|
+
comparison = sorter(a[i], b[i]);
|
|
123
108
|
if (comparison !== 0) {
|
|
124
109
|
return comparison;
|
|
125
110
|
}
|
|
@@ -158,72 +143,120 @@ let initDRPivotTable = function($, window, document) {
|
|
|
158
143
|
return key;
|
|
159
144
|
};
|
|
160
145
|
|
|
161
|
-
DRPivotData.prototype.
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
keys.push(record[attr] != null ? record[attr] : 'null');
|
|
146
|
+
DRPivotData.prototype.processRecord = function(record, useTotalsCalculation) {
|
|
147
|
+
if (useTotalsCalculation) {
|
|
148
|
+
if (!this.notFirst) {
|
|
149
|
+
this.keysLength = _.filter(_.keys(record), key => !_.includes(['data_types', 'formats', 'values_formats'], key)).length - 1;
|
|
150
|
+
this.notFirst = true;
|
|
167
151
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
152
|
+
let getRowAggregator = (function(_this) {
|
|
153
|
+
return function(key) {
|
|
154
|
+
return _this.aggregator(_this, key, []);
|
|
155
|
+
};
|
|
156
|
+
})(this);
|
|
157
|
+
let getColAggregator = (function(_this) {
|
|
158
|
+
return function(key) {
|
|
159
|
+
return _this.aggregator(_this, [], key);
|
|
160
|
+
};
|
|
161
|
+
})(this);
|
|
171
162
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
163
|
+
let rowKey = [];
|
|
164
|
+
for (k = 0; k < this.rowAttrs.length; k++) {
|
|
165
|
+
let attr = this.rowAttrs[k];
|
|
166
|
+
if (record.hasOwnProperty(attr)) {
|
|
167
|
+
rowKey.push((ref = record[attr]) != null ? ref : "null");
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
let colKey = [];
|
|
172
|
+
for (k = 0; k < this.colAttrs.length; k++) {
|
|
173
|
+
let attr = this.colAttrs[k];
|
|
174
|
+
if (record.hasOwnProperty(attr)) {
|
|
175
|
+
colKey.push((ref = record[attr]) != null ? ref : "null");
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
let flatRowKey = rowKey.join(delim);
|
|
180
|
+
let flatColKey = colKey.join(delim);
|
|
181
|
+
|
|
182
|
+
if (this.keysLength === rowKey.length + colKey.length) {
|
|
183
|
+
if (!this.rowKeys.some(rKey => rKey.join(delim) === flatRowKey)) {
|
|
184
|
+
this.rowKeys.push(rowKey);
|
|
185
|
+
}
|
|
186
|
+
if (!this.colKeys.some(cKey => cKey.join(delim) === flatColKey)) {
|
|
187
|
+
this.colKeys.push(colKey);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (!colKey.length && !rowKey.length) {
|
|
192
|
+
this.allTotal.push(record);
|
|
193
|
+
} else if (!colKey.length && rowKey.length) {
|
|
194
|
+
if (!this.rowTotals[flatRowKey]) {
|
|
195
|
+
this.rowTotals[flatRowKey] = getRowAggregator(rowKey.slice());
|
|
196
|
+
this.rowTotals[flatRowKey].push(record);
|
|
197
|
+
}
|
|
198
|
+
} else if (!rowKey.length && colKey.length) {
|
|
199
|
+
if (!this.colTotals[flatColKey]) {
|
|
200
|
+
this.colTotals[flatColKey] = getColAggregator(colKey.slice());
|
|
201
|
+
this.colTotals[flatColKey].push(record);
|
|
202
|
+
}
|
|
203
|
+
} else {
|
|
204
|
+
if (!this.tree[flatRowKey]) {
|
|
205
|
+
this.tree[flatRowKey] = {};
|
|
206
|
+
}
|
|
207
|
+
this.tree[flatRowKey][flatColKey] = this.aggregator(this, rowKey, colKey);
|
|
208
|
+
this.tree[flatRowKey][flatColKey].push(record);
|
|
209
|
+
}
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
176
212
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
213
|
+
var colKey, fColKey, fRowKey, flatColKey, flatRowKey, i, j, k, m, n, ref, results, rowKey;
|
|
214
|
+
rowKey = [];
|
|
215
|
+
colKey = [];
|
|
216
|
+
const recordValues = _.values(record);
|
|
217
|
+
const containsAverage = _.includes(recordValues, 'DR_Average');
|
|
218
|
+
const containsOthers = _.includes(recordValues, 'DR_Others');
|
|
219
|
+
if (!containsAverage && !containsOthers) {
|
|
220
|
+
this.allTotal.push(record);
|
|
181
221
|
}
|
|
182
|
-
|
|
222
|
+
rowKey = processKey(record, this.rowTotals, this.rowKeys, this.rowAttrs, containsAverage, containsOthers, (function(_this) {
|
|
183
223
|
return function(key) {
|
|
184
224
|
return _this.aggregator(_this, key, []);
|
|
185
225
|
};
|
|
186
|
-
})(this);
|
|
187
|
-
|
|
226
|
+
})(this));
|
|
227
|
+
colKey = processKey(record, this.colTotals, this.colKeys, this.colAttrs, containsAverage, containsOthers, (function(_this) {
|
|
188
228
|
return function(key) {
|
|
189
229
|
return _this.aggregator(_this, [], key);
|
|
190
230
|
};
|
|
191
|
-
})(this);
|
|
192
|
-
|
|
193
|
-
const rowKey = this.getAttrsKeys(record, this.rowAttrs);
|
|
194
|
-
const colKey = this.getAttrsKeys(record, this.colAttrs);
|
|
231
|
+
})(this));
|
|
195
232
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
if (!this.isKeysSortingDoneOnBackendSide && !isFlatKeyInPivotKeys(this.rowKeys, flatRowKey)) {
|
|
201
|
-
this.rowKeys.push(rowKey);
|
|
202
|
-
}
|
|
203
|
-
if (!this.isKeysSortingDoneOnBackendSide && !isFlatKeyInPivotKeys(this.colKeys, flatColKey)) {
|
|
204
|
-
this.colKeys.push(colKey);
|
|
205
|
-
}
|
|
233
|
+
m = rowKey.length - 1;
|
|
234
|
+
n = colKey.length - 1;
|
|
235
|
+
if (m < 0 || n < 0) {
|
|
236
|
+
return;
|
|
206
237
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
if (!this.rowTotals[flatRowKey]) {
|
|
212
|
-
this.rowTotals[flatRowKey] = getRowAggregator(rowKey.slice());
|
|
213
|
-
this.rowTotals[flatRowKey].push(record);
|
|
214
|
-
}
|
|
215
|
-
} else if (!rowKey.length && colKey.length) {
|
|
216
|
-
if (!this.colTotals[flatColKey]) {
|
|
217
|
-
this.colTotals[flatColKey] = getColAggregator(colKey.slice());
|
|
218
|
-
this.colTotals[flatColKey].push(record);
|
|
219
|
-
}
|
|
220
|
-
} else {
|
|
238
|
+
results = [];
|
|
239
|
+
for (i = k = 0, ref = m; 0 <= ref ? k <= ref : k >= ref; i = 0 <= ref ? ++k : --k) {
|
|
240
|
+
fRowKey = rowKey.slice(0, i + 1);
|
|
241
|
+
flatRowKey = fRowKey.join(delim);
|
|
221
242
|
if (!this.tree[flatRowKey]) {
|
|
222
243
|
this.tree[flatRowKey] = {};
|
|
223
244
|
}
|
|
224
|
-
|
|
225
|
-
|
|
245
|
+
results.push((function() {
|
|
246
|
+
var l, ref1, results1;
|
|
247
|
+
results1 = [];
|
|
248
|
+
for (j = l = 0, ref1 = n; 0 <= ref1 ? l <= ref1 : l >= ref1; j = 0 <= ref1 ? ++l : --l) {
|
|
249
|
+
fColKey = colKey.slice(0, j + 1);
|
|
250
|
+
flatColKey = fColKey.join(delim);
|
|
251
|
+
if (!this.tree[flatRowKey][flatColKey]) {
|
|
252
|
+
this.tree[flatRowKey][flatColKey] = this.aggregator(this, fRowKey, fColKey);
|
|
253
|
+
}
|
|
254
|
+
results1.push(this.tree[flatRowKey][flatColKey].push(record));
|
|
255
|
+
}
|
|
256
|
+
return results1;
|
|
257
|
+
}).call(this));
|
|
226
258
|
}
|
|
259
|
+
return results;
|
|
227
260
|
};
|
|
228
261
|
|
|
229
262
|
DRPivotData.prototype.getAggregator = function(rowKey, colKey) {
|
|
@@ -396,10 +429,13 @@ let initDRPivotTable = function($, window, document) {
|
|
|
396
429
|
switch (opts.chartOptions.negative_numbers.value) {
|
|
397
430
|
case 'red_minus':
|
|
398
431
|
return '<span style="color: red; fill: red;">' + aggregator.format(val, format_argument) + '</span>';
|
|
432
|
+
break;
|
|
399
433
|
case 'absolute':
|
|
400
434
|
return '(' + aggregator.format(Math.abs(val), format_argument) + ')';
|
|
435
|
+
break;
|
|
401
436
|
case 'red_absolute':
|
|
402
437
|
return '<span style="color: red; fill: red;">(' + aggregator.format(Math.abs(val), format_argument) + ')</span>';
|
|
438
|
+
break;
|
|
403
439
|
default:
|
|
404
440
|
return aggregator.format(val, format_argument);
|
|
405
441
|
}
|
|
@@ -435,11 +471,8 @@ let initDRPivotTable = function($, window, document) {
|
|
|
435
471
|
return resultsArr;
|
|
436
472
|
} else {
|
|
437
473
|
let tooMuch = false;
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
(pvtData.rowKeys.length > 1000 || pvtData.colKeys.length > 500) &&
|
|
441
|
-
(!opts.show_more_function_cols || !opts.show_more_function_cols) &&
|
|
442
|
-
!show_more_than_thousand_rows) {
|
|
474
|
+
if (pvtData && (pvtData.rowKeys.length > 1000 || pvtData.colKeys.length > 500) &&
|
|
475
|
+
(!opts.show_more_function_cols || !opts.show_more_function_cols)) {
|
|
443
476
|
pvtData.rowKeys = [];
|
|
444
477
|
pvtData.colKeys = [];
|
|
445
478
|
tooMuch = true;
|
|
@@ -451,11 +484,11 @@ let initDRPivotTable = function($, window, document) {
|
|
|
451
484
|
}
|
|
452
485
|
|
|
453
486
|
SubtotalRenderer = function(pivotData, opts, charttype, tooMuch = false, error_params) {
|
|
454
|
-
var addClass, allTotal, arrowCollapsed, arrowExpanded, buildColHeaderHeader, buildColHeaderHeaders, buildColHeaderHeadersClickEvents, buildColHeaders, buildColTotals, buildColTotalsHeader, buildGrandTotal, buildRowHeaderHeaders, buildRowHeaderHeadersClickEvents, buildRowHeaders, buildRowTotalsHeader, buildValues, classColCollapsed, classColExpanded, classColHide, classColShow, classCollapsed, classExpanded, classRowCollapsed, classRowExpanded, classRowHide, classRowShow, clickStatusCollapsed, clickStatusExpanded, colAttrs, colDisableAfter, colKeys, colTotals, collapseCol, collapseColsAt, collapseHideDescendantRow, collapseRow, collapseRowsAt, collapseShowColSubtotal, collapseShowRowSubtotal, applyInlineStyles, createElement, defaults, expandChildCol, expandChildRow, expandCol, expandColsAt, expandHideColSubtotal, expandHideRowSubtotal, expandRow, expandRowsAt, expandShowColSubtotal, expandShowRowSubtotal, getTableEventHandlers, hasClass, hideDescendantCol, isColDisable, isColDisableExpandCollapse, isColHideOnExpand, isRowDisable, isRowDisableExpandCollapse, isRowHideOnExpand, main, getSubtotalInBrackets, processKeys, encodeHtmlEntities, ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7, removeClass, replaceClass, rowAttrs, rowDisableAfter, rowKeys, rowTotals, setAttributes, showChildCol, showChildRow, toggleCol, toggleColHeaderHeader, toggleRow, toggleRowHeaderHeader, tree,
|
|
487
|
+
var addClass, allTotal, arrowCollapsed, arrowExpanded, buildColHeaderHeader, buildColHeaderHeaders, buildColHeaderHeadersClickEvents, buildColHeaders, buildColTotals, buildColTotalsHeader, buildGrandTotal, buildRowHeaderHeaders, buildRowHeaderHeadersClickEvents, buildRowHeaders, buildRowTotalsHeader, buildValues, classColCollapsed, classColExpanded, classColHide, classColShow, classCollapsed, classExpanded, classRowCollapsed, classRowExpanded, classRowHide, classRowShow, clickStatusCollapsed, clickStatusExpanded, colAttrs, colDisableAfter, colKeys, colTotals, collapseCol, collapseColsAt, collapseHideDescendantRow, collapseRow, collapseRowsAt, collapseShowColSubtotal, collapseShowRowSubtotal, applyInlineStyles, createElement, defaults, expandChildCol, expandChildRow, expandCol, expandColsAt, expandHideColSubtotal, expandHideRowSubtotal, expandRow, expandRowsAt, expandShowColSubtotal, expandShowRowSubtotal, getTableEventHandlers, hasClass, hideDescendantCol, isColDisable, isColDisableExpandCollapse, isColHideOnExpand, isRowDisable, isRowDisableExpandCollapse, isRowHideOnExpand, main, getSubtotalInBrackets, processKeys, encodeHtmlEntities, ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7, removeClass, replaceClass, rowAttrs, rowDisableAfter, rowKeys, rowTotals, setAttributes, showChildCol, showChildRow, toggleCol, toggleColHeaderHeader, toggleRow, toggleRowHeaderHeader, tree, assumptionSubscribe;
|
|
455
488
|
var createTotalValsBolder, createGrandTotalBolder, getHeaderColorProperties, colorizeRowLabelHeaders, colorizeTableIfNeed, valueNoDashes, getColorsWithOffsetForTable, offsetColors, handleFreezePanesScroll, selectFreezableElements, removeRowHeaderNullValue;
|
|
456
489
|
var getAdditionalAggregation, buildAdditionalHeaderCols, buildAdditionalHeaderRows, buildAdditionalColValues, buildAdditionalRowValues, buildAdditionalRowTotals, buildAdditionalColTotals;
|
|
457
490
|
var additionalFieldsCol, additionalFieldsRow, additionalFieldsList;
|
|
458
|
-
var getExistingAggregator;
|
|
491
|
+
var edit_assumptions, getExistingAggregator;
|
|
459
492
|
|
|
460
493
|
var horizontalFreezePaneClass = opts.chartOptions.table_options.freeze_panes ? ' horizontal-freeze-pane' : '';
|
|
461
494
|
var verticalFreezePaneClass = opts.chartOptions.table_options.freeze_panes ? ' vertical-freeze-pane' : '';
|
|
@@ -506,6 +539,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
506
539
|
if(opts.chartOptions.table_options.start_collapsed_columns) {
|
|
507
540
|
opts.collapseColsAt = 0;
|
|
508
541
|
}
|
|
542
|
+
edit_assumptions = opts.chartOptions.edit_assumptions;
|
|
509
543
|
isRowDisable = (ref = opts.rowSubtotalDisplay) != null ? ref.disableSubtotal : void 0;
|
|
510
544
|
isRowHideOnExpand = (ref1 = opts.rowSubtotalDisplay) != null ? ref1.hideOnExpand : !opts.chartOptions.table_options.show_subtotals_for_rows;
|
|
511
545
|
isRowDisableExpandCollapse = (ref2 = opts.rowSubtotalDisplay) != null ? ref2.disableExpandCollapse : void 0;
|
|
@@ -842,7 +876,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
842
876
|
return string_val;
|
|
843
877
|
};
|
|
844
878
|
|
|
845
|
-
processKeys = function(keysArr, className, dimention, attrs
|
|
879
|
+
processKeys = function(keysArr, className, dimention, attrs) {
|
|
846
880
|
for (let i = 0; i < keysArr.length; i++) {
|
|
847
881
|
const additionalField = _.find(additionalFieldsList, {key: keysArr[i][0]})
|
|
848
882
|
|
|
@@ -863,7 +897,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
863
897
|
lastCol = 0;
|
|
864
898
|
}
|
|
865
899
|
rMark = [];
|
|
866
|
-
th = createElement("th", className, valueNoDashes(encodeHtmlEntities(
|
|
900
|
+
th = createElement("th", className, valueNoDashes(encodeHtmlEntities(keysArr[0][0]) + getSubtotalInBrackets(keysArr, className, lastCol, lastRow, 0, 0)));
|
|
867
901
|
key = [];
|
|
868
902
|
key.push(keysArr[0][0]);
|
|
869
903
|
nodePos = 0;
|
|
@@ -883,7 +917,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
883
917
|
rMark[0] = node;
|
|
884
918
|
c = 1;
|
|
885
919
|
while (c <= lastCol) {
|
|
886
|
-
th = createElement("th", className, valueNoDashes(encodeHtmlEntities(
|
|
920
|
+
th = createElement("th", className, valueNoDashes(encodeHtmlEntities(keysArr[0][c]) + getSubtotalInBrackets(keysArr, className, lastCol, lastRow, 0, c)));
|
|
887
921
|
key = key.slice();
|
|
888
922
|
key.push(keysArr[0][c]);
|
|
889
923
|
++nodePos;
|
|
@@ -949,7 +983,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
949
983
|
}
|
|
950
984
|
|
|
951
985
|
|
|
952
|
-
th = createElement("th", className, valueNoDashes(encodeHtmlEntities(
|
|
986
|
+
th = createElement("th", className, valueNoDashes(encodeHtmlEntities(keysArr[r][c]) + getSubtotalInBrackets(keysArr, className, lastCol, lastRow, r, c)));
|
|
953
987
|
++nodePos;
|
|
954
988
|
node = {
|
|
955
989
|
node: nodePos,
|
|
@@ -1536,7 +1570,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
1536
1570
|
if ((isRowSubtotal && (isRowHideOnExpand || isRowDisable || rowHeader.col > rowDisableAfter)) || (isColSubtotal && (isColHideOnExpand || isColDisable || colHeader.col > colDisableAfter))) {
|
|
1537
1571
|
td.style.display = "none";
|
|
1538
1572
|
}
|
|
1539
|
-
|
|
1573
|
+
assumptionSubscribe(td, rowHeader, rowAttrs, colHeader, colAttrs, val);
|
|
1540
1574
|
|
|
1541
1575
|
tr.appendChild(td);
|
|
1542
1576
|
}
|
|
@@ -1574,7 +1608,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
1574
1608
|
td.style.display = "none";
|
|
1575
1609
|
}
|
|
1576
1610
|
|
|
1577
|
-
|
|
1611
|
+
assumptionSubscribe(td, rowHeader, rowAttrs, {key:[], flatKey:''}, colAttrs, val);
|
|
1578
1612
|
|
|
1579
1613
|
if(opts.chartOptions.table_options.show_row_total)
|
|
1580
1614
|
tr.appendChild(td);
|
|
@@ -1584,7 +1618,43 @@ let initDRPivotTable = function($, window, document) {
|
|
|
1584
1618
|
return results;
|
|
1585
1619
|
};
|
|
1586
1620
|
|
|
1587
|
-
|
|
1621
|
+
assumptionSubscribe = function(td, rowHeader, rowAttrs, colHeader, colAttrs, val){
|
|
1622
|
+
if(edit_assumptions){
|
|
1623
|
+
var filters = [];
|
|
1624
|
+
var i=0;
|
|
1625
|
+
var temp;
|
|
1626
|
+
for(i=0; i<rowHeader.key.length; i++){
|
|
1627
|
+
temp = {
|
|
1628
|
+
name: rowAttrs[i],
|
|
1629
|
+
values: [rowHeader.key[i]],
|
|
1630
|
+
is_excluded:false
|
|
1631
|
+
}
|
|
1632
|
+
filters.push(temp);
|
|
1633
|
+
}
|
|
1634
|
+
for(i=0; i<colHeader.key.length; i++){
|
|
1635
|
+
temp = {
|
|
1636
|
+
name: colAttrs[i],
|
|
1637
|
+
values: [colHeader.key[i]],
|
|
1638
|
+
is_excluded:false
|
|
1639
|
+
}
|
|
1640
|
+
filters.push(temp);
|
|
1641
|
+
}
|
|
1642
|
+
var obj_to_send = {
|
|
1643
|
+
"flatColKey": colHeader.flatKey,
|
|
1644
|
+
"flatRowKey": rowHeader.flatKey,
|
|
1645
|
+
"val": val,
|
|
1646
|
+
"filters": filters
|
|
1647
|
+
};
|
|
1648
|
+
|
|
1649
|
+
// td.addEventListener('dblclick', function(){
|
|
1650
|
+
// edit_assumptions.fn(obj_to_send, this);
|
|
1651
|
+
// });
|
|
1652
|
+
|
|
1653
|
+
td.addEventListener('click', function(){
|
|
1654
|
+
edit_assumptions.fn(obj_to_send, this);
|
|
1655
|
+
});
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1588
1658
|
if(opts.value_drill_down_fn){
|
|
1589
1659
|
td.classList.add('clickable');
|
|
1590
1660
|
td.addEventListener('click', function(rowKey, colKey, rowAttrs, colAttrs){
|
|
@@ -1645,7 +1715,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
1645
1715
|
td.style.display = "none";
|
|
1646
1716
|
}
|
|
1647
1717
|
|
|
1648
|
-
|
|
1718
|
+
assumptionSubscribe(td, {key:[], flatKey:''}, rowAttrs, h, colAttrs, val);
|
|
1649
1719
|
|
|
1650
1720
|
results.push(tr.appendChild(td));
|
|
1651
1721
|
}
|
|
@@ -1671,7 +1741,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
1671
1741
|
"data-value": val
|
|
1672
1742
|
}, getTableEventHandlers(val, [], []));
|
|
1673
1743
|
createTotalValsBolder(td);
|
|
1674
|
-
|
|
1744
|
+
assumptionSubscribe(td, {key:[], flatKey:''}, rowAttrs, {key:[], flatKey:''}, colAttrs, val);
|
|
1675
1745
|
|
|
1676
1746
|
tr.appendChild(td);
|
|
1677
1747
|
return result.appendChild(tr);
|
|
@@ -2337,7 +2407,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
2337
2407
|
return Array.from(wrapper.querySelectorAll(selectString));
|
|
2338
2408
|
}
|
|
2339
2409
|
|
|
2340
|
-
main = function(rowAttrs, rowKeys, colAttrs, colKeys
|
|
2410
|
+
main = function(rowAttrs, rowKeys, colAttrs, colKeys) {
|
|
2341
2411
|
var c,rowspan, colHeaderCols, colHeaderHeaders, colHeaders, h, k, l, len, len1, result, rowHeaderHeaders, rowHeaderRows, rowHeaders, tbody, thead, tr;
|
|
2342
2412
|
rowHeaders = [];
|
|
2343
2413
|
colHeaders = [];
|
|
@@ -2346,12 +2416,10 @@ let initDRPivotTable = function($, window, document) {
|
|
|
2346
2416
|
colHeaderHeaders = [];
|
|
2347
2417
|
colHeaderCols = [];
|
|
2348
2418
|
if (rowAttrs.length > 0 && rowKeys.length > 0) {
|
|
2349
|
-
|
|
2350
|
-
rowHeaders = processKeys(rowKeys, "pvtRowLabel", 'rows', rowAttrs, formattedKeys);
|
|
2419
|
+
rowHeaders = processKeys(rowKeys, "pvtRowLabel", 'rows', rowAttrs);
|
|
2351
2420
|
}
|
|
2352
2421
|
if (colAttrs.length > 0 && colKeys.length > 0) {
|
|
2353
|
-
|
|
2354
|
-
colHeaders = processKeys(colKeys, "pvtColLabel", 'cols', colAttrs, formattedKeys);
|
|
2422
|
+
colHeaders = processKeys(colKeys, "pvtColLabel", 'cols', colAttrs);
|
|
2355
2423
|
}
|
|
2356
2424
|
var tableClasses = ['pvtTable'];
|
|
2357
2425
|
if (opts.chartOptions.table_options.use_new_table_design) {
|
|
@@ -2496,7 +2564,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
2496
2564
|
|
|
2497
2565
|
return wrapper;
|
|
2498
2566
|
};
|
|
2499
|
-
return main(rowAttrs, rowKeys, colAttrs, colKeys
|
|
2567
|
+
return main(rowAttrs, rowKeys, colAttrs, colKeys);
|
|
2500
2568
|
};
|
|
2501
2569
|
// $.pivotUtilities.subtotal_renderers = SubtotalRenderer;
|
|
2502
2570
|
$.pivotUtilities.subtotal_renderers = NovixRenderer;
|