@datarailsshared/dr_renderer 1.2.58 → 1.2.62

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.58",
3
+ "version": "1.2.62",
4
4
  "description": "DataRails charts and tables renderer",
5
5
  "keywords": [
6
6
  "datarails",
@@ -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 && key[0] === 'DR_Average') {
131
+ totals[flatKey].push(record);
132
+ }
133
+ if (containsOthers && 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);
@@ -203,13 +213,18 @@ let initDRPivotTable = function($, window, document) {
203
213
  var colKey, fColKey, fRowKey, flatColKey, flatRowKey, i, j, k, m, n, ref, results, rowKey;
204
214
  rowKey = [];
205
215
  colKey = [];
206
- this.allTotal.push(record);
207
- rowKey = processKey(record, this.rowTotals, this.rowKeys, this.rowAttrs, (function(_this) {
216
+ const recordValues = Object.values(record);
217
+ const containsAverage = recordValues.includes('DR_Average');
218
+ const containsOthers = recordValues.includes('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) {
208
223
  return function(key) {
209
224
  return _this.aggregator(_this, key, []);
210
225
  };
211
226
  })(this));
212
- 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) {
213
228
  return function(key) {
214
229
  return _this.aggregator(_this, [], key);
215
230
  };
@@ -1194,6 +1209,9 @@ let initDRPivotTable = function($, window, document) {
1194
1209
  if (opts.chartOptions.table_options.hide_nulls_in_headers) {
1195
1210
  th.textContent = th.textContent.replace('[null]', '');
1196
1211
  }
1212
+ if (th.textContent === 'DR Others') {
1213
+ th.textContent = _.get(opts, "total_value_options.filter_options.filteredOutFieldName") || 'Others'
1214
+ }
1197
1215
 
1198
1216
  if (th.hasAttribute('data_show_more') && th.colSpan > 0 && !hasColLabels) {
1199
1217
  th.colSpan = th.colSpan - 1;
@@ -917,8 +917,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
917
917
  let xySum = 0;
918
918
  let squareXSum = 0;
919
919
  ob.data = [];
920
- if (row_n_value && row_n_value.length > 0)
921
- ob.name = row_n_value.join(highchartsRenderer.delimer);
920
+ if (row_n_value && row_n_value.length > 0) {
921
+ let othersName = lodash.get(opts, "total_value_options.filter_options.filteredOutFieldName") || 'Others';
922
+ ob.name = row_n_value.join(highchartsRenderer.delimer).replace('DR_Others', othersName);
923
+ }
922
924
 
923
925
  lodash.forEach(col_n_keys, function (col_n_value, index) {
924
926
  var agg = pivotData.getAggregator(row_n_value, col_n_value);
@@ -1056,8 +1058,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1056
1058
  let squareXSum = 0;
1057
1059
  var ob = {};
1058
1060
  ob.data = [];
1059
- if (row_n_value && row_n_value.length > 0)
1060
- ob.name = lodash.unescape(row_n_value.join(highchartsRenderer.delimer));
1061
+ if (row_n_value && row_n_value.length > 0) {
1062
+ let othersName = lodash.get(opts, "total_value_options.filter_options.filteredOutFieldName") || 'Others';
1063
+ ob.name = lodash.unescape(row_n_value.join(highchartsRenderer.delimer).replace('DR_Others', othersName));
1064
+ }
1061
1065
 
1062
1066
  ob.dataLabels = {
1063
1067
  allowOverlap: additionOptions && additionOptions.label ? additionOptions.label.overlap : false,
@@ -1176,6 +1180,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1176
1180
  }
1177
1181
 
1178
1182
  totalSeries.yAxis = opts.totalSeriesSettings.secondaryAxis ? 1 : undefined;
1183
+ } else if (chartType === 'combo-column-chart' || chartType === 'combo-stacked-chart') {
1184
+ totalSeries.type = 'column';
1179
1185
  }
1180
1186
  totalSeries.name = 'Total';
1181
1187
  totalSeries.data = [];
@@ -4997,7 +5003,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4997
5003
  return valToReturn;
4998
5004
  };
4999
5005
 
5000
- highchartsRenderer.widgetPlaceholders = Object.assign({}, $.pivotUtilities.errorHandling.placeholders);
5006
+ highchartsRenderer.widgetPlaceholders = lodash.assign({}, $.pivotUtilities.errorHandling.placeholders);
5001
5007
 
5002
5008
  highchartsRenderer.suboptions = {
5003
5009
  'default_show': {
@@ -7141,7 +7147,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
7141
7147
  return data_row[field_with_variant.name] == variance_config.name && data_row[field_for_sorting.name] != undefined;
7142
7148
  });
7143
7149
 
7144
- const sorting_variance = widget.options.total_value_options.sorting_variance === '' ? 'asc' : 'desc';
7150
+ const sorting_variance = widget.options.total_value_options && widget.options.total_value_options.sorting_variance === '' ? 'asc' : 'desc';
7145
7151
 
7146
7152
  if (widget.options.chartOptions.delta_column.sort_by_absolute_variance) {
7147
7153
  data_sorted = lodash.sortBy(data_sorted, function (o) {