@datarailsshared/dr_renderer 1.2.307-dragons → 1.2.308
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 +186 -89
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;
|
4439
4425
|
|
4440
|
-
|
4441
|
-
|
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);
|
4430
|
+
|
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
|
+
};
|
4451
|
+
|
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;
|
4444
4458
|
|
4445
|
-
|
4446
|
-
|
4447
|
-
|
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;
|
@@ -7055,6 +7078,18 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
7055
7078
|
value_name: 'is_percentage',
|
7056
7079
|
default_value: false,
|
7057
7080
|
hidden: true,
|
7081
|
+
}, {
|
7082
|
+
element_type: 'checkbox',
|
7083
|
+
element_label: 'Sort by variance',
|
7084
|
+
value_name: 'sort_by_variance',
|
7085
|
+
default_value: false,
|
7086
|
+
hidden: true
|
7087
|
+
}, {
|
7088
|
+
element_type: 'checkbox',
|
7089
|
+
element_label: 'Sort by absolute variance',
|
7090
|
+
value_name: 'sort_by_absolute_variance',
|
7091
|
+
default_value: false,
|
7092
|
+
hidden: true
|
7058
7093
|
}]
|
7059
7094
|
},
|
7060
7095
|
'delta_column_for_drill_down': {
|
@@ -7121,6 +7156,18 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
7121
7156
|
value_name: 'is_percentage',
|
7122
7157
|
default_value: false,
|
7123
7158
|
hidden: true,
|
7159
|
+
}, {
|
7160
|
+
element_type: 'checkbox',
|
7161
|
+
element_label: 'Sort by variance',
|
7162
|
+
value_name: 'sort_by_variance',
|
7163
|
+
default_value: false,
|
7164
|
+
hidden: true
|
7165
|
+
}, {
|
7166
|
+
element_type: 'checkbox',
|
7167
|
+
element_label: 'Sort by absolute variance',
|
7168
|
+
value_name: 'sort_by_absolute_variance',
|
7169
|
+
default_value: false,
|
7170
|
+
hidden: true
|
7124
7171
|
}, {
|
7125
7172
|
element_type: 'checkbox',
|
7126
7173
|
element_label: 'Filter zero values',
|
@@ -8637,9 +8684,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
8637
8684
|
const isCustomSorting = widget.options.sortingFields && Array.isArray(widget.options.sortingFields) && widget.options.sortingFields.length > 0;
|
8638
8685
|
if (isCustomSorting) {
|
8639
8686
|
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
|
-
);
|
8687
|
+
const fieldToSort = lodash.find(widget.options.sortingFields, element => element.id === field.id);
|
8643
8688
|
field.sorting = fieldToSort ? fieldToSort.sorting : field.sorting;
|
8644
8689
|
});
|
8645
8690
|
}
|
@@ -8721,9 +8766,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
8721
8766
|
});
|
8722
8767
|
} else if (isCustomSorting) {
|
8723
8768
|
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
|
-
);
|
8769
|
+
const fieldToSort = lodash.find(widget.options.sortingFields, element => element.id === field.id);
|
8727
8770
|
field.sorting = fieldToSort ? fieldToSort.sorting : field.sorting;
|
8728
8771
|
});
|
8729
8772
|
}
|
@@ -8758,9 +8801,61 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
8758
8801
|
}
|
8759
8802
|
|
8760
8803
|
/****** END *******/
|
8761
|
-
|
8762
|
-
|
8763
|
-
|
8804
|
+
|
8805
|
+
if (lodash.has(widget, "options.chartOptions.delta_column") &&
|
8806
|
+
widget.options.chartOptions.delta_column.field != '' &&
|
8807
|
+
(widget.options.chartOptions.delta_column.sort_by_variance ||
|
8808
|
+
widget.options.chartOptions.delta_column.sort_by_absolute_variance) &&
|
8809
|
+
widget.rows.length > 0 &&
|
8810
|
+
widget.cols.length > 0 &&
|
8811
|
+
widget.vals.length
|
8812
|
+
) {
|
8813
|
+
let variance_config = widget.options.chartOptions.delta_column;
|
8814
|
+
let val_field = widget.vals[0];
|
8815
|
+
let field_for_sorting = null;
|
8816
|
+
let field_with_variant = null;
|
8817
|
+
if (variance_config.field == "series") {
|
8818
|
+
field_for_sorting = widget.cols[0];
|
8819
|
+
field_with_variant = widget.rows[0];
|
8820
|
+
} else if (variance_config.field == "category") {
|
8821
|
+
field_for_sorting = widget.rows[0];
|
8822
|
+
field_with_variant = widget.cols[0];
|
8823
|
+
}
|
8824
|
+
|
8825
|
+
let data_sorted = lodash.filter(data, function (data_row) {
|
8826
|
+
return data_row[field_with_variant.name] == variance_config.name && data_row[field_for_sorting.name] != undefined;
|
8827
|
+
});
|
8828
|
+
|
8829
|
+
const sorting_variance = widget.options.total_value_options && widget.options.total_value_options.sorting_variance === '' ? 'asc' : 'desc';
|
8830
|
+
|
8831
|
+
if (widget.options.chartOptions.delta_column.sort_by_absolute_variance) {
|
8832
|
+
data_sorted = lodash.sortBy(data_sorted, function (o) {
|
8833
|
+
if (sorting_variance === 'desc') {
|
8834
|
+
return Math.abs(o[val_field.name]) * -1;
|
8835
|
+
}
|
8836
|
+
|
8837
|
+
return Math.abs(o[val_field.name]) * 1;
|
8838
|
+
});
|
8839
|
+
} else {
|
8840
|
+
data_sorted = lodash.orderBy(data_sorted, [val_field.name], [sorting_variance]);
|
8841
|
+
}
|
8842
|
+
|
8843
|
+
let values_for_sort = lodash.map(data_sorted, function (data_row) {
|
8844
|
+
return data_row[field_for_sorting.name];
|
8845
|
+
});
|
8846
|
+
|
8847
|
+
values_for_sort = lodash.uniq(values_for_sort);
|
8848
|
+
|
8849
|
+
if (values_for_sort.length > 0) {
|
8850
|
+
let field = lodash.find(datesFields, {name: field_for_sorting.name});
|
8851
|
+
if (field) {
|
8852
|
+
field.values = values_for_sort;
|
8853
|
+
field.sorting = null;
|
8854
|
+
} else {
|
8855
|
+
datesFields.push({name: field_for_sorting.name, values: values_for_sort});
|
8856
|
+
}
|
8857
|
+
}
|
8858
|
+
} else if (widget.options && widget.options.sortingValues) {
|
8764
8859
|
var field = lodash.find(datesFields, {name: widget.options.sortingValues.field});
|
8765
8860
|
if (field) {
|
8766
8861
|
field.values = widget.options.sortingValues.values;
|
@@ -9095,17 +9190,19 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
9095
9190
|
|
9096
9191
|
// if it is not total value - then add it as rowData data row and sum it up
|
9097
9192
|
// else - add total with calculated sum as new rowData data row (totals do not initially exist in BE response)
|
9098
|
-
if (value.trend !== 'total') {
|
9193
|
+
if (value && value.trend !== 'total') {
|
9099
9194
|
const rowIndex = lodash.findIndex(rowData, (responseRow) =>
|
9100
9195
|
lodash.every(categoryFields, (field, fieldKey) => responseRow[field.name] === value.key[fieldKey])
|
9101
9196
|
);
|
9102
|
-
|
9103
|
-
|
9104
|
-
|
9197
|
+
if (rowIndex >= 0) {
|
9198
|
+
modifiedRowData.push(rowData[rowIndex]);
|
9199
|
+
sum += rowData[rowIndex][valueField.name];
|
9200
|
+
rowData.splice(rowIndex, 1);
|
9201
|
+
}
|
9105
9202
|
} else {
|
9106
9203
|
const totalRow = {};
|
9107
9204
|
lodash.forEach(categoryFields, (field, fieldKey) => {
|
9108
|
-
totalRow[field.name] = value.key[fieldKey];
|
9205
|
+
totalRow[field.name] = value && value.key && value.key[fieldKey];
|
9109
9206
|
});
|
9110
9207
|
totalRow[valueField.name] = sum;
|
9111
9208
|
modifiedRowData.push(totalRow);
|