@datarailsshared/dr_renderer 1.2.378 → 1.2.382
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 +13 -13
- package/tests/highcharts_renderer.test.js +14 -12
package/package.json
CHANGED
@@ -6017,16 +6017,14 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
6017
6017
|
];
|
6018
6018
|
|
6019
6019
|
highchartsRenderer.getDefaultValueForChart = function (type, existing_options) {
|
6020
|
-
|
6021
|
-
|
6022
|
-
|
6023
|
-
|
6024
|
-
|
6025
|
-
}
|
6026
|
-
var valToReturn = {};
|
6020
|
+
const chartOpt = type === highchartsRenderer.richTextSubType.type
|
6021
|
+
? highchartsRenderer.richTextSubType
|
6022
|
+
: highchartsRenderer.getChartOptionsBySubType(type);
|
6023
|
+
|
6024
|
+
let valToReturn = {};
|
6027
6025
|
if (chartOpt) {
|
6028
|
-
lodash.forEach(chartOpt.suboptions,
|
6029
|
-
valToReturn[suboption.category_type] = highchartsRenderer.getDefaultValueForSubOptions(suboption
|
6026
|
+
lodash.forEach(chartOpt.suboptions, (suboption) => {
|
6027
|
+
valToReturn[suboption.category_type] = highchartsRenderer.getDefaultValueForSubOptions(suboption, existing_options);
|
6030
6028
|
});
|
6031
6029
|
}
|
6032
6030
|
|
@@ -6107,10 +6105,11 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
6107
6105
|
return key
|
6108
6106
|
};
|
6109
6107
|
|
6110
|
-
highchartsRenderer.getDefaultValueForSubOptions = function (
|
6111
|
-
|
6112
|
-
|
6108
|
+
highchartsRenderer.getDefaultValueForSubOptions = function (option, existing_options) {
|
6109
|
+
const valToReturn = {};
|
6110
|
+
|
6113
6111
|
if (option) {
|
6112
|
+
const type = option.category_type;
|
6114
6113
|
lodash.forEach(option.elements, function (elem) {
|
6115
6114
|
if (existing_options && lodash.has(existing_options, type + '.' + elem.value_name)) {
|
6116
6115
|
valToReturn[elem.value_name] = lodash.get(existing_options, type + '.' + elem.value_name);
|
@@ -8896,6 +8895,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
8896
8895
|
let datesFields = [];
|
8897
8896
|
datesFields = lodash.filter(widget.rows, element => element.type == 'Date');
|
8898
8897
|
datesFields = datesFields.concat(lodash.filter(widget.cols, element => element.type == 'Date'));
|
8898
|
+
datesFields = lodash.cloneDeep(datesFields);
|
8899
8899
|
|
8900
8900
|
const isCustomSorting = widget.options.sortingFields && Array.isArray(widget.options.sortingFields) && widget.options.sortingFields.length > 0;
|
8901
8901
|
if (isCustomSorting) {
|
@@ -8991,7 +8991,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
8991
8991
|
|
8992
8992
|
/* date string */
|
8993
8993
|
var rowsAndCols = [];
|
8994
|
-
rowsAndCols = widget.rows.concat(widget.cols);
|
8994
|
+
rowsAndCols = lodash.cloneDeep(widget.rows.concat(widget.cols));
|
8995
8995
|
|
8996
8996
|
if (widget.chart_type === highchartsRenderer.CHART_TYPES.WATERFALL_BREAKDOWN && !highchartsRenderer.sortHasBeenDoneOnBE(lodash.get(widget, 'pivot.keysObject'))) {
|
8997
8997
|
|
@@ -3436,17 +3436,19 @@ describe('highcharts_renderer', () => {
|
|
3436
3436
|
highchartsRenderer.suboptions = tempSubOptions;
|
3437
3437
|
});
|
3438
3438
|
|
3439
|
-
it('should return an empty object if
|
3440
|
-
const type = 'invalid_type';
|
3439
|
+
it('should return an empty object if passed suboption is falsy', () => {
|
3441
3440
|
const existing_options = {};
|
3442
|
-
const
|
3443
|
-
expect(
|
3441
|
+
const result1 = highchartsRenderer.getDefaultValueForSubOptions(null, existing_options);
|
3442
|
+
expect(result1).toEqual({});
|
3443
|
+
|
3444
|
+
const result2 = highchartsRenderer.getDefaultValueForSubOptions(undefined, existing_options);
|
3445
|
+
expect(result2).toEqual({});
|
3444
3446
|
});
|
3445
3447
|
|
3446
3448
|
it('should return default values for all elements in suboption', () => {
|
3447
|
-
const
|
3449
|
+
const suboption = suboptions.option1;
|
3448
3450
|
const existing_options = {};
|
3449
|
-
const result = highchartsRenderer.getDefaultValueForSubOptions(
|
3451
|
+
const result = highchartsRenderer.getDefaultValueForSubOptions(suboption, existing_options);
|
3450
3452
|
expect(result).toEqual({
|
3451
3453
|
value1: 'default1',
|
3452
3454
|
value2: 42,
|
@@ -3454,14 +3456,14 @@ describe('highcharts_renderer', () => {
|
|
3454
3456
|
});
|
3455
3457
|
|
3456
3458
|
it('should use existing options if available', () => {
|
3457
|
-
const
|
3459
|
+
const suboption = suboptions.option1;
|
3458
3460
|
const existing_options = {
|
3459
3461
|
type1: {
|
3460
3462
|
value1: 'existing1',
|
3461
3463
|
value2: 99,
|
3462
3464
|
},
|
3463
3465
|
};
|
3464
|
-
const result = highchartsRenderer.getDefaultValueForSubOptions(
|
3466
|
+
const result = highchartsRenderer.getDefaultValueForSubOptions(suboption, existing_options);
|
3465
3467
|
expect(result).toEqual({
|
3466
3468
|
value1: 'existing1',
|
3467
3469
|
value2: 99,
|
@@ -3469,16 +3471,16 @@ describe('highcharts_renderer', () => {
|
|
3469
3471
|
});
|
3470
3472
|
|
3471
3473
|
it('should ignore elements with type "devider"', () => {
|
3472
|
-
const
|
3474
|
+
const suboption = suboptions.option1;
|
3473
3475
|
const existing_options = {};
|
3474
|
-
const result = highchartsRenderer.getDefaultValueForSubOptions(
|
3476
|
+
const result = highchartsRenderer.getDefaultValueForSubOptions(suboption, existing_options);
|
3475
3477
|
expect(result).not.toHaveProperty('value3');
|
3476
3478
|
});
|
3477
3479
|
|
3478
3480
|
it('should clone default value if it is an object', () => {
|
3479
|
-
const
|
3481
|
+
const suboption = suboptions.option3;
|
3480
3482
|
const existing_options = {};
|
3481
|
-
const result = highchartsRenderer.getDefaultValueForSubOptions(
|
3483
|
+
const result = highchartsRenderer.getDefaultValueForSubOptions(suboption, existing_options);
|
3482
3484
|
expect(result.value1).toEqual(suboptions.option3.elements[0].default_value);
|
3483
3485
|
expect(result.value1).not.toBe(suboptions.option3.elements[0].default_value);
|
3484
3486
|
});
|