@datarailsshared/dr_renderer 1.2.45 → 1.2.49

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datarailsshared/dr_renderer",
3
- "version": "1.2.45",
3
+ "version": "1.2.49",
4
4
  "description": "DataRails charts and tables renderer",
5
5
  "keywords": [
6
6
  "datarails",
@@ -1003,6 +1003,10 @@ var DataFormatterImpl = function () {
1003
1003
 
1004
1004
  // Call function
1005
1005
  result = this.memoized[pattern].call(this, n, type);
1006
+
1007
+ if (result.value === result.pattern) {
1008
+ result.value = n;
1009
+ }
1006
1010
  }
1007
1011
  catch (e) {
1008
1012
 
@@ -384,12 +384,14 @@ let initDRPivotTable = function($, window, document) {
384
384
  pvtData.rowKeys = [];
385
385
  pvtData.colKeys = [];
386
386
  tooMuch = true;
387
+ opts.error_has_occurred = true;
388
+ opts.error_params = $.pivotUtilities.errorHandling.placeholders.tooMuchData;
387
389
  }
388
- return SubtotalRenderer(pvtData, opts, charttype, tooMuch);
390
+ return SubtotalRenderer(pvtData, opts, charttype, tooMuch, opts.error_params);
389
391
  }
390
392
  }
391
393
 
392
- SubtotalRenderer = function(pivotData, opts, charttype, tooMuch = false) {
394
+ SubtotalRenderer = function(pivotData, opts, charttype, tooMuch = false, error_params) {
393
395
  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
396
  var createTotalValsBolder, createGrandTotalBolder, getHeaderColorProperties, colorizeRowLabelHeaders, colorizeTableIfNeed, valueNoDashes, getColorsWithOffsetForTable, offsetColors, handleFreezePanesScroll, selectFreezableElements, removeRowHeaderNullValue;
395
397
  var edit_assumptions;
@@ -2132,7 +2134,9 @@ let initDRPivotTable = function($, window, document) {
2132
2134
  }
2133
2135
 
2134
2136
  if (tooMuch) {
2135
- 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>'));
2137
+ 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>');
2138
+
2139
+ resultsArr.push($.pivotUtilities.errorHandling.getErrorPlaceholder(error_params, useNewUx) || defaultPlaceholder);
2136
2140
  } else {
2137
2141
  var tableContainer = document.createElement("div");
2138
2142
  tableContainer.className = "pivot-div";
@@ -721,9 +721,9 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
721
721
  }
722
722
 
723
723
  if (to_match) {
724
- resultsArr.push($('<div class="noData"><i class="' + (useNewUx ? 'noData-image' : 'fa fa-info') + '"></i> Too much data to show</div>'));
724
+ resultsArr.push(highchartsRenderer.getWidgetPlaceholder(highchartsRenderer.widgetPlaceholders.tooMuchData));
725
725
  } else {
726
- resultsArr.push($('<div class="noData"><i class="' + (useNewUx ? 'noData-image' : 'fa fa-info') + '"></i> no data</div>'));
726
+ resultsArr.push(highchartsRenderer.getWidgetPlaceholder(highchartsRenderer.widgetPlaceholders.nodata));
727
727
  }
728
728
 
729
729
  temp_result.html(resultsArr);
@@ -731,6 +731,11 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
731
731
  return temp_result;
732
732
  };
733
733
 
734
+ highchartsRenderer.getWidgetPlaceholder = function(placeholder) {
735
+ const defaultPlaceholder = $('<div class="noData"><i class="' + (useNewUx ? 'noData-image' : 'fa fa-info') + '"></i> no data</div>');
736
+ return $.pivotUtilities.errorHandling.getErrorPlaceholder(placeholder, useNewUx) || defaultPlaceholder;
737
+ }
738
+
734
739
  highchartsRenderer.ptCreateElementAndDraw = function (chartOptions, opts) {
735
740
  if (lodash.get(opts, 'paletteOptions.widgetPalette', null)) {
736
741
  const mc_palette = lodash.find(lodash.get(opts.paletteOptions, 'monochromePalettes', []), { selected: true });
@@ -820,8 +825,12 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
820
825
 
821
826
  if (!seriesDataLength && !chartOptions.onlyText) {
822
827
  result = highchartsRenderer.getNoDataResult(chartOptions);
828
+ opts.error_has_occurred = true;
829
+ opts.error_params = highchartsRenderer.widgetPlaceholders.nodata;
823
830
  } else if (!chartOptions.onlyText && chartOptions.series && toMatch) {
824
831
  result = highchartsRenderer.getNoDataResult(chartOptions, toMatch);
832
+ opts.error_has_occurred = true;
833
+ opts.error_params = highchartsRenderer.widgetPlaceholders.tooMuchData;
825
834
  } else {
826
835
  chartOptions = highchartsRenderer.updateChartOptions(chartOptions, opts);
827
836
  chartOptions = highchartsRenderer.updateChartOptions(chartOptions, {credits: {enabled: false}});
@@ -3465,6 +3474,30 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3465
3474
  filter = (a) => a > bottomx;
3466
3475
  }
3467
3476
  break;
3477
+ case "filter_smallest":
3478
+ const smallest_sumOfFields = lodash.reduce(totals, (acc, curr) => acc += curr.sum, 0);
3479
+ const smallest = Math.floor((smallest_sumOfFields * vals[0])/100);
3480
+
3481
+ if (is_absolute)
3482
+ filter = (a) => Math.abs(a) > smallest;
3483
+ else
3484
+ filter = (a) => a > smallest;
3485
+ break;
3486
+ case "filter_largest":
3487
+ const largest_sumOfFields = lodash.reduce(totals, (acc, curr) => acc += curr.sum, 0);
3488
+ const largest = Math.floor((largest_sumOfFields * vals[0])/100);
3489
+
3490
+ if (is_absolute)
3491
+ filter = (a) => Math.abs(a) < largest;
3492
+ else
3493
+ filter = (a) => a < largest;
3494
+ break;
3495
+ case "filter_out_zero":
3496
+ if (is_absolute)
3497
+ filter = (a) => Math.abs(a) == 0;
3498
+ else
3499
+ filter = (a) => a == 0;
3500
+ break;
3468
3501
  default:
3469
3502
 
3470
3503
  }
@@ -3716,6 +3749,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3716
3749
  };
3717
3750
 
3718
3751
  highchartsRenderer.checkFreezePanesAvaliable = function (pivotView) {
3752
+ if (!pivotView || !pivotView.querySelector) {
3753
+ return;
3754
+ }
3755
+
3719
3756
  const tableContainer = pivotView.querySelector('.pivot-div');
3720
3757
  const tableHead = pivotView.querySelector('table.pvtTable thead');
3721
3758
  const tableHeadChildren = tableHead ? tableHead.children[0] : null;
@@ -3748,6 +3785,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3748
3785
  return {};
3749
3786
  }
3750
3787
 
3788
+ options.error_has_occurred = true;
3789
+ options.error_params = highchartsRenderer.widgetPlaceholders.nodata;
3751
3790
  return highchartsRenderer.getNoDataResult(options.rendererOptions);
3752
3791
  }
