@datarailsshared/dr_renderer 1.2.8 → 1.2.9
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 +53 -8
- package/README.md +5 -6
- package/babel.config.js +3 -0
- package/jest.config.js +27 -0
- package/package.json +25 -3
- package/src/charts/dr_gauge_chart.js +566 -0
- package/src/dataformatter.d.ts +13 -0
- package/src/dataformatter.js +60 -7
- package/src/dr-renderer-helpers.js +58 -0
- package/src/dr_chart_tooltip.js +277 -0
- package/src/dr_pivottable.js +606 -145
- package/src/graph-table-renderer.js +147 -0
- package/src/highcharts_renderer.js +5779 -2021
- package/src/index.js +8 -2
- package/src/novix_renderer.js +125 -48
- package/src/pivot.css +142 -17
- package/src/pivottable.js +84 -7
- package/src/published_items_renderer.js +365 -0
- package/src/seriesPointStyles-helper.js +43 -0
- package/tests/dr-renderer-helpers.test.js +150 -0
- package/tests/dr_chart_tooltip.test.js +739 -0
- package/tests/dr_gauge_chart.test.js +1931 -0
- package/tests/highcharts_renderer.test.js +9389 -0
- package/tests/mock/add-in-dynamic-ranges.json +127 -0
- package/tests/mock/add-in-functions.json +410 -0
- package/tests/mock/add-in-tables.json +347 -0
- package/tests/mock/tables.json +2258 -0
- package/tests/mock/widgets.json +403 -0
- package/tests/seriesPointStyles-helper.test.js +114 -0
- package/tsconfig.json +15 -0
- package/types/graph-table-renderer.d.ts +79 -0
- package/types/index.d.ts +1 -0
package/src/dr_pivottable.js
CHANGED
|
@@ -3,15 +3,19 @@ let initDRPivotTable = function($, window, document) {
|
|
|
3
3
|
var slice = [].slice;
|
|
4
4
|
var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
|
5
5
|
|
|
6
|
-
var DRPivotData, sortDateStrings, getSort, processKey, SubtotalRenderer, getFormattedNumber, largeToSmallSort, NovixRenderer;
|
|
7
|
-
|
|
8
|
-
var delim = " , ";
|
|
6
|
+
var DRPivotData, sortDateStrings, getSort, processKey, SubtotalRenderer, getFormattedNumber, largeToSmallSort, largeToSmallSortByAbsolute, NovixRenderer;
|
|
9
7
|
const newTableColors = ['rgb(127, 196, 255)', 'rgb(200, 243,243)', 'rgb(247, 161, 173)', 'rgb(255, 237, 178)', 'rgb(221, 239, 255)',
|
|
10
8
|
'rgb(171, 216, 255)', 'rgb(174, 231, 220)', 'rgb(227, 255, 236)', 'rgb(162, 215, 227)', 'rgb(223, 239, 236)'];
|
|
9
|
+
|
|
10
|
+
var delim = " , ";
|
|
11
11
|
const useNewUx = document.ReportHippo && document.ReportHippo && document.ReportHippo.user &&
|
|
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
|
+
|
|
15
19
|
DRPivotData = (function(superClass) {
|
|
16
20
|
extend(DRPivotData, superClass);
|
|
17
21
|
|
|
@@ -91,6 +95,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
91
95
|
|
|
92
96
|
DRPivotData.prototype.arrSort = function(attrs) {
|
|
93
97
|
var a, sortersArr;
|
|
98
|
+
const sortByValueAttrs = this.sortByValueAttrs;
|
|
94
99
|
sortersArr = (function() {
|
|
95
100
|
var l, len1, results;
|
|
96
101
|
results = [];
|
|
@@ -100,11 +105,21 @@ let initDRPivotTable = function($, window, document) {
|
|
|
100
105
|
}
|
|
101
106
|
return results;
|
|
102
107
|
}).call(this);
|
|
108
|
+
|
|
103
109
|
return function(a, b) {
|
|
104
110
|
var comparison, i, sorter;
|
|
105
111
|
for (i in sortersArr) {
|
|
106
|
-
|
|
107
|
-
|
|
112
|
+
const index = parseInt(i);
|
|
113
|
+
sorter = sortersArr[index];
|
|
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
|
+
}
|
|
108
123
|
if (comparison !== 0) {
|
|
109
124
|
return comparison;
|
|
110
125
|
}
|
|
@@ -113,7 +128,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
113
128
|
};
|
|
114
129
|
};
|
|
115
130
|
|
|
116
|
-
processKey = function(record, totals, keys, attrs, getAggregator) {
|
|
131
|
+
processKey = function(record, totals, keys, attrs, containsAverage, containsOthers, getAggregator) {
|
|
117
132
|
var addKey, attr, flatKey, k, key, len, ref;
|
|
118
133
|
key = [];
|
|
119
134
|
addKey = false;
|
|
@@ -125,7 +140,17 @@ let initDRPivotTable = function($, window, document) {
|
|
|
125
140
|
totals[flatKey] = getAggregator(key.slice());
|
|
126
141
|
addKey = true;
|
|
127
142
|
}
|
|
128
|
-
|
|
143
|
+
|
|
144
|
+
if (containsAverage || containsOthers) {
|
|
145
|
+
if (containsAverage && !containsOthers && key[0] === 'DR_Average') {
|
|
146
|
+
totals[flatKey].push(record);
|
|
147
|
+
}
|
|
148
|
+
if (containsOthers && !containsAverage && key[0] === 'DR_Others') {
|
|
149
|
+
totals[flatKey].push(record);
|
|
150
|
+
}
|
|
151
|
+
} else {
|
|
152
|
+
totals[flatKey].push(record);
|
|
153
|
+
}
|
|
129
154
|
}
|
|
130
155
|
if (addKey) {
|
|
131
156
|
keys.push(key);
|
|
@@ -133,54 +158,79 @@ let initDRPivotTable = function($, window, document) {
|
|
|
133
158
|
return key;
|
|
134
159
|
};
|
|
135
160
|
|
|
161
|
+
DRPivotData.prototype.getAttrsKeys = function(record, attrs) {
|
|
162
|
+
const keys = [];
|
|
163
|
+
for (let k = 0; k < attrs.length; k++) {
|
|
164
|
+
const attr = attrs[k];
|
|
165
|
+
if (record.hasOwnProperty(attr)) {
|
|
166
|
+
keys.push(record[attr] != null ? record[attr] : 'null');
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return keys;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
DRPivotData.prototype.getFlatKey = function(record, attrs) {
|
|
173
|
+
const keys = this.getAttrsKeys(record, attrs);
|
|
174
|
+
return keys.join(delim);
|
|
175
|
+
}
|
|
176
|
+
|
|
136
177
|
DRPivotData.prototype.processRecord = function(record) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
178
|
+
if (!this.notFirst) {
|
|
179
|
+
this.keysLength = _.filter(_.keys(record), key => !_.includes(['data_types', 'formats', 'values_formats'], key)).length - 1;
|
|
180
|
+
this.notFirst = true;
|
|
181
|
+
}
|
|
182
|
+
let getRowAggregator = (function(_this) {
|
|
142
183
|
return function(key) {
|
|
143
184
|
return _this.aggregator(_this, key, []);
|
|
144
185
|
};
|
|
145
|
-
})(this)
|
|
146
|
-
|
|
186
|
+
})(this);
|
|
187
|
+
let getColAggregator = (function(_this) {
|
|
147
188
|
return function(key) {
|
|
148
189
|
return _this.aggregator(_this, [], key);
|
|
149
190
|
};
|
|
150
|
-
})(this)
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
191
|
+
})(this);
|
|
192
|
+
|
|
193
|
+
const rowKey = this.getAttrsKeys(record, this.rowAttrs);
|
|
194
|
+
const colKey = this.getAttrsKeys(record, this.colAttrs);
|
|
195
|
+
|
|
196
|
+
let flatRowKey = rowKey.join(delim);
|
|
197
|
+
let flatColKey = colKey.join(delim);
|
|
198
|
+
|
|
199
|
+
if (this.keysLength === rowKey.length + colKey.length) {
|
|
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
|
+
}
|
|
155
206
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
207
|
+
|
|
208
|
+
if (!colKey.length && !rowKey.length) {
|
|
209
|
+
this.allTotal.push(record);
|
|
210
|
+
} else if (!colKey.length && rowKey.length) {
|
|
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 {
|
|
160
221
|
if (!this.tree[flatRowKey]) {
|
|
161
222
|
this.tree[flatRowKey] = {};
|
|
162
223
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
results1 = [];
|
|
166
|
-
for (j = l = 0, ref1 = n; 0 <= ref1 ? l <= ref1 : l >= ref1; j = 0 <= ref1 ? ++l : --l) {
|
|
167
|
-
fColKey = colKey.slice(0, j + 1);
|
|
168
|
-
flatColKey = fColKey.join(delim);
|
|
169
|
-
if (!this.tree[flatRowKey][flatColKey]) {
|
|
170
|
-
this.tree[flatRowKey][flatColKey] = this.aggregator(this, fRowKey, fColKey);
|
|
171
|
-
}
|
|
172
|
-
results1.push(this.tree[flatRowKey][flatColKey].push(record));
|
|
173
|
-
}
|
|
174
|
-
return results1;
|
|
175
|
-
}).call(this));
|
|
224
|
+
this.tree[flatRowKey][flatColKey] = this.aggregator(this, rowKey, colKey);
|
|
225
|
+
this.tree[flatRowKey][flatColKey].push(record);
|
|
176
226
|
}
|
|
177
|
-
return results;
|
|
178
227
|
};
|
|
179
228
|
|
|
180
229
|
DRPivotData.prototype.getAggregator = function(rowKey, colKey) {
|
|
181
230
|
var agg, flatColKey, flatRowKey;
|
|
182
|
-
|
|
183
|
-
|
|
231
|
+
let hebrewMarkRegex = new RegExp(String.fromCharCode(8206), 'g');
|
|
232
|
+
flatRowKey = rowKey.join(delim).replace(hebrewMarkRegex, '');
|
|
233
|
+
flatColKey = colKey.join(delim).replace(hebrewMarkRegex, '');
|
|
184
234
|
if (rowKey.length === 0 && colKey.length === 0) {
|
|
185
235
|
agg = this.allTotal;
|
|
186
236
|
} else if (rowKey.length === 0) {
|
|
@@ -286,7 +336,11 @@ let initDRPivotTable = function($, window, document) {
|
|
|
286
336
|
};
|
|
287
337
|
};
|
|
288
338
|
|
|
289
|
-
|
|
339
|
+
largeToSmallSortByAbsolute = function (as, bs) {
|
|
340
|
+
return largeToSmallSort(as , bs, true);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
largeToSmallSort = function(as, bs, is_abs = false) {
|
|
290
344
|
var a, a1, b, b1, rd, rx, rz;
|
|
291
345
|
rx = /(\d+)|(\D+)/g;
|
|
292
346
|
rd = /\d/;
|
|
@@ -298,6 +352,11 @@ let initDRPivotTable = function($, window, document) {
|
|
|
298
352
|
if (isNaN(bs)) {
|
|
299
353
|
return 1;
|
|
300
354
|
}
|
|
355
|
+
|
|
356
|
+
if (is_abs) {
|
|
357
|
+
return Math.abs(bs) - Math.abs(as);
|
|
358
|
+
}
|
|
359
|
+
|
|
301
360
|
return bs - as;
|
|
302
361
|
}
|
|
303
362
|
a = String(as).toLowerCase();
|
|
@@ -337,13 +396,10 @@ let initDRPivotTable = function($, window, document) {
|
|
|
337
396
|
switch (opts.chartOptions.negative_numbers.value) {
|
|
338
397
|
case 'red_minus':
|
|
339
398
|
return '<span style="color: red; fill: red;">' + aggregator.format(val, format_argument) + '</span>';
|
|
340
|
-
break;
|
|
341
399
|
case 'absolute':
|
|
342
400
|
return '(' + aggregator.format(Math.abs(val), format_argument) + ')';
|
|
343
|
-
break;
|
|
344
401
|
case 'red_absolute':
|
|
345
402
|
return '<span style="color: red; fill: red;">(' + aggregator.format(Math.abs(val), format_argument) + ')</span>';
|
|
346
|
-
break;
|
|
347
403
|
default:
|
|
348
404
|
return aggregator.format(val, format_argument);
|
|
349
405
|
}
|
|
@@ -379,20 +435,45 @@ let initDRPivotTable = function($, window, document) {
|
|
|
379
435
|
return resultsArr;
|
|
380
436
|
} else {
|
|
381
437
|
let tooMuch = false;
|
|
382
|
-
|
|
383
|
-
|
|
438
|
+
const show_more_than_thousand_rows = _.get(opts, 'chartOptions.table_options.show_more_than_thousand_rows', false);
|
|
439
|
+
if (pvtData &&
|
|
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) {
|
|
384
443
|
pvtData.rowKeys = [];
|
|
385
444
|
pvtData.colKeys = [];
|
|
386
445
|
tooMuch = true;
|
|
446
|
+
opts.error_has_occurred = true;
|
|
447
|
+
opts.error_params = $.pivotUtilities.errorHandling.placeholders.tooMuchData;
|
|
387
448
|
}
|
|
388
|
-
return SubtotalRenderer(pvtData, opts, charttype, tooMuch);
|
|
449
|
+
return SubtotalRenderer(pvtData, opts, charttype, tooMuch, opts.error_params);
|
|
389
450
|
}
|
|
390
451
|
}
|
|
391
452
|
|
|
392
|
-
SubtotalRenderer = function(pivotData, opts, charttype, tooMuch = false) {
|
|
393
|
-
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, 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,
|
|
394
|
-
var createTotalValsBolder, createGrandTotalBolder, getHeaderColorProperties, colorizeRowLabelHeaders, colorizeTableIfNeed, valueNoDashes;
|
|
395
|
-
var
|
|
453
|
+
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, subscribeToClick;
|
|
455
|
+
var createTotalValsBolder, createGrandTotalBolder, getHeaderColorProperties, colorizeRowLabelHeaders, colorizeTableIfNeed, valueNoDashes, getColorsWithOffsetForTable, offsetColors, handleFreezePanesScroll, selectFreezableElements, removeRowHeaderNullValue;
|
|
456
|
+
var getAdditionalAggregation, buildAdditionalHeaderCols, buildAdditionalHeaderRows, buildAdditionalColValues, buildAdditionalRowValues, buildAdditionalRowTotals, buildAdditionalColTotals;
|
|
457
|
+
var additionalFieldsCol, additionalFieldsRow, additionalFieldsList;
|
|
458
|
+
var getExistingAggregator;
|
|
459
|
+
|
|
460
|
+
var horizontalFreezePaneClass = opts.chartOptions.table_options.freeze_panes ? ' horizontal-freeze-pane' : '';
|
|
461
|
+
var verticalFreezePaneClass = opts.chartOptions.table_options.freeze_panes ? ' vertical-freeze-pane' : '';
|
|
462
|
+
var axisFreezePaneClass = opts.chartOptions.table_options.freeze_panes ? ' axis-freeze-pane' : '';
|
|
463
|
+
|
|
464
|
+
var elementToTransform = {
|
|
465
|
+
X: horizontalFreezePaneClass,
|
|
466
|
+
Y: verticalFreezePaneClass,
|
|
467
|
+
XY: axisFreezePaneClass,
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
additionalFieldsCol = [];
|
|
471
|
+
additionalFieldsRow = [];
|
|
472
|
+
additionalFieldsList = [
|
|
473
|
+
{key: 'DR_Average', name: 'DR_Average'},
|
|
474
|
+
{key: 'DR_Others', name: _.get(opts, "total_value_options.filter_options.filteredOutFieldName") || 'Others'}
|
|
475
|
+
];
|
|
476
|
+
$.pivotUtilities.additionalFieldsList = additionalFieldsList;
|
|
396
477
|
|
|
397
478
|
defaults = {
|
|
398
479
|
table: {
|
|
@@ -425,7 +506,6 @@ let initDRPivotTable = function($, window, document) {
|
|
|
425
506
|
if(opts.chartOptions.table_options.start_collapsed_columns) {
|
|
426
507
|
opts.collapseColsAt = 0;
|
|
427
508
|
}
|
|
428
|
-
edit_assumptions = opts.chartOptions.edit_assumptions;
|
|
429
509
|
isRowDisable = (ref = opts.rowSubtotalDisplay) != null ? ref.disableSubtotal : void 0;
|
|
430
510
|
isRowHideOnExpand = (ref1 = opts.rowSubtotalDisplay) != null ? ref1.hideOnExpand : !opts.chartOptions.table_options.show_subtotals_for_rows;
|
|
431
511
|
isRowDisableExpandCollapse = (ref2 = opts.rowSubtotalDisplay) != null ? ref2.disableExpandCollapse : void 0;
|
|
@@ -437,13 +517,21 @@ let initDRPivotTable = function($, window, document) {
|
|
|
437
517
|
arrowCollapsed = opts.arrowCollapsed != null ? opts.arrowCollapsed : opts.arrowCollapsed = '<i class="fa fa-plus dr-icon-add"></i> ';
|
|
438
518
|
arrowExpanded = opts.arrowExpanded != null ? opts.arrowExpanded : opts.arrowExpanded = '<i class="fa fa-minus dr-icon-minus"></i> ';
|
|
439
519
|
colAttrs = pivotData.colAttrs;
|
|
520
|
+
rowAttrs = pivotData.rowAttrs;
|
|
521
|
+
rowKeys = pivotData.getRowKeys();
|
|
440
522
|
|
|
441
523
|
if (charttype == 'column-chart' || charttype == 'column-chart-stacked') {
|
|
442
|
-
|
|
524
|
+
if (_.get(opts, 'chartOptions.table_options.transpose_table', false)) {
|
|
525
|
+
rowAttrs = [rowAttrs[0]];
|
|
526
|
+
if (rowKeys && rowKeys.length) {
|
|
527
|
+
rowKeys = rowKeys.map( function(_, index) {
|
|
528
|
+
return [rowKeys[index][0]];
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
} else if (colAttrs.length) {
|
|
532
|
+
colAttrs = [colAttrs[0]];
|
|
533
|
+
}
|
|
443
534
|
}
|
|
444
|
-
|
|
445
|
-
rowAttrs = pivotData.rowAttrs;
|
|
446
|
-
rowKeys = pivotData.getRowKeys();
|
|
447
535
|
colKeys = pivotData.getColKeys();
|
|
448
536
|
tree = pivotData.tree;
|
|
449
537
|
rowTotals = pivotData.rowTotals;
|
|
@@ -510,19 +598,87 @@ let initDRPivotTable = function($, window, document) {
|
|
|
510
598
|
return value;
|
|
511
599
|
};
|
|
512
600
|
|
|
601
|
+
offsetColors = function (offset, colorsArray) {
|
|
602
|
+
if (offset > opts.defaults_colors.length) {
|
|
603
|
+
offset = offset % opts.defaults_colors;
|
|
604
|
+
}
|
|
605
|
+
var colors_to_return = JSON.parse(JSON.stringify(colorsArray));
|
|
606
|
+
for (var i = 0; i < offset; i++) {
|
|
607
|
+
colors_to_return.push(colors_to_return.shift());
|
|
608
|
+
}
|
|
609
|
+
return colors_to_return;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
getColorsWithOffsetForTable = function (value) {
|
|
613
|
+
var colors = [];
|
|
614
|
+
|
|
615
|
+
if (opts.paletteOptions && opts.paletteOptions.widgetPalette) {
|
|
616
|
+
const mc_palette = _.find(_.get(opts.paletteOptions, 'monochromePalettes', []), { selected: true });
|
|
617
|
+
colors = mc_palette ? mc_palette.colors : opts.paletteOptions.widgetPalette;
|
|
618
|
+
} else if (opts.paletteOptions && opts.paletteOptions.dashboardPalette && opts.paletteOptions.dashboardPalette.colors) {
|
|
619
|
+
colors = opts.paletteOptions.dashboardPalette.colors;
|
|
620
|
+
} else {
|
|
621
|
+
colors = newTableColors;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
var isNewDesign = useNewUx && opts.chartOptions.table_options.use_new_table_design;
|
|
625
|
+
if (value) {
|
|
626
|
+
var offset = parseInt(value);
|
|
627
|
+
if (offset) {
|
|
628
|
+
if (isNewDesign) {
|
|
629
|
+
return offsetColors(offset, colors);
|
|
630
|
+
} else {
|
|
631
|
+
return offsetColors(offset, opts.defaults_colors);
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
return isNewDesign ? colors : opts.defaults_colors;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
function invertColors(color) {
|
|
639
|
+
const hexLuminance = 186;
|
|
640
|
+
const rgbLuminance = 0.5;
|
|
641
|
+
let isHex = color[0] === '#';
|
|
642
|
+
let r;
|
|
643
|
+
let g;
|
|
644
|
+
let b;
|
|
645
|
+
if (!isHex) {
|
|
646
|
+
let rgbaColorParts = color.replace(/[^0-9.,]/g, '').split(',');
|
|
647
|
+
r = rgbaColorParts[0]/255;
|
|
648
|
+
g = rgbaColorParts[1]/255;
|
|
649
|
+
b = rgbaColorParts[2]/255;
|
|
650
|
+
} else {
|
|
651
|
+
color = color.slice(1);
|
|
652
|
+
|
|
653
|
+
if (color.length === 3) {
|
|
654
|
+
color = color[0].repeat(2) + color[1].repeat(2) + color[2].repeat(2);
|
|
655
|
+
} else if (color.length !== 6) {
|
|
656
|
+
return "#FFFFFF";
|
|
657
|
+
}
|
|
658
|
+
r = parseInt(color.slice(0, 2), 16);
|
|
659
|
+
g = parseInt(color.slice(2, 4), 16);
|
|
660
|
+
b = parseInt(color.slice(4, 6), 16);
|
|
661
|
+
}
|
|
662
|
+
return (r * 0.299 + g * 0.587 + b * 0.114) > (isHex ? hexLuminance : rgbLuminance)
|
|
663
|
+
? '#000000'
|
|
664
|
+
: '#FFFFFF';
|
|
665
|
+
}
|
|
666
|
+
|
|
513
667
|
colorizeRowLabelHeaders = function(element, cols_count){
|
|
514
668
|
if(opts.chartOptions.table_options.colorize_headers == true &&
|
|
515
669
|
opts.defaults_colors && opts.defaults_colors.length > 0){
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
var color_to_set = useNewUx && opts.chartOptions.table_options.use_new_table_design ?
|
|
519
|
-
newTableColors[cols_count] :
|
|
520
|
-
opts.defaults_colors[cols_count];
|
|
670
|
+
var offsetColor = getColorsWithOffsetForTable(opts.chartOptions.table_options.table_colors_offset);
|
|
671
|
+
var color_to_set = offsetColor[cols_count];
|
|
521
672
|
if(color_to_set){
|
|
522
673
|
element.style.setProperty("background-color", color_to_set, "important");
|
|
523
674
|
element.style.setProperty("border-color", color_to_set, "important");
|
|
524
|
-
element.style.color =
|
|
675
|
+
element.style.color = invertColors(color_to_set);
|
|
525
676
|
element.style.fontWeight = "bold";
|
|
677
|
+
if (opts.chartOptions.table_options.freeze_panes && element.firstChild) {
|
|
678
|
+
for (const child of element.children) {
|
|
679
|
+
child.style.setProperty("background-color", color_to_set, "important");
|
|
680
|
+
}
|
|
681
|
+
}
|
|
526
682
|
}
|
|
527
683
|
}
|
|
528
684
|
};
|
|
@@ -540,15 +696,19 @@ let initDRPivotTable = function($, window, document) {
|
|
|
540
696
|
getHeaderColorProperties = function(element, col_number = 0){
|
|
541
697
|
if(opts.chartOptions.table_options.colorize_headers == true &&
|
|
542
698
|
opts.defaults_colors && opts.defaults_colors.length > 0){
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
opts.defaults_colors[col_number];
|
|
699
|
+
const offsetColor = getColorsWithOffsetForTable(opts.chartOptions.table_options.table_colors_offset);
|
|
700
|
+
var color_to_set = offsetColor[col_number];
|
|
546
701
|
if(color_to_set){
|
|
547
702
|
element.style.setProperty("background-color", color_to_set, "important");
|
|
548
703
|
element.style.setProperty("border-color", color_to_set, "important");
|
|
549
704
|
element.style.setProperty("vertical-align", "baseline");
|
|
550
|
-
element.style.color =
|
|
705
|
+
element.style.color = invertColors(color_to_set);
|
|
551
706
|
element.style.fontWeight = "bold";
|
|
707
|
+
if (opts.chartOptions.table_options.freeze_panes && element.firstChild) {
|
|
708
|
+
for (const child of element.children) {
|
|
709
|
+
child.style.setProperty("background-color", color_to_set, "important");
|
|
710
|
+
}
|
|
711
|
+
}
|
|
552
712
|
}
|
|
553
713
|
}
|
|
554
714
|
};
|
|
@@ -583,6 +743,35 @@ let initDRPivotTable = function($, window, document) {
|
|
|
583
743
|
}
|
|
584
744
|
return eventHandlers;
|
|
585
745
|
};
|
|
746
|
+
applyInlineStyles = function(element, className) {
|
|
747
|
+
const tableDesignOptions = opts.chartOptions.table_design_options;
|
|
748
|
+
let optionName;
|
|
749
|
+
if (!className) return element;
|
|
750
|
+
|
|
751
|
+
if(element.className){
|
|
752
|
+
if (_.includes(element.className, 'pvtAxisLabel') ||
|
|
753
|
+
_.includes(element.className, 'pvtColLabel')) {
|
|
754
|
+
optionName = 'columns';
|
|
755
|
+
}else if (_.includes(element.className,'pvtRowLabel')) {
|
|
756
|
+
optionName = 'rows';
|
|
757
|
+
} else if (_.includes(element.className,'pvtVal') &&
|
|
758
|
+
!_.includes(element.className,'pvtTotal')) {
|
|
759
|
+
optionName = 'values';
|
|
760
|
+
} else if (_.includes(element.className,'colTotal') ||
|
|
761
|
+
_.includes(element.className,'rowTotal') ||
|
|
762
|
+
_.includes(element.className,'pvtGrandTotal')) {
|
|
763
|
+
optionName = 'totals';
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
if(optionName && tableDesignOptions){
|
|
768
|
+
element.style.fontSize = tableDesignOptions[optionName + '_font_size'] + 'px';
|
|
769
|
+
element.style.textAlign = tableDesignOptions[optionName + '_align_text'];
|
|
770
|
+
element.style.fontFamily = tableDesignOptions[optionName + '_font_style'];
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
return element;
|
|
774
|
+
}
|
|
586
775
|
createElement = function(elementType, className, textContent, attributes, eventHandlers) {
|
|
587
776
|
var attr, e, event, handler, val;
|
|
588
777
|
e = document.createElement(elementType);
|
|
@@ -607,6 +796,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
607
796
|
e.addEventListener(event, handler);
|
|
608
797
|
}
|
|
609
798
|
}
|
|
799
|
+
applyInlineStyles(e, className);
|
|
610
800
|
return e;
|
|
611
801
|
};
|
|
612
802
|
setAttributes = function(e, attrs) {
|
|
@@ -641,7 +831,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
641
831
|
if(!string_val || typeof(string_val) != 'string' ){
|
|
642
832
|
return string_val;
|
|
643
833
|
}
|
|
644
|
-
var entityMap = {"'":"'","<":"<",">":">","
|
|
834
|
+
var entityMap = {"'":"'","<":"<",">":">","¡":"¡","¢":"¢","£":"£","¤":"¤","¥":"¥","¦":"¦","§":"§","¨":"¨","©":"©","ª":"ª","«":"«","¬":"¬","®":"®","¯":"¯","°":"°","±":"±","²":"²","³":"³","´":"´","µ":"µ","¶":"¶","·":"·","¸":"¸","¹":"¹","º":"º","»":"»","¼":"¼","½":"½","¾":"¾","¿":"¿","À":"À","Á":"Á","Â":"Â","Ã":"Ã","Ä":"Ä","Å":"Å","Æ":"Æ","Ç":"Ç","È":"È","É":"É","Ê":"Ê","Ë":"Ë","Ì":"Ì","Í":"Í","Î":"Î","Ï":"Ï","Ð":"Ð","Ñ":"Ñ","Ò":"Ò","Ó":"Ó","Ô":"Ô","Õ":"Õ","Ö":"Ö","×":"×","Ø":"Ø","Ù":"Ù","Ú":"Ú","Û":"Û","Ü":"Ü","Ý":"Ý","Þ":"Þ","ß":"ß","à":"à","á":"á","â":"â","ã":"ã","ä":"ä","å":"å","æ":"æ","ç":"ç","è":"è","é":"é","ê":"ê","ë":"ë","ì":"ì","í":"í","î":"î","ï":"ï","ð":"ð","ñ":"ñ","ò":"ò","ó":"ó","ô":"ô","õ":"õ","ö":"ö","÷":"÷","ø":"ø","ù":"ù","ú":"ú","û":"û","ü":"ü","ý":"ý","þ":"þ","ÿ":"ÿ","Œ":"Œ","œ":"œ","Š":"Š","š":"š","Ÿ":"Ÿ","ƒ":"ƒ","ˆ":"ˆ","˜":"˜","Α":"Α","Β":"Β","Γ":"Γ","Δ":"Δ","Ε":"Ε","Ζ":"Ζ","Η":"Η","Θ":"Θ","Ι":"Ι","Κ":"Κ","Λ":"Λ","Μ":"Μ","Ν":"Ν","Ξ":"Ξ","Ο":"Ο","Π":"Π","Ρ":"Ρ","Σ":"Σ","Τ":"Τ","Υ":"Υ","Φ":"Φ","Χ":"Χ","Ψ":"Ψ","Ω":"Ω","α":"α","β":"β","γ":"γ","δ":"δ","ε":"ε","ζ":"ζ","η":"η","θ":"θ","ι":"ι","κ":"κ","λ":"λ","μ":"μ","ν":"ν","ξ":"ξ","ο":"ο","π":"π","ρ":"ρ","ς":"ς","σ":"σ","τ":"τ","υ":"υ","φ":"φ","χ":"χ","ψ":"ψ","ω":"ω","ϑ":"ϑ","ϒ":"&Upsih;","ϖ":"ϖ","–":"–","—":"—","‘":"‘","’":"’","‚":"‚","“":"“","”":"”","„":"„","†":"†","‡":"‡","•":"•","…":"…","‰":"‰","′":"′","″":"″","‹":"‹","›":"›","‾":"‾","⁄":"⁄","€":"€","ℑ":"ℑ","℘":"℘","ℜ":"ℜ","™":"™","ℵ":"ℵ","←":"←","↑":"↑","→":"→","↓":"↓","↔":"↔","↵":"↵","⇐":"⇐","⇑":"&UArr;","⇒":"⇒","⇓":"⇓","⇔":"⇔","∀":"∀","∂":"∂","∃":"∃","∅":"∅","∇":"∇","∈":"∈","∉":"∉","∋":"∋","∏":"∏","∑":"∑","−":"−","∗":"∗","√":"√","∝":"∝","∞":"∞","∠":"∠","∧":"∧","∨":"∨","∩":"∩","∪":"∪","∫":"∫","∴":"∴","∼":"∼","≅":"≅","≈":"≈","≠":"≠","≡":"≡","≤":"≤","≥":"≥","⊂":"⊂","⊃":"⊃","⊄":"⊄","⊆":"⊆","⊇":"⊇","⊕":"⊕","⊗":"⊗","⊥":"⊥","⋅":"⋅","⌈":"⌈","⌉":"⌉","⌊":"⌊","⌋":"⌋","⟨":"⟨","⟩":"⟩","◊":"◊","♠":"♠","♣":"♣","♥":"♥","♦":"♦"};
|
|
645
835
|
string_val = string_val.replace(/&/g, '&');
|
|
646
836
|
string_val = string_val.replace(/"/g, '"');
|
|
647
837
|
for (var key in entityMap) {
|
|
@@ -652,16 +842,28 @@ let initDRPivotTable = function($, window, document) {
|
|
|
652
842
|
return string_val;
|
|
653
843
|
};
|
|
654
844
|
|
|
655
|
-
processKeys = function(keysArr, className, dimention, attrs) {
|
|
845
|
+
processKeys = function(keysArr, className, dimention, attrs, formattedKeys) {
|
|
846
|
+
for (let i = 0; i < keysArr.length; i++) {
|
|
847
|
+
const additionalField = _.find(additionalFieldsList, {key: keysArr[i][0]})
|
|
848
|
+
|
|
849
|
+
if (additionalField) {
|
|
850
|
+
dimention === 'rows'
|
|
851
|
+
? additionalFieldsRow.push(additionalField)
|
|
852
|
+
: additionalFieldsCol.push(additionalField);
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
|
|
656
856
|
var c, headers, k, key, lastCol, lastRow, node, nodePos, r, rMark, ref8, repeats, th, x;
|
|
857
|
+
const showAllData = opts && opts.chartOptions && opts.chartOptions.table_options && opts.chartOptions.table_options.show_all;
|
|
858
|
+
|
|
657
859
|
headers = [];
|
|
658
860
|
lastRow = keysArr.length - 1;
|
|
659
861
|
lastCol = keysArr[0].length - 1;
|
|
660
|
-
if(lastCol > 0 && className == "pvtColLabel" && (charttype == 'column-chart' || charttype == 'column-chart-stacked')){
|
|
862
|
+
if(lastCol > 0 && className == "pvtColLabel" && !_.get(opts, 'chartOptions.table_options.transpose_table', false) && (charttype == 'column-chart' || charttype == 'column-chart-stacked')){
|
|
661
863
|
lastCol = 0;
|
|
662
864
|
}
|
|
663
865
|
rMark = [];
|
|
664
|
-
th = createElement("th", className, valueNoDashes(encodeHtmlEntities(
|
|
866
|
+
th = createElement("th", className, valueNoDashes(encodeHtmlEntities(formattedKeys[0][0]) + getSubtotalInBrackets(keysArr, className, lastCol, lastRow, 0, 0)));
|
|
665
867
|
key = [];
|
|
666
868
|
key.push(keysArr[0][0]);
|
|
667
869
|
nodePos = 0;
|
|
@@ -681,7 +883,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
681
883
|
rMark[0] = node;
|
|
682
884
|
c = 1;
|
|
683
885
|
while (c <= lastCol) {
|
|
684
|
-
th = createElement("th", className, valueNoDashes(encodeHtmlEntities(
|
|
886
|
+
th = createElement("th", className, valueNoDashes(encodeHtmlEntities(formattedKeys[0][c]) + getSubtotalInBrackets(keysArr, className, lastCol, lastRow, 0, c)));
|
|
685
887
|
key = key.slice();
|
|
686
888
|
key.push(keysArr[0][c]);
|
|
687
889
|
++nodePos;
|
|
@@ -718,7 +920,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
718
920
|
|
|
719
921
|
if(c === 0 && ((dimention == 'rows' && opts.show_more_function_rows)
|
|
720
922
|
|| (dimention == 'cols' && opts.show_more_function_cols)
|
|
721
|
-
) && headers.length > opts.show_more_max_items)
|
|
923
|
+
) && headers.length > opts.show_more_max_items && !showAllData)
|
|
722
924
|
{
|
|
723
925
|
key=['...'];
|
|
724
926
|
|
|
@@ -747,7 +949,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
747
949
|
}
|
|
748
950
|
|
|
749
951
|
|
|
750
|
-
th = createElement("th", className, valueNoDashes(encodeHtmlEntities(
|
|
952
|
+
th = createElement("th", className, valueNoDashes(encodeHtmlEntities(formattedKeys[r][c]) + getSubtotalInBrackets(keysArr, className, lastCol, lastRow, r, c)));
|
|
751
953
|
++nodePos;
|
|
752
954
|
node = {
|
|
753
955
|
node: nodePos,
|
|
@@ -788,7 +990,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
788
990
|
var className, colAttr, textContent, th, clickStatus;
|
|
789
991
|
colAttr = colAttrs[col];
|
|
790
992
|
textContent = opts.labelsConvertFunction(colAttr);
|
|
791
|
-
className = "pvtAxisLabel";
|
|
993
|
+
className = "pvtAxisLabel" + axisFreezePaneClass;
|
|
792
994
|
if (col < colAttrs.length - 1) {
|
|
793
995
|
if (!(isColDisableExpandCollapse || isColDisable || col > colDisableAfter)) {
|
|
794
996
|
if(opts.collapseColsAt == 0){
|
|
@@ -826,13 +1028,14 @@ let initDRPivotTable = function($, window, document) {
|
|
|
826
1028
|
else{
|
|
827
1029
|
rowSpan = colAttrs.length;
|
|
828
1030
|
}
|
|
829
|
-
tr.appendChild(createElement("th",
|
|
1031
|
+
tr.appendChild(createElement("th", axisFreezePaneClass, null, {
|
|
830
1032
|
colspan: rowAttrs.length,
|
|
831
1033
|
rowspan: rowSpan
|
|
832
1034
|
}));
|
|
833
1035
|
}
|
|
834
|
-
|
|
1036
|
+
|
|
835
1037
|
buildColHeaderHeader(thead, colHeaderHeaders, rowAttrs, colAttrs, tr, 0);
|
|
1038
|
+
getHeaderColorProperties(tr);
|
|
836
1039
|
results = [];
|
|
837
1040
|
for (c = k = 1, ref8 = colAttrs.length; 1 <= ref8 ? k <= ref8 : k >= ref8; c = 1 <= ref8 ? ++k : --k) {
|
|
838
1041
|
if (!(c < colAttrs.length)) {
|
|
@@ -840,7 +1043,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
840
1043
|
}
|
|
841
1044
|
tr = createElement("tr");
|
|
842
1045
|
if (opts.chartOptions.table_options.colorize_headers == true && rowAttrs.length !== 0) {
|
|
843
|
-
tr.appendChild(createElement("th",
|
|
1046
|
+
tr.appendChild(createElement("th", axisFreezePaneClass, null, {
|
|
844
1047
|
colspan: rowAttrs.length
|
|
845
1048
|
}));
|
|
846
1049
|
}
|
|
@@ -869,6 +1072,9 @@ let initDRPivotTable = function($, window, document) {
|
|
|
869
1072
|
return results;
|
|
870
1073
|
};
|
|
871
1074
|
buildColHeaders = function(colHeaderHeaders, colHeaderCols, colHeader, rowAttrs, colAttrs) {
|
|
1075
|
+
const additionalField = _.find(additionalFieldsList, {key: colHeader.key[0]})
|
|
1076
|
+
if (additionalField) return;
|
|
1077
|
+
|
|
872
1078
|
var colspan, h, hh, isColSubtotal, k, len, ref8, rowspan, sTh, style, th, tr;
|
|
873
1079
|
ref8 = colHeader.children;
|
|
874
1080
|
for (k = 0, len = ref8.length; k < len; k++) {
|
|
@@ -882,7 +1088,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
882
1088
|
++hh.nHeaders;
|
|
883
1089
|
tr = hh.tr;
|
|
884
1090
|
th = colHeader.th;
|
|
885
|
-
addClass(th, "col" + colHeader.row + " colcol" + colHeader.col + " " + classColShow);
|
|
1091
|
+
addClass(th, "col" + colHeader.row + " colcol" + colHeader.col + " " + classColShow + verticalFreezePaneClass);
|
|
886
1092
|
//getHeaderColorProperties(th, colHeader.col);
|
|
887
1093
|
if (isColHideOnExpand || isColDisable || (isColSubtotal && colHeader.col > colDisableAfter)) {
|
|
888
1094
|
colspan = colHeader.leaves;
|
|
@@ -916,7 +1122,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
916
1122
|
return toggleCol(colHeaderHeaders, colHeaderCols, parseInt(event.currentTarget.getAttribute("data-colnode")));
|
|
917
1123
|
};
|
|
918
1124
|
rowspan = colAttrs.length - (colHeader.col + 1) + (rowAttrs.length !== 0 ? 1 : 0);
|
|
919
|
-
style = "pvtColLabel pvtColSubtotal " + classColExpanded;
|
|
1125
|
+
style = "pvtColLabel pvtColSubtotal " + classColExpanded + verticalFreezePaneClass;
|
|
920
1126
|
style += " col" + colHeader.row + " colcol" + colHeader.col;
|
|
921
1127
|
if (isColHideOnExpand || isColDisable || colHeader.col > colDisableAfter) {
|
|
922
1128
|
style += " " + classColHide;
|
|
@@ -935,6 +1141,9 @@ let initDRPivotTable = function($, window, document) {
|
|
|
935
1141
|
}
|
|
936
1142
|
colHeader.clickStatus = clickStatusExpanded;
|
|
937
1143
|
tr.appendChild(th);
|
|
1144
|
+
if (opts.chartOptions.table_options.freeze_panes) {
|
|
1145
|
+
getHeaderColorProperties(tr);
|
|
1146
|
+
}
|
|
938
1147
|
colHeader.tr = tr;
|
|
939
1148
|
return colHeaderCols.push(colHeader);
|
|
940
1149
|
};
|
|
@@ -946,7 +1155,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
946
1155
|
if (!hasProp.call(rowAttrs, i)) continue;
|
|
947
1156
|
rowAttr = rowAttrs[i];
|
|
948
1157
|
textContent = opts.labelsConvertFunction(rowAttr);
|
|
949
|
-
className = "pvtAxisLabel";
|
|
1158
|
+
className = "pvtAxisLabel" + axisFreezePaneClass;
|
|
950
1159
|
if (i < rowAttrs.length - 1) {
|
|
951
1160
|
className += " expanded";
|
|
952
1161
|
if (!(isRowDisableExpandCollapse || isRowDisable || i > rowDisableAfter)) {
|
|
@@ -973,7 +1182,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
973
1182
|
});
|
|
974
1183
|
}
|
|
975
1184
|
if (colAttrs.length !== 0) {
|
|
976
|
-
th = createElement("th");
|
|
1185
|
+
th = createElement("th", axisFreezePaneClass);
|
|
977
1186
|
tr.appendChild(th);
|
|
978
1187
|
}
|
|
979
1188
|
colorizeRowLabelHeaders(tr, colAttrs.length);
|
|
@@ -1010,7 +1219,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
1010
1219
|
rowspan = 1;
|
|
1011
1220
|
}
|
|
1012
1221
|
|
|
1013
|
-
th = createElement("th", "pvtTotalLabel rowTotal", opts.localeStrings.totals, {
|
|
1222
|
+
th = createElement("th", "pvtTotalLabel rowTotal" + verticalFreezePaneClass , opts.localeStrings.totals, {
|
|
1014
1223
|
rowspan: rowspan
|
|
1015
1224
|
});
|
|
1016
1225
|
|
|
@@ -1020,9 +1229,17 @@ let initDRPivotTable = function($, window, document) {
|
|
|
1020
1229
|
}
|
|
1021
1230
|
|
|
1022
1231
|
//getHeaderColorProperties(th);
|
|
1023
|
-
|
|
1232
|
+
if (opts.chartOptions.table_options.freeze_panes) {
|
|
1233
|
+
tr.appendChild(th);
|
|
1234
|
+
getHeaderColorProperties(tr);
|
|
1235
|
+
} else {
|
|
1236
|
+
return tr.appendChild(th);
|
|
1237
|
+
}
|
|
1024
1238
|
};
|
|
1025
|
-
buildRowHeaders = function(tbody, rowHeaderHeaders, rowHeaderRows, rowHeader, rowAttrs, colAttrs, highlighted) {
|
|
1239
|
+
buildRowHeaders = function(tbody, rowHeaderHeaders, rowHeaderRows, rowHeader, rowAttrs, colAttrs, highlighted, hasColLabels) {
|
|
1240
|
+
const additionalField = _.find(additionalFieldsList, {key: rowHeader.key[0]})
|
|
1241
|
+
if (additionalField) return;
|
|
1242
|
+
|
|
1026
1243
|
var colspan, h, hh, isRowSubtotal, k, len, ref8, results, style, th, tr;
|
|
1027
1244
|
hh = rowHeaderHeaders.hh[rowHeader.col];
|
|
1028
1245
|
++hh.expandedCount;
|
|
@@ -1042,7 +1259,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
1042
1259
|
}
|
|
1043
1260
|
|
|
1044
1261
|
isRowSubtotal = rowHeader.children.length !== 0;
|
|
1045
|
-
addClass(th, "row" + rowHeader.row + " rowcol" + rowHeader.col + " " + classRowShow);
|
|
1262
|
+
addClass(th, "row" + rowHeader.row + " rowcol" + rowHeader.col + " " + classRowShow + horizontalFreezePaneClass);
|
|
1046
1263
|
if (highlighted) {
|
|
1047
1264
|
addClass(th, "highlighted");
|
|
1048
1265
|
}
|
|
@@ -1052,9 +1269,17 @@ let initDRPivotTable = function($, window, document) {
|
|
|
1052
1269
|
"rowspan": rowHeader.descendants + 1,
|
|
1053
1270
|
"colspan": colspan
|
|
1054
1271
|
});
|
|
1055
|
-
if (opts.chartOptions.table_options.hide_nulls_in_headers
|
|
1056
|
-
th.textContent = '';
|
|
1272
|
+
if (opts.chartOptions.table_options.hide_nulls_in_headers) {
|
|
1273
|
+
th.textContent = th.textContent.replace('[null]', '');
|
|
1274
|
+
}
|
|
1275
|
+
if (th.textContent === 'DR Others') {
|
|
1276
|
+
th.textContent = _.get(opts, "total_value_options.filter_options.filteredOutFieldName") || 'Others'
|
|
1057
1277
|
}
|
|
1278
|
+
|
|
1279
|
+
if (th.hasAttribute('data_show_more') && th.colSpan > 0 && !hasColLabels) {
|
|
1280
|
+
th.colSpan = th.colSpan - 1;
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1058
1283
|
tr.appendChild(th);
|
|
1059
1284
|
if (isRowSubtotal) {
|
|
1060
1285
|
addClass(tr, classRowExpanded);
|
|
@@ -1070,6 +1295,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
1070
1295
|
style = "pvtRowLabel pvtRowSubtotal " + classRowExpanded;
|
|
1071
1296
|
style += " row" + rowHeader.row + " rowcol" + rowHeader.col;
|
|
1072
1297
|
style += isRowHideOnExpand || isRowDisable || rowHeader.col > rowDisableAfter ? " " + classRowHide : " " + classRowShow;
|
|
1298
|
+
style += horizontalFreezePaneClass;
|
|
1073
1299
|
th = createElement("th", style, opts.localeStrings.subtotals, {
|
|
1074
1300
|
"colspan": colspan,
|
|
1075
1301
|
"data-rownode": rowHeader.node
|
|
@@ -1087,12 +1313,184 @@ let initDRPivotTable = function($, window, document) {
|
|
|
1087
1313
|
results = [];
|
|
1088
1314
|
for (k = 0, len = ref8.length; k < len; k++) {
|
|
1089
1315
|
h = ref8[k];
|
|
1090
|
-
results.push(buildRowHeaders(tbody, rowHeaderHeaders, rowHeaderRows, h, rowAttrs, colAttrs, highlighted));
|
|
1316
|
+
results.push(buildRowHeaders(tbody, rowHeaderHeaders, rowHeaderRows, h, rowAttrs, colAttrs, highlighted, hasColLabels));
|
|
1091
1317
|
}
|
|
1092
1318
|
return results;
|
|
1093
1319
|
};
|
|
1320
|
+
|
|
1321
|
+
getAdditionalAggregation = function (rowKey, colKey) {
|
|
1322
|
+
if ((tree && tree[rowKey] && tree[rowKey][colKey])
|
|
1323
|
+
&& (rowKey !== '...' || colKey !== '...')) {
|
|
1324
|
+
return tree[rowKey][colKey];
|
|
1325
|
+
} else {
|
|
1326
|
+
return {
|
|
1327
|
+
value: (function() {
|
|
1328
|
+
return null;
|
|
1329
|
+
}),
|
|
1330
|
+
format: function() {
|
|
1331
|
+
return "";
|
|
1332
|
+
}
|
|
1333
|
+
};
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
buildAdditionalHeaderCols = function (tr, rowAttrs, colAttrs) {
|
|
1338
|
+
let rowspan, th;
|
|
1339
|
+
|
|
1340
|
+
rowspan = 1;
|
|
1341
|
+
if (colAttrs.length !== 0) {
|
|
1342
|
+
rowspan = colAttrs.length + (rowAttrs.length === 0 ? 0 : 1);
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
for (let i = 0; i < additionalFieldsCol.length; i++) {
|
|
1346
|
+
const col = additionalFieldsCol[i];
|
|
1347
|
+
th = createElement("th", "pvtColLabel" + verticalFreezePaneClass , col.name, {
|
|
1348
|
+
rowspan: rowspan
|
|
1349
|
+
});
|
|
1350
|
+
|
|
1351
|
+
if (opts.chartOptions.table_options.freeze_panes) {
|
|
1352
|
+
tr.appendChild(th);
|
|
1353
|
+
getHeaderColorProperties(tr);
|
|
1354
|
+
} else {
|
|
1355
|
+
return tr.appendChild(th);
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1358
|
+
};
|
|
1359
|
+
|
|
1360
|
+
buildAdditionalHeaderRows = function (fieldName, rowAttrs, colAttrs) {
|
|
1361
|
+
let colspan, th, tr;
|
|
1362
|
+
|
|
1363
|
+
tr = createElement("tr");
|
|
1364
|
+
colspan = rowAttrs.length + (colAttrs.length === 0 ? 0 : 1);
|
|
1365
|
+
th = createElement("th", "pvtRowLabel" + horizontalFreezePaneClass, fieldName, {
|
|
1366
|
+
colspan: colspan
|
|
1367
|
+
});
|
|
1368
|
+
|
|
1369
|
+
tr.appendChild(th);
|
|
1370
|
+
return tr;
|
|
1371
|
+
};
|
|
1372
|
+
|
|
1373
|
+
buildAdditionalColValues = function (tr, rowKey, rowHeader) {
|
|
1374
|
+
for (let i = 0; i < additionalFieldsCol.length; i++) {
|
|
1375
|
+
const colKey = additionalFieldsCol[i].key;
|
|
1376
|
+
const totalAggregator = getAdditionalAggregation(rowKey, colKey);
|
|
1377
|
+
const val = totalAggregator.value();
|
|
1378
|
+
const formattedValue = getFormattedNumber(val, totalAggregator, opts)
|
|
1379
|
+
|
|
1380
|
+
let className = "pvtVal rowshow colshow";
|
|
1381
|
+
className += " row" + rowHeader.row + " rowcol" + rowHeader.col;
|
|
1382
|
+
|
|
1383
|
+
const td = createElement("td", className, formattedValue, {
|
|
1384
|
+
"data-value": val,
|
|
1385
|
+
"data-row": "row" + rowHeader.row,
|
|
1386
|
+
"data-rowcol": "col" + rowHeader.col,
|
|
1387
|
+
"data-rownode": rowHeader.node
|
|
1388
|
+
}, getTableEventHandlers(val, rowHeader.key, []));
|
|
1389
|
+
|
|
1390
|
+
if (rowHeader.children.length && rowHeader.clickStatus === 'expanded') {
|
|
1391
|
+
td.style.display = 'none';
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
tr.appendChild(td)
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
buildAdditionalRowValues = function (tr, colHeaderCols, rowKey) {
|
|
1399
|
+
for (let i = 0; i < colHeaderCols.length; i++) {
|
|
1400
|
+
const colHeader = colHeaderCols[i];
|
|
1401
|
+
const colKey = colHeader.flatKey;
|
|
1402
|
+
const totalAggregator = getAdditionalAggregation(rowKey, colKey);
|
|
1403
|
+
const val = totalAggregator.value();
|
|
1404
|
+
const formattedValue = getFormattedNumber(val, totalAggregator, opts)
|
|
1405
|
+
|
|
1406
|
+
const className = "pvtVal col" + i + " colcol" + 0;
|
|
1407
|
+
const td = createElement("td", className, formattedValue, {
|
|
1408
|
+
"data-value": val,
|
|
1409
|
+
"data-for": "col" + 0,
|
|
1410
|
+
"data-colnode": "" + i
|
|
1411
|
+
});
|
|
1412
|
+
|
|
1413
|
+
if (colHeader.children.length && colHeader.clickStatus === 'expanded') {
|
|
1414
|
+
td.style.display = 'none';
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
tr.appendChild(td);
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
if (additionalFieldsCol.length) {
|
|
1421
|
+
for (let i = 0; i < additionalFieldsCol.length; i++) {
|
|
1422
|
+
const totalAggregator = getAdditionalAggregation(rowKey, additionalFieldsCol[i].key);
|
|
1423
|
+
const val = totalAggregator.value();
|
|
1424
|
+
const formattedValue = getFormattedNumber(val, totalAggregator, opts)
|
|
1425
|
+
|
|
1426
|
+
const className = "pvtVal col" + i + " colcol" + 0;
|
|
1427
|
+
const td = createElement("td", className, formattedValue, {
|
|
1428
|
+
"data-value": val,
|
|
1429
|
+
"data-for": "col" + 0,
|
|
1430
|
+
"data-colnode": "" + i
|
|
1431
|
+
});
|
|
1432
|
+
|
|
1433
|
+
tr.appendChild(td);
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
if(opts.chartOptions.table_options.show_row_total) {
|
|
1438
|
+
buildAdditionalRowTotals(tr, rowKey)
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
buildAdditionalRowTotals = function (tr, rowKey) {
|
|
1443
|
+
const totalAggregator = getExistingAggregator(rowTotals, rowKey);
|
|
1444
|
+
const value = totalAggregator.value();
|
|
1445
|
+
const formattedValue = getFormattedNumber(value, totalAggregator, opts)
|
|
1446
|
+
|
|
1447
|
+
let style = "pvtTotal pvtAddFiled rowTotal";
|
|
1448
|
+
const td = createElement("td", style, formattedValue, {
|
|
1449
|
+
"data-value": value
|
|
1450
|
+
});
|
|
1451
|
+
|
|
1452
|
+
tr.appendChild(td);
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
buildAdditionalColTotals = function (tr, rowHeaderRows, colKey, colHeader) {
|
|
1456
|
+
const totalAggregator = getExistingAggregator(colTotals, colKey)
|
|
1457
|
+
const value = totalAggregator.value();
|
|
1458
|
+
const formattedValue = getFormattedNumber(value, totalAggregator, opts);
|
|
1459
|
+
|
|
1460
|
+
if (!colHeader) {
|
|
1461
|
+
colHeader = {}
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
let style = "pvtTotal pvtAddField colTotal";
|
|
1465
|
+
style += " col" + colHeader.row || "-1" + " colcol" + colHeader.col || "-1";
|
|
1466
|
+
|
|
1467
|
+
const td = createElement("td", style, formattedValue, {
|
|
1468
|
+
"data-value": value,
|
|
1469
|
+
"data-rowcol": "col" + colHeader.col || "-1",
|
|
1470
|
+
"data-rownode": "" + colHeader.node || "-1"
|
|
1471
|
+
}, getTableEventHandlers(value, [], colHeader.key || []));
|
|
1472
|
+
|
|
1473
|
+
return td;
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
getExistingAggregator = function (aggregator, key) {
|
|
1477
|
+
if (!aggregator[key]) {
|
|
1478
|
+
return {
|
|
1479
|
+
value: (function () {
|
|
1480
|
+
return null;
|
|
1481
|
+
}),
|
|
1482
|
+
format: function () {
|
|
1483
|
+
return "";
|
|
1484
|
+
}
|
|
1485
|
+
};
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
return aggregator[key];
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1094
1491
|
buildValues = function(rowHeaderRows, colHeaderCols, rowAttrs, colAttrs) {
|
|
1095
1492
|
var aggregator, colHeader, eventHandlers, flatColKey, flatRowKey, isColSubtotal, isRowSubtotal, k, l, len, len1, ref8, results, rowHeader, style, td, totalAggregator, tr, val;
|
|
1493
|
+
|
|
1096
1494
|
results = [];
|
|
1097
1495
|
for (k = 0, len = rowHeaderRows.length; k < len; k++) {
|
|
1098
1496
|
rowHeader = rowHeaderRows[k];
|
|
@@ -1138,10 +1536,15 @@ let initDRPivotTable = function($, window, document) {
|
|
|
1138
1536
|
if ((isRowSubtotal && (isRowHideOnExpand || isRowDisable || rowHeader.col > rowDisableAfter)) || (isColSubtotal && (isColHideOnExpand || isColDisable || colHeader.col > colDisableAfter))) {
|
|
1139
1537
|
td.style.display = "none";
|
|
1140
1538
|
}
|
|
1141
|
-
|
|
1539
|
+
subscribeToClick(td, rowHeader, rowAttrs, colHeader, colAttrs, val);
|
|
1142
1540
|
|
|
1143
1541
|
tr.appendChild(td);
|
|
1144
1542
|
}
|
|
1543
|
+
|
|
1544
|
+
if (additionalFieldsCol.length > 0) {
|
|
1545
|
+
buildAdditionalColValues(tr, flatRowKey, rowHeader);
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1145
1548
|
totalAggregator = rowTotals[flatRowKey];
|
|
1146
1549
|
if(!totalAggregator){
|
|
1147
1550
|
totalAggregator = {
|
|
@@ -1171,7 +1574,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
1171
1574
|
td.style.display = "none";
|
|
1172
1575
|
}
|
|
1173
1576
|
|
|
1174
|
-
|
|
1577
|
+
subscribeToClick(td, rowHeader, rowAttrs, {key:[], flatKey:''}, colAttrs, val);
|
|
1175
1578
|
|
|
1176
1579
|
if(opts.chartOptions.table_options.show_row_total)
|
|
1177
1580
|
tr.appendChild(td);
|
|
@@ -1181,43 +1584,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
1181
1584
|
return results;
|
|
1182
1585
|
};
|
|
1183
1586
|
|
|
1184
|
-
|
|
1185
|
-
if(edit_assumptions){
|
|
1186
|
-
var filters = [];
|
|
1187
|
-
var i=0;
|
|
1188
|
-
var temp;
|
|
1189
|
-
for(i=0; i<rowHeader.key.length; i++){
|
|
1190
|
-
temp = {
|
|
1191
|
-
name: rowAttrs[i],
|
|
1192
|
-
values: [rowHeader.key[i]],
|
|
1193
|
-
is_excluded:false
|
|
1194
|
-
}
|
|
1195
|
-
filters.push(temp);
|
|
1196
|
-
}
|
|
1197
|
-
for(i=0; i<colHeader.key.length; i++){
|
|
1198
|
-
temp = {
|
|
1199
|
-
name: colAttrs[i],
|
|
1200
|
-
values: [colHeader.key[i]],
|
|
1201
|
-
is_excluded:false
|
|
1202
|
-
}
|
|
1203
|
-
filters.push(temp);
|
|
1204
|
-
}
|
|
1205
|
-
var obj_to_send = {
|
|
1206
|
-
"flatColKey": colHeader.flatKey,
|
|
1207
|
-
"flatRowKey": rowHeader.flatKey,
|
|
1208
|
-
"val": val,
|
|
1209
|
-
"filters": filters
|
|
1210
|
-
};
|
|
1211
|
-
|
|
1212
|
-
// td.addEventListener('dblclick', function(){
|
|
1213
|
-
// edit_assumptions.fn(obj_to_send, this);
|
|
1214
|
-
// });
|
|
1215
|
-
|
|
1216
|
-
td.addEventListener('click', function(){
|
|
1217
|
-
edit_assumptions.fn(obj_to_send, this);
|
|
1218
|
-
});
|
|
1219
|
-
}
|
|
1220
|
-
|
|
1587
|
+
subscribeToClick = function(td, rowHeader, rowAttrs, colHeader, colAttrs, val){
|
|
1221
1588
|
if(opts.value_drill_down_fn){
|
|
1222
1589
|
td.classList.add('clickable');
|
|
1223
1590
|
td.addEventListener('click', function(rowKey, colKey, rowAttrs, colAttrs){
|
|
@@ -1233,7 +1600,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
1233
1600
|
var colspan, th, tr;
|
|
1234
1601
|
tr = createElement("tr");
|
|
1235
1602
|
colspan = rowAttrs.length + (colAttrs.length === 0 ? 0 : 1);
|
|
1236
|
-
th = createElement("th", "pvtTotalLabel colTotal", opts.localeStrings.totals, {
|
|
1603
|
+
th = createElement("th", "pvtTotalLabel colTotal" + horizontalFreezePaneClass, opts.localeStrings.totals, {
|
|
1237
1604
|
colspan: colspan
|
|
1238
1605
|
});
|
|
1239
1606
|
if (opts.totalFilterElements && opts.totalFilterElements.col_total) {
|
|
@@ -1243,13 +1610,13 @@ let initDRPivotTable = function($, window, document) {
|
|
|
1243
1610
|
tr.appendChild(th);
|
|
1244
1611
|
return tr;
|
|
1245
1612
|
};
|
|
1246
|
-
buildColTotals = function(tr, colHeaderCols, rowAttrs, colAttrs) {
|
|
1613
|
+
buildColTotals = function(tr, colHeaderCols, rowHeaderRows, rowAttrs, colAttrs) {
|
|
1247
1614
|
var h, isColSubtotal, k, len, results, style, td, totalAggregator, val;
|
|
1248
1615
|
results = [];
|
|
1249
|
-
createGrandTotalBolder(tr);
|
|
1250
1616
|
for (k = 0, len = colHeaderCols.length; k < len; k++) {
|
|
1251
1617
|
h = colHeaderCols[k];
|
|
1252
1618
|
isColSubtotal = h.children.length !== 0;
|
|
1619
|
+
|
|
1253
1620
|
totalAggregator = colTotals[h.flatKey];
|
|
1254
1621
|
if(!totalAggregator){
|
|
1255
1622
|
totalAggregator = {
|
|
@@ -1278,25 +1645,42 @@ let initDRPivotTable = function($, window, document) {
|
|
|
1278
1645
|
td.style.display = "none";
|
|
1279
1646
|
}
|
|
1280
1647
|
|
|
1281
|
-
|
|
1648
|
+
subscribeToClick(td, {key:[], flatKey:''}, rowAttrs, h, colAttrs, val);
|
|
1282
1649
|
|
|
1283
1650
|
results.push(tr.appendChild(td));
|
|
1284
1651
|
}
|
|
1652
|
+
|
|
1653
|
+
if (additionalFieldsCol.length > 0) {
|
|
1654
|
+
for (let i = 0; i < additionalFieldsCol.length; i++) {
|
|
1655
|
+
const colKey = additionalFieldsCol[i].key;
|
|
1656
|
+
|
|
1657
|
+
td = buildAdditionalColTotals(tr, rowHeaderRows, colKey, h);
|
|
1658
|
+
results.push(tr.appendChild(td));
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1662
|
+
createGrandTotalBolder(tr);
|
|
1285
1663
|
return results;
|
|
1286
1664
|
};
|
|
1287
1665
|
buildGrandTotal = function(result, tr, rowAttrs, colAttrs) {
|
|
1288
1666
|
var td, totalAggregator, val;
|
|
1667
|
+
|
|
1289
1668
|
totalAggregator = allTotal;
|
|
1290
1669
|
val = totalAggregator.value();
|
|
1291
1670
|
td = createElement("td", "pvtGrandTotal", getFormattedNumber(val, totalAggregator, opts), {
|
|
1292
1671
|
"data-value": val
|
|
1293
1672
|
}, getTableEventHandlers(val, [], []));
|
|
1294
1673
|
createTotalValsBolder(td);
|
|
1295
|
-
|
|
1674
|
+
subscribeToClick(td, {key:[], flatKey:''}, rowAttrs, {key:[], flatKey:''}, colAttrs, val);
|
|
1296
1675
|
|
|
1297
1676
|
tr.appendChild(td);
|
|
1298
1677
|
return result.appendChild(tr);
|
|
1299
1678
|
};
|
|
1679
|
+
removeRowHeaderNullValue = function(h) {
|
|
1680
|
+
if (opts.chartOptions.table_options.hide_nulls_in_headers) {
|
|
1681
|
+
h.th.innerHTML = h.th.innerHTML.replace('[null]' , '');
|
|
1682
|
+
}
|
|
1683
|
+
};
|
|
1300
1684
|
hideDescendantCol = function(d) {
|
|
1301
1685
|
return $(d.th).closest('table.pvtTable').find("tbody tr td[data-colnode=\"" + d.node + "\"], th[data-colnode=\"" + d.node + "\"]").removeClass(classColShow).addClass(classColHide).css('display', "none");
|
|
1302
1686
|
};
|
|
@@ -1512,6 +1896,9 @@ let initDRPivotTable = function($, window, document) {
|
|
|
1512
1896
|
collapseShowRowSubtotal(h);
|
|
1513
1897
|
--rowspan;
|
|
1514
1898
|
}
|
|
1899
|
+
|
|
1900
|
+
removeRowHeaderNullValue(h);
|
|
1901
|
+
|
|
1515
1902
|
p = h.parent;
|
|
1516
1903
|
while (p) {
|
|
1517
1904
|
p.th.rowSpan -= rowspan;
|
|
@@ -1638,6 +2025,9 @@ let initDRPivotTable = function($, window, document) {
|
|
|
1638
2025
|
expandShowRowSubtotal(h);
|
|
1639
2026
|
}
|
|
1640
2027
|
}
|
|
2028
|
+
|
|
2029
|
+
removeRowHeaderNullValue(h);
|
|
2030
|
+
|
|
1641
2031
|
p = h.parent;
|
|
1642
2032
|
while (p) {
|
|
1643
2033
|
p.th.rowSpan += rowspan;
|
|
@@ -1920,7 +2310,34 @@ let initDRPivotTable = function($, window, document) {
|
|
|
1920
2310
|
return collapseRowsAt(rowHeaderHeaders, rowHeaderRows, rowAttrs, rowAttr);
|
|
1921
2311
|
}
|
|
1922
2312
|
};
|
|
1923
|
-
|
|
2313
|
+
|
|
2314
|
+
handleFreezePanesScroll = function(freezableElements) {
|
|
2315
|
+
return function(event) {
|
|
2316
|
+
if (event.target.dataset.canFreezePanes) return;
|
|
2317
|
+
|
|
2318
|
+
const wrapper = event.target;
|
|
2319
|
+
|
|
2320
|
+
const translateY = `translate(0px, ${wrapper.scrollTop}px)`;
|
|
2321
|
+
const translateX = `translate(${wrapper.scrollLeft}px, 0px)`;
|
|
2322
|
+
const translateXY = `translate(${wrapper.scrollLeft}px, ${wrapper.scrollTop}px)`;
|
|
2323
|
+
|
|
2324
|
+
_.forEach(freezableElements, function (element) {
|
|
2325
|
+
let currentTranslate = translateY;
|
|
2326
|
+
currentTranslate = element.className.includes(elementToTransform.X) ? translateX : currentTranslate;
|
|
2327
|
+
currentTranslate = element.className.includes(elementToTransform.XY) ? translateXY : currentTranslate;
|
|
2328
|
+
element.style.transform = currentTranslate;
|
|
2329
|
+
});
|
|
2330
|
+
}
|
|
2331
|
+
};
|
|
2332
|
+
|
|
2333
|
+
selectFreezableElements = function(wrapper) {
|
|
2334
|
+
const selectString =_.map(_.values(elementToTransform), function (item) {
|
|
2335
|
+
return `.${item.replace(' ', '')}`;
|
|
2336
|
+
}).join(',');
|
|
2337
|
+
return Array.from(wrapper.querySelectorAll(selectString));
|
|
2338
|
+
}
|
|
2339
|
+
|
|
2340
|
+
main = function(rowAttrs, rowKeys, colAttrs, colKeys, pivotData) {
|
|
1924
2341
|
var c,rowspan, colHeaderCols, colHeaderHeaders, colHeaders, h, k, l, len, len1, result, rowHeaderHeaders, rowHeaderRows, rowHeaders, tbody, thead, tr;
|
|
1925
2342
|
rowHeaders = [];
|
|
1926
2343
|
colHeaders = [];
|
|
@@ -1929,13 +2346,21 @@ let initDRPivotTable = function($, window, document) {
|
|
|
1929
2346
|
colHeaderHeaders = [];
|
|
1930
2347
|
colHeaderCols = [];
|
|
1931
2348
|
if (rowAttrs.length > 0 && rowKeys.length > 0) {
|
|
1932
|
-
|
|
2349
|
+
const formattedKeys = pivotData.getFormattedRowKeys(rowKeys);
|
|
2350
|
+
rowHeaders = processKeys(rowKeys, "pvtRowLabel", 'rows', rowAttrs, formattedKeys);
|
|
1933
2351
|
}
|
|
1934
2352
|
if (colAttrs.length > 0 && colKeys.length > 0) {
|
|
1935
|
-
|
|
2353
|
+
const formattedKeys = pivotData.getFormattedColKeys(colKeys);
|
|
2354
|
+
colHeaders = processKeys(colKeys, "pvtColLabel", 'cols', colAttrs, formattedKeys);
|
|
1936
2355
|
}
|
|
1937
|
-
var tableClasses =
|
|
1938
|
-
|
|
2356
|
+
var tableClasses = ['pvtTable'];
|
|
2357
|
+
if (opts.chartOptions.table_options.use_new_table_design) {
|
|
2358
|
+
tableClasses.push('newPvtTable');
|
|
2359
|
+
}
|
|
2360
|
+
if (!pivotData.aggregator().uniq) {
|
|
2361
|
+
tableClasses.push('numbers-to-right');
|
|
2362
|
+
}
|
|
2363
|
+
result = createElement("table", tableClasses.join(' ') , null, {
|
|
1939
2364
|
style: "display: none;"
|
|
1940
2365
|
});
|
|
1941
2366
|
|
|
@@ -1953,10 +2378,20 @@ let initDRPivotTable = function($, window, document) {
|
|
|
1953
2378
|
}
|
|
1954
2379
|
if (rowAttrs.length > 0) {
|
|
1955
2380
|
buildRowHeaderHeaders(thead, rowHeaderHeaders, rowAttrs, colAttrs);
|
|
2381
|
+
|
|
2382
|
+
if (colAttrs.length === 0 && additionalFieldsCol.length > 0) {
|
|
2383
|
+
buildAdditionalHeaderCols(rowHeaderHeaders.tr, rowAttrs, colAttrs)
|
|
2384
|
+
}
|
|
2385
|
+
|
|
1956
2386
|
if (colAttrs.length === 0 && opts.chartOptions.table_options.show_row_total) {
|
|
1957
2387
|
buildRowTotalsHeader(rowHeaderHeaders.tr, rowAttrs, colAttrs);
|
|
1958
2388
|
}
|
|
1959
2389
|
}
|
|
2390
|
+
|
|
2391
|
+
if (colAttrs.length > 0 && additionalFieldsCol.length > 0) {
|
|
2392
|
+
buildAdditionalHeaderCols(colHeaderHeaders[0].tr, rowAttrs, colAttrs)
|
|
2393
|
+
}
|
|
2394
|
+
|
|
1960
2395
|
if (colAttrs.length > 0 && opts.chartOptions.table_options.show_row_total) {
|
|
1961
2396
|
buildRowTotalsHeader(colHeaderHeaders[0].tr, rowAttrs, colAttrs);
|
|
1962
2397
|
if(opts.chartOptions.table_options.colorize_headers == true){
|
|
@@ -1965,24 +2400,44 @@ let initDRPivotTable = function($, window, document) {
|
|
|
1965
2400
|
if(c == colHeaderHeaders.length-1){
|
|
1966
2401
|
rowspan = 2;
|
|
1967
2402
|
}
|
|
1968
|
-
colHeaderHeaders[c].tr.appendChild(createElement("th",
|
|
2403
|
+
colHeaderHeaders[c].tr.appendChild(createElement("th", verticalFreezePaneClass, "",{rowspan: rowspan}));
|
|
2404
|
+
if (opts.chartOptions.table_options.freeze_panes) {
|
|
2405
|
+
getHeaderColorProperties(colHeaderHeaders[c].tr, c);
|
|
2406
|
+
}
|
|
1969
2407
|
}
|
|
1970
2408
|
}
|
|
1971
2409
|
}
|
|
1972
2410
|
tbody = createElement("tbody");
|
|
1973
2411
|
result.appendChild(tbody);
|
|
2412
|
+
|
|
2413
|
+
const hasColLabels = !!thead.querySelector('.pvtColLabel');
|
|
2414
|
+
|
|
1974
2415
|
if (rowAttrs.length > 0) {
|
|
1975
2416
|
for (l = 0, len1 = rowHeaders.length; l < len1; l++) {
|
|
1976
2417
|
h = rowHeaders[l];
|
|
1977
|
-
buildRowHeaders(tbody, rowHeaderHeaders, rowHeaderRows, h, rowAttrs, colAttrs, l%2 === 0);
|
|
2418
|
+
buildRowHeaders(tbody, rowHeaderHeaders, rowHeaderRows, h, rowAttrs, colAttrs, l%2 === 0, hasColLabels);
|
|
1978
2419
|
}
|
|
1979
2420
|
}
|
|
1980
2421
|
buildRowHeaderHeadersClickEvents(rowHeaderHeaders, rowHeaderRows, rowAttrs);
|
|
1981
2422
|
buildValues(rowHeaderRows, colHeaderCols, rowAttrs, colAttrs);
|
|
2423
|
+
|
|
2424
|
+
if (additionalFieldsRow.length > 0) {
|
|
2425
|
+
for (let i = 0; i < additionalFieldsRow.length; i++) {
|
|
2426
|
+
const field = additionalFieldsRow[i];
|
|
2427
|
+
tr = buildAdditionalHeaderRows(field.name, rowAttrs, colAttrs);
|
|
2428
|
+
|
|
2429
|
+
if (colAttrs.length > 0) {
|
|
2430
|
+
buildAdditionalRowValues(tr, colHeaderCols, field.key);
|
|
2431
|
+
}
|
|
2432
|
+
|
|
2433
|
+
tbody.appendChild(tr);
|
|
2434
|
+
}
|
|
2435
|
+
}
|
|
2436
|
+
|
|
1982
2437
|
if(opts.chartOptions.table_options.show_column_total){
|
|
1983
2438
|
tr = buildColTotalsHeader(rowAttrs, colAttrs);
|
|
1984
2439
|
if (colAttrs.length > 0) {
|
|
1985
|
-
buildColTotals(tr, colHeaderCols, rowAttrs, colAttrs);
|
|
2440
|
+
buildColTotals(tr, colHeaderCols, rowHeaderRows, rowAttrs, colAttrs);
|
|
1986
2441
|
}
|
|
1987
2442
|
if(opts.chartOptions.table_options.show_row_total)
|
|
1988
2443
|
buildGrandTotal(tbody, tr, rowAttrs, colAttrs);
|
|
@@ -2021,11 +2476,16 @@ let initDRPivotTable = function($, window, document) {
|
|
|
2021
2476
|
}
|
|
2022
2477
|
|
|
2023
2478
|
if (tooMuch) {
|
|
2024
|
-
|
|
2479
|
+
const defaultPlaceholder = $('<div class="noData"><i class="fa fa-info"></i> There are too many rows to display in the table.<br>Please filter or change the table type in options.</div>');
|
|
2480
|
+
|
|
2481
|
+
resultsArr.push($.pivotUtilities.errorHandling.getErrorPlaceholder(error_params) || defaultPlaceholder);
|
|
2025
2482
|
} else {
|
|
2026
2483
|
var tableContainer = document.createElement("div");
|
|
2027
2484
|
tableContainer.className = "pivot-div";
|
|
2028
2485
|
tableContainer.appendChild(result);
|
|
2486
|
+
if (opts.chartOptions.table_options.freeze_panes) {
|
|
2487
|
+
tableContainer.onscroll = handleFreezePanesScroll(selectFreezableElements(tableContainer));
|
|
2488
|
+
}
|
|
2029
2489
|
resultsArr.push(tableContainer);
|
|
2030
2490
|
}
|
|
2031
2491
|
|
|
@@ -2036,7 +2496,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
2036
2496
|
|
|
2037
2497
|
return wrapper;
|
|
2038
2498
|
};
|
|
2039
|
-
return main(rowAttrs, rowKeys, colAttrs, colKeys);
|
|
2499
|
+
return main(rowAttrs, rowKeys, colAttrs, colKeys, pivotData);
|
|
2040
2500
|
};
|
|
2041
2501
|
// $.pivotUtilities.subtotal_renderers = SubtotalRenderer;
|
|
2042
2502
|
$.pivotUtilities.subtotal_renderers = NovixRenderer;
|
|
@@ -2045,6 +2505,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
2045
2505
|
$.pivotUtilities.getFormattedNumber = getFormattedNumber;
|
|
2046
2506
|
$.pivotUtilities.sortDateStrings = sortDateStrings;
|
|
2047
2507
|
$.pivotUtilities.largeToSmallSort = largeToSmallSort;
|
|
2508
|
+
$.pivotUtilities.largeToSmallSortByAbsolute = largeToSmallSortByAbsolute;
|
|
2048
2509
|
$.pivotUtilities.getPivotDataModel = function(input, opts){ return new DRPivotData(input, opts); }
|
|
2049
2510
|
$.pivotUtilities.getPivotTableFormula = function(rowData, opts, func, colFields, rowFields, aggregationDefaults, utils) {
|
|
2050
2511
|
let totalStr = 'Grand Totals';
|
|
@@ -2081,7 +2542,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
2081
2542
|
headerRow.push(colAttrs[i]);
|
|
2082
2543
|
// Add row keys
|
|
2083
2544
|
_.forEach(colKeys, function (keys) {
|
|
2084
|
-
headerRow.push(utils.getHeaderValue(keys[i], colFields[i].type));
|
|
2545
|
+
headerRow.push(utils.getHeaderValue(keys[i], colFields[i].type, opts.dateValuesDictionary));
|
|
2085
2546
|
// Calc formulas in first time
|
|
2086
2547
|
if (i === 0) {
|
|
2087
2548
|
colFormulas.push(utils.createKeysFormula(colFields, keys, colFormulas.length + 1, true));
|
|
@@ -2099,7 +2560,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
2099
2560
|
// Formatting row keys
|
|
2100
2561
|
let keysFormatted = [];
|
|
2101
2562
|
for (let k = 0; k < rowKeys[i].length; k++) {
|
|
2102
|
-
keysFormatted.push(utils.getHeaderValue(rowKeys[i][k], rowFields[k].type))
|
|
2563
|
+
keysFormatted.push(utils.getHeaderValue(rowKeys[i][k], rowFields[k].type, opts.dateValuesDictionary))
|
|
2103
2564
|
}
|
|
2104
2565
|
// Add row keys
|
|
2105
2566
|
matrix.push(keysFormatted.concat(null));
|
|
@@ -2123,7 +2584,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
2123
2584
|
let headerRow = [colAttrs[i]];
|
|
2124
2585
|
// Add keys
|
|
2125
2586
|
_.forEach(colKeys, function (keys) {
|
|
2126
|
-
headerRow.push(utils.getHeaderValue(keys[i], colFields[i].type));
|
|
2587
|
+
headerRow.push(utils.getHeaderValue(keys[i], colFields[i].type, opts.dateValuesDictionary));
|
|
2127
2588
|
// Calc formulas in first time
|
|
2128
2589
|
if (i === 0) {
|
|
2129
2590
|
colFormulas.push(utils.createKeysFormula(colFields, keys, colFormulas.length + 1, true));
|
|
@@ -2153,7 +2614,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
2153
2614
|
// Formatting row keys
|
|
2154
2615
|
let keysFormatted = [];
|
|
2155
2616
|
for (let k = 0; k < rowKeys[i].length; k++) {
|
|
2156
|
-
keysFormatted.push(utils.getHeaderValue(rowKeys[i][k], rowFields[k].type))
|
|
2617
|
+
keysFormatted.push(utils.getHeaderValue(rowKeys[i][k], rowFields[k].type, opts.dateValuesDictionary))
|
|
2157
2618
|
}
|
|
2158
2619
|
// Add row keys
|
|
2159
2620
|
matrix.push(keysFormatted);
|