@datarailsshared/dr_renderer 1.2.248-dragons → 1.2.250

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.248-dragons",
3
+ "version": "1.2.250",
4
4
  "description": "DataRails charts and tables renderer",
5
5
  "keywords": [
6
6
  "datarails",
@@ -1042,7 +1042,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1042
1042
  if (row_n_value && row_n_value.length > 0) {
1043
1043
  ob.name = row_n_value.join(highchartsRenderer.delimer).replace('DR_Others', othersName);
1044
1044
  }
1045
-
1046
1045
  lodash.forEach(col_n_keys, function (col_n_value, index) {
1047
1046
  var agg = pivotData.getAggregator(row_n_value, col_n_value);
1048
1047
  var val = agg.value();
@@ -1259,7 +1258,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1259
1258
  if (opts.trendLine) {
1260
1259
  const a = ((ySum * squareXSum) - (xSum * xySum)) / ((n * squareXSum) - (xSum * xSum));
1261
1260
  const b = ((n * xySum) - (xSum* ySum)) / ((n * squareXSum) - (xSum * xSum));
1262
-
1263
1261
  const trendSeries = lodash.clone(chart_series[chart_series.length - 1]);
1264
1262
  trendSeries.className = 'trendSeries';
1265
1263
  trendSeries.name = highchartsRenderer.getTrendSeriesName(trendSeries);
@@ -1270,7 +1268,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1270
1268
  if (colors && colors[i]) {
1271
1269
  trendSeries.color = colors[i];
1272
1270
  }
1273
-
1274
1271
  trendSerieses.push(trendSeries);
1275
1272
  }
1276
1273
  i++;
@@ -1287,7 +1284,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1287
1284
  }
1288
1285
 
1289
1286
  let weights = { line: 2,spline: 3 ,area:-2, areaspline: -1, scatter:4, column: 1 };
1290
-
1291
1287
  if (opts.comboOptions && lodash.includes(chartType,'combo') && !lodash.isEqual(row_n_keys, EMPTY_ROW_N_KEYS)) {
1292
1288
  chart_series.forEach((series, seriesIndex) => {
1293
1289
  const savedSeriesOption = lodash.find(opts.comboOptions.seriesOptions, {series: series.name});
@@ -1465,12 +1461,20 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1465
1461
  val = val * -1;
1466
1462
  }
1467
1463
 
1464
+ const baseColor = {
1465
+ total: '',
1466
+ decrease: '#BF1D30',
1467
+ increase: '#20A452',
1468
+ };
1469
+
1468
1470
  const name = value.trend === 'total' ? value.formattedKey || value.key[0] : keys.join(highchartsRenderer.delimer);
1469
1471
  let color = '';
1470
1472
  if (value.color) {
1471
1473
  color = value.color;
1472
1474
  } else {
1473
- color = lodash.get(waterfallOptions, 'colors', {})[value.trend];
1475
+ color = lodash.get(waterfallOptions, 'colors', {})
1476
+ ? lodash.get(waterfallOptions, 'colors', {})[value.trend]
1477
+ : baseColor[value.trend];
1474
1478
  }
1475
1479
 
1476
1480
  resultObject.data.push({
@@ -5361,13 +5365,16 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
5361
5365
  dynamicRangeOptions.pivot.calculatedValues = highchartsRenderer.objectCopyJsonMethod(dynamicRangeOptions.calculated_values || []);
5362
5366
  }
5363
5367
 
5364
- highchartsRenderer.addTemplateDataToCalcModel = function (selectedTemplate, calcModelOptions) {
5368
+ highchartsRenderer.addTemplateDataToCalcModel = function (selectedTemplate, calcModelOptions, calcModelPredefinedField) {
5365
5369
  highchartsRenderer.setWidgetFieldsToTemplate(selectedTemplate);
5366
5370
  const fields = highchartsRenderer.objectCopyJsonMethod(selectedTemplate.fields);
5371
+ const predefinedField = lodash.cloneDeep(calcModelPredefinedField);
5367
5372
 
5368
5373
  const fillData = (fieldsArr, ignoreFieldsIdToRemove = []) => {
5369
5374
  const destinationArr = [];
5370
5375
  lodash.forEach(fieldsArr, function (valObj) {
5376
+ if (!valObj) return;
5377
+
5371
5378
  const fieldOb = lodash.find(fields, { id: valObj.id });
5372
5379
  if (fieldOb) {
5373
5380
  destinationArr.push(fieldOb);
@@ -5403,37 +5410,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
5403
5410
  }
5404
5411
  })();
5405
5412
 
5406
- const reportingMonthRegex = /reporting[_\s]month/i;
5407
-
5408
- const predefinedField = {
5409
- value: {
5410
- regex: /posting[_\s]amount/i,
5411
- allowedFieldTypes: ['Float', 'Integer'],
5412
- fields: [],
5413
- },
5414
- dataType: {
5415
- regex: /^(data[_\s]type[_\s]by|data[_\s]type)$/i,
5416
- allowedFieldTypes: ['Text'],
5417
- fields: [],
5418
- },
5419
- date: {
5420
- regex: reportingMonthRegex,
5421
- allowedFieldTypes: ['Date'],
5422
- fields: [],
5423
- },
5424
- filters: {
5425
- isMultipleFields: true,
5426
- regex: /^(scenario|DR_ACC_L0)$/i,
5427
- fields: [],
5428
- },
5429
- dataSeries: {
5430
- isMultipleFields: true,
5431
- regex: /^(scenario|account[_\s]full|entity|intercompany|posting[_\s]currency|reporting[_\s]currency|report[_\s]field|USER_TO_DR_ACC_KEY|USER_TO_DR_KPI_KEY)$/i,
5432
- fields: [],
5433
- },
5434
- };
5435
-
5436
- if (!lodash.get(calcModelOptions, 'config', false)) {
5413
+ if (!lodash.get(calcModelOptions, 'config', false) && predefinedField) {
5437
5414
  /**
5438
5415
  * alias stronger than name (order in array is important)
5439
5416
  * Firstly we try to get predefined field by aliases and then fill in by names
@@ -5451,13 +5428,18 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
5451
5428
  : [lodash.find(fields, field => canAssignPredefinedField(predefinedField[key], key, field, value, opposite, ignoredFields))].filter(f => !!f);
5452
5429
 
5453
5430
  if (result && result.length) {
5431
+ if (!predefinedField[key].fields) {
5432
+ predefinedField[key].fields = [];
5433
+ }
5434
+
5454
5435
  predefinedField[key].fields.push(...result);
5455
5436
  }
5456
5437
  });
5457
5438
  }
5458
5439
  }
5459
5440
 
5460
- const filters = lodash.get(calcModelOptions, 'config.filters', predefinedField.filters.fields);
5441
+ const defaultFilters = lodash.get(predefinedField, 'filters.fields', []);
5442
+ const filters = lodash.get(calcModelOptions, 'config.filters', defaultFilters);
5461
5443
 
5462
5444
  lodash.forEach(filters, function (filterObj) {
5463
5445
  const fieldOb = lodash.find(fields, { id: filterObj.id });
@@ -5478,13 +5460,23 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
5478
5460
  }
5479
5461
  });
5480
5462
 
5481
- const storedGroupByFields = lodash.get(calcModelOptions, 'config.group_by', predefinedField.dataSeries.fields);
5482
- const storedDateFields = [lodash.get(calcModelOptions, 'config.date_field', predefinedField.date.fields[0])].filter(f => !!f);
5483
- const storedAggFields = [lodash.get(calcModelOptions, 'config.agg_field', predefinedField.value.fields[0])].filter(f => !!f);
5484
- const storedDataTypeFields = [lodash.get(calcModelOptions, 'config.data_type_field', predefinedField.dataType.fields[0])].filter(f => !!f);
5485
- const scenarioField = lodash.get(calcModelOptions, 'config.scenario', lodash.find(predefinedField.filters.fields, filter => [filter.name, filter.alias].includes('scenario')));
5486
- const reportingMonthFieldWithAlias = lodash.find(fields, _field => reportingMonthRegex.test(_field.alias));
5487
- const reportingMonthFieldWithName = lodash.find(fields, _field => reportingMonthRegex.test(_field.name));
5463
+ const defaultGroupByValues = lodash.get(predefinedField, 'dataSeries.fields', []);
5464
+ const storedGroupByFields = lodash.get(calcModelOptions, 'config.group_by', defaultGroupByValues);
5465
+
5466
+ const defaultDateValue = lodash.get(predefinedField, 'date.fields[0]', undefined);
5467
+ const storedDateFields = [lodash.get(calcModelOptions, 'config.date_field', defaultDateValue)].filter(f => !!f);
5468
+
5469
+ const defaultAggValue = lodash.get(predefinedField, 'value.fields[0]', undefined);
5470
+ const storedAggFields = [lodash.get(calcModelOptions, 'config.agg_field', defaultAggValue)].filter(f => !!f);
5471
+
5472
+ const defaultDataTypeValue = lodash.get(predefinedField, 'dataType.fields[0]', undefined);
5473
+ const storedDataTypeFields = [lodash.get(calcModelOptions, 'config.data_type_field', defaultDataTypeValue)].filter(f => !!f);
5474
+
5475
+ const reportingMonthRegex = /reporting[_\s]month/i;
5476
+ const scenarioRegex = /scenario/i;
5477
+
5478
+ const scenarioField = lodash.find(fields, _field => scenarioRegex.test(_field.alias)) || lodash.find(fields, _field => scenarioRegex.test(_field.name));
5479
+ const reportingMonthField = lodash.find(fields, _field => reportingMonthRegex.test(_field.alias)) || lodash.find(fields, _field => reportingMonthRegex.test(_field.name));
5488
5480
 
5489
5481
  /**
5490
5482
  * We can have several common fields, so we should ignore deleting during fillData
@@ -5503,7 +5495,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
5503
5495
  selectedFieldsArray: dataSeriesFields,
5504
5496
  filtersArray: filterFields,
5505
5497
  scenarioField,
5506
- reportingMonthField: reportingMonthFieldWithAlias || reportingMonthFieldWithName,
5498
+ reportingMonthField,
5507
5499
  dateFields,
5508
5500
  dataTypeFields,
5509
5501
  valueFields