3753
3792
 
@@ -3756,6 +3795,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3756
3795
  return {};
3757
3796
  }
3758
3797
 
3798
+ options.error_has_occurred = true;
3799
+ options.error_params = highchartsRenderer.widgetPlaceholders.tooMuchData;
3759
3800
  return highchartsRenderer.getNoDataResult(options.rendererOptions, true);
3760
3801
  }
3761
3802
 
@@ -4674,6 +4715,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4674
4715
  return valToReturn;
4675
4716
  };
4676
4717
 
4718
+ highchartsRenderer.widgetPlaceholders = Object.assign({}, $.pivotUtilities.errorHandling.placeholders);
4719
+
4677
4720
  highchartsRenderer.suboptions = {
4678
4721
  'default_show': {
4679
4722
  category_class: 'google-visualization-charteditor-mini-more',
package/src/pivottable.js CHANGED
@@ -7,7 +7,7 @@ let initPivotTable = function($, window, document) {
7
7
  /*
8
8
  Utilities
9
9
  */
10
- var PivotData, addSeparators, aggregatorTemplates, aggregators, dayNamesEn, derivers, getSort, locales, mthNamesEn, naturalSort, numberFormat, pivotTableRenderer, rd, renderers, rx, rz, sortAs, usFmt, usFmtInt, usFmtPct, zeroPad;
10
+ var PivotData, addSeparators, aggregatorTemplates, aggregators, dayNamesEn, derivers, getSort, locales, mthNamesEn, naturalSort, numberFormat, pivotTableRenderer, rd, renderers, rx, rz, sortAs, usFmt, usFmtInt, usFmtPct, zeroPad, errorHandling;
11
11
  addSeparators = function(nStr, thousandsSep, decimalSep) {
12
12
  var rgx, x, x1, x2;
13
13
  nStr += '';
@@ -610,6 +610,47 @@ let initPivotTable = function($, window, document) {
610
610
  }
611
611
  return naturalSort;
612
612
  };
613
+ errorHandling = {
614
+ placeholders: {
615
+ nodata: {
616
+ title: 'No Data Available',
617
+ text: 'This might happen because of a global filter or a change in the underlying data',
618
+ btnText: '',
619
+ class: 'nodata',
620
+ },
621
+ noPermission: {
622
+ title: 'No Permission',
623
+ text: 'You do not have permission to view the data',
624
+ btnText: 'Request Permission',
625
+ class: 'no-permission',
626
+ },
627
+ tooMuchData: {
628
+ title: 'There is too much data. Please edit this widget',
629
+ text: '',
630
+ btnText: 'Edit Widget',
631
+ class: 'too-much-data',
632
+ },
633
+ noPublishItem: {
634
+ title: 'We can’t find the published item in the source file',
635
+ text: '',
636
+ btnText: 'Go to filebox',
637
+ class: 'no-publish-item',
638
+ },
639
+ },
640
+ getErrorPlaceholder: function(placeholder, useNewUx = true) {
641
+ if (placeholder && typeof placeholder === 'object') {
642
+ return $(`
643
+ <div class="noData">
644
+ <div class="noData-title">${placeholder.title}</div>
645
+ <i class="noData-image ${useNewUx ? placeholder.class : 'fa fa-info'}"></i>
646
+ <div class="noData-text">${placeholder.text}</div>
647
+ <div class="noData-error-action"></div>
648
+ </div>
649
+ `);
650
+ }
651
+ return null;
652
+ },
653
+ };
613
654
 
614
655
  /*
615
656
  Data Model class
@@ -890,7 +931,8 @@ let initPivotTable = function($, window, document) {
890
931
  naturalSort: naturalSort,
891
932
  numberFormat: numberFormat,
892
933
  sortAs: sortAs,
893
- PivotData: PivotData
934
+ PivotData: PivotData,
935
+ errorHandling: errorHandling,
894
936
  };
895
937
 
896
938
  /*