@datarailsshared/dr_renderer 1.2.208 → 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.208",
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": {
@@ -1339,15 +1343,11 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1339
1343
  return chart_series;
1340
1344
  }
1341
1345
 
1342
- highchartsRenderer.ptCreateWaterfallBreakdownSeries = function (pivotData, onlyNumbers, additionOptions, opts) {
1346
+ highchartsRenderer.ptCreateWaterfallBreakdownSeries = function (pivotData, additionOptions, opts) {
1343
1347
  const colorOptions = opts.breakdown_options.colors;
1344
- var chart_series = [],
1345
- row_n_keys = pivotData.getRowKeys(),
1346
- col_n_keys = pivotData.getColKeys();
1347
-
1348
- if (row_n_keys.length === 0) {
1349
- row_n_keys.push([]);
1350
- }
1348
+ const chart_series = [];
1349
+ const row_n_keys = pivotData.getRowKeys();
1350
+ const col_n_keys = pivotData.getColKeys();
1351
1351
 
1352
1352
  let resultObject = {
1353
1353
  data: [],
@@ -1363,61 +1363,48 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1363
1363
  };
1364
1364
  resultObject = highchartsRenderer.getDataLabelsOptions(additionOptions, resultObject);
1365
1365
 
1366
- const breakdownValues = [];
1367
1366
  lodash.forEach(col_n_keys, function(col_n_value, col_index) {
1368
- breakdownValues.push([]);
1369
- lodash.forEach(row_n_keys, function (row_n_value, row_index) {
1370
- var agg = pivotData.getAggregator(row_n_value, col_n_value);
1371
- var val = agg.value();
1372
-
1373
- if (val != null && $.isNumeric(val)) {
1374
- val = parseFloat(val);
1375
- } else if (onlyNumbers) {
1376
- val = NaN;
1377
- } else {
1378
- val = 0;
1379
- }
1380
1367
 
1381
- breakdownValues[col_index][row_index] = val;
1368
+ const totalColumnValue = pivotData.getAggregator([], col_n_value).value();
1369
+ const nextTotalColumnKey = col_n_keys[col_index + 1];
1370
+ const nextTotalColumnValue = nextTotalColumnKey ? pivotData.getAggregator([], nextTotalColumnKey).value() : null;
1371
+ resultObject.data.push({
1372
+ y: totalColumnValue,
1373
+ name: lodash.unescape(col_n_value).replace('DR_Others', highchartsRenderer.getOthersName(opts)),
1374
+ isSum: !!col_index,
1375
+ isTotal: true,
1376
+ color: colorOptions.total,
1377
+ });
1382
1378
 
1383
- if (col_index) {
1384
- const value = val - breakdownValues[col_index - 1][row_index];
1379
+ if (col_index !== col_n_keys.length - 1) {
1380
+ lodash.forEach(row_n_keys, function (row_n_value) {
1381
+ const agg = pivotData.getAggregator(row_n_value, col_n_value);
1382
+ let val = agg.value();
1385
1383
 
1386
- if (value) {
1387
- var tmoobj = {};
1388
- var key = row_n_value;
1389
- if (lodash.isArray(row_n_value)) {
1390
- key = row_n_value[0];
1391
- }
1384
+ val = $.isNumeric(val) ? parseFloat(val) : 0;
1385
+ if (val) {
1386
+ const tmoobj = {};
1387
+ const key = lodash.isArray(row_n_value) ? row_n_value[0] : row_n_value;
1392
1388
  tmoobj.name = lodash.unescape(key);
1393
-
1389
+
1394
1390
  if (tmoobj.name) {
1395
1391
  tmoobj.name = tmoobj.name.replace('DR_Others', highchartsRenderer.getOthersName(opts));
1396
1392
  }
1397
-
1398
1393
  if (lodash.isEmpty(String(tmoobj.name))) {
1399
1394
  tmoobj.name = lodash.unescape(col_n_value);
1400
1395
  tmoobj.visible = false;
1401
1396
  }
1402
- tmoobj.y = value;
1397
+
1398
+ tmoobj.y = val;
1403
1399
  tmoobj.colKeys = [lodash.unescape(col_n_keys[col_index - 1]), lodash.unescape(col_n_value)];
1404
1400
  resultObject.data.push(tmoobj);
1405
1401
  }
1406
- }
1407
- });
1408
1402
 
1409
- const totalValueAgg = pivotData.getAggregator([], col_n_value);
1410
- resultObject.data.push({
1411
- y: totalValueAgg.value(),
1412
- name: lodash.unescape(col_n_value).replace('DR_Others', highchartsRenderer.getOthersName(opts)),
1413
- isSum: !!col_index,
1414
- isTotal: true,
1415
- color: colorOptions.total,
1416
- });
1403
+ });
1404
+ }
1417
1405
  });
1418
1406
 
1419
1407
  chart_series.push(resultObject);
1420
-
1421
1408
  opts.chart_series = [];
1422
1409
  if (!lodash.isEqual(row_n_keys, EMPTY_ROW_N_KEYS)) {
1423
1410
  chart_series.forEach(series => {
@@ -3191,6 +3178,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3191
3178
  ? opts.chartOptions
3192
3179
  : highchartsRenderer.getDefaultValueForChart(highchartsRenderer.CHART_TYPES.WATERFALL_BREAKDOWN);
3193
3180
 
3181
+ pivotData.colKeys = lodash.map(lodash.keys(pivotData.colTotals), key => [key]);
3182
+
3194
3183
  chartOptions.chart = {
3195
3184
  type: 'waterfall',
3196
3185
  zoomType: additionOptions && additionOptions.chart && additionOptions.chart.zoom_type ? additionOptions.chart.zoom_type : 'None',
@@ -3241,7 +3230,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3241
3230
  chartOptions.colors = opts.paletteOptions.dashboardPalette.colors;
3242
3231
  }
3243
3232
  chartOptions.series = highchartsRenderer
3244
- .ptCreateWaterfallBreakdownSeries(pivotData, null, additionOptions, opts);
3233
+ .ptCreateWaterfallBreakdownSeries(pivotData, additionOptions, opts);
3245
3234
 
3246
3235
  chartOptions = highchartsRenderer.prepareAxisX(chartOptions, additionOptions, pivotData.getColKeys());
3247
3236
  chartOptions.plotOptions = {
@@ -4966,12 +4955,28 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4966
4955
  }
4967
4956
  });
4968
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
+
4969
4970
  // fill rows fields
4970
- lodash.forEach(widgetOptions.rows, function (valObj) {
4971
- fieldOb = lodash.find(fields, {id: valObj.id});
4972
- if (fieldOb) {
4973
- legendFields.push(fieldOb);
4974
- 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
+ }
4975
4980
  }
4976
4981
  });
4977
4982
 
@@ -7939,7 +7944,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
7939
7944
  };
7940
7945
 
7941
7946
  highchartsRenderer.createDateFromString = function (dateString, format) {
7942
- if ((format && !highchartsRenderer.isDateFormat(dateString, format)) || !highchartsRenderer.isDate(dateString)) {
7947
+ if (!(format && highchartsRenderer.isDateFormat(dateString, format) || highchartsRenderer.isDate(dateString))) {
7943
7948
  return null;
7944
7949
  }
7945
7950
  const utcDate = format
@@ -8093,6 +8098,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8093
8098
  filter.is_excluded = false;
8094
8099
  } else {
8095
8100
  filter = highchartsRenderer.createDrillDownFilterObject(widget, widget.cols[0], colKey[0]);
8101
+ filters.push(filter);
8096
8102
  }
8097
8103
  filter.values = [];
8098
8104
  for (let i = 0; i < colKey.length; i++) {
@@ -8695,7 +8701,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8695
8701
  rows = [];
8696
8702
  } else {
8697
8703
  rows = cols;
8698
- cols = [];
8704
+ cols = [point.colKeys[1]];
8699
8705
  }
8700
8706
  return { rows, cols };
8701
8707
  }
@@ -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
+ }