@datarailsshared/dr_renderer 1.5.39 → 1.5.46
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
|
@@ -2131,8 +2131,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
2131
2131
|
};
|
|
2132
2132
|
|
|
2133
2133
|
highchartsRenderer.addSecondYAxis = function (pivotData, chartOptions, additionOptions, opts) {
|
|
2134
|
-
|
|
2135
|
-
const forcePercentage = lodash.get(opts, 'comboOptions.secondaryAxisSettings.is_percentage', false) || lodash.get(additionOptions, 'delta_column.is_percentage', false);
|
|
2134
|
+
const forcePercentage = lodash.get(opts, 'comboOptions.secondaryAxisSettings.is_percentage', false) || lodash.get(additionOptions, 'delta_column.is_percentage', false);
|
|
2136
2135
|
|
|
2137
2136
|
chartOptions.yAxis = [chartOptions.yAxis];
|
|
2138
2137
|
chartOptions.yAxis[1] = {
|
|
@@ -2141,13 +2140,13 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
2141
2140
|
title: {
|
|
2142
2141
|
text: highchartsRenderer.encodeHTMLBrackets(opts.comboOptions.secondaryAxisSettings.name),
|
|
2143
2142
|
style: {
|
|
2144
|
-
color:
|
|
2143
|
+
color: CHART_COLORS.LABEL_SECOND
|
|
2145
2144
|
}
|
|
2146
2145
|
},
|
|
2147
2146
|
labels: {
|
|
2148
2147
|
formatter: highchartsRenderer.defaultValueLabelsFormatter(pivotData, opts, forcePercentage),
|
|
2149
2148
|
style: {
|
|
2150
|
-
color:
|
|
2149
|
+
color: CHART_COLORS.LABEL_SECOND
|
|
2151
2150
|
}
|
|
2152
2151
|
},
|
|
2153
2152
|
opposite: true,
|
|
@@ -9316,12 +9315,28 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
9316
9315
|
if (!keys || !invertedDateStringMap) {
|
|
9317
9316
|
return;
|
|
9318
9317
|
}
|
|
9318
|
+
const dateWidgetFields = lodash.filter(widgetFields, obj => obj.type === 'Date');
|
|
9319
9319
|
const replaceNestedKeys = (nestedKeys) => {
|
|
9320
9320
|
for (let i = 0; i < nestedKeys.length; i++) {
|
|
9321
9321
|
if (Array.isArray(nestedKeys[i])) {
|
|
9322
9322
|
replaceNestedKeys(nestedKeys[i]);
|
|
9323
|
-
}
|
|
9324
|
-
|
|
9323
|
+
}
|
|
9324
|
+
else if (invertedDateStringMap[nestedKeys[i]] && widgetFields[i] && widgetFields[i].type === 'Date') {
|
|
9325
|
+
const getFormat = (obj) => (lodash.get(obj, 'format') ?? '').toUpperCase();
|
|
9326
|
+
const isSameDateFormats = lodash.every(dateWidgetFields, obj => getFormat(obj) === getFormat(dateWidgetFields[0]));
|
|
9327
|
+
|
|
9328
|
+
if (isSameDateFormats) {
|
|
9329
|
+
nestedKeys[i] = invertedDateStringMap[nestedKeys[i]];
|
|
9330
|
+
continue;
|
|
9331
|
+
}
|
|
9332
|
+
|
|
9333
|
+
// Reformatting dates when "widgetFields" array contains fields with different formats
|
|
9334
|
+
// Fixes the issue - https://datarailsteam.atlassian.net/browse/DR-37813
|
|
9335
|
+
// Will be removed once "format_dates_as_other_axis_types" FF is deleted
|
|
9336
|
+
const format = (widgetFields[i].format ?? "MM/DD/YYYY").toUpperCase();
|
|
9337
|
+
const date = new Date(parseInt(nestedKeys[i]) * 1000);
|
|
9338
|
+
const formattedDateString = moment_lib(date).utcOffset(0).format(format) + "";
|
|
9339
|
+
nestedKeys[i] = formattedDateString;
|
|
9325
9340
|
}
|
|
9326
9341
|
}
|
|
9327
9342
|
};
|
|
@@ -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
|
|