@datarailsshared/dr_renderer 1.4.105 → 1.4.112

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.4.105",
3
+ "version": "1.4.112",
4
4
  "description": "DataRails charts and tables renderer",
5
5
  "keywords": [
6
6
  "datarails",
@@ -177,7 +177,7 @@ let initDRPivotTable = function($, window, document) {
177
177
  return keys.join(delim);
178
178
  }
179
179
 
180
- DRPivotData.prototype.processRecord = function(record) {
180
+ DRPivotData.prototype.processRecord = function(record, isSmartQueriesEnabled) {
181
181
  if (!this.notFirst) {
182
182
  this.keysLength = _.filter(_.keys(record), key => !_.includes(['data_types', 'formats', 'values_formats'], key)).length - 1;
183
183
  this.notFirst = true;
@@ -211,7 +211,9 @@ let initDRPivotTable = function($, window, document) {
211
211
  if (!colKey.length && !rowKey.length) {
212
212
  this.allTotal.push(record);
213
213
  } else if (!colKey.length && rowKey.length) {
214
- if (!this.rowTotals[flatRowKey]) {
214
+ if (!this.rowTotals[flatRowKey] && !(record['Scenario Cycle']
215
+ && isSmartQueriesEnabled
216
+ && (record['Scenario'] === 'SQ_Actuals' || record['Scenario'] === 'Forecast'))) {
215
217
  this.rowTotals[flatRowKey] = getRowAggregator(rowKey.slice());
216
218
  this.rowTotals[flatRowKey].push(record);
217
219
  }
@@ -5308,7 +5308,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
5308
5308
  break;
5309
5309
  }
5310
5310
  options.comboOptions.seriesOptions.push(deltaColumnSeries);
5311
- options.comboOptions.secondaryAxisSettings.name = options.chartOptions.delta_column.name.replace('_', '');
5312
5311
  options.comboOptions.secondaryAxisSettings.is_percentage = options.chartOptions.delta_column.is_percentage;
5313
5312
  }
5314
5313
  };
package/src/pivottable.js CHANGED
@@ -641,6 +641,7 @@ let initPivotTable = function($, window, document) {
641
641
  this.filter = (ref9 = opts.filter) != null ? ref9 : (function() {
642
642
  return true;
643
643
  });
644
+ this.isSmartQueriesEnabled = opts.rendererOptions?.chartOptions?.isSmartQueriesEnabled || false;
644
645
  this.tree = {};
645
646
 
646
647
  this.isKeysSortingDoneOnBackendSide = opts.keysObject && typeof opts.keysObject === 'object' && helpers.backendSortingKeysAreNotEmpty(opts.keysObject);
@@ -670,7 +671,7 @@ let initPivotTable = function($, window, document) {
670
671
  PivotData.forEachRecord(this.input, this.derivedAttributes, (function(_this) {
671
672
  return function(record) {
672
673
  if (_this.filter(record)) {
673
- return _this.processRecord(record);
674
+ return _this.processRecord(record, _this.isSmartQueriesEnabled);
674
675
  }
675
676
  };
676
677
  })(this));
@@ -25,8 +25,7 @@ function createSingleDataSeriesForForecast(chart_series, chartOptions, pivotData
25
25
 
26
26
  function buildChartSeriesFromPivotInputOnly(input, actuals, forecast, midMonthOffset, name) {
27
27
  const filtered = input.filter(item =>
28
- (item.Scenario === DR_SCENARIO.SQ_Actuals || item.Scenario === DR_SCENARIO.Forecast) &&
29
- item.Amount !== 0 && !!item['Reporting Month']
28
+ (item.Scenario === DR_SCENARIO.SQ_Actuals || item.Scenario === DR_SCENARIO.Forecast) && !!item['Reporting Month']
30
29
  );
31
30
 
32
31
  const data = lodash.map(filtered, item => ({
@@ -34,7 +33,7 @@ function buildChartSeriesFromPivotInputOnly(input, actuals, forecast, midMonthOf
34
33
  name: item['Reporting Month'],
35
34
  initialName: item['Reporting Month'],
36
35
  type: item.Scenario,
37
- })).sort((a, b) => new Date(a.name) - new Date(b.name));
36
+ })).sort((a, b) => sortRowValuesByName(a, b));
38
37
 
39
38
  const sqCount = lodash.filter(input, item => item.Scenario === DR_SCENARIO.SQ_Actuals).length;
40
39
 
@@ -64,7 +63,9 @@ function buildChartSeriesForMultipleSeriesCombinedLine(chart_series, input, actu
64
63
  initialName: item['Reporting Month'],
65
64
  type: item.Scenario,
66
65
  }))
67
- .value().sort((a, b) => new Date(a.name) - new Date(b.name));
66
+ .value().sort((a, b) => {
67
+ return sortRowValuesByName(a, b);
68
+ });
68
69
  if (!data.length) {
69
70
  resultingSeries.push(series);
70
71
  continue;
@@ -86,6 +87,12 @@ function buildChartSeriesForMultipleSeriesCombinedLine(chart_series, input, actu
86
87
  return resultingSeries;
87
88
  }
88
89
 
90
+ function sortRowValuesByName(rowValueA, rowValueB) {
91
+ const aDate = new Date(rowValueA.name);
92
+ const bDate = new Date(rowValueB.name);
93
+ return !isNaN(aDate.getTime()) && !isNaN(bDate.getTime()) ? aDate - bDate : rowValueA.name.localeCompare(rowValueB.name);
94
+ }
95
+
89
96
  function buildChartSeriesFromSeries(chart_series, actuals, forecast, midMonthOffset) {
90
97
  const seriesA = lodash.find(chart_series, s => s.name && lodash.includes(s.name, DR_SCENARIO.SQ_Actuals));
91
98
  const seriesB = lodash.find(chart_series, s => s.name && lodash.includes(s.name, DR_SCENARIO.Forecast));
@@ -2071,7 +2071,7 @@ describe('highcharts_renderer', () => {
2071
2071
  highchartsRenderer.updateBackwardCompatibleWidgetOptions(currentOptions, null);
2072
2072
  expect(currentOptions.comboOptions).toEqual({
2073
2073
  secondaryAxisSettings: {
2074
- name: 'TESTtest',
2074
+ name: 'Secondary Axis',
2075
2075
  max: null,
2076
2076
  min: null,
2077
2077
  is_percentage: true