@datarailsshared/dr_renderer 1.2.209 → 1.2.210-dragons

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.209",
3
+ "version": "1.2.210-dragons",
4
4
  "description": "DataRails charts and tables renderer",
5
5
  "keywords": [
6
6
  "datarails",
@@ -2421,8 +2421,14 @@ let initDRPivotTable = function($, window, document) {
2421
2421
  if (colAttrs.length > 0 && colKeys.length > 0) {
2422
2422
  colHeaders = processKeys(colKeys, "pvtColLabel", 'cols', colAttrs);
2423
2423
  }
2424
- var tableClasses = useNewUx && opts.chartOptions.table_options.use_new_table_design ? 'pvtTable newPvtTable' : 'pvtTable';
2425
- 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, {
2426
2432
  style: "display: none;"
2427
2433
  });
2428
2434
 
@@ -87,6 +87,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
87
87
  EXCEL_VIEWER: 'excel_viewer',
88
88
  };
89
89
 
90
+ highchartsRenderer.VIRTUAL_FIELDS = {
91
+ WATERFALL_VARIANCE: 'DR_WATERFALL_VARIANCE',
92
+ };
93
+
90
94
  highchartsRenderer.highcharts_theme = {
91
95
  "colors": highchartsRenderer.defaults_colors,
92
96
  "chart": {
@@ -1344,7 +1348,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1344
1348
  const chart_series = [];
1345
1349
  const row_n_keys = pivotData.getRowKeys();
1346
1350
  const col_n_keys = pivotData.getColKeys();
1347
- const hasBreakdownValues = lodash.get(opts, 'breakdown_options.values.breakdown.length');
1348
1351
 
1349
1352
  let resultObject = {
1350
1353
  data: [],
@@ -1376,9 +1379,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1376
1379
  if (col_index !== col_n_keys.length - 1) {
1377
1380
  lodash.forEach(row_n_keys, function (row_n_value) {
1378
1381
  const agg = pivotData.getAggregator(row_n_value, col_n_value);
1379
- let val = hasBreakdownValues
1380
- ? agg.value()
1381
- : nextTotalColumnValue - totalColumnValue;
1382
+ let val = agg.value();
1382
1383
 
1383
1384
  val = $.isNumeric(val) ? parseFloat(val) : 0;
1384
1385
  if (val) {
@@ -1398,12 +1399,12 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1398
1399
  tmoobj.colKeys = [lodash.unescape(col_n_keys[col_index - 1]), lodash.unescape(col_n_value)];
1399
1400
  resultObject.data.push(tmoobj);
1400
1401
  }
1402
+
1401
1403
  });
1402
1404
  }
1403
1405
  });
1404
1406
 
1405
1407
  chart_series.push(resultObject);
1406
-
1407
1408
  opts.chart_series = [];
1408
1409
  if (!lodash.isEqual(row_n_keys, EMPTY_ROW_N_KEYS)) {
1409
1410
  chart_series.forEach(series => {
@@ -4954,12 +4955,28 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4954
4955
  }
4955
4956
  });
4956
4957
 
4958
+ // add virtual fields to rows if required
4959
+ let rows = widgetOptions.rows;
4960
+ if (!lodash.get(widgetOptions, 'rows.length') && widgetOptions.options.breakdown_options) {
4961
+ rows = [
4962
+ {
4963
+ id: -1,
4964
+ name: highchartsRenderer.VIRTUAL_FIELDS.WATERFALL_VARIANCE,
4965
+ type: 'Text',
4966
+ },
4967
+ ];
4968
+ }
4969
+
4957
4970
  // fill rows fields
4958
- lodash.forEach(widgetOptions.rows, function (valObj) {
4959
- fieldOb = lodash.find(fields, {id: valObj.id});
4960
- if (fieldOb) {
4961
- legendFields.push(fieldOb);
4962
- lodash.remove(fields, {id: fieldOb.id});
4971
+ lodash.forEach(rows, function (valObj) {
4972
+ if (lodash.includes(highchartsRenderer.VIRTUAL_FIELDS, valObj.name)) {
4973
+ legendFields.push(valObj);
4974
+ } else {
4975
+ fieldOb = lodash.find(fields, {id: valObj.id});
4976
+ if (fieldOb) {
4977
+ legendFields.push(fieldOb);
4978
+ lodash.remove(fields, {id: fieldOb.id});
4979
+ }
4963
4980
  }
4964
4981
  });
4965
4982
 
@@ -7927,7 +7944,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
7927
7944
  };
7928
7945
 
7929
7946
  highchartsRenderer.createDateFromString = function (dateString, format) {
7930
- if ((format && !highchartsRenderer.isDateFormat(dateString, format)) || !highchartsRenderer.isDate(dateString)) {
7947
+ if (!(format && highchartsRenderer.isDateFormat(dateString, format) || highchartsRenderer.isDate(dateString))) {
7931
7948
  return null;
7932
7949
  }
7933
7950
  const utcDate = format
@@ -8081,6 +8098,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8081
8098
  filter.is_excluded = false;
8082
8099
  } else {
8083
8100
  filter = highchartsRenderer.createDrillDownFilterObject(widget, widget.cols[0], colKey[0]);
8101
+ filters.push(filter);
8084
8102
  }
8085
8103
  filter.values = [];
8086
8104
  for (let i = 0; i < colKey.length; i++) {
@@ -28,8 +28,6 @@ let initNovixRenderer = function($, window, document, Handsontable){
28
28
  const delim = " , ";
29
29
  const subtotal = "subtotalDatarailsPlaceholder";
30
30
  const replaceValue = "SubTotals";
31
- const useNewUx = document.ReportHippo && document.ReportHippo && document.ReportHippo.user &&
32
- document.ReportHippo.user.organization.settings && document.ReportHippo.user.organization.settings.use_new_ux;
33
31
 
34
32
  $.pivotUtilities.novix_renderers = {
35
33
 
@@ -889,9 +887,14 @@ let initNovixRenderer = function($, window, document, Handsontable){
889
887
 
890
888
  // inject the widgetId to the class name so we can separate the tables by it
891
889
  // look for the search side on line 653 "opts.$el.find(".widget-id-" + opts.widgetId);"
892
- return `<div class='novixPivot widget-id-${opts.widgetId} ${
893
- useNewUx && opts.chartOptions.table_options.use_new_table_design ? 'handsontable-new' : ''
894
- }' style='overflow:auto'></div>`;
890
+ var tableClasses = ['novixPivot', `widget-id-${opts.widgetId}`];
891
+ if (opts.chartOptions.table_options.use_new_table_design) {
892
+ tableClasses.push('handsontable-new');
893
+ }
894
+ if (!pvtData.aggregator().uniq) {
895
+ tableClasses.push('numbers-to-right');
896
+ }
897
+ return `<div class='${tableClasses.join(' ')}' style='overflow:auto'></div>`;
895
898
  }
896
899
 
897
900
  };
package/src/pivot.css CHANGED
@@ -29,9 +29,6 @@ table.pvtTable tbody tr th > i {
29
29
  font-size: 10px;
30
30
  }
31
31
 
32
- table.pvtTable .pvtColLabel {text-align: center;}
33
- table.pvtTable .pvtTotalLabel {text-align: right;}
34
-
35
32
  table.pvtTable tbody tr td {
36
33
  color: #3D3D3D;
37
34
  padding: 5px;
@@ -263,11 +260,6 @@ table.pvtTable.newPvtTable tbody tr td.rowTotal {
263
260
  background-color: #dfe6ec !important;
264
261
  border-color: #ffffff !important;
265
262
  }
266
- table.pvtTable.newPvtTable .pvtColLabel,
267
- table.pvtTable.newPvtTable .pvtTotalLabel,
268
- table.pvtTable.newPvtTable .pvtTotalLabel.rowTotal {
269
- text-align: left;
270
- }
271
263
 
272
264
  table.pvtTable.newPvtTable tbody tr th .fa {
273
265
  padding: 2px;
@@ -408,3 +400,27 @@ table.pvtTable.newPvtTable tbody tr td:hover:after {
408
400
  top: 4px;
409
401
  font-size: 12px;
410
402
  }
403
+
404
+
405
+ /* Table cells alignment */
406
+ table.pvtTable .pvtColLabel {text-align: center;}
407
+ table.pvtTable .pvtTotalLabel {text-align: right;}
408
+
409
+ table.pvtTable.newPvtTable .pvtColLabel,
410
+ table.pvtTable.newPvtTable .pvtTotalLabel,
411
+ table.pvtTable.newPvtTable .pvtTotalLabel.rowTotal {
412
+ text-align: left;
413
+ }
414
+
415
+ table.pvtTable thead tr th.pvtColLabel,
416
+ table.pvtTable thead tr th.pvtTotalLabel {
417
+ text-align: center !important;
418
+ }
419
+
420
+ table.pvtTable.numbers-to-right tbody tr td.pvtVal,
421
+ table.pvtTable.numbers-to-right tbody tr td.rowTotal.rowTotal,
422
+ table.pvtTable.numbers-to-right tbody tr td.pvtGrandTotal {
423
+ text-align: right !important;
424
+ padding-right: 9px;
425
+ line-height: 15px;
426
+ }