@datarailsshared/dr_renderer 1.2.235-dragons → 1.2.237
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 +1 -1
- package/src/highcharts_renderer.js +109 -33
package/package.json
CHANGED
|
@@ -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});
|
|
@@ -4970,7 +4966,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
4970
4966
|
};
|
|
4971
4967
|
|
|
4972
4968
|
highchartsRenderer.isSystemField = function (field) {
|
|
4973
|
-
var regex = new RegExp("^(Parent_Name|Parent_Id|FileBox_ID|FileBox_Name|DataMapper_Name|Doc_ID|Doc_version|Label|Submission_Date|User|table_id|Latest_In_Dim|Tab_name|CP_Name|DT_.+|VT_.+|System_.+)$", "m");
|
|
4969
|
+
var regex = new RegExp("^(Calc_Model_Name|Calc_Model_ID|Parent_Name|Parent_Id|FileBox_ID|FileBox_Name|DataMapper_Name|Doc_ID|Doc_version|Label|Submission_Date|User|table_id|Latest_In_Dim|Tab_name|CP_Name|DT_.+|VT_.+|System_.+)$", "m");
|
|
4974
4970
|
|
|
4975
4971
|
return (field.category && field.category.includes("")) || regex.test(field.name)
|
|
4976
4972
|
};
|
|
@@ -5333,34 +5329,104 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
5333
5329
|
|
|
5334
5330
|
highchartsRenderer.addTemplateDataToCalcModel = function (selectedTemplate, calcModelOptions) {
|
|
5335
5331
|
highchartsRenderer.setWidgetFieldsToTemplate(selectedTemplate);
|
|
5336
|
-
|
|
5337
|
-
const scenarioName = 'scenario';
|
|
5338
5332
|
const fields = highchartsRenderer.objectCopyJsonMethod(selectedTemplate.fields);
|
|
5339
|
-
const fieldScenarioAlias = _.find(fields, field => (field.alias || '').toLowerCase() === scenarioName)
|
|
5340
|
-
const fieldScenario = _.find(fields, field => (field.name || '').toLowerCase() === scenarioName)
|
|
5341
|
-
const filters = calcModelOptions.config && calcModelOptions.config.filters;
|
|
5342
5333
|
|
|
5343
|
-
const
|
|
5344
|
-
|
|
5345
|
-
const dateFields = [];
|
|
5346
|
-
const dataTypeFields = [];
|
|
5347
|
-
const dataSeriesFields = [];
|
|
5348
|
-
|
|
5349
|
-
let scenarioField = lodash.get(calcModelOptions, 'config.scenario', undefined) || fieldScenarioAlias || fieldScenario;
|
|
5350
|
-
let fieldOb;
|
|
5351
|
-
|
|
5352
|
-
const fillData = (fieldsArr, destinationArr) => {
|
|
5334
|
+
const fillData = (fieldsArr, ignoreFieldsIdToRemove = []) => {
|
|
5335
|
+
const destinationArr = [];
|
|
5353
5336
|
lodash.forEach(fieldsArr, function (valObj) {
|
|
5354
|
-
fieldOb = lodash.find(fields, { id: valObj.id });
|
|
5337
|
+
const fieldOb = lodash.find(fields, { id: valObj.id });
|
|
5355
5338
|
if (fieldOb) {
|
|
5356
5339
|
destinationArr.push(fieldOb);
|
|
5357
|
-
lodash.remove(fields, { id: fieldOb.id });
|
|
5340
|
+
!lodash.includes(ignoreFieldsIdToRemove, fieldOb.id) && lodash.remove(fields, { id: fieldOb.id });
|
|
5358
5341
|
}
|
|
5359
5342
|
});
|
|
5343
|
+
|
|
5344
|
+
return destinationArr;
|
|
5345
|
+
}
|
|
5346
|
+
|
|
5347
|
+
const canAssignPredefinedField = (() => {
|
|
5348
|
+
const assignedFields = {};
|
|
5349
|
+
|
|
5350
|
+
return function (predefinedData, type, field, bindValue, oppositeValue) {
|
|
5351
|
+
if (!assignedFields[type]) {
|
|
5352
|
+
assignedFields[type] = [];
|
|
5353
|
+
}
|
|
5354
|
+
|
|
5355
|
+
const isFieldMatch = predefinedData.regex.test(field[bindValue] || '');
|
|
5356
|
+
|
|
5357
|
+
const isFieldTypeCorrect = predefinedData.allowedFieldTypes
|
|
5358
|
+
? lodash.includes(predefinedData.allowedFieldTypes, field.type) : true;
|
|
5359
|
+
|
|
5360
|
+
const isFieldAssigned = assignedFields[type].includes(field[bindValue].toLowerCase())
|
|
5361
|
+
|| assignedFields[type].includes(field[oppositeValue].toLowerCase());
|
|
5362
|
+
|
|
5363
|
+
if (!(isFieldMatch && isFieldTypeCorrect)) return false;
|
|
5364
|
+
|
|
5365
|
+
const loweredFieldValue = field[bindValue].toLowerCase();
|
|
5366
|
+
assignedFields[type].push(loweredFieldValue, loweredFieldValue.replaceAll('_', ' '));
|
|
5367
|
+
|
|
5368
|
+
return !isFieldAssigned;
|
|
5369
|
+
}
|
|
5370
|
+
})();
|
|
5371
|
+
|
|
5372
|
+
const reportingMonthRegex = /reporting[_\s]month/i;
|
|
5373
|
+
|
|
5374
|
+
const predefinedField = {
|
|
5375
|
+
value: {
|
|
5376
|
+
regex: /posting[_\s]amount/i,
|
|
5377
|
+
allowedFieldTypes: ['Float', 'Integer'],
|
|
5378
|
+
fields: [],
|
|
5379
|
+
},
|
|
5380
|
+
dataType: {
|
|
5381
|
+
regex: /data[_\s]type[_\s]by/i,
|
|
5382
|
+
allowedFieldTypes: ['Text'],
|
|
5383
|
+
fields: [],
|
|
5384
|
+
},
|
|
5385
|
+
date: {
|
|
5386
|
+
regex: reportingMonthRegex,
|
|
5387
|
+
allowedFieldTypes: ['Date'],
|
|
5388
|
+
fields: [],
|
|
5389
|
+
},
|
|
5390
|
+
filters: {
|
|
5391
|
+
isMultipleFields: true,
|
|
5392
|
+
regex: /^(scenario|DR_ACC_L0)$/i,
|
|
5393
|
+
fields: [],
|
|
5394
|
+
},
|
|
5395
|
+
dataSeries: {
|
|
5396
|
+
isMultipleFields: true,
|
|
5397
|
+
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,
|
|
5398
|
+
fields: [],
|
|
5399
|
+
},
|
|
5400
|
+
};
|
|
5401
|
+
|
|
5402
|
+
if (!lodash.get(calcModelOptions, 'config', false)) {
|
|
5403
|
+
/**
|
|
5404
|
+
* alias stronger than name (order in array is important)
|
|
5405
|
+
* Firstly we try to get predefined field by aliases and then fill in by names
|
|
5406
|
+
* */
|
|
5407
|
+
const fieldsDataQueueConfig = [
|
|
5408
|
+
{ value: 'alias', opposite: 'name' },
|
|
5409
|
+
{ value: 'name', opposite: 'alias' }
|
|
5410
|
+
];
|
|
5411
|
+
|
|
5412
|
+
for (const key in predefinedField) {
|
|
5413
|
+
lodash.forEach(fieldsDataQueueConfig, ({value, opposite}) => {
|
|
5414
|
+
const ignoredFields = predefinedField[key].ignoreAssignedFields;
|
|
5415
|
+
const result = predefinedField[key].isMultipleFields
|
|
5416
|
+
? lodash.filter(fields, field => canAssignPredefinedField(predefinedField[key], key, field, value, opposite, ignoredFields))
|
|
5417
|
+
: [lodash.find(fields, field => canAssignPredefinedField(predefinedField[key], key, field, value, opposite, ignoredFields))].filter(f => !!f);
|
|
5418
|
+
|
|
5419
|
+
if (result && result.length) {
|
|
5420
|
+
predefinedField[key].fields.push(...result);
|
|
5421
|
+
}
|
|
5422
|
+
});
|
|
5423
|
+
}
|
|
5360
5424
|
}
|
|
5361
5425
|
|
|
5426
|
+
const filters = lodash.get(calcModelOptions, 'config.filters', predefinedField.filters.fields);
|
|
5427
|
+
|
|
5362
5428
|
lodash.forEach(filters, function (filterObj) {
|
|
5363
|
-
fieldOb = lodash.find(fields, { id: filterObj.id });
|
|
5429
|
+
const fieldOb = lodash.find(fields, { id: filterObj.id });
|
|
5364
5430
|
if (!fieldOb) return;
|
|
5365
5431
|
|
|
5366
5432
|
filterObj.values = filterObj.values && lodash.map(filterObj.values, highchartsRenderer.decodeFunc);
|
|
@@ -5378,22 +5444,32 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
5378
5444
|
}
|
|
5379
5445
|
});
|
|
5380
5446
|
|
|
5381
|
-
const storedGroupByFields = lodash.get(calcModelOptions, 'config.group_by',
|
|
5382
|
-
const storedDateFields = [lodash.get(calcModelOptions, 'config.date_field',
|
|
5383
|
-
const storedAggFields = [lodash.get(calcModelOptions, 'config.agg_field',
|
|
5384
|
-
const storedDataTypeFields = [lodash.get(calcModelOptions, 'config.data_type_field',
|
|
5385
|
-
|
|
5386
|
-
|
|
5387
|
-
|
|
5388
|
-
|
|
5389
|
-
|
|
5390
|
-
|
|
5447
|
+
const storedGroupByFields = lodash.get(calcModelOptions, 'config.group_by', predefinedField.dataSeries.fields);
|
|
5448
|
+
const storedDateFields = [lodash.get(calcModelOptions, 'config.date_field', predefinedField.date.fields[0])].filter(f => !!f);
|
|
5449
|
+
const storedAggFields = [lodash.get(calcModelOptions, 'config.agg_field', predefinedField.value.fields[0])].filter(f => !!f);
|
|
5450
|
+
const storedDataTypeFields = [lodash.get(calcModelOptions, 'config.data_type_field', predefinedField.dataType.fields[0])].filter(f => !!f);
|
|
5451
|
+
const scenarioField = lodash.get(calcModelOptions, 'config.scenario', lodash.find(predefinedField.filters.fields, filter => [filter.name, filter.alias].includes('scenario')));
|
|
5452
|
+
const reportingMonthFieldWithAlias = lodash.find(fields, _field => reportingMonthRegex.test(_field.alias));
|
|
5453
|
+
const reportingMonthFieldWithName = lodash.find(fields, _field => reportingMonthRegex.test(_field.name));
|
|
5454
|
+
|
|
5455
|
+
/**
|
|
5456
|
+
* We can have several common fields, so we should ignore deleting during fillData
|
|
5457
|
+
* */
|
|
5458
|
+
const commonFieldsId = [scenarioField && scenarioField.id];
|
|
5459
|
+
const filterFields = fillData(filters, commonFieldsId);
|
|
5460
|
+
const valueFields = fillData(storedAggFields, commonFieldsId);
|
|
5461
|
+
const dateFields = fillData(storedDateFields, commonFieldsId);
|
|
5462
|
+
const dataTypeFields = fillData(storedDataTypeFields, commonFieldsId);
|
|
5463
|
+
const dataSeriesFields = fillData(storedGroupByFields, commonFieldsId);
|
|
5464
|
+
|
|
5465
|
+
lodash.remove(fields, _field => lodash.includes(commonFieldsId, _field.id));
|
|
5391
5466
|
|
|
5392
5467
|
calcModelOptions.pivot = {
|
|
5393
5468
|
fieldsArray: fields,
|
|
5394
5469
|
selectedFieldsArray: dataSeriesFields,
|
|
5395
5470
|
filtersArray: filterFields,
|
|
5396
5471
|
scenarioField,
|
|
5472
|
+
reportingMonthField: reportingMonthFieldWithAlias || reportingMonthFieldWithName,
|
|
5397
5473
|
dateFields,
|
|
5398
5474
|
dataTypeFields,
|
|
5399
5475
|
valueFields
|