@datarailsshared/dr_renderer 1.2.307-dragons → 1.2.309
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/dr_pivottable.js +2 -13
- package/src/highcharts_renderer.js +199 -90
- package/tests/highcharts_renderer.test.js +12 -0
package/package.json
CHANGED
package/src/dr_pivottable.js
CHANGED
@@ -91,7 +91,6 @@ let initDRPivotTable = function($, window, document) {
|
|
91
91
|
|
92
92
|
DRPivotData.prototype.arrSort = function(attrs) {
|
93
93
|
var a, sortersArr;
|
94
|
-
const sortByValueAttrs = this.sortByValueAttrs;
|
95
94
|
sortersArr = (function() {
|
96
95
|
var l, len1, results;
|
97
96
|
results = [];
|
@@ -101,21 +100,11 @@ let initDRPivotTable = function($, window, document) {
|
|
101
100
|
}
|
102
101
|
return results;
|
103
102
|
}).call(this);
|
104
|
-
|
105
103
|
return function(a, b) {
|
106
104
|
var comparison, i, sorter;
|
107
105
|
for (i in sortersArr) {
|
108
|
-
|
109
|
-
|
110
|
-
if (sortByValueAttrs.indexOf(attrs[index]) !== -1) {
|
111
|
-
|
112
|
-
// For case current Field attrs[index] is sorted by value we are concatenating values passed to sorter function
|
113
|
-
// Concatenation is done from first field in a block (first axis or first series) until current field index.
|
114
|
-
// Cause for this case sorting will be as list of these concatenated strings (which is prepared in getSortingByValueOrderList)
|
115
|
-
comparison = sorter(a.slice(0, index + 1).join(','), b.slice(0, index + 1).join(','));
|
116
|
-
} else {
|
117
|
-
comparison = sorter(a[index], b[index]);
|
118
|
-
}
|
106
|
+
sorter = sortersArr[i];
|
107
|
+
comparison = sorter(a[i], b[i]);
|
119
108
|
if (comparison !== 0) {
|
120
109
|
return comparison;
|
121
110
|
}
|
@@ -1150,7 +1150,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
1150
1150
|
ob.name = row_n_value.join(highchartsRenderer.delimer)
|
1151
1151
|
.replace(highchartsRenderer.DR_OTHERS_KEY, othersName);
|
1152
1152
|
}
|
1153
|
-
|
1154
1153
|
lodash.forEach(col_n_keys, function (col_n_value, index) {
|
1155
1154
|
var agg = pivotData.getAggregator(row_n_value, col_n_value);
|
1156
1155
|
var val = agg.value();
|
@@ -1392,7 +1391,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
1392
1391
|
if (opts.trendLine) {
|
1393
1392
|
const a = ((ySum * squareXSum) - (xSum * xySum)) / ((n * squareXSum) - (xSum * xSum));
|
1394
1393
|
const b = ((n * xySum) - (xSum* ySum)) / ((n * squareXSum) - (xSum * xSum));
|
1395
|
-
|
1396
1394
|
const trendSeries = lodash.clone(chart_series[chart_series.length - 1]);
|
1397
1395
|
trendSeries.className = 'trendSeries';
|
1398
1396
|
trendSeries.name = highchartsRenderer.getTrendSeriesName(trendSeries);
|
@@ -1403,7 +1401,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
1403
1401
|
if (colors && colors[i]) {
|
1404
1402
|
trendSeries.color = colors[i];
|
1405
1403
|
}
|
1406
|
-
|
1407
1404
|
trendSerieses.push(trendSeries);
|
1408
1405
|
}
|
1409
1406
|
i++;
|
@@ -1420,7 +1417,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
1420
1417
|
}
|
1421
1418
|
|
1422
1419
|
let weights = { line: 2,spline: 3 ,area:-2, areaspline: -1, scatter:4, column: 1 };
|
1423
|
-
|
1424
1420
|
if (opts.comboOptions && lodash.includes(chartType,'combo') && !lodash.isEqual(row_n_keys, EMPTY_ROW_N_KEYS)) {
|
1425
1421
|
chart_series.forEach((series, seriesIndex) => {
|
1426
1422
|
const savedSeriesOption = lodash.find(opts.comboOptions.seriesOptions, {series: series.name});
|
@@ -1640,18 +1636,19 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
1640
1636
|
? lodash.get(waterfallOptions, 'colors', {}).increase || baseColor.increase
|
1641
1637
|
: lodash.get(waterfallOptions, 'colors', {}).decrease || baseColor.decrease;
|
1642
1638
|
}
|
1643
|
-
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1654
|
-
|
1639
|
+
if (val !== 0) {
|
1640
|
+
resultObject.data.push({
|
1641
|
+
y: val,
|
1642
|
+
name: lodash.replace(
|
1643
|
+
lodash.unescape(name), highchartsRenderer.DR_OTHERS_KEY, highchartsRenderer.getOthersName(opts)
|
1644
|
+
),
|
1645
|
+
totalIndex: value.trend === 'total' ? index : undefined,
|
1646
|
+
isSum: value.trend === 'total',
|
1647
|
+
isTotal: value.trend === 'total',
|
1648
|
+
color,
|
1649
|
+
colsForTotal: value.trend === 'total' ? keys : null,
|
1650
|
+
});
|
1651
|
+
}
|
1655
1652
|
});
|
1656
1653
|
chart_series.push(resultObject);
|
1657
1654
|
chart_series.push(
|
@@ -2675,7 +2672,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
2675
2672
|
}
|
2676
2673
|
};
|
2677
2674
|
}
|
2678
|
-
|
2675
|
+
|
2679
2676
|
if (lodash.get(chartOptions, 'plotOptions.series.point.events')) {
|
2680
2677
|
chartOptions.plotOptions.series.point.events.mouseOver = opts.trackUserInsightsTooltipFunc;
|
2681
2678
|
chartOptions.plotOptions.series.point.events.mouseOut = opts.trackUserInsightsTooltipFunc;
|
@@ -4411,42 +4408,72 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4411
4408
|
return ret_str;
|
4412
4409
|
};
|
4413
4410
|
|
4414
|
-
highchartsRenderer.
|
4415
|
-
let
|
4416
|
-
|
4417
|
-
|
4418
|
-
|
4419
|
-
|
4420
|
-
let valueForComparison;
|
4421
|
-
if (sortingOptions.sort_by === 'variance') {
|
4422
|
-
const varianceConfig = widget.options.chartOptions.delta_column;
|
4423
|
-
const data = pivotData.input;
|
4424
|
-
const varianceField = varianceConfig.field === 'category' ? widget.cols[0] : widget.rows[0];
|
4425
|
-
const varianceRowsForCurrentKey = lodash.filter(data, row =>
|
4426
|
-
row[varianceField.name] === varianceConfig.name
|
4427
|
-
&& lodash.every(secondArray, (item, index) => row[attrs[index]] === item)
|
4428
|
-
);
|
4411
|
+
highchartsRenderer.getNewAttrSortingForCol = function (pivotData, sortingOptions) {
|
4412
|
+
let rowAttrs, rowKeys, colKeys, colAttrs;
|
4413
|
+
rowAttrs = pivotData.rowAttrs;
|
4414
|
+
rowKeys = pivotData.rowKeys;
|
4415
|
+
colKeys = pivotData.colKeys;
|
4416
|
+
colAttrs = pivotData.colAttrs;
|
4429
4417
|
|
4430
|
-
valueForComparison = lodash.reduce(varianceRowsForCurrentKey, (a, d) => a + d[widget.vals[0].name], 0);
|
4431
|
-
} else {
|
4432
|
-
let getAggregatorParams = [firstArray, secondArray];
|
4433
4418
|
|
4434
|
-
|
4435
|
-
|
4436
|
-
|
4437
|
-
|
4438
|
-
|
4419
|
+
if (!colAttrs || colAttrs.length == 0) {
|
4420
|
+
return null;
|
4421
|
+
}
|
4422
|
+
|
4423
|
+
let values_names_arr = [];
|
4424
|
+
let keysArray = sortingOptions.field ? rowKeys : colKeys;
|
4425
|
+
|
4426
|
+
lodash.forEach(keysArray, function (val) {
|
4427
|
+
let firstArray = sortingOptions.field ? [val[0]] : [];
|
4428
|
+
let secondArray = sortingOptions.field ? sortingOptions.field.split(highchartsRenderer.delimer) : [val[0]];
|
4429
|
+
let aggregator_subtotal = pivotData.getAggregator(firstArray, secondArray);
|
4439
4430
|
|
4440
|
-
|
4441
|
-
|
4431
|
+
if (aggregator_subtotal) {
|
4432
|
+
let value_subtotal = aggregator_subtotal.value();
|
4433
|
+
if (sortingOptions && sortingOptions.is_absolute && !isNaN(parseFloat(value_subtotal))) {
|
4434
|
+
value_subtotal = Math.abs(value_subtotal);
|
4442
4435
|
}
|
4436
|
+
values_names_arr.push({name: val[0], value: value_subtotal});
|
4443
4437
|
}
|
4438
|
+
});
|
4439
|
+
|
4440
|
+
// ORDERING
|
4441
|
+
let sorting_vector = ['asc'];
|
4442
|
+
if (sortingOptions && sortingOptions.type == 'largestToSmallest') {
|
4443
|
+
sorting_vector = ['desc'];
|
4444
|
+
}
|
4445
|
+
values_names_arr = lodash.orderBy(values_names_arr, ['value'], sorting_vector);
|
4446
|
+
|
4447
|
+
// map only names
|
4448
|
+
let attr_sorted_values = lodash.map(values_names_arr, 'name');
|
4449
|
+
return {name: sortingOptions.field ? rowAttrs[0] : colAttrs[0], values: attr_sorted_values};
|
4450
|
+
};
|
4444
4451
|
|
4445
|
-
|
4446
|
-
|
4447
|
-
|
4452
|
+
highchartsRenderer.getNewAttrSortingForRow = function (pivotData, sortingOptions) {
|
4453
|
+
let rowAttrs, rowKeys, colKeys, colAttrs;
|
4454
|
+
rowAttrs = pivotData.rowAttrs;
|
4455
|
+
rowKeys = pivotData.rowKeys;
|
4456
|
+
colKeys = pivotData.colKeys;
|
4457
|
+
colAttrs = pivotData.colAttrs;
|
4458
|
+
|
4459
|
+
if (!rowAttrs || rowAttrs.length == 0) {
|
4460
|
+
return null;
|
4461
|
+
}
|
4462
|
+
|
4463
|
+
let values_names_arr = [];
|
4464
|
+
let keysArray = sortingOptions.field ? colKeys : rowKeys;
|
4465
|
+
|
4466
|
+
lodash.forEach(keysArray, function (val) {
|
4467
|
+
let firstArray = sortingOptions.field ? sortingOptions.field.split(highchartsRenderer.delimer) : [val[0]];
|
4468
|
+
let secondArray = sortingOptions.field ? [val[0]] : [];
|
4469
|
+
let aggregator_subtotal = pivotData.getAggregator(firstArray, secondArray);
|
4470
|
+
|
4471
|
+
if (aggregator_subtotal) {
|
4472
|
+
let value_subtotal = aggregator_subtotal.value();
|
4473
|
+
if (sortingOptions && sortingOptions.is_absolute && !isNaN(parseFloat(value_subtotal))) {
|
4474
|
+
value_subtotal = Math.abs(value_subtotal);
|
4448
4475
|
}
|
4449
|
-
values_names_arr.push({name:
|
4476
|
+
values_names_arr.push({name: val[0], value: value_subtotal});
|
4450
4477
|
}
|
4451
4478
|
});
|
4452
4479
|
|
@@ -4458,33 +4485,36 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4458
4485
|
values_names_arr = lodash.orderBy(values_names_arr, ['value'], sorting_vector);
|
4459
4486
|
|
4460
4487
|
// map only names
|
4461
|
-
|
4488
|
+
let attr_sorted_values = lodash.map(values_names_arr, 'name');
|
4489
|
+
return {name: sortingOptions.field ? colAttrs[0] : rowAttrs[0], values: attr_sorted_values};
|
4462
4490
|
};
|
4463
4491
|
|
4464
|
-
highchartsRenderer.generateSortingFunctionByValues = function (
|
4492
|
+
highchartsRenderer.generateSortingFunctionByValues = function (sortingOptions, pivotData, opts) {
|
4493
|
+
let new_map;
|
4494
|
+
let axis = highchartsRenderer.getAxis(sortingOptions.axis, opts);
|
4495
|
+
if (axis == 'col_total') {
|
4496
|
+
new_map = highchartsRenderer.getNewAttrSortingForCol(pivotData, sortingOptions);
|
4497
|
+
} else if (axis == 'row_total') {
|
4498
|
+
new_map = highchartsRenderer.getNewAttrSortingForRow(pivotData, sortingOptions);
|
4499
|
+
}
|
4500
|
+
|
4465
4501
|
let old_sorters_function = opts.sorters;
|
4466
4502
|
if (!old_sorters_function) {
|
4467
4503
|
old_sorters_function = function () {
|
4468
4504
|
};
|
4469
4505
|
}
|
4470
|
-
|
4471
|
-
|
4472
|
-
|
4473
|
-
|
4474
|
-
|
4475
|
-
|
4476
|
-
|
4477
|
-
|
4478
|
-
sortingOptions.sorting,
|
4479
|
-
pivotData[isColumnSort ? 'colKeys' : 'rowKeys'],
|
4480
|
-
pivotData[isColumnSort ? 'colAttrs' : 'rowAttrs'],
|
4481
|
-
fieldIndex,
|
4482
|
-
widget
|
4483
|
-
);
|
4484
|
-
return $.pivotUtilities.sortAs(orderedNamesList);
|
4485
|
-
} else {
|
4486
|
-
return old_sorters_function(attr);
|
4506
|
+
if (new_map) {
|
4507
|
+
var sortAs = $.pivotUtilities.sortAs;
|
4508
|
+
let new_sorters_function = function (attr) {
|
4509
|
+
if (new_map.name == attr) {
|
4510
|
+
return $.pivotUtilities.sortAs(new_map.values);
|
4511
|
+
} else {
|
4512
|
+
return old_sorters_function(attr);
|
4513
|
+
}
|
4487
4514
|
}
|
4515
|
+
return new_sorters_function;
|
4516
|
+
} else {
|
4517
|
+
return old_sorters_function;
|
4488
4518
|
}
|
4489
4519
|
};
|
4490
4520
|
|
@@ -4688,7 +4718,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4688
4718
|
result = null;
|
4689
4719
|
try {
|
4690
4720
|
pivotData = $.pivotUtilities.getPivotDataModel(rowData, opts);
|
4691
|
-
pivotData.sortByValueAttrs = [];
|
4692
4721
|
try {
|
4693
4722
|
if (options && options.onlyOptions) {
|
4694
4723
|
if (!opts.rendererOptions) {
|
@@ -4696,15 +4725,9 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4696
4725
|
}
|
4697
4726
|
opts.rendererOptions.onlyOptions = true;
|
4698
4727
|
}
|
4699
|
-
|
4700
|
-
|
4701
|
-
|
4702
|
-
sortingField => lodash.includes(['field_values', 'variance'], lodash.get(sortingField, 'sorting.sort_by'))
|
4703
|
-
);
|
4704
|
-
|
4705
|
-
if (sortByValueSettings.length) {
|
4706
|
-
pivotData.sortByValueAttrs = lodash.map(sortByValueSettings, fieldSorting => fieldSorting.name);
|
4707
|
-
let new_sorting_function = highchartsRenderer.generateSortingFunctionByValues(sortByValueSettings, pivotData, opts, widget);
|
4728
|
+
var totalFilters = lodash.get(opts, 'rendererOptions.total_value_options', null);
|
4729
|
+
if (totalFilters && totalFilters.sorting_options) {
|
4730
|
+
let new_sorting_function = highchartsRenderer.generateSortingFunctionByValues(totalFilters.sorting_options, pivotData, opts);
|
4708
4731
|
opts.sorters = new_sorting_function;
|
4709
4732
|
optsFiltered.sorters = new_sorting_function;
|
4710
4733
|
pivotData.sorters = new_sorting_function;
|
@@ -5019,7 +5042,19 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
5019
5042
|
};
|
5020
5043
|
|
5021
5044
|
highchartsRenderer.isSystemField = function (field) {
|
5022
|
-
|
5045
|
+
const features = lodash.get(document, 'ReportHippo.user.features', []);
|
5046
|
+
const dynamicSystemFields = [];
|
5047
|
+
|
5048
|
+
const areMultipleAndScenarioTags = lodash.includes(features, 'multiple_dimension_tags')
|
5049
|
+
&& lodash.includes(features, 'use_new_scenario_tag');
|
5050
|
+
|
5051
|
+
if (areMultipleAndScenarioTags) {
|
5052
|
+
dynamicSystemFields.push('Scenario', 'Budget Cycle');
|
5053
|
+
}
|
5054
|
+
|
5055
|
+
const regexDelimer = '|';
|
5056
|
+
const dynamicSystemFieldsRegex = dynamicSystemFields.length ? dynamicSystemFields.join(regexDelimer) + regexDelimer : '';
|
5057
|
+
var regex = new RegExp(`^(${dynamicSystemFieldsRegex}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");
|
5023
5058
|
|
5024
5059
|
return (field.category && field.category.includes("")) || regex.test(field.name)
|
5025
5060
|
};
|
@@ -7055,6 +7090,18 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
7055
7090
|
value_name: 'is_percentage',
|
7056
7091
|
default_value: false,
|
7057
7092
|
hidden: true,
|
7093
|
+
}, {
|
7094
|
+
element_type: 'checkbox',
|
7095
|
+
element_label: 'Sort by variance',
|
7096
|
+
value_name: 'sort_by_variance',
|
7097
|
+
default_value: false,
|
7098
|
+
hidden: true
|
7099
|
+
}, {
|
7100
|
+
element_type: 'checkbox',
|
7101
|
+
element_label: 'Sort by absolute variance',
|
7102
|
+
value_name: 'sort_by_absolute_variance',
|
7103
|
+
default_value: false,
|
7104
|
+
hidden: true
|
7058
7105
|
}]
|
7059
7106
|
},
|
7060
7107
|
'delta_column_for_drill_down': {
|
@@ -7121,6 +7168,18 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
7121
7168
|
value_name: 'is_percentage',
|
7122
7169
|
default_value: false,
|
7123
7170
|
hidden: true,
|
7171
|
+
}, {
|
7172
|
+
element_type: 'checkbox',
|
7173
|
+
element_label: 'Sort by variance',
|
7174
|
+
value_name: 'sort_by_variance',
|
7175
|
+
default_value: false,
|
7176
|
+
hidden: true
|
7177
|
+
}, {
|
7178
|
+
element_type: 'checkbox',
|
7179
|
+
element_label: 'Sort by absolute variance',
|
7180
|
+
value_name: 'sort_by_absolute_variance',
|
7181
|
+
default_value: false,
|
7182
|
+
hidden: true
|
7124
7183
|
}, {
|
7125
7184
|
element_type: 'checkbox',
|
7126
7185
|
element_label: 'Filter zero values',
|
@@ -8637,9 +8696,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
8637
8696
|
const isCustomSorting = widget.options.sortingFields && Array.isArray(widget.options.sortingFields) && widget.options.sortingFields.length > 0;
|
8638
8697
|
if (isCustomSorting) {
|
8639
8698
|
lodash.forEach(datesFields, function (field) {
|
8640
|
-
const fieldToSort = lodash.find(
|
8641
|
-
widget.options.sortingFields, element => element.id === field.id && lodash.get(element, 'sorting.sort_by') === 'field_items'
|
8642
|
-
);
|
8699
|
+
const fieldToSort = lodash.find(widget.options.sortingFields, element => element.id === field.id);
|
8643
8700
|
field.sorting = fieldToSort ? fieldToSort.sorting : field.sorting;
|
8644
8701
|
});
|
8645
8702
|
}
|
@@ -8721,9 +8778,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
8721
8778
|
});
|
8722
8779
|
} else if (isCustomSorting) {
|
8723
8780
|
lodash.forEach(rowsAndCols, function (field) {
|
8724
|
-
const fieldToSort = lodash.find(
|
8725
|
-
widget.options.sortingFields, element => element.id === field.id && lodash.get(element, 'sorting.sort_by') === 'field_items'
|
8726
|
-
);
|
8781
|
+
const fieldToSort = lodash.find(widget.options.sortingFields, element => element.id === field.id);
|
8727
8782
|
field.sorting = fieldToSort ? fieldToSort.sorting : field.sorting;
|
8728
8783
|
});
|
8729
8784
|
}
|
@@ -8758,9 +8813,61 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
8758
8813
|
}
|
8759
8814
|
|
8760
8815
|
/****** END *******/
|
8761
|
-
|
8762
|
-
|
8763
|
-
|
8816
|
+
|
8817
|
+
if (lodash.has(widget, "options.chartOptions.delta_column") &&
|
8818
|
+
widget.options.chartOptions.delta_column.field != '' &&
|
8819
|
+
(widget.options.chartOptions.delta_column.sort_by_variance ||
|
8820
|
+
widget.options.chartOptions.delta_column.sort_by_absolute_variance) &&
|
8821
|
+
widget.rows.length > 0 &&
|
8822
|
+
widget.cols.length > 0 &&
|
8823
|
+
widget.vals.length
|
8824
|
+
) {
|
8825
|
+
let variance_config = widget.options.chartOptions.delta_column;
|
8826
|
+
let val_field = widget.vals[0];
|
8827
|
+
let field_for_sorting = null;
|
8828
|
+
let field_with_variant = null;
|
8829
|
+
if (variance_config.field == "series") {
|
8830
|
+
field_for_sorting = widget.cols[0];
|
8831
|
+
field_with_variant = widget.rows[0];
|
8832
|
+
} else if (variance_config.field == "category") {
|
8833
|
+
field_for_sorting = widget.rows[0];
|
8834
|
+
field_with_variant = widget.cols[0];
|
8835
|
+
}
|
8836
|
+
|
8837
|
+
let data_sorted = lodash.filter(data, function (data_row) {
|
8838
|
+
return data_row[field_with_variant.name] == variance_config.name && data_row[field_for_sorting.name] != undefined;
|
8839
|
+
});
|
8840
|
+
|
8841
|
+
const sorting_variance = widget.options.total_value_options && widget.options.total_value_options.sorting_variance === '' ? 'asc' : 'desc';
|
8842
|
+
|
8843
|
+
if (widget.options.chartOptions.delta_column.sort_by_absolute_variance) {
|
8844
|
+
data_sorted = lodash.sortBy(data_sorted, function (o) {
|
8845
|
+
if (sorting_variance === 'desc') {
|
8846
|
+
return Math.abs(o[val_field.name]) * -1;
|
8847
|
+
}
|
8848
|
+
|
8849
|
+
return Math.abs(o[val_field.name]) * 1;
|
8850
|
+
});
|
8851
|
+
} else {
|
8852
|
+
data_sorted = lodash.orderBy(data_sorted, [val_field.name], [sorting_variance]);
|
8853
|
+
}
|
8854
|
+
|
8855
|
+
let values_for_sort = lodash.map(data_sorted, function (data_row) {
|
8856
|
+
return data_row[field_for_sorting.name];
|
8857
|
+
});
|
8858
|
+
|
8859
|
+
values_for_sort = lodash.uniq(values_for_sort);
|
8860
|
+
|
8861
|
+
if (values_for_sort.length > 0) {
|
8862
|
+
let field = lodash.find(datesFields, {name: field_for_sorting.name});
|
8863
|
+
if (field) {
|
8864
|
+
field.values = values_for_sort;
|
8865
|
+
field.sorting = null;
|
8866
|
+
} else {
|
8867
|
+
datesFields.push({name: field_for_sorting.name, values: values_for_sort});
|
8868
|
+
}
|
8869
|
+
}
|
8870
|
+
} else if (widget.options && widget.options.sortingValues) {
|
8764
8871
|
var field = lodash.find(datesFields, {name: widget.options.sortingValues.field});
|
8765
8872
|
if (field) {
|
8766
8873
|
field.values = widget.options.sortingValues.values;
|
@@ -9095,17 +9202,19 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
9095
9202
|
|
9096
9203
|
// if it is not total value - then add it as rowData data row and sum it up
|
9097
9204
|
// else - add total with calculated sum as new rowData data row (totals do not initially exist in BE response)
|
9098
|
-
if (value.trend !== 'total') {
|
9205
|
+
if (value && value.trend !== 'total') {
|
9099
9206
|
const rowIndex = lodash.findIndex(rowData, (responseRow) =>
|
9100
9207
|
lodash.every(categoryFields, (field, fieldKey) => responseRow[field.name] === value.key[fieldKey])
|
9101
9208
|
);
|
9102
|
-
|
9103
|
-
|
9104
|
-
|
9209
|
+
if (rowIndex >= 0) {
|
9210
|
+
modifiedRowData.push(rowData[rowIndex]);
|
9211
|
+
sum += rowData[rowIndex][valueField.name];
|
9212
|
+
rowData.splice(rowIndex, 1);
|
9213
|
+
}
|
9105
9214
|
} else {
|
9106
9215
|
const totalRow = {};
|
9107
9216
|
lodash.forEach(categoryFields, (field, fieldKey) => {
|
9108
|
-
totalRow[field.name] = value.key[fieldKey];
|
9217
|
+
totalRow[field.name] = value && value.key && value.key[fieldKey];
|
9109
9218
|
});
|
9110
9219
|
totalRow[valueField.name] = sum;
|
9111
9220
|
modifiedRowData.push(totalRow);
|
@@ -1154,6 +1154,18 @@ describe('highcharts_renderer', () => {
|
|
1154
1154
|
};
|
1155
1155
|
expect(highchartsRenderer.isSystemField(field)).toBe(false);
|
1156
1156
|
});
|
1157
|
+
|
1158
|
+
describe('dynamic system fields', () => {
|
1159
|
+
it('should count Scenario & Budget Cycle as system field', () => {
|
1160
|
+
lodash.set(document, 'ReportHippo.user.features', ['multiple_dimension_tags', 'use_new_scenario_tag']);
|
1161
|
+
|
1162
|
+
const fieldWithScenario = { name: 'Scenario' };
|
1163
|
+
expect(highchartsRenderer.isSystemField(fieldWithScenario)).toBe(true);
|
1164
|
+
|
1165
|
+
const fieldWithBudgetCycle = { name: 'Budget Cycle' };
|
1166
|
+
expect(highchartsRenderer.isSystemField(fieldWithBudgetCycle)).toBe(true);
|
1167
|
+
});
|
1168
|
+
});
|
1157
1169
|
});
|
1158
1170
|
|
1159
1171
|
describe('function getFieldColorClass', () => {
|