@datarailsshared/dr_renderer 1.5.41 → 1.5.50
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
|
@@ -1521,7 +1521,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1521
1521
|
if ($.isNumeric(val)) {
|
|
1522
1522
|
val = parseFloat(val);
|
|
1523
1523
|
}
|
|
1524
|
-
} else
|
|
1524
|
+
} else {
|
|
1525
|
+
// don't check helpers.isShowingEmptyValues as e2e rely on empty values being present in the DOM for column charts
|
|
1525
1526
|
if (onlyNumbers)
|
|
1526
1527
|
val = NaN;
|
|
1527
1528
|
else
|
|
@@ -6639,7 +6640,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
6639
6640
|
element_type: 'checkbox',
|
|
6640
6641
|
value_name: 'dislay_empty_values',
|
|
6641
6642
|
element_label: 'Display empty values',
|
|
6642
|
-
default_value:
|
|
6643
|
+
default_value: false
|
|
6643
6644
|
},
|
|
6644
6645
|
]
|
|
6645
6646
|
},
|
|
@@ -6667,7 +6668,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
6667
6668
|
element_type: 'checkbox',
|
|
6668
6669
|
value_name: 'dislay_empty_values',
|
|
6669
6670
|
element_label: 'Display empty values',
|
|
6670
|
-
default_value:
|
|
6671
|
+
default_value: false
|
|
6671
6672
|
},
|
|
6672
6673
|
{
|
|
6673
6674
|
element_type: 'devider',
|
|
@@ -9315,12 +9316,28 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
9315
9316
|
if (!keys || !invertedDateStringMap) {
|
|
9316
9317
|
return;
|
|
9317
9318
|
}
|
|
9319
|
+
const dateWidgetFields = lodash.filter(widgetFields, obj => obj.type === 'Date');
|
|
9318
9320
|
const replaceNestedKeys = (nestedKeys) => {
|
|
9319
9321
|
for (let i = 0; i < nestedKeys.length; i++) {
|
|
9320
9322
|
if (Array.isArray(nestedKeys[i])) {
|
|
9321
9323
|
replaceNestedKeys(nestedKeys[i]);
|
|
9322
|
-
}
|
|
9323
|
-
|
|
9324
|
+
}
|
|
9325
|
+
else if (invertedDateStringMap[nestedKeys[i]] && widgetFields[i] && widgetFields[i].type === 'Date') {
|
|
9326
|
+
const getFormat = (obj) => (lodash.get(obj, 'format') ?? '').toUpperCase();
|
|
9327
|
+
const isSameDateFormats = lodash.every(dateWidgetFields, obj => getFormat(obj) === getFormat(dateWidgetFields[0]));
|
|
9328
|
+
|
|
9329
|
+
if (isSameDateFormats) {
|
|
9330
|
+
nestedKeys[i] = invertedDateStringMap[nestedKeys[i]];
|
|
9331
|
+
continue;
|
|
9332
|
+
}
|
|
9333
|
+
|
|
9334
|
+
// Reformatting dates when "widgetFields" array contains fields with different formats
|
|
9335
|
+
// Fixes the issue - https://datarailsteam.atlassian.net/browse/DR-37813
|
|
9336
|
+
// Will be removed once "format_dates_as_other_axis_types" FF is deleted
|
|
9337
|
+
const format = (widgetFields[i].format ?? "MM/DD/YYYY").toUpperCase();
|
|
9338
|
+
const date = new Date(parseInt(nestedKeys[i]) * 1000);
|
|
9339
|
+
const formattedDateString = moment_lib(date).utcOffset(0).format(format) + "";
|
|
9340
|
+
nestedKeys[i] = formattedDateString;
|
|
9324
9341
|
}
|
|
9325
9342
|
}
|
|
9326
9343
|
};
|
|
@@ -30,21 +30,29 @@ function getSqAggregator(tree, rowKey, flatColKey) {
|
|
|
30
30
|
|
|
31
31
|
function handleForecastSeries(chart_series, chartOptions, pivotData) {
|
|
32
32
|
const midMonthOffset = 0.5;
|
|
33
|
-
const sqInput = _.filter(pivotData.input, item => item['Scenario'] === DR_SCENARIO.SQ_Actuals);
|
|
33
|
+
const sqInput = _.filter(pivotData.input, item => item['Scenario'] === DR_SCENARIO.SQ_Actuals && !!item['Reporting Month']);
|
|
34
34
|
const noSqSeries = _.filter(chart_series, (s) => !_.includes(s.name, DR_SCENARIO.SQ_Actuals)); // SQ_Actuals are just base for forecast
|
|
35
35
|
|
|
36
36
|
return _.map(noSqSeries, series => {
|
|
37
37
|
const itemScenario = getSqScenarioCycle(series.name);
|
|
38
|
-
const
|
|
38
|
+
const sqItems = _.filter(sqInput, item => {
|
|
39
|
+
const itemRowKey = pivotData.getFlatKey(item, pivotData.rowAttrs);
|
|
39
40
|
|
|
40
|
-
|
|
41
|
+
if(itemRowKey.includes(DR_SCENARIO.SQ_Actuals)) {
|
|
42
|
+
return _.startsWith(itemRowKey, itemScenario);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return series.name === itemRowKey;
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
if(!sqItems.length) return series;
|
|
41
49
|
|
|
42
50
|
return {
|
|
43
51
|
name: series.name,
|
|
44
52
|
data: series.data,
|
|
45
53
|
zoneAxis: "x",
|
|
46
54
|
zones: [
|
|
47
|
-
{ value:
|
|
55
|
+
{ value: sqItems.length - midMonthOffset, dashStyle: chartOptions.chart.actuals },
|
|
48
56
|
{ dashStyle: chartOptions.chart.forecast },
|
|
49
57
|
],
|
|
50
58
|
}
|
|
@@ -5964,6 +5964,40 @@ describe('highcharts_renderer', () => {
|
|
|
5964
5964
|
highchartsRenderer.replaceSortingKeysWithMappedValues(null, invertedDateStringMap, widget.rows);
|
|
5965
5965
|
highchartsRenderer.replaceSortingKeysWithMappedValues(null, invertedDateStringMap, widget.rows);
|
|
5966
5966
|
});
|
|
5967
|
+
|
|
5968
|
+
// This test was added to cover an edge case where multiple Date fields have the same date values
|
|
5969
|
+
// but require different formatting based on their individual field settings
|
|
5970
|
+
// Fixes the issue - https://datarailsteam.atlassian.net/browse/DR-37813
|
|
5971
|
+
// Will be removed once "format_dates_as_other_axis_types" FF is deleted
|
|
5972
|
+
it('should reformat dates when widget fields have same dates, but different formats', () => {
|
|
5973
|
+
const keysObject = {
|
|
5974
|
+
col_keys: [
|
|
5975
|
+
[1648684800, 1648684800, 1648684800],
|
|
5976
|
+
],
|
|
5977
|
+
row_keys: [],
|
|
5978
|
+
row_keys_by_cols: [],
|
|
5979
|
+
};
|
|
5980
|
+
|
|
5981
|
+
const invertedDateStringMap = {
|
|
5982
|
+
1648684800: '03/31/2022',
|
|
5983
|
+
};
|
|
5984
|
+
|
|
5985
|
+
const widget = {
|
|
5986
|
+
cols: [
|
|
5987
|
+
{ type: 'Date', format: null }, // Default format MM/DD/YYYY
|
|
5988
|
+
{ type: 'Date', format: 'MM-DD-YYYY' },
|
|
5989
|
+
{ type: 'Date', format: 'DD/MM/YYYY' },
|
|
5990
|
+
],
|
|
5991
|
+
rows: [],
|
|
5992
|
+
pivot: { keysObject },
|
|
5993
|
+
};
|
|
5994
|
+
|
|
5995
|
+
highchartsRenderer.replaceSortingKeysWithMappedValues(keysObject.col_keys, invertedDateStringMap, widget.cols);
|
|
5996
|
+
|
|
5997
|
+
expect(keysObject.col_keys[0][0]).toBe('03/31/2022');
|
|
5998
|
+
expect(keysObject.col_keys[0][1]).toBe('03-31-2022');
|
|
5999
|
+
expect(keysObject.col_keys[0][2]).toBe('31/03/2022');
|
|
6000
|
+
});
|
|
5967
6001
|
});
|
|
5968
6002
|
|
|
5969
6003
|
|