@datarailsshared/dr_renderer 1.5.120 → 1.5.124
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/README.md +2 -0
- package/package.json +1 -1
- package/src/dr-renderer-helpers.js +0 -1
- package/src/highcharts_renderer.js +16 -125
- package/tests/highcharts_renderer.test.js +3 -66
package/package.json
CHANGED
|
@@ -72,7 +72,6 @@ function isShowingEmptyValues(additionOptions) {
|
|
|
72
72
|
const DELIMER = ' , '
|
|
73
73
|
const FEATURES = {
|
|
74
74
|
ENABLE_NEW_WIDGET_VALUE_FORMATTING: 'enable_new_widget_value_formatting',
|
|
75
|
-
FORMAT_DATES_AS_OTHER_AXIS_TYPES: 'format_dates_as_other_axis_types',
|
|
76
75
|
MULTIPLE_DIMENSION_TAGS: 'multiple_dimension_tags',
|
|
77
76
|
USE_NEW_SCENARIO_TAG: 'use_new_scenario_tag',
|
|
78
77
|
ENABLE_GAUGE_DYNAMIC_GOAL: 'enable_gauge_dynamic_goal',
|
|
@@ -297,8 +297,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
297
297
|
let wrappedFormattedValue = highchartsRenderer.getSpanWrapper(formatted_value);
|
|
298
298
|
|
|
299
299
|
const category_text = tooltipOptions.show_x_axis ? `<b>${cols[0] || this.key}</b>` : '';
|
|
300
|
-
const series_text = tooltipOptions.show_data_series
|
|
301
|
-
? `<br/><span style="color: ${this.series.color};">\u200E${this.series.name}</span>: `
|
|
300
|
+
const series_text = tooltipOptions.show_data_series
|
|
301
|
+
? `<br/><span style="color: ${this.series.color};">\u200E${this.series.name}</span>: `
|
|
302
302
|
: '';
|
|
303
303
|
wrappedFormattedValue = tooltipOptions.show_value ? wrappedFormattedValue : '';
|
|
304
304
|
|
|
@@ -1790,19 +1790,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1790
1790
|
resultObject = highchartsRenderer.getDataLabelsOptions(additionOptions, resultObject);
|
|
1791
1791
|
lodash.forEach(waterfallOptions.values.walkthrough, function(value, index) {
|
|
1792
1792
|
|
|
1793
|
-
|
|
1794
|
-
if (value.trend === 'total' || highchartsRenderer.isFormattingDatesAsOtherAxisTypes()) {
|
|
1795
|
-
keys = value.key;
|
|
1796
|
-
} else {
|
|
1797
|
-
lodash.forEach(value.key, (item) => {
|
|
1798
|
-
const findKeyByValue = lodash.find(
|
|
1799
|
-
Object.keys(pivotData.dateValuesDictionary || {}),
|
|
1800
|
-
key => pivotData.dateValuesDictionary[key] === item
|
|
1801
|
-
);
|
|
1802
|
-
keys.push(findKeyByValue ? findKeyByValue : item);
|
|
1803
|
-
})
|
|
1804
|
-
}
|
|
1805
|
-
|
|
1793
|
+
const keys = value.key;
|
|
1806
1794
|
const agg = pivotData.getAggregator([], keys);
|
|
1807
1795
|
|
|
1808
1796
|
if (keys[0] === 'Total') {
|
|
@@ -7472,18 +7460,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
7472
7460
|
return {};
|
|
7473
7461
|
};
|
|
7474
7462
|
|
|
7475
|
-
highchartsRenderer.createDateFromString = function (dateString, format) {
|
|
7476
|
-
if (!(format && highchartsRenderer.isDateFormat(dateString, format) || highchartsRenderer.isDate(dateString))) {
|
|
7477
|
-
return null;
|
|
7478
|
-
}
|
|
7479
|
-
const utcDate = format
|
|
7480
|
-
? moment_lib.utc(dateString, format, true)
|
|
7481
|
-
: moment_lib.utc(dateString);
|
|
7482
|
-
return utcDate.startOf('day').unix();
|
|
7483
|
-
}
|
|
7484
|
-
|
|
7485
7463
|
highchartsRenderer.prepareDrillDownFilters = function (r_keys, c_keys, widget) {
|
|
7486
|
-
const isFormattingDatesAsOtherAxisTypes = highchartsRenderer.isFormattingDatesAsOtherAxisTypes();
|
|
7487
7464
|
let row_key = r_keys;
|
|
7488
7465
|
let col_key = c_keys;
|
|
7489
7466
|
if (widget.options &&
|
|
@@ -7504,11 +7481,9 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
7504
7481
|
let label = col_value;
|
|
7505
7482
|
if (widget.cols[0].type === 'Date' && col_value !== NULL_VALUE) {
|
|
7506
7483
|
const format = highchartsRenderer.getDateFieldFormat(widget, widget.cols[0]);
|
|
7507
|
-
let date =
|
|
7484
|
+
let date = +col_value;
|
|
7508
7485
|
colFilter.values.push(date);
|
|
7509
|
-
label =
|
|
7510
|
-
? highchartsRenderer.returnRawDataValue(widget.cols[0].type, +col_value, format, widget.cols[0].name)
|
|
7511
|
-
: col_value;
|
|
7486
|
+
label = highchartsRenderer.returnRawDataValue(widget.cols[0].type, +col_value, format, widget.cols[0].name);
|
|
7512
7487
|
} else {
|
|
7513
7488
|
colFilter.values.push(col_value);
|
|
7514
7489
|
}
|
|
@@ -7537,9 +7512,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
7537
7512
|
return;
|
|
7538
7513
|
}
|
|
7539
7514
|
temp.values = datetrange;
|
|
7540
|
-
temp.values.label =
|
|
7541
|
-
? highchartsRenderer.returnRawDataValue(widget.cols[index].type, +col_value, format, widget.cols[index].name)
|
|
7542
|
-
: col_value;
|
|
7515
|
+
temp.values.label = highchartsRenderer.returnRawDataValue(widget.cols[index].type, +col_value, format, widget.cols[index].name);
|
|
7543
7516
|
} else {
|
|
7544
7517
|
temp.values = [col_value];
|
|
7545
7518
|
}
|
|
@@ -7560,9 +7533,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
7560
7533
|
return;
|
|
7561
7534
|
}
|
|
7562
7535
|
temp.values = datetrange;
|
|
7563
|
-
temp.values.label =
|
|
7564
|
-
? highchartsRenderer.returnRawDataValue(widget.rows[index].type, +row_value, format, widget.rows[index].name)
|
|
7565
|
-
: row_value;
|
|
7536
|
+
temp.values.label = highchartsRenderer.returnRawDataValue(widget.rows[index].type, +row_value, format, widget.rows[index].name);
|
|
7566
7537
|
} else {
|
|
7567
7538
|
temp.values = [row_value];
|
|
7568
7539
|
}
|
|
@@ -7611,7 +7582,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
7611
7582
|
};
|
|
7612
7583
|
|
|
7613
7584
|
highchartsRenderer.prepareDrillDownGraphFilters = function (r_key, c_key, widget) {
|
|
7614
|
-
const isFormattingDatesAsOtherAxisTypes = highchartsRenderer.isFormattingDatesAsOtherAxisTypes();
|
|
7615
7585
|
let rowKey = r_key;
|
|
7616
7586
|
let colKey = c_key;
|
|
7617
7587
|
let widgetOptions = typeof widget.options === 'string' ? JSON.parse(widget.options) : widget.options;
|
|
@@ -7649,12 +7619,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
7649
7619
|
let value = colKey[i];
|
|
7650
7620
|
switch (widget.cols[0].type) {
|
|
7651
7621
|
case 'Date':
|
|
7652
|
-
if (value
|
|
7653
|
-
value = highchartsRenderer.createDateFromString(
|
|
7654
|
-
value,
|
|
7655
|
-
highchartsRenderer.getDateFieldFormat(widget, widget.cols[0])
|
|
7656
|
-
);
|
|
7657
|
-
} else if (!isNaN(value)) {
|
|
7622
|
+
if (!isNaN(value)) {
|
|
7658
7623
|
value = +value;
|
|
7659
7624
|
}
|
|
7660
7625
|
break;
|
|
@@ -7768,44 +7733,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
7768
7733
|
return res;
|
|
7769
7734
|
};
|
|
7770
7735
|
|
|
7771
|
-
highchartsRenderer.replaceSortingKeysWithMappedValues = function(keys, invertedDateStringMap, widgetFields) {
|
|
7772
|
-
if (!keys || !invertedDateStringMap) {
|
|
7773
|
-
return;
|
|
7774
|
-
}
|
|
7775
|
-
const dateWidgetFields = lodash.filter(widgetFields, obj => obj.type === 'Date');
|
|
7776
|
-
const replaceNestedKeys = (nestedKeys) => {
|
|
7777
|
-
for (let i = 0; i < nestedKeys.length; i++) {
|
|
7778
|
-
if (Array.isArray(nestedKeys[i])) {
|
|
7779
|
-
replaceNestedKeys(nestedKeys[i]);
|
|
7780
|
-
}
|
|
7781
|
-
else if (invertedDateStringMap[nestedKeys[i]] && widgetFields[i] && widgetFields[i].type === 'Date') {
|
|
7782
|
-
const getFormat = (obj) => (lodash.get(obj, 'format') ?? '').toUpperCase();
|
|
7783
|
-
const isSameDateFormats = lodash.every(dateWidgetFields, obj => getFormat(obj) === getFormat(dateWidgetFields[0]));
|
|
7784
|
-
|
|
7785
|
-
if (isSameDateFormats) {
|
|
7786
|
-
nestedKeys[i] = invertedDateStringMap[nestedKeys[i]];
|
|
7787
|
-
continue;
|
|
7788
|
-
}
|
|
7789
|
-
|
|
7790
|
-
// Reformatting dates when "widgetFields" array contains fields with different formats
|
|
7791
|
-
// Fixes the issue - https://datarailsteam.atlassian.net/browse/DR-37813
|
|
7792
|
-
// Will be removed once "format_dates_as_other_axis_types" FF is deleted
|
|
7793
|
-
const format = (widgetFields[i].format ?? "MM/DD/YYYY").toUpperCase();
|
|
7794
|
-
const date = new Date(parseInt(nestedKeys[i]) * 1000);
|
|
7795
|
-
const formattedDateString = moment_lib(date).utcOffset(0).format(format) + "";
|
|
7796
|
-
nestedKeys[i] = formattedDateString;
|
|
7797
|
-
}
|
|
7798
|
-
}
|
|
7799
|
-
};
|
|
7800
|
-
|
|
7801
|
-
for (let i = 0; i < keys.length; i++) {
|
|
7802
|
-
replaceNestedKeys(keys[i]);
|
|
7803
|
-
}
|
|
7804
|
-
}
|
|
7805
|
-
|
|
7806
7736
|
highchartsRenderer.getWidgetDataSorters = function (res, widget, defaultDateFormat) {
|
|
7807
|
-
const isFormattingDatesAsOtherAxisTypes = highchartsRenderer.isFormattingDatesAsOtherAxisTypes();
|
|
7808
|
-
|
|
7809
7737
|
if ($.pivotUtilities && !$.pivotUtilities.additionalFieldsList) {
|
|
7810
7738
|
$.pivotUtilities.additionalFieldsList = [
|
|
7811
7739
|
{key: 'DR_Average', name: 'DR_Average'},
|
|
@@ -7830,7 +7758,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
7830
7758
|
|
|
7831
7759
|
datesFields = lodash.map(datesFields, function (row) {
|
|
7832
7760
|
return {
|
|
7833
|
-
"format":
|
|
7761
|
+
"format": null,
|
|
7834
7762
|
"name": row.name,
|
|
7835
7763
|
"type": row.type,
|
|
7836
7764
|
"values": [],
|
|
@@ -7838,44 +7766,14 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
7838
7766
|
} //'MMM - yyyy' format
|
|
7839
7767
|
});
|
|
7840
7768
|
|
|
7841
|
-
if (!isFormattingDatesAsOtherAxisTypes) {
|
|
7842
|
-
lodash.forEach(datesFields, function (row) {
|
|
7843
|
-
row.val_not_convert = highchartsRenderer.check_values_not_for_convert(widget, row.name);
|
|
7844
|
-
});
|
|
7845
|
-
}
|
|
7846
|
-
|
|
7847
7769
|
if (datesFields.length > 0) {
|
|
7848
7770
|
widget.pivot.invertedDateStringMap = {};
|
|
7849
7771
|
lodash.forEach(res, function (element) {
|
|
7850
7772
|
for (var i in datesFields) {
|
|
7851
7773
|
if (element.hasOwnProperty(datesFields[i].name)) {
|
|
7852
7774
|
datesFields[i].values.push(element[datesFields[i].name]);
|
|
7853
|
-
|
|
7854
|
-
if (!isFormattingDatesAsOtherAxisTypes) {
|
|
7855
|
-
const dateStringValue = highchartsRenderer.returnRawDataValue(
|
|
7856
|
-
datesFields[i].type, element[datesFields[i].name],
|
|
7857
|
-
defaultDateFormat ? defaultDateFormat : datesFields[i].format,
|
|
7858
|
-
datesFields[i].name, datesFields[i].val_not_convert);
|
|
7859
|
-
if (widget.pivot) {
|
|
7860
|
-
if (!widget.pivot.dateValuesDictionary) {
|
|
7861
|
-
widget.pivot.dateValuesDictionary = {}
|
|
7862
|
-
}
|
|
7863
|
-
widget.pivot.dateValuesDictionary[dateStringValue] = element[datesFields[i].name];
|
|
7864
|
-
widget.pivot.invertedDateStringMap[element[datesFields[i].name]] = dateStringValue;
|
|
7865
|
-
}
|
|
7866
|
-
element[datesFields[i].name] = dateStringValue;
|
|
7867
|
-
}
|
|
7868
7775
|
}
|
|
7869
7776
|
}
|
|
7870
|
-
if (!isFormattingDatesAsOtherAxisTypes) {
|
|
7871
|
-
const keysObject = lodash.get(widget, 'pivot.keysObject');
|
|
7872
|
-
|
|
7873
|
-
lodash.forEach(['col_keys', 'row_keys', 'row_keys_by_cols'], (keysListName) => {
|
|
7874
|
-
const widgetFields = keysListName === 'col_keys' ? widget.cols : widget.rows;
|
|
7875
|
-
highchartsRenderer
|
|
7876
|
-
.replaceSortingKeysWithMappedValues(lodash.get(keysObject, keysListName), widget.pivot.invertedDateStringMap, widgetFields);
|
|
7877
|
-
});
|
|
7878
|
-
}
|
|
7879
7777
|
});
|
|
7880
7778
|
}
|
|
7881
7779
|
};
|
|
@@ -8235,9 +8133,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
8235
8133
|
filter.values = field.type === 'Date' && colKey !== NULL_VALUE
|
|
8236
8134
|
? highchartsRenderer.createDateTypeFromValue(colKey, format)
|
|
8237
8135
|
: [colKey];
|
|
8238
|
-
filter.value_to_show = field.type === 'Date'
|
|
8239
|
-
? highchartsRenderer.returnRawDataValue(field.type, +colKey, format, field.name)
|
|
8240
|
-
: colKey;
|
|
8136
|
+
filter.value_to_show = field.type === 'Date' ? highchartsRenderer.returnRawDataValue(field.type, +colKey, format, field.name) : colKey;
|
|
8241
8137
|
}
|
|
8242
8138
|
}
|
|
8243
8139
|
|
|
@@ -8330,12 +8226,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
8330
8226
|
return pivotData.isFormattingAxisLabels;
|
|
8331
8227
|
}
|
|
8332
8228
|
|
|
8333
|
-
highchartsRenderer.isFormattingDatesAsOtherAxisTypes = function () {
|
|
8334
|
-
return highchartsRenderer.hasFeature(FEATURES.FORMAT_DATES_AS_OTHER_AXIS_TYPES);
|
|
8335
|
-
}
|
|
8336
|
-
|
|
8337
8229
|
// Method for getting formatted kyes for Axis (cols, rows)
|
|
8338
|
-
highchartsRenderer.getFormattedKey = function (initialKey, pivotData, type
|
|
8230
|
+
highchartsRenderer.getFormattedKey = function (initialKey, pivotData, type) {
|
|
8339
8231
|
const isFlatKey = lodash.isString(initialKey) || lodash.isNumber(initialKey);
|
|
8340
8232
|
if (isFlatKey || lodash.isArray(initialKey)) {
|
|
8341
8233
|
let values = isFlatKey ? initialKey.toString().split(highchartsRenderer.delimer) : lodash.cloneDeep(initialKey);
|
|
@@ -8344,10 +8236,9 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
8344
8236
|
const formatInfo = pivotData[type][key] || {};
|
|
8345
8237
|
const valueToFloat = parseFloat(value);
|
|
8346
8238
|
const isDate = formatInfo.type === 'Date' && (moment_lib(valueToFloat).isValid() || moment_lib(value, formatInfo.format).isValid());
|
|
8347
|
-
const isDateFormatting = isDate && (forceFormatDates || highchartsRenderer.isFormattingDatesAsOtherAxisTypes());
|
|
8348
8239
|
const isNumberFormatting = !isDate && formatInfo.format && highchartsRenderer.isFormattingNumberAxis(pivotData);
|
|
8349
8240
|
|
|
8350
|
-
if (isNumberFormatting ||
|
|
8241
|
+
if (isNumberFormatting || isDate) {
|
|
8351
8242
|
values[key] = highchartsRenderer.returnRawDataValue(
|
|
8352
8243
|
formatInfo.type,
|
|
8353
8244
|
!isNaN(valueToFloat) ? valueToFloat : value,
|
|
@@ -8372,13 +8263,13 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
8372
8263
|
return highchartsRenderer.getFormattedKey(initialValue, pivotData, 'rowFormats')
|
|
8373
8264
|
}
|
|
8374
8265
|
|
|
8375
|
-
highchartsRenderer.getFormattedKeys = function(pivotData, isCols, keys
|
|
8266
|
+
highchartsRenderer.getFormattedKeys = function(pivotData, isCols, keys) {
|
|
8376
8267
|
keys = keys || (isCols ? pivotData.getColKeys() : pivotData.getRowKeys());
|
|
8377
|
-
return lodash.map(keys, key => highchartsRenderer.getFormattedKey(key, pivotData, isCols ? 'colFormats' : 'rowFormats'
|
|
8268
|
+
return lodash.map(keys, key => highchartsRenderer.getFormattedKey(key, pivotData, isCols ? 'colFormats' : 'rowFormats'));
|
|
8378
8269
|
}
|
|
8379
8270
|
|
|
8380
|
-
highchartsRenderer.getFormattedColKeys = function(pivotData, keys
|
|
8381
|
-
return highchartsRenderer.getFormattedKeys(pivotData, true, keys
|
|
8271
|
+
highchartsRenderer.getFormattedColKeys = function(pivotData, keys) {
|
|
8272
|
+
return highchartsRenderer.getFormattedKeys(pivotData, true, keys);
|
|
8382
8273
|
}
|
|
8383
8274
|
|
|
8384
8275
|
highchartsRenderer.getFormattedRowKeys = function(pivotData, keys) {
|
|
@@ -5088,12 +5088,7 @@ describe('highcharts_renderer', () => {
|
|
|
5088
5088
|
});
|
|
5089
5089
|
|
|
5090
5090
|
describe('formatting Dates', () => {
|
|
5091
|
-
|
|
5092
|
-
lodash.set(document, 'ReportHippo.user.features', []);
|
|
5093
|
-
});
|
|
5094
|
-
|
|
5095
|
-
it('should return formatted multivalue colKey as array (format_dates_as_other_axis_types is ON)', () => {
|
|
5096
|
-
highchartsRenderer.setFeatures(['format_dates_as_other_axis_types']);
|
|
5091
|
+
it('should return formatted multivalue colKey as array', () => {
|
|
5097
5092
|
const initialKey = [1687277052, 1687277052];
|
|
5098
5093
|
const pivotData = {
|
|
5099
5094
|
colFormats: [{ type: 'Date', format: 'MM/DD/YYYY' }, { type: 'Date', format: 'MMM-yy' }],
|
|
@@ -5104,8 +5099,7 @@ describe('highcharts_renderer', () => {
|
|
|
5104
5099
|
expect(formattedKey).toEqual(['06/20/2023', 'Jun-23']);
|
|
5105
5100
|
});
|
|
5106
5101
|
|
|
5107
|
-
it('should return formatted multivalue rowKey as array
|
|
5108
|
-
highchartsRenderer.setFeatures(['format_dates_as_other_axis_types']);
|
|
5102
|
+
it('should return formatted multivalue rowKey as array', () => {
|
|
5109
5103
|
const initialKey = [1687277052, 1687277052];
|
|
5110
5104
|
const pivotData = {
|
|
5111
5105
|
rowFormats: [{ type: 'Date', format: 'MM/DD/YYYY' }, { type: 'Date', format: 'MMM-yy' }],
|
|
@@ -5116,32 +5110,7 @@ describe('highcharts_renderer', () => {
|
|
|
5116
5110
|
expect(formattedKey).toEqual(['06/20/2023', 'Jun-23']);
|
|
5117
5111
|
});
|
|
5118
5112
|
|
|
5119
|
-
it('should return NOT formatted multivalue colKey as array (format_dates_as_other_axis_types is OFF)', () => {
|
|
5120
|
-
highchartsRenderer.setFeatures([]);
|
|
5121
|
-
const initialKeyAlreadyFormatted = ['10/10/2020', '10/10/2021'];
|
|
5122
|
-
const pivotData = {
|
|
5123
|
-
colFormats: [{ type: 'Date', format: 'MM/DD/YYYY' }, { type: 'Date', format: 'MMM-yy' }],
|
|
5124
|
-
isFormattingAxisLabels: true,
|
|
5125
|
-
};
|
|
5126
|
-
const type = 'colFormats';
|
|
5127
|
-
const formattedKey = highchartsRenderer.getFormattedKey(initialKeyAlreadyFormatted, pivotData, type);
|
|
5128
|
-
expect(formattedKey).toEqual(initialKeyAlreadyFormatted);
|
|
5129
|
-
});
|
|
5130
|
-
|
|
5131
|
-
it('should return NOT formatted multivalue rowKey as array (format_dates_as_other_axis_types is OFF)', () => {
|
|
5132
|
-
highchartsRenderer.setFeatures([]);
|
|
5133
|
-
const initialKeyAlreadyFormatted = ['10/10/2020', '10/10/2021'];
|
|
5134
|
-
const pivotData = {
|
|
5135
|
-
rowFormats: [{ type: 'Date', format: 'MM/DD/YYYY' }, { type: 'Date', format: 'MMM-yy' }],
|
|
5136
|
-
isFormattingAxisLabels: true,
|
|
5137
|
-
};
|
|
5138
|
-
const type = 'rowFormats';
|
|
5139
|
-
const formattedKey = highchartsRenderer.getFormattedKey(initialKeyAlreadyFormatted, pivotData, type);
|
|
5140
|
-
expect(formattedKey).toEqual(initialKeyAlreadyFormatted);
|
|
5141
|
-
});
|
|
5142
|
-
|
|
5143
5113
|
it('should return NOT formatted value when type is Date but value is not a valid moment date', () => {
|
|
5144
|
-
lodash.set(document, 'ReportHippo.user.features', ['format_dates_as_other_axis_types']);
|
|
5145
5114
|
const initialKey = ['Some Text Value', 'Another Text'];
|
|
5146
5115
|
const pivotData = {
|
|
5147
5116
|
colFormats: [{ type: 'Date' }, { type: 'Date' }],
|
|
@@ -5151,28 +5120,6 @@ describe('highcharts_renderer', () => {
|
|
|
5151
5120
|
const formattedKey = highchartsRenderer.getFormattedKey(initialKey, pivotData, type);
|
|
5152
5121
|
expect(formattedKey).toEqual(initialKey);
|
|
5153
5122
|
});
|
|
5154
|
-
|
|
5155
|
-
it('should return formatted value when type is Date and value is a valid moment date (format_dates_as_other_axis_types is OFF)', () => {
|
|
5156
|
-
const initialKey = ['Feb-24', 'Jan-24'];
|
|
5157
|
-
const pivotData = {
|
|
5158
|
-
colFormats: [{ type: 'Date' }, { type: 'Date' }],
|
|
5159
|
-
isFormattingAxisLabels: true,
|
|
5160
|
-
};
|
|
5161
|
-
const type = 'colFormats';
|
|
5162
|
-
const formattedKey = highchartsRenderer.getFormattedKey(initialKey, pivotData, type);
|
|
5163
|
-
expect(formattedKey).toEqual(initialKey);
|
|
5164
|
-
});
|
|
5165
|
-
|
|
5166
|
-
it('should return formatted value when type is Date and value is a valid moment date (with valid format)', () => {
|
|
5167
|
-
const initialKey = ['Q4-20'];
|
|
5168
|
-
const pivotData = {
|
|
5169
|
-
colFormats: [{ format: "[Q]Q-YY", name: "Date", type: "Date" }],
|
|
5170
|
-
isFormattingAxisLabels: true,
|
|
5171
|
-
};
|
|
5172
|
-
const type = 'colFormats';
|
|
5173
|
-
const formattedKey = highchartsRenderer.getFormattedKey(initialKey, pivotData, type);
|
|
5174
|
-
expect(formattedKey).toEqual(initialKey);
|
|
5175
|
-
});
|
|
5176
5123
|
});
|
|
5177
5124
|
});
|
|
5178
5125
|
|
|
@@ -5274,7 +5221,7 @@ describe('highcharts_renderer', () => {
|
|
|
5274
5221
|
|
|
5275
5222
|
it('should getFormattedColKeys call getFormattedKeys for colFormats', () => {
|
|
5276
5223
|
highchartsRenderer.getFormattedColKeys('test1', 'test2');
|
|
5277
|
-
expect(highchartsRenderer.getFormattedKeys).toHaveBeenCalledWith('test1', true, 'test2'
|
|
5224
|
+
expect(highchartsRenderer.getFormattedKeys).toHaveBeenCalledWith('test1', true, 'test2');
|
|
5278
5225
|
});
|
|
5279
5226
|
|
|
5280
5227
|
it('should getFormattedRowKeys call getFormattedKeys for rowFormats', () => {
|
|
@@ -6027,14 +5974,6 @@ describe('highcharts_renderer', () => {
|
|
|
6027
5974
|
describe('Function tableCSVExportRenderer', () => {
|
|
6028
5975
|
window._ = lodash;
|
|
6029
5976
|
|
|
6030
|
-
beforeEach(() => {
|
|
6031
|
-
lodash.set(document, 'ReportHippo.user.features', ['format_dates_as_other_axis_types']);
|
|
6032
|
-
});
|
|
6033
|
-
|
|
6034
|
-
afterEach(() => {
|
|
6035
|
-
lodash.set(document, 'ReportHippo.user.features', []);
|
|
6036
|
-
});
|
|
6037
|
-
|
|
6038
5977
|
it('should create csv json object representation based on pivot data (only cols)', () => {
|
|
6039
5978
|
const chartOptions = {
|
|
6040
5979
|
table_options: {
|
|
@@ -8154,7 +8093,6 @@ describe('highcharts_renderer', () => {
|
|
|
8154
8093
|
});
|
|
8155
8094
|
spyOn(highchartsRenderer, 'getFormattedColKey')
|
|
8156
8095
|
.and.callFake((initialName, pivotData) => `formatted(${ initialName })`);
|
|
8157
|
-
spyOn(highchartsRenderer, 'isFormattingDatesAsOtherAxisTypes').and.returnValue(true);
|
|
8158
8096
|
});
|
|
8159
8097
|
|
|
8160
8098
|
it("should create appropriate series for case when only one column field and one total", () => {
|
|
@@ -9215,7 +9153,6 @@ describe('highcharts_renderer', () => {
|
|
|
9215
9153
|
.and.callFake((initialName, pivotData) => `formatted_col(${ initialName })`);
|
|
9216
9154
|
spyOn(highchartsRenderer, 'getFormattedRowKey')
|
|
9217
9155
|
.and.callFake((initialName, pivotData) => `formatted_row(${ initialName })`);
|
|
9218
|
-
spyOn(highchartsRenderer, 'isFormattingDatesAsOtherAxisTypes').and.returnValue(true);
|
|
9219
9156
|
});
|
|
9220
9157
|
|
|
9221
9158
|
it("should create appropriate series for case no breakdown field (one row value - Variance instead)", () => {
|