@datarailsshared/dr_renderer 1.2.13 → 1.2.15

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.
@@ -3,11 +3,11 @@ 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.
@@ -113,7 +113,7 @@ let initDRPivotTable = function($, window, document) {
113
113
  };
114
114
  };
115
115
 
116
- processKey = function(record, totals, keys, attrs, getAggregator) {
116
+ processKey = function(record, totals, keys, attrs, containsAverage, containsOthers, getAggregator) {
117
117
  var addKey, attr, flatKey, k, key, len, ref;
118
118
  key = [];
119
119
  addKey = false;
@@ -125,7 +125,17 @@ let initDRPivotTable = function($, window, document) {
125
125
  totals[flatKey] = getAggregator(key.slice());
126
126
  addKey = true;
127
127
  }
128
- totals[flatKey].push(record);
128
+
129
+ if (containsAverage || containsOthers) {
130
+ if (containsAverage && !containsOthers && key[0] === 'DR_Average') {
131
+ totals[flatKey].push(record);
132
+ }
133
+ if (containsOthers && !containsAverage && key[0] === 'DR_Others') {
134
+ totals[flatKey].push(record);
135
+ }
136
+ } else {
137
+ totals[flatKey].push(record);
138
+ }
129
139
  }
130
140
  if (addKey) {
131
141
  keys.push(key);
@@ -133,21 +143,93 @@ let initDRPivotTable = function($, window, document) {
133
143
  return key;
134
144
  };
135
145
 
136
- DRPivotData.prototype.processRecord = function(record) {
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;
151
+ }
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);
162
+
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
+ }
212
+
137
213
  var colKey, fColKey, fRowKey, flatColKey, flatRowKey, i, j, k, m, n, ref, results, rowKey;
138
214
  rowKey = [];
139
215
  colKey = [];
