@datarailsshared/dr_renderer 1.2.67 → 1.2.71

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.67",
3
+ "version": "1.2.71",
4
4
  "description": "DataRails charts and tables renderer",
5
5
  "keywords": [
6
6
  "datarails",
@@ -127,10 +127,10 @@ let initDRPivotTable = function($, window, document) {
127
127
  }
128
128
 
129
129
  if (containsAverage || containsOthers) {
130
- if (containsAverage && key[0] === 'DR_Average') {
130
+ if (containsAverage && !containsOthers && key[0] === 'DR_Average') {
131
131
  totals[flatKey].push(record);
132
132
  }
133
- if (containsOthers && key[0] === 'DR_Others') {
133
+ if (containsOthers && !containsAverage && key[0] === 'DR_Others') {
134
134
  totals[flatKey].push(record);
135
135
  }
136
136
  } else {
@@ -487,7 +487,7 @@ let initDRPivotTable = function($, window, document) {
487
487
  var createTotalValsBolder, createGrandTotalBolder, getHeaderColorProperties, colorizeRowLabelHeaders, colorizeTableIfNeed, valueNoDashes, getColorsWithOffsetForTable, offsetColors, handleFreezePanesScroll, selectFreezableElements, removeRowHeaderNullValue;
488
488
  var getAdditionalAggregation, buildAdditionalHeaderCols, buildAdditionalHeaderRows, buildAdditionalColValues, buildAdditionalRowValues, buildAdditionalRowTotals, buildAdditionalColTotals;
489
489
  var additionalFieldsCol, additionalFieldsRow, additionalFieldsList;
490
- var edit_assumptions;
490
+ var edit_assumptions, getExistingAggregator;
491
491
 
492
492
  var horizontalFreezePaneClass = opts.chartOptions.table_options.freeze_panes ? ' horizontal-freeze-pane' : '';
493
493
  var verticalFreezePaneClass = opts.chartOptions.table_options.freeze_panes ? ' vertical-freeze-pane' : '';
@@ -1355,14 +1355,11 @@ let initDRPivotTable = function($, window, document) {
1355
1355
  }
1356
1356
 
1357
1357
  buildAdditionalRowValues = function (tr, colHeaderCols, rowKey) {
1358
- let totalRowValue = 0;
1359
-
1360
1358
  for (let i = 0; i < colHeaderCols.length; i++) {
1361
1359
  const colKey = colHeaderCols[i].flatKey;
1362
1360
  const totalAggregator = getAdditionalAggregation(rowKey, colKey);
1363
1361
  const val = totalAggregator.value();
1364
1362
  const formattedValue = getFormattedNumber(val, totalAggregator, opts)
1365
- totalRowValue += +formattedValue;
1366
1363
 
1367
1364
  let className = " col" + i + " colcol" + 0;
1368
1365
  const td = createElement("td", className, formattedValue, {
@@ -1374,46 +1371,73 @@ let initDRPivotTable = function($, window, document) {
1374
1371
  tr.appendChild(td);
1375
1372
  }
1376
1373
 
1374
+ if (additionalFieldsCol.length) {
1375
+ for (let i = 0; i < additionalFieldsCol.length; i++) {
1376
+ const totalAggregator = getAdditionalAggregation(rowKey, additionalFieldsCol[i].key);
1377
+ const val = totalAggregator.value();
1378
+ const formattedValue = getFormattedNumber(val, totalAggregator, opts)
1379
+
1380
+ let className = " col" + i + " colcol" + 0;
1381
+ const td = createElement("td", className, formattedValue, {
1382
+ "data-value": val,
1383
+ "data-for": "col" + 0,
1384
+ "data-colnode": "" + i
1385
+ });
1386
+
1387
+ tr.appendChild(td);
1388
+ }
1389
+ }
1390
+
1377
1391
  if(opts.chartOptions.table_options.show_row_total) {
1378
- buildAdditionalRowTotals(tr, totalRowValue)
1392
+ buildAdditionalRowTotals(tr, rowKey)
1379
1393
  }
1380
1394
  }
1381
1395
 
1382
- buildAdditionalRowTotals = function (tr, totalRowValue) {
1383
- let style = "pvtTotal pvtAddFiled rowTotal";
1396
+ buildAdditionalRowTotals = function (tr, rowKey) {
1397
+ const totalAggregator = getExistingAggregator(rowTotals, rowKey);
1398
+ const value = totalAggregator.value();
1399
+ const formattedValue = getFormattedNumber(value, totalAggregator, opts)
1384
1400
 
1385
- const td = createElement("td", style, totalRowValue, {
1386
- "data-value": totalRowValue
1401
+ let style = "pvtTotal pvtAddFiled rowTotal";
1402
+ const td = createElement("td", style, formattedValue, {
1403
+ "data-value": value
1387
1404
  });
1388
1405
 
1389
1406
  tr.appendChild(td);
1390
1407
  }
1391
1408
 
1392
1409
  buildAdditionalColTotals = function (tr, rowHeaderRows, colKey, colHeader) {
1393
- let othersVal = 0;
1394
- let val;
1395
-
1396
- for (let i = 0; i < rowHeaderRows.length; i++) {
1397
- const rowKey = rowHeaderRows[i].flatKey;
1398
- const totalAggregator = getAdditionalAggregation(rowKey, colKey);
1399
- val = totalAggregator.value();
1400
-
1401
- othersVal += +getFormattedNumber(val, totalAggregator, opts);
1402
- }
1410
+ const totalAggregator = getExistingAggregator(colTotals, colKey)
1411
+ const value = totalAggregator.value();
1412
+ const formattedValue = getFormattedNumber(value, totalAggregator, opts);
1403
1413
 
1404
1414
  let style = "pvtTotal pvtAddField colTotal";
1405
1415
  style += " col" + colHeader.row + " colcol" + colHeader.col;
1406
1416
 
1407
- const td = createElement("td", style, othersVal, {
1408
- "data-value": othersVal,
1417
+ const td = createElement("td", style, formattedValue, {
1418
+ "data-value": value,
1409
1419
  "data-rowcol": "col" + colHeader.col,
1410
1420
  "data-rownode": "" + colHeader.node
1411
- }, getTableEventHandlers(othersVal, [], colHeader.key));
1412
-
1421
+ }, getTableEventHandlers(value, [], colHeader.key));
1413
1422
 
1414
1423
  return td;
1415
1424
  }
1416
1425
 
1426
+ getExistingAggregator = function (aggregator, key) {
1427
+ if (!aggregator[key]) {
1428
+ return {
1429
+ value: (function () {
1430
+ return null;
1431
+ }),
1432
+ format: function () {
1433
+ return "";
1434
+ }
1435
+ };
1436
+ }
1437
+
1438
+ return aggregator[key];
1439
+ }
1440
+
1417
1441
  buildValues = function(rowHeaderRows, colHeaderCols, rowAttrs, colAttrs) {
1418
1442
  var aggregator, colHeader, eventHandlers, flatColKey, flatRowKey, isColSubtotal, isRowSubtotal, k, l, len, len1, ref8, results, rowHeader, style, td, totalAggregator, tr, val;
1419
1443
 
@@ -917,6 +917,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
917
917
  const n = col_n_keys.length;
918
918
  const xSum = (1 + n) / 2 * n;
919
919
  const trendSerieses = [];
920
+ const othersName = lodash.get(opts, "total_value_options.filter_options.filteredOutFieldName") || 'Others';
920
921
 
921
922
  lodash.forEach(row_n_keys, function (row_n_value) {
922
923
  var ob = {};
@@ -925,7 +926,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
925
926
  let squareXSum = 0;
926
927
  ob.data = [];
927
928
  if (row_n_value && row_n_value.length > 0) {
928
- let othersName = lodash.get(opts, "total_value_options.filter_options.filteredOutFieldName") || 'Others';
929
929
  ob.name = row_n_value.join(highchartsRenderer.delimer).replace('DR_Others', othersName);
930
930
  }
931
931
 
@@ -933,6 +933,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
933
933
  var agg = pivotData.getAggregator(row_n_value, col_n_value);
934
934
  var val = agg.value();
935
935
 
936
+ if (col_n_value[0] === 'DR_Others') {
937
+ col_n_value[0] = othersName;
938
+ }
939
+
936
940
  if (isUniqueVals && agg.uniq)
937
941
  val = agg.uniq.join('<br>');
938
942
 
@@ -1059,6 +1063,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1059
1063
  const n = col_n_keys.length;
1060
1064
  const xSum = (1 + n) / 2 * n;
1061
1065
  const trendSerieses = [];
1066
+ const othersName = lodash.get(opts, "total_value_options.filter_options.filteredOutFieldName") || 'Others';
1062
1067
 
1063
1068
  lodash.forEach(row_n_keys, function (row_n_value) {
1064
1069
  let ySum = 0;
@@ -1067,7 +1072,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1067
1072
  var ob = {};
1068
1073
  ob.data = [];
1069
1074
  if (row_n_value && row_n_value.length > 0) {
1070
- let othersName = lodash.get(opts, "total_value_options.filter_options.filteredOutFieldName") || 'Others';
1071
1075
  ob.name = lodash.unescape(row_n_value.join(highchartsRenderer.delimer).replace('DR_Others', othersName));
1072
1076
  }
1073
1077
 
@@ -1105,6 +1109,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1105
1109
  }
1106
1110
  tmoobj.name = lodash.unescape(key);
1107
1111
 
1112
+ if (tmoobj.name) {
1113
+ tmoobj.name = tmoobj.name.replace('DR_Others', othersName);
1114
+ }
1115
+
1108
1116
  if (lodash.isEmpty(String(tmoobj.name))) {
1109
1117
  tmoobj.name = "[blank]";
1110
1118
  }
@@ -2007,7 +2015,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
2007
2015
  };
2008
2016
 
2009
2017
  highchartsRenderer.setTitleAndSubTitle = function (chartOptions, opts, additionOptions) {
2010
- chartOptions.title = opts.chartOptions.hideChartHeader ? { text: '' } : {
2018
+ chartOptions.title = opts.chartOptions.hideChartHeader ? null : {
2011
2019
  align: 'center',
2012
2020
  text: opts && opts.chart_title ? opts.chart_title : "",
2013
2021
  style: {