140
- this.allTotal.push(record);
141
- rowKey = processKey(record, this.rowTotals, this.rowKeys, this.rowAttrs, (function(_this) {
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);
221
+ }
222
+ rowKey = processKey(record, this.rowTotals, this.rowKeys, this.rowAttrs, containsAverage, containsOthers, (function(_this) {
142
223
  return function(key) {
143
224
  return _this.aggregator(_this, key, []);
144
225
  };
145
226
  })(this));
146
- colKey = processKey(record, this.colTotals, this.colKeys, this.colAttrs, (function(_this) {
227
+ colKey = processKey(record, this.colTotals, this.colKeys, this.colAttrs, containsAverage, containsOthers, (function(_this) {
147
228
  return function(key) {
148
229
  return _this.aggregator(_this, [], key);
149
230
  };
150
231
  })(this));
232
+
151
233
  m = rowKey.length - 1;
152
234
  n = colKey.length - 1;
153
235
  if (m < 0 || n < 0) {
@@ -179,8 +261,9 @@ let initDRPivotTable = function($, window, document) {
179
261
 
180
262
  DRPivotData.prototype.getAggregator = function(rowKey, colKey) {
181
263
  var agg, flatColKey, flatRowKey;
182
- flatRowKey = rowKey.join(delim);
183
- flatColKey = colKey.join(delim);
264
+ let hebrewMarkRegex = new RegExp(String.fromCharCode(8206), 'g');
265
+ flatRowKey = rowKey.join(delim).replace(hebrewMarkRegex, '');
266
+ flatColKey = colKey.join(delim).replace(hebrewMarkRegex, '');
184
267
  if (rowKey.length === 0 && colKey.length === 0) {
185
268
  agg = this.allTotal;
186
269
  } else if (rowKey.length === 0) {
@@ -286,7 +369,11 @@ let initDRPivotTable = function($, window, document) {
286
369
  };
287
370
  };
288
371
 
289
- largeToSmallSort = function(as, bs) {
372
+ largeToSmallSortByAbsolute = function (as, bs) {
373
+ return largeToSmallSort(as , bs, true);
374
+ }
375
+
376
+ largeToSmallSort = function(as, bs, is_abs = false) {
290
377
  var a, a1, b, b1, rd, rx, rz;
291
378
  rx = /(\d+)|(\D+)/g;
292
379
  rd = /\d/;
@@ -298,6 +385,11 @@ let initDRPivotTable = function($, window, document) {
298
385
  if (isNaN(bs)) {
299
386
  return 1;
300
387
  }
388
+
389
+ if (is_abs) {
390
+ return Math.abs(bs) - Math.abs(as);
391
+ }
392
+
301
393
  return bs - as;
302
394
  }
303
395
  a = String(as).toLowerCase();
@@ -384,15 +476,37 @@ let initDRPivotTable = function($, window, document) {
384
476
  pvtData.rowKeys = [];
385
477
  pvtData.colKeys = [];
386
478
  tooMuch = true;
479
+ opts.error_has_occurred = true;
480
+ opts.error_params = $.pivotUtilities.errorHandling.placeholders.tooMuchData;
387
481
  }
388
- return SubtotalRenderer(pvtData, opts, charttype, tooMuch);
482
+ return SubtotalRenderer(pvtData, opts, charttype, tooMuch, opts.error_params);
389
483
  }
390
484
  }
391
485
 
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, assumptionSubscribe;
394
- var createTotalValsBolder, createGrandTotalBolder, getHeaderColorProperties, colorizeRowLabelHeaders, colorizeTableIfNeed, valueNoDashes;
395
- var edit_assumptions;
486
+ SubtotalRenderer = function(pivotData, opts, charttype, tooMuch = false, error_params) {
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;
488
+ var createTotalValsBolder, createGrandTotalBolder, getHeaderColorProperties, colorizeRowLabelHeaders, colorizeTableIfNeed, valueNoDashes, getColorsWithOffsetForTable, offsetColors, handleFreezePanesScroll, selectFreezableElements, removeRowHeaderNullValue;
489
+ var getAdditionalAggregation, buildAdditionalHeaderCols, buildAdditionalHeaderRows, buildAdditionalColValues, buildAdditionalRowValues, buildAdditionalRowTotals, buildAdditionalColTotals;
490
+ var additionalFieldsCol, additionalFieldsRow, additionalFieldsList;
491
+ var edit_assumptions, getExistingAggregator;
492
+
493
+ var horizontalFreezePaneClass = opts.chartOptions.table_options.freeze_panes ? ' horizontal-freeze-pane' : '';
494
+ var verticalFreezePaneClass = opts.chartOptions.table_options.freeze_panes ? ' vertical-freeze-pane' : '';
495
+ var axisFreezePaneClass = opts.chartOptions.table_options.freeze_panes ? ' axis-freeze-pane' : '';
496
+
497
+ var elementToTransform = {
498
+ X: horizontalFreezePaneClass,
499
+ Y: verticalFreezePaneClass,
500
+ XY: axisFreezePaneClass,
501
+ }
502
+
503
+ additionalFieldsCol = [];
504
+ additionalFieldsRow = [];
505
+ additionalFieldsList = [
506
+ {key: 'DR_Average', name: 'DR_Average'},
507
+ {key: 'DR_Others', name: _.get(opts, "total_value_options.filter_options.filteredOutFieldName") || 'Others'}
508
+ ];
509
+ $.pivotUtilities.additionalFieldsList = additionalFieldsList;
396
510
 
397
511
  defaults = {
398
512
  table: {
@@ -437,13 +551,21 @@ let initDRPivotTable = function($, window, document) {
437
551
  arrowCollapsed = opts.arrowCollapsed != null ? opts.arrowCollapsed : opts.arrowCollapsed = '<i class="fa fa-plus dr-icon-add"></i> ';
438
552
  arrowExpanded = opts.arrowExpanded != null ? opts.arrowExpanded : opts.arrowExpanded = '<i class="fa fa-minus dr-icon-minus"></i> ';
439
553
  colAttrs = pivotData.colAttrs;
554
+ rowAttrs = pivotData.rowAttrs;
555
+ rowKeys = pivotData.getRowKeys();
440
556
 
441
557
  if (charttype == 'column-chart' || charttype == 'column-chart-stacked') {
442
- colAttrs = [colAttrs[0]];
558
+ if (_.get(opts, 'chartOptions.table_options.transpose_table', false)) {
559
+ rowAttrs = [rowAttrs[0]];
560
+ if (rowKeys && rowKeys.length) {
561
+ rowKeys = rowKeys.map( function(_, index) {
562
+ return [rowKeys[index][0]];
563
+ });
564
+ }
565
+ } else if (colAttrs.length) {
566
+ colAttrs = [colAttrs[0]];
567
+ }
443
568
  }
444
-
445
- rowAttrs = pivotData.rowAttrs;
446
- rowKeys = pivotData.getRowKeys();
447
569
  colKeys = pivotData.getColKeys();
448
570
  tree = pivotData.tree;
449
571
  rowTotals = pivotData.rowTotals;
@@ -510,19 +632,87 @@ let initDRPivotTable = function($, window, document) {
510
632
  return value;
511
633
  };
512
634
 
635
+ offsetColors = function (offset, colorsArray) {
636
+ if (offset > opts.defaults_colors.length) {
637
+ offset = offset % opts.defaults_colors;
638
+ }
639
+ var colors_to_return = JSON.parse(JSON.stringify(colorsArray));
640
+ for (var i = 0; i < offset; i++) {
641
+ colors_to_return.push(colors_to_return.shift());
642
+ }
643
+ return colors_to_return;
644
+ }
645
+
646
+ getColorsWithOffsetForTable = function (value) {
647
+ var colors = [];
648
+
649
+ if (opts.paletteOptions && opts.paletteOptions.widgetPalette) {
650
+ const mc_palette = _.find(_.get(opts.paletteOptions, 'monochromePalettes', []), { selected: true });
651
+ colors = mc_palette ? mc_palette.colors : opts.paletteOptions.widgetPalette;
652
+ } else if (opts.paletteOptions && opts.paletteOptions.dashboardPalette && opts.paletteOptions.dashboardPalette.colors) {
653
+ colors = opts.paletteOptions.dashboardPalette.colors;
654
+ } else {
655
+ colors = newTableColors;
656
+ }
657
+
658
+ var isNewDesign = useNewUx && opts.chartOptions.table_options.use_new_table_design;
659
+ if (value) {
660
+ var offset = parseInt(value);
661
+ if (offset) {
662
+ if (isNewDesign) {
663
+ return offsetColors(offset, colors);
664
+ } else {
665
+ return offsetColors(offset, opts.defaults_colors);
666
+ }
667
+ }
668
+ }
669
+ return isNewDesign ? colors : opts.defaults_colors;
670
+ }
671
+
672
+ function invertColors(color) {
673
+ const hexLuminance = 186;
674
+ const rgbLuminance = 0.5;
675
+ let isHex = color[0] === '#';
676
+ let r;
677
+ let g;
678
+ let b;
679
+ if (!isHex) {
680
+ let rgbaColorParts = color.replace(/[^0-9.,]/g, '').split(',');
681
+ r = rgbaColorParts[0]/255;
682
+ g = rgbaColorParts[1]/255;
683
+ b = rgbaColorParts[2]/255;
684
+ } else {
685
+ color = color.slice(1);
686
+
687
+ if (color.length === 3) {
688
+ color = color[0].repeat(2) + color[1].repeat(2) + color[2].repeat(2);
689
+ } else if (color.length !== 6) {
690
+ return "#FFFFFF";
691
+ }
692
+ r = parseInt(color.slice(0, 2), 16);
693
+ g = parseInt(color.slice(2, 4), 16);
694
+ b = parseInt(color.slice(4, 6), 16);
695
+ }
696
+ return (r * 0.299 + g * 0.587 + b * 0.114) > (isHex ? hexLuminance : rgbLuminance)
697
+ ? '#000000'
698
+ : '#FFFFFF';
699
+ }
700
+
513
701
  colorizeRowLabelHeaders = function(element, cols_count){
514
702
  if(opts.chartOptions.table_options.colorize_headers == true &&
515
703
  opts.defaults_colors && opts.defaults_colors.length > 0){
516
- if(cols_count > 0)
517
- cols_count = cols_count - 1;
518
- var color_to_set = useNewUx && opts.chartOptions.table_options.use_new_table_design ?
519
- newTableColors[cols_count] :
520
- opts.defaults_colors[cols_count];
704
+ var offsetColor = getColorsWithOffsetForTable(opts.chartOptions.table_options.table_colors_offset);
705
+ var color_to_set = offsetColor[cols_count];
521
706
  if(color_to_set){
522
707
  element.style.setProperty("background-color", color_to_set, "important");
523
708
  element.style.setProperty("border-color", color_to_set, "important");
524
- element.style.color = useNewUx && opts.chartOptions.table_options.use_new_table_design? '#3a3b39' : '#FFFFFF';
709
+ element.style.color = invertColors(color_to_set);
525
710
  element.style.fontWeight = "bold";
711
+ if (opts.chartOptions.table_options.freeze_panes && element.firstChild) {
712
+ for (const child of element.children) {
713
+ child.style.setProperty("background-color", color_to_set, "important");
714
+ }
715
+ }
526
716
  }
527
717
  }
528
718
  };
@@ -540,15 +730,19 @@ let initDRPivotTable = function($, window, document) {
540
730
  getHeaderColorProperties = function(element, col_number = 0){
541
731
  if(opts.chartOptions.table_options.colorize_headers == true &&
542
732
  opts.defaults_colors && opts.defaults_colors.length > 0){
543
- var color_to_set = useNewUx && opts.chartOptions.table_options.use_new_table_design ?
544
- newTableColors[col_number] :
545
- opts.defaults_colors[col_number];
733
+ const offsetColor = getColorsWithOffsetForTable(opts.chartOptions.table_options.table_colors_offset);
734
+ var color_to_set = offsetColor[col_number];
546
735
  if(color_to_set){
547
736
  element.style.setProperty("background-color", color_to_set, "important");
548
737
  element.style.setProperty("border-color", color_to_set, "important");
549
738
  element.style.setProperty("vertical-align", "baseline");
550
- element.style.color = useNewUx && opts.chartOptions.table_options.use_new_table_design? '#3a3b39' : '#FFFFFF';
739
+ element.style.color = invertColors(color_to_set);
551
740
  element.style.fontWeight = "bold";
741
+ if (opts.chartOptions.table_options.freeze_panes && element.firstChild) {
742
+ for (const child of element.children) {
743
+ child.style.setProperty("background-color", color_to_set, "important");
744
+ }
745
+ }
552
746
  }
553
747
  }
554
748
  };
@@ -583,6 +777,35 @@ let initDRPivotTable = function($, window, document) {
583
777
  }
584
778
  return eventHandlers;
585
779
  };
780
+ applyInlineStyles = function(element, className) {
781
+ const tableDesignOptions = opts.chartOptions.table_design_options;
782
+ let optionName;
783
+ if (!className) return element;
784
+
785
+ if(element.className){
786
+ if (_.includes(element.className, 'pvtAxisLabel') ||
787
+ _.includes(element.className, 'pvtColLabel')) {
788
+ optionName = 'columns';
789
+ }else if (_.includes(element.className,'pvtRowLabel')) {
790
+ optionName = 'rows';
791
+ } else if (_.includes(element.className,'pvtVal') &&
792
+ !_.includes(element.className,'pvtTotal')) {
793
+ optionName = 'values';
794
+ } else if (_.includes(element.className,'colTotal') ||
795
+ _.includes(element.className,'rowTotal') ||
796
+ _.includes(element.className,'pvtGrandTotal')) {
797
+ optionName = 'totals';
798
+ }
799
+ }
800
+
801
+ if(optionName && tableDesignOptions){
802
+ element.style.fontSize = tableDesignOptions[optionName + '_font_size'] + 'px';
803
+ element.style.textAlign = tableDesignOptions[optionName + '_align_text'];
804
+ element.style.fontFamily = tableDesignOptions[optionName + '_font_style'];
805
+ }
806
+
807
+ return element;
808
+ }
586
809
  createElement = function(elementType, className, textContent, attributes, eventHandlers) {
587
810
  var attr, e, event, handler, val;
588
811
  e = document.createElement(elementType);
@@ -607,6 +830,7 @@ let initDRPivotTable = function($, window, document) {
607
830
  e.addEventListener(event, handler);
608
831
  }
609
832
  }
833
+ applyInlineStyles(e, className);
610
834
  return e;
611
835
  };
612
836
  setAttributes = function(e, attrs) {
@@ -641,7 +865,7 @@ let initDRPivotTable = function($, window, document) {
641
865
  if(!string_val || typeof(string_val) != 'string' ){
642
866
  return string_val;
643
867
  }
644
- var entityMap = {"'":"&apos;","<":"&lt;",">":"&gt;"," ":"&nbsp;","¡":"&iexcl;","¢":"&cent;","£":"&pound;","¤":"&curren;","¥":"&yen;","¦":"&brvbar;","§":"&sect;","¨":"&uml;","©":"&copy;","ª":"&ordf;","«":"&laquo;","¬":"&not;","®":"&reg;","¯":"&macr;","°":"&deg;","±":"&plusmn;","²":"&sup2;","³":"&sup3;","´":"&acute;","µ":"&micro;","¶":"&para;","·":"&middot;","¸":"&cedil;","¹":"&sup1;","º":"&ordm;","»":"&raquo;","¼":"&frac14;","½":"&frac12;","¾":"&frac34;","¿":"&iquest;","À":"&Agrave;","Á":"&Aacute;","Â":"&Acirc;","Ã":"&Atilde;","Ä":"&Auml;","Å":"&Aring;","Æ":"&AElig;","Ç":"&Ccedil;","È":"&Egrave;","É":"&Eacute;","Ê":"&Ecirc;","Ë":"&Euml;","Ì":"&Igrave;","Í":"&Iacute;","Î":"&Icirc;","Ï":"&Iuml;","Ð":"&ETH;","Ñ":"&Ntilde;","Ò":"&Ograve;","Ó":"&Oacute;","Ô":"&Ocirc;","Õ":"&Otilde;","Ö":"&Ouml;","×":"&times;","Ø":"&Oslash;","Ù":"&Ugrave;","Ú":"&Uacute;","Û":"&Ucirc;","Ü":"&Uuml;","Ý":"&Yacute;","Þ":"&THORN;","ß":"&szlig;","à":"&agrave;","á":"&aacute;","â":"&acirc;","ã":"&atilde;","ä":"&auml;","å":"&aring;","æ":"&aelig;","ç":"&ccedil;","è":"&egrave;","é":"&eacute;","ê":"&ecirc;","ë":"&euml;","ì":"&igrave;","í":"&iacute;","î":"&icirc;","ï":"&iuml;","ð":"&eth;","ñ":"&ntilde;","ò":"&ograve;","ó":"&oacute;","ô":"&ocirc;","õ":"&otilde;","ö":"&ouml;","÷":"&divide;","ø":"&oslash;","ù":"&ugrave;","ú":"&uacute;","û":"&ucirc;","ü":"&uuml;","ý":"&yacute;","þ":"&thorn;","ÿ":"&yuml;","Œ":"&OElig;","œ":"&oelig;","Š":"&Scaron;","š":"&scaron;","Ÿ":"&Yuml;","ƒ":"&fnof;","ˆ":"&circ;","˜":"&tilde;","Α":"&Alpha;","Β":"&Beta;","Γ":"&Gamma;","Δ":"&Delta;","Ε":"&Epsilon;","Ζ":"&Zeta;","Η":"&Eta;","Θ":"&Theta;","Ι":"&Iota;","Κ":"&Kappa;","Λ":"&Lambda;","Μ":"&Mu;","Ν":"&Nu;","Ξ":"&Xi;","Ο":"&Omicron;","Π":"&Pi;","Ρ":"&Rho;","Σ":"&Sigma;","Τ":"&Tau;","Υ":"&Upsilon;","Φ":"&Phi;","Χ":"&Chi;","Ψ":"&Psi;","Ω":"&Omega;","α":"&alpha;","β":"&beta;","γ":"&gamma;","δ":"&delta;","ε":"&epsilon;","ζ":"&zeta;","η":"&eta;","θ":"&theta;","ι":"&iota;","κ":"&kappa;","λ":"&lambda;","μ":"&mu;","ν":"&nu;","ξ":"&xi;","ο":"&omicron;","π":"&pi;","ρ":"&rho;","ς":"&sigmaf;","σ":"&sigma;","τ":"&tau;","υ":"&upsilon;","φ":"&phi;","χ":"&chi;","ψ":"&psi;","ω":"&omega;","ϑ":"&thetasym;","ϒ":"&Upsih;","ϖ":"&piv;","–":"&ndash;","—":"&mdash;","‘":"&lsquo;","’":"&rsquo;","‚":"&sbquo;","“":"&ldquo;","”":"&rdquo;","„":"&bdquo;","†":"&dagger;","‡":"&Dagger;","•":"&bull;","…":"&hellip;","‰":"&permil;","′":"&prime;","″":"&Prime;","‹":"&lsaquo;","›":"&rsaquo;","‾":"&oline;","⁄":"&frasl;","€":"&euro;","ℑ":"&image;","℘":"&weierp;","ℜ":"&real;","™":"&trade;","ℵ":"&alefsym;","←":"&larr;","↑":"&uarr;","→":"&rarr;","↓":"&darr;","↔":"&harr;","↵":"&crarr;","⇐":"&lArr;","⇑":"&UArr;","⇒":"&rArr;","⇓":"&dArr;","⇔":"&hArr;","∀":"&forall;","∂":"&part;","∃":"&exist;","∅":"&empty;","∇":"&nabla;","∈":"&isin;","∉":"&notin;","∋":"&ni;","∏":"&prod;","∑":"&sum;","−":"&minus;","∗":"&lowast;","√":"&radic;","∝":"&prop;","∞":"&infin;","∠":"&ang;","∧":"&and;","∨":"&or;","∩":"&cap;","∪":"&cup;","∫":"&int;","∴":"&there4;","∼":"&sim;","≅":"&cong;","≈":"&asymp;","≠":"&ne;","≡":"&equiv;","≤":"&le;","≥":"&ge;","⊂":"&sub;","⊃":"&sup;","⊄":"&nsub;","⊆":"&sube;","⊇":"&supe;","⊕":"&oplus;","⊗":"&otimes;","⊥":"&perp;","⋅":"&sdot;","⌈":"&lceil;","⌉":"&rceil;","⌊":"&lfloor;","⌋":"&rfloor;","⟨":"&lang;","⟩":"&rang;","◊":"&loz;","♠":"&spades;","♣":"&clubs;","♥":"&hearts;","♦":"&diams;"};
868
+ var entityMap = {"'":"&apos;","<":"&lt;",">":"&gt;","¡":"&iexcl;","¢":"&cent;","£":"&pound;","¤":"&curren;","¥":"&yen;","¦":"&brvbar;","§":"&sect;","¨":"&uml;","©":"&copy;","ª":"&ordf;","«":"&laquo;","¬":"&not;","®":"&reg;","¯":"&macr;","°":"&deg;","±":"&plusmn;","²":"&sup2;","³":"&sup3;","´":"&acute;","µ":"&micro;","¶":"&para;","·":"&middot;","¸":"&cedil;","¹":"&sup1;","º":"&ordm;","»":"&raquo;","¼":"&frac14;","½":"&frac12;","¾":"&frac34;","¿":"&iquest;","À":"&Agrave;","Á":"&Aacute;","Â":"&Acirc;","Ã":"&Atilde;","Ä":"&Auml;","Å":"&Aring;","Æ":"&AElig;","Ç":"&Ccedil;","È":"&Egrave;","É":"&Eacute;","Ê":"&Ecirc;","Ë":"&Euml;","Ì":"&Igrave;","Í":"&Iacute;","Î":"&Icirc;","Ï":"&Iuml;","Ð":"&ETH;","Ñ":"&Ntilde;","Ò":"&Ograve;","Ó":"&Oacute;","Ô":"&Ocirc;","Õ":"&Otilde;","Ö":"&Ouml;","×":"&times;","Ø":"&Oslash;","Ù":"&Ugrave;","Ú":"&Uacute;","Û":"&Ucirc;","Ü":"&Uuml;","Ý":"&Yacute;","Þ":"&THORN;","ß":"&szlig;","à":"&agrave;","á":"&aacute;","â":"&acirc;","ã":"&atilde;","ä":"&auml;","å":"&aring;","æ":"&aelig;","ç":"&ccedil;","è":"&egrave;","é":"&eacute;","ê":"&ecirc;","ë":"&euml;","ì":"&igrave;","í":"&iacute;","î":"&icirc;","ï":"&iuml;","ð":"&eth;","ñ":"&ntilde;","ò":"&ograve;","ó":"&oacute;","ô":"&ocirc;","õ":"&otilde;","ö":"&ouml;","÷":"&divide;","ø":"&oslash;","ù":"&ugrave;","ú":"&uacute;","û":"&ucirc;","ü":"&uuml;","ý":"&yacute;","þ":"&thorn;","ÿ":"&yuml;","Œ":"&OElig;","œ":"&oelig;","Š":"&Scaron;","š":"&scaron;","Ÿ":"&Yuml;","ƒ":"&fnof;","ˆ":"&circ;","˜":"&tilde;","Α":"&Alpha;","Β":"&Beta;","Γ":"&Gamma;","Δ":"&Delta;","Ε":"&Epsilon;","Ζ":"&Zeta;","Η":"&Eta;","Θ":"&Theta;","Ι":"&Iota;","Κ":"&Kappa;","Λ":"&Lambda;","Μ":"&Mu;","Ν":"&Nu;","Ξ":"&Xi;","Ο":"&Omicron;","Π":"&Pi;","Ρ":"&Rho;","Σ":"&Sigma;","Τ":"&Tau;","Υ":"&Upsilon;","Φ":"&Phi;","Χ":"&Chi;","Ψ":"&Psi;","Ω":"&Omega;","α":"&alpha;","β":"&beta;","γ":"&gamma;","δ":"&delta;","ε":"&epsilon;","ζ":"&zeta;","η":"&eta;","θ":"&theta;","ι":"&iota;","κ":"&kappa;","λ":"&lambda;","μ":"&mu;","ν":"&nu;","ξ":"&xi;","ο":"&omicron;","π":"&pi;","ρ":"&rho;","ς":"&sigmaf;","σ":"&sigma;","τ":"&tau;","υ":"&upsilon;","φ":"&phi;","χ":"&chi;","ψ":"&psi;","ω":"&omega;","ϑ":"&thetasym;","ϒ":"&Upsih;","ϖ":"&piv;","–":"&ndash;","—":"&mdash;","‘":"&lsquo;","’":"&rsquo;","‚":"&sbquo;","“":"&ldquo;","”":"&rdquo;","„":"&bdquo;","†":"&dagger;","‡":"&Dagger;","•":"&bull;","…":"&hellip;","‰":"&permil;","′":"&prime;","″":"&Prime;","‹":"&lsaquo;","›":"&rsaquo;","‾":"&oline;","⁄":"&frasl;","€":"&euro;","ℑ":"&image;","℘":"&weierp;","ℜ":"&real;","™":"&trade;","ℵ":"&alefsym;","←":"&larr;","↑":"&uarr;","→":"&rarr;","↓":"&darr;","↔":"&harr;","↵":"&crarr;","⇐":"&lArr;","⇑":"&UArr;","⇒":"&rArr;","⇓":"&dArr;","⇔":"&hArr;","∀":"&forall;","∂":"&part;","∃":"&exist;","∅":"&empty;","∇":"&nabla;","∈":"&isin;","∉":"&notin;","∋":"&ni;","∏":"&prod;","∑":"&sum;","−":"&minus;","∗":"&lowast;","√":"&radic;","∝":"&prop;","∞":"&infin;","∠":"&ang;","∧":"&and;","∨":"&or;","∩":"&cap;","∪":"&cup;","∫":"&int;","∴":"&there4;","∼":"&sim;","≅":"&cong;","≈":"&asymp;","≠":"&ne;","≡":"&equiv;","≤":"&le;","≥":"&ge;","⊂":"&sub;","⊃":"&sup;","⊄":"&nsub;","⊆":"&sube;","⊇":"&supe;","⊕":"&oplus;","⊗":"&otimes;","⊥":"&perp;","⋅":"&sdot;","⌈":"&lceil;","⌉":"&rceil;","⌊":"&lfloor;","⌋":"&rfloor;","⟨":"&lang;","⟩":"&rang;","◊":"&loz;","♠":"&spades;","♣":"&clubs;","♥":"&hearts;","♦":"&diams;"};
645
869
  string_val = string_val.replace(/&/g, '&amp;');
646
870
  string_val = string_val.replace(/"/g, '&quot;');
647
871
  for (var key in entityMap) {
@@ -653,11 +877,23 @@ let initDRPivotTable = function($, window, document) {
653
877
  };
654
878
 
655
879
  processKeys = function(keysArr, className, dimention, attrs) {
880
+ for (let i = 0; i < keysArr.length; i++) {
881
+ const additionalField = _.find(additionalFieldsList, {key: keysArr[i][0]})
882
+
883
+ if (additionalField) {
884
+ dimention === 'rows'
885
+ ? additionalFieldsRow.push(additionalField)
886
+ : additionalFieldsCol.push(additionalField);
887
+ }
888
+ }
889
+
656
890
  var c, headers, k, key, lastCol, lastRow, node, nodePos, r, rMark, ref8, repeats, th, x;
891
+ const showAllData = opts && opts.chartOptions && opts.chartOptions.table_options && opts.chartOptions.table_options.show_all;
892
+
657
893
  headers = [];
658
894
  lastRow = keysArr.length - 1;
659
895
  lastCol = keysArr[0].length - 1;
660
- if(lastCol > 0 && className == "pvtColLabel" && (charttype == 'column-chart' || charttype == 'column-chart-stacked')){
896
+ if(lastCol > 0 && className == "pvtColLabel" && !_.get(opts, 'chartOptions.table_options.transpose_table', false) && (charttype == 'column-chart' || charttype == 'column-chart-stacked')){
661
897
  lastCol = 0;
662
898
  }
663
899
  rMark = [];
@@ -718,7 +954,7 @@ let initDRPivotTable = function($, window, document) {
718
954
 
719
955
  if(c === 0 && ((dimention == 'rows' && opts.show_more_function_rows)
720
956
  || (dimention == 'cols' && opts.show_more_function_cols)
721
- ) && headers.length > opts.show_more_max_items)
957
+ ) && headers.length > opts.show_more_max_items && !showAllData)
722
958
  {
723
959
  key=['...'];
724
960
 
@@ -788,7 +1024,7 @@ let initDRPivotTable = function($, window, document) {
788
1024
  var className, colAttr, textContent, th, clickStatus;
789
1025
  colAttr = colAttrs[col];
790
1026
  textContent = opts.labelsConvertFunction(colAttr);
791
- className = "pvtAxisLabel";
1027
+ className = "pvtAxisLabel" + axisFreezePaneClass;
792
1028
  if (col < colAttrs.length - 1) {
793
1029
  if (!(isColDisableExpandCollapse || isColDisable || col > colDisableAfter)) {
794
1030
  if(opts.collapseColsAt == 0){
@@ -826,13 +1062,14 @@ let initDRPivotTable = function($, window, document) {
826
1062
  else{
827
1063
  rowSpan = colAttrs.length;
828
1064
  }
829
- tr.appendChild(createElement("th", null, null, {
1065
+ tr.appendChild(createElement("th", axisFreezePaneClass, null, {
830
1066
  colspan: rowAttrs.length,
831
1067
  rowspan: rowSpan
832
1068
  }));
833
1069
  }
834
- getHeaderColorProperties(tr);
1070
+
835
1071
  buildColHeaderHeader(thead, colHeaderHeaders, rowAttrs, colAttrs, tr, 0);
1072
+ getHeaderColorProperties(tr);
836
1073
  results = [];
837
1074
  for (c = k = 1, ref8 = colAttrs.length; 1 <= ref8 ? k <= ref8 : k >= ref8; c = 1 <= ref8 ? ++k : --k) {
838
1075
  if (!(c < colAttrs.length)) {
@@ -840,7 +1077,7 @@ let initDRPivotTable = function($, window, document) {
840
1077
  }
841
1078
  tr = createElement("tr");
842
1079
  if (opts.chartOptions.table_options.colorize_headers == true && rowAttrs.length !== 0) {
843
- tr.appendChild(createElement("th", null, null, {
1080
+ tr.appendChild(createElement("th", axisFreezePaneClass, null, {
844
1081
  colspan: rowAttrs.length
845
1082
  }));
846
1083
  }
@@ -869,6 +1106,9 @@ let initDRPivotTable = function($, window, document) {
869
1106
  return results;
870
1107
  };
871
1108
  buildColHeaders = function(colHeaderHeaders, colHeaderCols, colHeader, rowAttrs, colAttrs) {
1109
+ const additionalField = _.find(additionalFieldsList, {key: colHeader.key[0]})
1110
+ if (additionalField) return;
1111
+
872
1112
  var colspan, h, hh, isColSubtotal, k, len, ref8, rowspan, sTh, style, th, tr;
873
1113
  ref8 = colHeader.children;
874
1114
  for (k = 0, len = ref8.length; k < len; k++) {
@@ -882,7 +1122,7 @@ let initDRPivotTable = function($, window, document) {
882
1122
  ++hh.nHeaders;
883
1123
  tr = hh.tr;
884
1124
  th = colHeader.th;
885
- addClass(th, "col" + colHeader.row + " colcol" + colHeader.col + " " + classColShow);
1125
+ addClass(th, "col" + colHeader.row + " colcol" + colHeader.col + " " + classColShow + verticalFreezePaneClass);
886
1126
  //getHeaderColorProperties(th, colHeader.col);
887
1127
  if (isColHideOnExpand || isColDisable || (isColSubtotal && colHeader.col > colDisableAfter)) {
888
1128
  colspan = colHeader.leaves;
@@ -916,7 +1156,7 @@ let initDRPivotTable = function($, window, document) {
916
1156
  return toggleCol(colHeaderHeaders, colHeaderCols, parseInt(event.currentTarget.getAttribute("data-colnode")));
917
1157
  };
918
1158
  rowspan = colAttrs.length - (colHeader.col + 1) + (rowAttrs.length !== 0 ? 1 : 0);
919
- style = "pvtColLabel pvtColSubtotal " + classColExpanded;
1159
+ style = "pvtColLabel pvtColSubtotal " + classColExpanded + verticalFreezePaneClass;
920
1160
  style += " col" + colHeader.row + " colcol" + colHeader.col;
921
1161
  if (isColHideOnExpand || isColDisable || colHeader.col > colDisableAfter) {
922
1162
  style += " " + classColHide;
@@ -935,6 +1175,9 @@ let initDRPivotTable = function($, window, document) {
935
1175
  }
936
1176
  colHeader.clickStatus = clickStatusExpanded;
937
1177
  tr.appendChild(th);
1178
+ if (opts.chartOptions.table_options.freeze_panes) {
1179
+ getHeaderColorProperties(tr);
1180
+ }
938
1181
  colHeader.tr = tr;
939
1182
  return colHeaderCols.push(colHeader);
940
1183
  };
@@ -946,7 +1189,7 @@ let initDRPivotTable = function($, window, document) {
946
1189
  if (!hasProp.call(rowAttrs, i)) continue;
947
1190
  rowAttr = rowAttrs[i];
948
1191
  textContent = opts.labelsConvertFunction(rowAttr);
949
- className = "pvtAxisLabel";
1192
+ className = "pvtAxisLabel" + axisFreezePaneClass;
950
1193
  if (i < rowAttrs.length - 1) {
951
1194
  className += " expanded";
952
1195
  if (!(isRowDisableExpandCollapse || isRowDisable || i > rowDisableAfter)) {
@@ -973,7 +1216,7 @@ let initDRPivotTable = function($, window, document) {
973
1216
  });
974
1217
  }
975
1218
  if (colAttrs.length !== 0) {
976
- th = createElement("th");
1219
+ th = createElement("th", axisFreezePaneClass);
977
1220
  tr.appendChild(th);
978
1221
  }
979
1222
  colorizeRowLabelHeaders(tr, colAttrs.length);
@@ -1010,7 +1253,7 @@ let initDRPivotTable = function($, window, document) {
1010
1253
  rowspan = 1;
1011
1254
  }
1012
1255
 
1013
- th = createElement("th", "pvtTotalLabel rowTotal", opts.localeStrings.totals, {
1256
+ th = createElement("th", "pvtTotalLabel rowTotal" + verticalFreezePaneClass , opts.localeStrings.totals, {
1014
1257
  rowspan: rowspan
1015
1258
  });
1016
1259
 
@@ -1020,9 +1263,17 @@ let initDRPivotTable = function($, window, document) {
1020
1263
  }
1021
1264
 
1022
1265
  //getHeaderColorProperties(th);
1023
- return tr.appendChild(th);
1266
+ if (opts.chartOptions.table_options.freeze_panes) {
1267
+ tr.appendChild(th);
1268
+ getHeaderColorProperties(tr);
1269
+ } else {
1270
+ return tr.appendChild(th);
1271
+ }
1024
1272
  };
1025
- buildRowHeaders = function(tbody, rowHeaderHeaders, rowHeaderRows, rowHeader, rowAttrs, colAttrs, highlighted) {
1273
+ buildRowHeaders = function(tbody, rowHeaderHeaders, rowHeaderRows, rowHeader, rowAttrs, colAttrs, highlighted, hasColLabels) {
1274
+ const additionalField = _.find(additionalFieldsList, {key: rowHeader.key[0]})
1275
+ if (additionalField) return;
1276
+
1026
1277
  var colspan, h, hh, isRowSubtotal, k, len, ref8, results, style, th, tr;
1027
1278
  hh = rowHeaderHeaders.hh[rowHeader.col];
1028
1279
  ++hh.expandedCount;
@@ -1042,7 +1293,7 @@ let initDRPivotTable = function($, window, document) {
1042
1293
  }
1043
1294
 
1044
1295
  isRowSubtotal = rowHeader.children.length !== 0;
1045
- addClass(th, "row" + rowHeader.row + " rowcol" + rowHeader.col + " " + classRowShow);
1296
+ addClass(th, "row" + rowHeader.row + " rowcol" + rowHeader.col + " " + classRowShow + horizontalFreezePaneClass);
1046
1297
  if (highlighted) {
1047
1298
  addClass(th, "highlighted");
1048
1299
  }
@@ -1052,9 +1303,17 @@ let initDRPivotTable = function($, window, document) {
1052
1303
  "rowspan": rowHeader.descendants + 1,
1053
1304
  "colspan": colspan
1054
1305
  });
1055
- if (opts.chartOptions.table_options.hide_nulls_in_headers && th.textContent === '[null]') {
1056
- th.textContent = '';
1306
+ if (opts.chartOptions.table_options.hide_nulls_in_headers) {
1307
+ th.textContent = th.textContent.replace('[null]', '');
1308
+ }
1309
+ if (th.textContent === 'DR Others') {
1310
+ th.textContent = _.get(opts, "total_value_options.filter_options.filteredOutFieldName") || 'Others'
1311
+ }
1312
+
1313
+ if (th.hasAttribute('data_show_more') && th.colSpan > 0 && !hasColLabels) {
1314
+ th.colSpan = th.colSpan - 1;
1057
1315
  }
1316
+
1058
1317
  tr.appendChild(th);
1059
1318
  if (isRowSubtotal) {
1060
1319
  addClass(tr, classRowExpanded);
@@ -1070,6 +1329,7 @@ let initDRPivotTable = function($, window, document) {
1070
1329
  style = "pvtRowLabel pvtRowSubtotal " + classRowExpanded;
1071
1330
  style += " row" + rowHeader.row + " rowcol" + rowHeader.col;
1072
1331
  style += isRowHideOnExpand || isRowDisable || rowHeader.col > rowDisableAfter ? " " + classRowHide : " " + classRowShow;
1332
+ style += horizontalFreezePaneClass;
1073
1333
  th = createElement("th", style, opts.localeStrings.subtotals, {
1074
1334
  "colspan": colspan,
1075
1335
  "data-rownode": rowHeader.node
@@ -1087,12 +1347,184 @@ let initDRPivotTable = function($, window, document) {
1087
1347
  results = [];
1088
1348
  for (k = 0, len = ref8.length; k < len; k++) {
1089
1349
  h = ref8[k];
1090
- results.push(buildRowHeaders(tbody, rowHeaderHeaders, rowHeaderRows, h, rowAttrs, colAttrs, highlighted));
1350
+ results.push(buildRowHeaders(tbody, rowHeaderHeaders, rowHeaderRows, h, rowAttrs, colAttrs, highlighted, hasColLabels));
1091
1351
  }
1092
1352
  return results;
1093
1353
  };
1354
+
1355
+ getAdditionalAggregation = function (rowKey, colKey) {
1356
+ if ((tree && tree[rowKey] && tree[rowKey][colKey])
1357
+ && (rowKey !== '...' || colKey !== '...')) {
1358
+ return tree[rowKey][colKey];
1359
+ } else {
1360
+ return {
1361
+ value: (function() {
1362
+ return null;
1363
+ }),
1364
+ format: function() {
1365
+ return "";
1366
+ }
1367
+ };
1368
+ }
1369
+ }
1370
+
1371
+ buildAdditionalHeaderCols = function (tr, rowAttrs, colAttrs) {
1372
+ let rowspan, th;
1373
+
1374
+ rowspan = 1;
1375
+ if (colAttrs.length !== 0) {
1376
+ rowspan = colAttrs.length + (rowAttrs.length === 0 ? 0 : 1);
1377
+ }
1378
+
1379
+ for (let i = 0; i < additionalFieldsCol.length; i++) {
1380
+ const col = additionalFieldsCol[i];
1381
+ th = createElement("th", "pvtColLabel" + verticalFreezePaneClass , col.name, {
1382
+ rowspan: rowspan
1383
+ });
1384
+
1385
+ if (opts.chartOptions.table_options.freeze_panes) {
1386
+ tr.appendChild(th);
1387
+ getHeaderColorProperties(tr);
1388
+ } else {
1389
+ return tr.appendChild(th);
1390
+ }
1391
+ }
1392
+ };
1393
+
1394
+ buildAdditionalHeaderRows = function (fieldName, rowAttrs, colAttrs) {
1395
+ let colspan, th, tr;
1396
+
1397
+ tr = createElement("tr");
1398
+ colspan = rowAttrs.length + (colAttrs.length === 0 ? 0 : 1);
1399
+ th = createElement("th", "pvtRowLabel" + horizontalFreezePaneClass, fieldName, {
1400
+ colspan: colspan
1401
+ });
1402
+
1403
+ tr.appendChild(th);
1404
+ return tr;
1405
+ };
1406
+
1407
+ buildAdditionalColValues = function (tr, rowKey, rowHeader) {
1408
+ for (let i = 0; i < additionalFieldsCol.length; i++) {
1409
+ const colKey = additionalFieldsCol[i].key;
1410
+ const totalAggregator = getAdditionalAggregation(rowKey, colKey);
1411
+ const val = totalAggregator.value();
1412
+ const formattedValue = getFormattedNumber(val, totalAggregator, opts)
1413
+
1414
+ let className = "pvtVal rowshow colshow";
1415
+ className += " row" + rowHeader.row + " rowcol" + rowHeader.col;
1416
+
1417
+ const td = createElement("td", className, formattedValue, {
1418
+ "data-value": val,
1419
+ "data-row": "row" + rowHeader.row,
1420
+ "data-rowcol": "col" + rowHeader.col,
1421
+ "data-rownode": rowHeader.node
1422
+ }, getTableEventHandlers(val, rowHeader.key, []));
1423
+
1424
+ if (rowHeader.children.length && rowHeader.clickStatus === 'expanded') {
1425
+ td.style.display = 'none';
1426
+ }
1427
+
1428
+ tr.appendChild(td)
1429
+ }
1430
+ }
1431
+
1432
+ buildAdditionalRowValues = function (tr, colHeaderCols, rowKey) {
1433
+ for (let i = 0; i < colHeaderCols.length; i++) {
1434
+ const colHeader = colHeaderCols[i];
1435
+ const colKey = colHeader.flatKey;
1436
+ const totalAggregator = getAdditionalAggregation(rowKey, colKey);
1437
+ const val = totalAggregator.value();
1438
+ const formattedValue = getFormattedNumber(val, totalAggregator, opts)
1439
+
1440
+ const className = "pvtVal col" + i + " colcol" + 0;
1441
+ const td = createElement("td", className, formattedValue, {
1442
+ "data-value": val,
1443
+ "data-for": "col" + 0,
1444
+ "data-colnode": "" + i
1445
+ });
1446
+
1447
+ if (colHeader.children.length && colHeader.clickStatus === 'expanded') {
1448
+ td.style.display = 'none';
1449
+ }
1450
+
1451
+ tr.appendChild(td);
1452
+ }
1453
+
1454
+ if (additionalFieldsCol.length) {
1455
+ for (let i = 0; i < additionalFieldsCol.length; i++) {
1456
+ const totalAggregator = getAdditionalAggregation(rowKey, additionalFieldsCol[i].key);
1457
+ const val = totalAggregator.value();
1458
+ const formattedValue = getFormattedNumber(val, totalAggregator, opts)
1459
+
1460
+ const className = "pvtVal col" + i + " colcol" + 0;
1461
+ const td = createElement("td", className, formattedValue, {
1462
+ "data-value": val,
1463
+ "data-for": "col" + 0,
1464
+ "data-colnode": "" + i
1465
+ });
1466
+
1467
+ tr.appendChild(td);
1468
+ }
1469
+ }
1470
+
1471
+ if(opts.chartOptions.table_options.show_row_total) {
1472
+ buildAdditionalRowTotals(tr, rowKey)
1473
+ }
1474
+ }
1475
+
1476
+ buildAdditionalRowTotals = function (tr, rowKey) {
1477
+ const totalAggregator = getExistingAggregator(rowTotals, rowKey);
1478
+ const value = totalAggregator.value();
1479
+ const formattedValue = getFormattedNumber(value, totalAggregator, opts)
1480
+
1481
+ let style = "pvtTotal pvtAddFiled rowTotal";
1482
+ const td = createElement("td", style, formattedValue, {
1483
+ "data-value": value
1484
+ });
1485
+
1486
+ tr.appendChild(td);
1487
+ }
1488
+
1489
+ buildAdditionalColTotals = function (tr, rowHeaderRows, colKey, colHeader) {
1490
+ const totalAggregator = getExistingAggregator(colTotals, colKey)
1491
+ const value = totalAggregator.value();
1492
+ const formattedValue = getFormattedNumber(value, totalAggregator, opts);
1493
+
1494
+ if (!colHeader) {
1495
+ colHeader = {}
1496
+ }
1497
+
1498
+ let style = "pvtTotal pvtAddField colTotal";
1499
+ style += " col" + colHeader.row || "-1" + " colcol" + colHeader.col || "-1";
1500
+
1501
+ const td = createElement("td", style, formattedValue, {
1502
+ "data-value": value,
1503
+ "data-rowcol": "col" + colHeader.col || "-1",
1504
+ "data-rownode": "" + colHeader.node || "-1"
1505
+ }, getTableEventHandlers(value, [], colHeader.key || []));
1506
+
1507
+ return td;
1508
+ }
1509
+
1510
+ getExistingAggregator = function (aggregator, key) {
1511
+ if (!aggregator[key]) {
1512
+ return {
1513
+ value: (function () {
1514
+ return null;
1515
+ }),
1516
+ format: function () {
1517
+ return "";
1518
+ }
1519
+ };
1520
+ }
1521
+
1522
+ return aggregator[key];
1523
+ }
1524
+
1094
1525
  buildValues = function(rowHeaderRows, colHeaderCols, rowAttrs, colAttrs) {
1095
1526
  var aggregator, colHeader, eventHandlers, flatColKey, flatRowKey, isColSubtotal, isRowSubtotal, k, l, len, len1, ref8, results, rowHeader, style, td, totalAggregator, tr, val;
1527
+
1096
1528
  results = [];
1097
1529
  for (k = 0, len = rowHeaderRows.length; k < len; k++) {
1098
1530
  rowHeader = rowHeaderRows[k];
@@ -1142,6 +1574,11 @@ let initDRPivotTable = function($, window, document) {
1142
1574
 
1143
1575
  tr.appendChild(td);
1144
1576
  }
1577
+
1578
+ if (additionalFieldsCol.length > 0) {
1579
+ buildAdditionalColValues(tr, flatRowKey, rowHeader);
1580
+ }
1581
+
1145
1582
  totalAggregator = rowTotals[flatRowKey];
1146
1583
  if(!totalAggregator){
1147
1584
  totalAggregator = {
@@ -1233,7 +1670,7 @@ let initDRPivotTable = function($, window, document) {
1233
1670
  var colspan, th, tr;
1234
1671
  tr = createElement("tr");
1235
1672
  colspan = rowAttrs.length + (colAttrs.length === 0 ? 0 : 1);
1236
- th = createElement("th", "pvtTotalLabel colTotal", opts.localeStrings.totals, {
1673
+ th = createElement("th", "pvtTotalLabel colTotal" + horizontalFreezePaneClass, opts.localeStrings.totals, {
1237
1674
  colspan: colspan
1238
1675
  });
1239
1676
  if (opts.totalFilterElements && opts.totalFilterElements.col_total) {
@@ -1243,13 +1680,13 @@ let initDRPivotTable = function($, window, document) {
1243
1680
  tr.appendChild(th);
1244
1681
  return tr;
1245
1682
  };
1246
- buildColTotals = function(tr, colHeaderCols, rowAttrs, colAttrs) {
1683
+ buildColTotals = function(tr, colHeaderCols, rowHeaderRows, rowAttrs, colAttrs) {
1247
1684
  var h, isColSubtotal, k, len, results, style, td, totalAggregator, val;
1248
1685
  results = [];
1249
- createGrandTotalBolder(tr);
1250
1686
  for (k = 0, len = colHeaderCols.length; k < len; k++) {
1251
1687
  h = colHeaderCols[k];
1252
1688
  isColSubtotal = h.children.length !== 0;
1689
+
1253
1690
  totalAggregator = colTotals[h.flatKey];
1254
1691
  if(!totalAggregator){
1255
1692
  totalAggregator = {
@@ -1282,10 +1719,22 @@ let initDRPivotTable = function($, window, document) {
1282
1719
 
1283
1720
  results.push(tr.appendChild(td));
1284
1721
  }
1722
+
1723
+ if (additionalFieldsCol.length > 0) {
1724
+ for (let i = 0; i < additionalFieldsCol.length; i++) {
1725
+ const colKey = additionalFieldsCol[i].key;
1726
+
1727
+ td = buildAdditionalColTotals(tr, rowHeaderRows, colKey, h);
1728
+ results.push(tr.appendChild(td));
1729
+ }
1730
+ }
1731
+
1732
+ createGrandTotalBolder(tr);
1285
1733
  return results;
1286
1734
  };
1287
1735
  buildGrandTotal = function(result, tr, rowAttrs, colAttrs) {
1288
1736
  var td, totalAggregator, val;
1737
+
1289
1738
  totalAggregator = allTotal;
1290
1739
  val = totalAggregator.value();
1291
1740
  td = createElement("td", "pvtGrandTotal", getFormattedNumber(val, totalAggregator, opts), {
@@ -1297,6 +1746,11 @@ let initDRPivotTable = function($, window, document) {
1297
1746
  tr.appendChild(td);
1298
1747
  return result.appendChild(tr);
1299
1748
  };
1749
+ removeRowHeaderNullValue = function(h) {
1750
+ if (opts.chartOptions.table_options.hide_nulls_in_headers) {
1751
+ h.th.innerHTML = h.th.innerHTML.replace('[null]' , '');
1752
+ }
1753
+ };
1300
1754
  hideDescendantCol = function(d) {
1301
1755
  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
1756
  };
@@ -1512,6 +1966,9 @@ let initDRPivotTable = function($, window, document) {
1512
1966
  collapseShowRowSubtotal(h);
1513
1967
  --rowspan;
1514
1968
  }
1969
+
1970
+ removeRowHeaderNullValue(h);
1971
+
1515
1972
  p = h.parent;
1516
1973
  while (p) {
1517
1974
  p.th.rowSpan -= rowspan;
@@ -1638,6 +2095,9 @@ let initDRPivotTable = function($, window, document) {
1638
2095
  expandShowRowSubtotal(h);
1639
2096
  }
1640
2097
  }
2098
+
2099
+ removeRowHeaderNullValue(h);
2100
+
1641
2101
  p = h.parent;
1642
2102
  while (p) {
1643
2103
  p.th.rowSpan += rowspan;
@@ -1920,6 +2380,33 @@ let initDRPivotTable = function($, window, document) {
1920
2380
  return collapseRowsAt(rowHeaderHeaders, rowHeaderRows, rowAttrs, rowAttr);
1921
2381
  }
1922
2382
  };
2383
+
2384
+ handleFreezePanesScroll = function(freezableElements) {
2385
+ return function(event) {
2386
+ if (event.target.dataset.canFreezePanes) return;
2387
+
2388
+ const wrapper = event.target;
2389
+
2390
+ const translateY = `translate(0px, ${wrapper.scrollTop}px)`;
2391
+ const translateX = `translate(${wrapper.scrollLeft}px, 0px)`;
2392
+ const translateXY = `translate(${wrapper.scrollLeft}px, ${wrapper.scrollTop}px)`;
2393
+
2394
+ _.forEach(freezableElements, function (element) {
2395
+ let currentTranslate = translateY;
2396
+ currentTranslate = element.className.includes(elementToTransform.X) ? translateX : currentTranslate;
2397
+ currentTranslate = element.className.includes(elementToTransform.XY) ? translateXY : currentTranslate;
2398
+ element.style.transform = currentTranslate;
2399
+ });
2400
+ }
2401
+ };
2402
+
2403
+ selectFreezableElements = function(wrapper) {
2404
+ const selectString =_.map(_.values(elementToTransform), function (item) {
2405
+ return `.${item.replace(' ', '')}`;
2406
+ }).join(',');
2407
+ return Array.from(wrapper.querySelectorAll(selectString));
2408
+ }
2409
+
1923
2410
  main = function(rowAttrs, rowKeys, colAttrs, colKeys) {
1924
2411
  var c,rowspan, colHeaderCols, colHeaderHeaders, colHeaders, h, k, l, len, len1, result, rowHeaderHeaders, rowHeaderRows, rowHeaders, tbody, thead, tr;
1925
2412
  rowHeaders = [];
@@ -1934,8 +2421,14 @@ let initDRPivotTable = function($, window, document) {
1934
2421
  if (colAttrs.length > 0 && colKeys.length > 0) {
1935
2422
  colHeaders = processKeys(colKeys, "pvtColLabel", 'cols', colAttrs);
1936
2423
  }
1937
- var tableClasses = useNewUx && opts.chartOptions.table_options.use_new_table_design ? 'pvtTable newPvtTable' : 'pvtTable';
1938
- result = createElement("table", tableClasses , null, {
2424
+ var tableClasses = ['pvtTable'];
2425
+ if (opts.chartOptions.table_options.use_new_table_design) {
2426
+ tableClasses.push('newPvtTable');
2427
+ }
2428
+ if (!pivotData.aggregator().uniq) {
2429
+ tableClasses.push('numbers-to-right');
2430
+ }
2431
+ result = createElement("table", tableClasses.join(' ') , null, {
1939
2432
  style: "display: none;"
1940
2433
  });
1941
2434
 
@@ -1953,10 +2446,20 @@ let initDRPivotTable = function($, window, document) {
1953
2446
  }
1954
2447
  if (rowAttrs.length > 0) {
1955
2448
  buildRowHeaderHeaders(thead, rowHeaderHeaders, rowAttrs, colAttrs);
2449
+
2450
+ if (colAttrs.length === 0 && additionalFieldsCol.length > 0) {
2451
+ buildAdditionalHeaderCols(rowHeaderHeaders.tr, rowAttrs, colAttrs)
2452
+ }
2453
+
1956
2454
  if (colAttrs.length === 0 && opts.chartOptions.table_options.show_row_total) {
1957
2455
  buildRowTotalsHeader(rowHeaderHeaders.tr, rowAttrs, colAttrs);
1958
2456
  }
1959
2457
  }
2458
+
2459
+ if (colAttrs.length > 0 && additionalFieldsCol.length > 0) {
2460
+ buildAdditionalHeaderCols(colHeaderHeaders[0].tr, rowAttrs, colAttrs)
2461
+ }
2462
+
1960
2463
  if (colAttrs.length > 0 && opts.chartOptions.table_options.show_row_total) {
1961
2464
  buildRowTotalsHeader(colHeaderHeaders[0].tr, rowAttrs, colAttrs);
1962
2465
  if(opts.chartOptions.table_options.colorize_headers == true){
@@ -1965,24 +2468,44 @@ let initDRPivotTable = function($, window, document) {
1965
2468
  if(c == colHeaderHeaders.length-1){
1966
2469
  rowspan = 2;
1967
2470
  }
1968
- colHeaderHeaders[c].tr.appendChild(createElement("th", "", "",{rowspan: rowspan}));
2471
+ colHeaderHeaders[c].tr.appendChild(createElement("th", verticalFreezePaneClass, "",{rowspan: rowspan}));
2472
+ if (opts.chartOptions.table_options.freeze_panes) {
2473
+ getHeaderColorProperties(colHeaderHeaders[c].tr, c);
2474
+ }
1969
2475
  }
1970
2476
  }
1971
2477
  }
1972
2478
  tbody = createElement("tbody");
1973
2479
  result.appendChild(tbody);
2480
+
2481
+ const hasColLabels = !!thead.querySelector('.pvtColLabel');
2482
+
1974
2483
  if (rowAttrs.length > 0) {
1975
2484
  for (l = 0, len1 = rowHeaders.length; l < len1; l++) {
1976
2485
  h = rowHeaders[l];
1977
- buildRowHeaders(tbody, rowHeaderHeaders, rowHeaderRows, h, rowAttrs, colAttrs, l%2 === 0);
2486
+ buildRowHeaders(tbody, rowHeaderHeaders, rowHeaderRows, h, rowAttrs, colAttrs, l%2 === 0, hasColLabels);
1978
2487
  }
1979
2488
  }
1980
2489
  buildRowHeaderHeadersClickEvents(rowHeaderHeaders, rowHeaderRows, rowAttrs);
1981
2490
  buildValues(rowHeaderRows, colHeaderCols, rowAttrs, colAttrs);
2491
+
2492
+ if (additionalFieldsRow.length > 0) {
2493
+ for (let i = 0; i < additionalFieldsRow.length; i++) {
2494
+ const field = additionalFieldsRow[i];
2495
+ tr = buildAdditionalHeaderRows(field.name, rowAttrs, colAttrs);
2496
+
2497
+ if (colAttrs.length > 0) {
2498
+ buildAdditionalRowValues(tr, colHeaderCols, field.key);
2499
+ }
2500
+
2501
+ tbody.appendChild(tr);
2502
+ }
2503
+ }
2504
+
1982
2505
  if(opts.chartOptions.table_options.show_column_total){
1983
2506
  tr = buildColTotalsHeader(rowAttrs, colAttrs);
1984
2507
  if (colAttrs.length > 0) {
1985
- buildColTotals(tr, colHeaderCols, rowAttrs, colAttrs);
2508
+ buildColTotals(tr, colHeaderCols, rowHeaderRows, rowAttrs, colAttrs);
1986
2509
  }
1987
2510
  if(opts.chartOptions.table_options.show_row_total)
1988
2511
  buildGrandTotal(tbody, tr, rowAttrs, colAttrs);
@@ -2021,11 +2544,16 @@ let initDRPivotTable = function($, window, document) {
2021
2544
  }
2022
2545
 
2023
2546
  if (tooMuch) {
2024
- resultsArr.push($('<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>'));
2547
+ 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>');
2548
+
2549
+ resultsArr.push($.pivotUtilities.errorHandling.getErrorPlaceholder(error_params) || defaultPlaceholder);
2025
2550
  } else {
2026
2551
  var tableContainer = document.createElement("div");
2027
2552
  tableContainer.className = "pivot-div";
2028
2553
  tableContainer.appendChild(result);
2554
+ if (opts.chartOptions.table_options.freeze_panes) {
2555
+ tableContainer.onscroll = handleFreezePanesScroll(selectFreezableElements(tableContainer));
2556
+ }
2029
2557
  resultsArr.push(tableContainer);
2030
2558
  }
2031
2559
 
@@ -2045,6 +2573,7 @@ let initDRPivotTable = function($, window, document) {
2045
2573
  $.pivotUtilities.getFormattedNumber = getFormattedNumber;
2046
2574
  $.pivotUtilities.sortDateStrings = sortDateStrings;
2047
2575
  $.pivotUtilities.largeToSmallSort = largeToSmallSort;
2576
+ $.pivotUtilities.largeToSmallSortByAbsolute = largeToSmallSortByAbsolute;
2048
2577
  $.pivotUtilities.getPivotDataModel = function(input, opts){ return new DRPivotData(input, opts); }
2049
2578
  $.pivotUtilities.getPivotTableFormula = function(rowData, opts, func, colFields, rowFields, aggregationDefaults, utils) {
2050
2579
  let totalStr = 'Grand Totals';
@@ -2081,7 +2610,7 @@ let initDRPivotTable = function($, window, document) {
2081
2610
  headerRow.push(colAttrs[i]);
2082
2611
  // Add row keys
2083
2612
  _.forEach(colKeys, function (keys) {
2084
- headerRow.push(utils.getHeaderValue(keys[i], colFields[i].type));
2613
+ headerRow.push(utils.getHeaderValue(keys[i], colFields[i].type, opts.dateValuesDictionary));
2085
2614
  // Calc formulas in first time
2086
2615
  if (i === 0) {
2087
2616
  colFormulas.push(utils.createKeysFormula(colFields, keys, colFormulas.length + 1, true));
@@ -2099,7 +2628,7 @@ let initDRPivotTable = function($, window, document) {
2099
2628
  // Formatting row keys
2100
2629
  let keysFormatted = [];
2101
2630
  for (let k = 0; k < rowKeys[i].length; k++) {
2102
- keysFormatted.push(utils.getHeaderValue(rowKeys[i][k], rowFields[k].type))
2631
+ keysFormatted.push(utils.getHeaderValue(rowKeys[i][k], rowFields[k].type, opts.dateValuesDictionary))
2103
2632
  }
2104
2633
  // Add row keys
2105
2634
  matrix.push(keysFormatted.concat(null));
@@ -2123,7 +2652,7 @@ let initDRPivotTable = function($, window, document) {
2123
2652
  let headerRow = [colAttrs[i]];
2124
2653
  // Add keys
2125
2654
  _.forEach(colKeys, function (keys) {
2126
- headerRow.push(utils.getHeaderValue(keys[i], colFields[i].type));
2655
+ headerRow.push(utils.getHeaderValue(keys[i], colFields[i].type, opts.dateValuesDictionary));
2127
2656
  // Calc formulas in first time
2128
2657
  if (i === 0) {
2129
2658
  colFormulas.push(utils.createKeysFormula(colFields, keys, colFormulas.length + 1, true));
@@ -2153,7 +2682,7 @@ let initDRPivotTable = function($, window, document) {
2153
2682
  // Formatting row keys
2154
2683
  let keysFormatted = [];
2155
2684
  for (let k = 0; k < rowKeys[i].length; k++) {
2156
- keysFormatted.push(utils.getHeaderValue(rowKeys[i][k], rowFields[k].type))
2685
+ keysFormatted.push(utils.getHeaderValue(rowKeys[i][k], rowFields[k].type, opts.dateValuesDictionary))
2157
2686
  }
2158
2687
  // Add row keys
2159
2688
  matrix.push(keysFormatted);