@datarailsshared/dr_renderer 1.2.55 → 1.2.59
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 +23 -5
- package/src/highcharts_renderer.js +114 -48
package/package.json
CHANGED
package/src/dr_pivottable.js
CHANGED
|
@@ -113,7 +113,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
113
113
|
};
|
|
114
114
|
};
|
|
115
115
|
|
|
116
|
-
processKey = function(record, totals, keys, attrs, getAggregator) {
|
|
116
|
+
processKey = function(record, totals, keys, attrs, containsAverage, containsOthers, getAggregator) {
|
|
117
117
|
var addKey, attr, flatKey, k, key, len, ref;
|
|
118
118
|
key = [];
|
|
119
119
|
addKey = false;
|
|
@@ -125,7 +125,17 @@ let initDRPivotTable = function($, window, document) {
|
|
|
125
125
|
totals[flatKey] = getAggregator(key.slice());
|
|
126
126
|
addKey = true;
|
|
127
127
|
}
|
|
128
|
-
|
|
128
|
+
|
|
129
|
+
if (containsAverage || containsOthers) {
|
|
130
|
+
if (containsAverage && key[0] === 'DR_Average') {
|
|
131
|
+
totals[flatKey].push(record);
|
|
132
|
+
}
|
|
133
|
+
if (containsOthers && key[0] === 'DR_Others') {
|
|
134
|
+
totals[flatKey].push(record);
|
|
135
|
+
}
|
|
136
|
+
} else {
|
|
137
|
+
totals[flatKey].push(record);
|
|
138
|
+
}
|
|
129
139
|
}
|
|
130
140
|
if (addKey) {
|
|
131
141
|
keys.push(key);
|
|
@@ -203,13 +213,18 @@ let initDRPivotTable = function($, window, document) {
|
|
|
203
213
|
var colKey, fColKey, fRowKey, flatColKey, flatRowKey, i, j, k, m, n, ref, results, rowKey;
|
|
204
214
|
rowKey = [];
|
|
205
215
|
colKey = [];
|
|
206
|
-
|
|
207
|
-
|
|
216
|
+
const recordValues = Object.values(record);
|
|
217
|
+
const containsAverage = recordValues.includes('DR_Average');
|
|
218
|
+
const containsOthers = recordValues.includes('DR_Others');
|
|
219
|
+
if (!containsAverage && !containsOthers) {
|
|
220
|
+
this.allTotal.push(record);
|
|
221
|
+
}
|
|
222
|
+
rowKey = processKey(record, this.rowTotals, this.rowKeys, this.rowAttrs, containsAverage, containsOthers, (function(_this) {
|
|
208
223
|
return function(key) {
|
|
209
224
|
return _this.aggregator(_this, key, []);
|
|
210
225
|
};
|
|
211
226
|
})(this));
|
|
212
|
-
colKey = processKey(record, this.colTotals, this.colKeys, this.colAttrs, (function(_this) {
|
|
227
|
+
colKey = processKey(record, this.colTotals, this.colKeys, this.colAttrs, containsAverage, containsOthers, (function(_this) {
|
|
213
228
|
return function(key) {
|
|
214
229
|
return _this.aggregator(_this, [], key);
|
|
215
230
|
};
|
|
@@ -1194,6 +1209,9 @@ let initDRPivotTable = function($, window, document) {
|
|
|
1194
1209
|
if (opts.chartOptions.table_options.hide_nulls_in_headers) {
|
|
1195
1210
|
th.textContent = th.textContent.replace('[null]', '');
|
|
1196
1211
|
}
|
|
1212
|
+
if (th.textContent === 'DR Others') {
|
|
1213
|
+
th.textContent = _.get(opts, "total_value_options.filter_options.filteredOutFieldName") || 'Others'
|
|
1214
|
+
}
|
|
1197
1215
|
|
|
1198
1216
|
if (th.hasAttribute('data_show_more') && th.colSpan > 0 && !hasColLabels) {
|
|
1199
1217
|
th.colSpan = th.colSpan - 1;
|
|
@@ -909,6 +909,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
909
909
|
var variat_serias = null;
|
|
910
910
|
const n = col_n_keys.length;
|
|
911
911
|
const xSum = (1 + n) / 2 * n;
|
|
912
|
+
const trendSerieses = [];
|
|
912
913
|
|
|
913
914
|
lodash.forEach(row_n_keys, function (row_n_value) {
|
|
914
915
|
var ob = {};
|
|
@@ -916,8 +917,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
916
917
|
let xySum = 0;
|
|
917
918
|
let squareXSum = 0;
|
|
918
919
|
ob.data = [];
|
|
919
|
-
if (row_n_value && row_n_value.length > 0)
|
|
920
|
-
|
|
920
|
+
if (row_n_value && row_n_value.length > 0) {
|
|
921
|
+
let othersName = lodash.get(opts, "total_value_options.filter_options.filteredOutFieldName") || 'Others';
|
|
922
|
+
ob.name = row_n_value.join(highchartsRenderer.delimer).replace('DR_Others', othersName);
|
|
923
|
+
}
|
|
921
924
|
|
|
922
925
|
lodash.forEach(col_n_keys, function (col_n_value, index) {
|
|
923
926
|
var agg = pivotData.getAggregator(row_n_value, col_n_value);
|
|
@@ -973,11 +976,12 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
973
976
|
trendSeries.color = colors[i];
|
|
974
977
|
}
|
|
975
978
|
|
|
976
|
-
|
|
979
|
+
trendSerieses.push(trendSeries);
|
|
977
980
|
}
|
|
978
981
|
|
|
979
982
|
i++;
|
|
980
983
|
});
|
|
984
|
+
const ethalonSeries = chart_series[chart_series.length - 1];
|
|
981
985
|
|
|
982
986
|
if (has_delta && additionOptions && additionOptions.delta_column.only_variant) {
|
|
983
987
|
if (variat_serias)
|
|
@@ -996,10 +1000,19 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
996
1000
|
}
|
|
997
1001
|
}
|
|
998
1002
|
|
|
999
|
-
|
|
1003
|
+
opts.chart_series = []
|
|
1004
|
+
|
|
1005
|
+
if (!lodash.isEqual(row_n_keys, [[]])) {
|
|
1006
|
+
chart_series.forEach(series => {
|
|
1007
|
+
opts.chart_series.push(series.name);
|
|
1008
|
+
})
|
|
1009
|
+
}
|
|
1000
1010
|
|
|
1001
1011
|
if (opts.total) {
|
|
1002
|
-
const newSeries = lodash.clone(
|
|
1012
|
+
const newSeries = lodash.clone(ethalonSeries);
|
|
1013
|
+
if (opts.totalSeriesSettings) {
|
|
1014
|
+
newSeries.yAxis = opts.totalSeriesSettings.secondaryAxis ? 1 : undefined;
|
|
1015
|
+
}
|
|
1003
1016
|
newSeries.name = 'Total';
|
|
1004
1017
|
newSeries.data = [];
|
|
1005
1018
|
col_n_keys.forEach(columnKey => {
|
|
@@ -1013,6 +1026,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1013
1026
|
chart_series.push(newSeries);
|
|
1014
1027
|
}
|
|
1015
1028
|
|
|
1029
|
+
chart_series = [...chart_series, ...trendSerieses]
|
|
1030
|
+
|
|
1031
|
+
highchartsRenderer.moveSeriesToSecondYAxisIfNeeded(chart_series, pivotData, chartOptions, additionOptions, opts, opts.total && opts.totalSeriesSettings && opts.totalSeriesSettings.secondaryAxis);
|
|
1032
|
+
|
|
1016
1033
|
return chart_series;
|
|
1017
1034
|
};
|
|
1018
1035
|
|
|
@@ -1033,6 +1050,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1033
1050
|
var variat_serias = null;
|
|
1034
1051
|
const n = col_n_keys.length;
|
|
1035
1052
|
const xSum = (1 + n) / 2 * n;
|
|
1053
|
+
const trendSerieses = [];
|
|
1036
1054
|
|
|
1037
1055
|
lodash.forEach(row_n_keys, function (row_n_value) {
|
|
1038
1056
|
let ySum = 0;
|
|
@@ -1040,8 +1058,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1040
1058
|
let squareXSum = 0;
|
|
1041
1059
|
var ob = {};
|
|
1042
1060
|
ob.data = [];
|
|
1043
|
-
if (row_n_value && row_n_value.length > 0)
|
|
1044
|
-
|
|
1061
|
+
if (row_n_value && row_n_value.length > 0) {
|
|
1062
|
+
let othersName = lodash.get(opts, "total_value_options.filter_options.filteredOutFieldName") || 'Others';
|
|
1063
|
+
ob.name = lodash.unescape(row_n_value.join(highchartsRenderer.delimer).replace('DR_Others', othersName));
|
|
1064
|
+
}
|
|
1045
1065
|
|
|
1046
1066
|
ob.dataLabels = {
|
|
1047
1067
|
allowOverlap: additionOptions && additionOptions.label ? additionOptions.label.overlap : false,
|
|
@@ -1101,6 +1121,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1101
1121
|
|
|
1102
1122
|
chart_series.push(ob);
|
|
1103
1123
|
|
|
1124
|
+
|
|
1104
1125
|
if (opts.trendLine) {
|
|
1105
1126
|
const a = ((ySum * squareXSum) - (xSum * xySum)) / ((n * squareXSum) - (xSum * xSum));
|
|
1106
1127
|
const b = ((n * xySum) - (xSum* ySum)) / ((n * squareXSum) - (xSum * xSum));
|
|
@@ -1115,11 +1136,13 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1115
1136
|
trendSeries.color = colors[i];
|
|
1116
1137
|
}
|
|
1117
1138
|
|
|
1118
|
-
|
|
1139
|
+
trendSerieses.push(trendSeries);
|
|
1119
1140
|
}
|
|
1120
1141
|
i++;
|
|
1121
1142
|
});
|
|
1122
1143
|
|
|
1144
|
+
const ethalonSeries = chart_series[chart_series.length - 1];
|
|
1145
|
+
|
|
1123
1146
|
if (has_delta && additionOptions.delta_column.only_variant) {
|
|
1124
1147
|
if (variat_serias)
|
|
1125
1148
|
return [variat_serias];
|
|
@@ -1128,42 +1151,36 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1128
1151
|
}
|
|
1129
1152
|
}
|
|
1130
1153
|
|
|
1131
|
-
highchartsRenderer.moveSeriesToSecondYAxisIfNeeded(chart_series, pivotData, chartOptions, additionOptions, opts);
|
|
1132
|
-
|
|
1133
1154
|
let weights = { line: 2,spline: 3 ,area:-2, areaspline: -1, scatter:4, column: 1 };
|
|
1134
1155
|
|
|
1135
|
-
if (opts.comboOptions && chartType.includes('combo')) {
|
|
1156
|
+
if (opts.comboOptions && chartType.includes('combo') && !lodash.isEqual(row_n_keys, [[]])) {
|
|
1136
1157
|
chart_series.forEach((series, seriesIndex) => {
|
|
1137
1158
|
const savedSeriesOption = lodash.find(opts.comboOptions.seriesOptions, {series: series.name});
|
|
1138
1159
|
if (savedSeriesOption) {
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
series.type = 'line';
|
|
1142
|
-
break;
|
|
1143
|
-
case 'line-chart-smooth':
|
|
1144
|
-
series.type = 'spline';
|
|
1145
|
-
break;
|
|
1146
|
-
case 'area-chart':
|
|
1147
|
-
series.type = 'area';
|
|
1148
|
-
break;
|
|
1149
|
-
case 'area-chart-smooth':
|
|
1150
|
-
series.type = 'areaspline';
|
|
1151
|
-
break;
|
|
1152
|
-
case 'scatter-chart':
|
|
1153
|
-
series.type = 'scatter';
|
|
1154
|
-
break;
|
|
1155
|
-
case 'column-chart' || 'column-chart-stacked':
|
|
1156
|
-
delete series.type;
|
|
1157
|
-
break;
|
|
1158
|
-
}
|
|
1159
|
-
} else if (seriesIndex === chart_series.length - 1 && !has_delta) {
|
|
1160
|
+
highchartsRenderer.setChartTypeBySeriesType(savedSeriesOption.chartType, series);
|
|
1161
|
+
} else if (seriesIndex === chart_series.length - 1 && chart_series.length > 1 && !has_delta && !opts.total && !trendSerieses.length) {
|
|
1160
1162
|
series.type = 'line';
|
|
1161
1163
|
}
|
|
1162
1164
|
});
|
|
1163
1165
|
}
|
|
1164
1166
|
|
|
1167
|
+
opts.chart_series = []
|
|
1168
|
+
|
|
1169
|
+
if (!lodash.isEqual(row_n_keys, [[]])) {
|
|
1170
|
+
chart_series.forEach(series => {
|
|
1171
|
+
opts.chart_series.push(series.name);
|
|
1172
|
+
})
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1165
1175
|
if (opts.total) {
|
|
1166
|
-
const totalSeries = lodash.clone(
|
|
1176
|
+
const totalSeries = lodash.clone(ethalonSeries);
|
|
1177
|
+
if (opts.totalSeriesSettings) {
|
|
1178
|
+
if (chartType.includes('combo')) {
|
|
1179
|
+
highchartsRenderer.setChartTypeBySeriesType(opts.totalSeriesSettings.chartType, totalSeries);
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
totalSeries.yAxis = opts.totalSeriesSettings.secondaryAxis ? 1 : undefined;
|
|
1183
|
+
}
|
|
1167
1184
|
totalSeries.name = 'Total';
|
|
1168
1185
|
totalSeries.data = [];
|
|
1169
1186
|
col_n_keys.forEach(columnKey => {
|
|
@@ -1179,6 +1196,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1179
1196
|
chart_series.push(totalSeries);
|
|
1180
1197
|
}
|
|
1181
1198
|
|
|
1199
|
+
chart_series = [...chart_series, ...trendSerieses];
|
|
1200
|
+
|
|
1201
|
+
highchartsRenderer.moveSeriesToSecondYAxisIfNeeded(chart_series, pivotData, chartOptions, additionOptions, opts, opts.total && opts.totalSeriesSettings && opts.totalSeriesSettings.secondaryAxis);
|
|
1202
|
+
|
|
1182
1203
|
chart_series.sort((a,b) => {
|
|
1183
1204
|
return (weights[a.type] || 0) > (weights[b.type] || 0) ? 1 : (weights[a.type] || 0) < (weights[b.type] || 0) ? -1 : 0
|
|
1184
1205
|
});
|
|
@@ -1186,6 +1207,22 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1186
1207
|
return chart_series;
|
|
1187
1208
|
}
|
|
1188
1209
|
|
|
1210
|
+
highchartsRenderer.setChartTypeBySeriesType = function (type, series) {
|
|
1211
|
+
const types = {
|
|
1212
|
+
'line-chart': 'line',
|
|
1213
|
+
'line-chart-smooth': 'spline',
|
|
1214
|
+
'area-chart': 'area',
|
|
1215
|
+
'area-chart-smooth': 'areaspline',
|
|
1216
|
+
'scatter-chart': 'scatter',
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
if (type === 'column-chart' || type === 'column-chart-stacked') {
|
|
1220
|
+
delete series.type;
|
|
1221
|
+
} else {
|
|
1222
|
+
series.type = types[type]
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1189
1226
|
highchartsRenderer.getVariantSeries = function (series, delta_column_options) {
|
|
1190
1227
|
const varianceColor = delta_column_options.color || highchartsRenderer.variance_color || Highcharts.getOptions().colors[7];
|
|
1191
1228
|
series.name = delta_column_options.name.replace('_', '');
|
|
@@ -1357,7 +1394,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1357
1394
|
});
|
|
1358
1395
|
};
|
|
1359
1396
|
|
|
1360
|
-
highchartsRenderer.moveSeriesToSecondYAxisIfNeeded = function(chartSeries, pivotData, chartOptions, additionOptions, opts) {
|
|
1397
|
+
highchartsRenderer.moveSeriesToSecondYAxisIfNeeded = function(chartSeries, pivotData, chartOptions, additionOptions, opts, forceAddSecondaryAxis) {
|
|
1361
1398
|
if (!opts || !opts.comboOptions) {
|
|
1362
1399
|
return;
|
|
1363
1400
|
}
|
|
@@ -1373,11 +1410,15 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1373
1410
|
}
|
|
1374
1411
|
});
|
|
1375
1412
|
|
|
1376
|
-
if (addSecondYAxis) {
|
|
1413
|
+
if (addSecondYAxis || forceAddSecondaryAxis) {
|
|
1377
1414
|
highchartsRenderer.addSecondYAxis(pivotData, chartOptions, additionOptions, opts);
|
|
1378
1415
|
}
|
|
1379
1416
|
}
|
|
1380
1417
|
|
|
1418
|
+
highchartsRenderer.encodeHTMLBrackets = function (string) {
|
|
1419
|
+
return string.replaceAll('<', '<').replaceAll('>', '>');
|
|
1420
|
+
};
|
|
1421
|
+
|
|
1381
1422
|
highchartsRenderer.addSecondYAxis = function (pivotData, chartOptions, additionOptions, opts) {
|
|
1382
1423
|
const varianceColor = (additionOptions && additionOptions.delta_column.color) || (highchartsRenderer && highchartsRenderer.variance_color) || Highcharts.getOptions().colors[7];
|
|
1383
1424
|
let labels_formatter = opts.comboOptions.secondaryAxisSettings.is_percentage ?
|
|
@@ -1389,7 +1430,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1389
1430
|
min: !isNaN(parseInt(opts.comboOptions.secondaryAxisSettings.min)) ? opts.comboOptions.secondaryAxisSettings.min : null,
|
|
1390
1431
|
max: !isNaN(parseInt(opts.comboOptions.secondaryAxisSettings.max)) ? opts.comboOptions.secondaryAxisSettings.max : null,
|
|
1391
1432
|
title: {
|
|
1392
|
-
text: opts.comboOptions.secondaryAxisSettings.name,
|
|
1433
|
+
text: highchartsRenderer.encodeHTMLBrackets(opts.comboOptions.secondaryAxisSettings.name),
|
|
1393
1434
|
style: {
|
|
1394
1435
|
color: varianceColor
|
|
1395
1436
|
}
|
|
@@ -2609,7 +2650,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
2609
2650
|
} else if (lodash.get(opts, 'paletteOptions.dashboardPalette.colors', null)) {
|
|
2610
2651
|
chartOptions.colors = opts.paletteOptions.dashboardPalette.colors;
|
|
2611
2652
|
}
|
|
2612
|
-
chartOptions.series = highchartsRenderer.ptCreateColumnSeries(pivotData, chartOptions.colors, null, true, true,
|
|
2653
|
+
chartOptions.series = highchartsRenderer.ptCreateColumnSeries(pivotData, chartOptions.colors, null, true, true, additionOptions, opts, chartOptions, chartType);
|
|
2613
2654
|
//chartOptions.drilldown = {}
|
|
2614
2655
|
|
|
2615
2656
|
highchartsRenderer.handleGridLines(additionOptions, chartOptions)
|
|
@@ -3716,15 +3757,25 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
3716
3757
|
};
|
|
3717
3758
|
|
|
3718
3759
|
highchartsRenderer.getNewAttrSortingForCol = function (pivotData, sortingOptions) {
|
|
3719
|
-
let
|
|
3720
|
-
|
|
3760
|
+
let rowAttrs, rowKeys, colKeys, colAttrs;
|
|
3761
|
+
rowAttrs = pivotData.rowAttrs;
|
|
3762
|
+
rowKeys = pivotData.rowKeys;
|
|
3721
3763
|
colKeys = pivotData.colKeys;
|
|
3764
|
+
colAttrs = pivotData.colAttrs;
|
|
3765
|
+
|
|
3766
|
+
|
|
3722
3767
|
if (!colAttrs || colAttrs.length == 0) {
|
|
3723
3768
|
return null;
|
|
3724
3769
|
}
|
|
3770
|
+
|
|
3725
3771
|
let values_names_arr = [];
|
|
3726
|
-
|
|
3727
|
-
|
|
3772
|
+
let keysArray = sortingOptions.field ? rowKeys : colKeys;
|
|
3773
|
+
|
|
3774
|
+
lodash.forEach(keysArray, function (val) {
|
|
3775
|
+
let firstArray = sortingOptions.field ? [val[0]] : [];
|
|
3776
|
+
let secondArray = sortingOptions.field ? sortingOptions.field.split(highchartsRenderer.delimer) : [val[0]];
|
|
3777
|
+
let aggregator_subtotal = pivotData.getAggregator(firstArray, secondArray);
|
|
3778
|
+
|
|
3728
3779
|
if (aggregator_subtotal) {
|
|
3729
3780
|
let value_subtotal = aggregator_subtotal.value();
|
|
3730
3781
|
if (sortingOptions && sortingOptions.is_absolute && !isNaN(parseFloat(value_subtotal))) {
|
|
@@ -3743,19 +3794,28 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
3743
3794
|
|
|
3744
3795
|
// map only names
|
|
3745
3796
|
let attr_sorted_values = lodash.map(values_names_arr, 'name');
|
|
3746
|
-
return {name: colAttrs[0], values: attr_sorted_values};
|
|
3797
|
+
return {name: sortingOptions.field ? rowAttrs[0] : colAttrs[0], values: attr_sorted_values};
|
|
3747
3798
|
};
|
|
3748
3799
|
|
|
3749
3800
|
highchartsRenderer.getNewAttrSortingForRow = function (pivotData, sortingOptions) {
|
|
3750
|
-
let rowAttrs, rowKeys;
|
|
3801
|
+
let rowAttrs, rowKeys, colKeys, colAttrs;
|
|
3751
3802
|
rowAttrs = pivotData.rowAttrs;
|
|
3752
3803
|
rowKeys = pivotData.rowKeys;
|
|
3804
|
+
colKeys = pivotData.colKeys;
|
|
3805
|
+
colAttrs = pivotData.colAttrs;
|
|
3806
|
+
|
|
3753
3807
|
if (!rowAttrs || rowAttrs.length == 0) {
|
|
3754
3808
|
return null;
|
|
3755
3809
|
}
|
|
3810
|
+
|
|
3756
3811
|
let values_names_arr = [];
|
|
3757
|
-
|
|
3758
|
-
|
|
3812
|
+
let keysArray = sortingOptions.field ? colKeys : rowKeys;
|
|
3813
|
+
|
|
3814
|
+
lodash.forEach(keysArray, function (val) {
|
|
3815
|
+
let firstArray = sortingOptions.field ? sortingOptions.field.split(highchartsRenderer.delimer) : [val[0]];
|
|
3816
|
+
let secondArray = sortingOptions.field ? [val[0]] : [];
|
|
3817
|
+
let aggregator_subtotal = pivotData.getAggregator(firstArray, secondArray);
|
|
3818
|
+
|
|
3759
3819
|
if (aggregator_subtotal) {
|
|
3760
3820
|
let value_subtotal = aggregator_subtotal.value();
|
|
3761
3821
|
if (sortingOptions && sortingOptions.is_absolute && !isNaN(parseFloat(value_subtotal))) {
|
|
@@ -3774,7 +3834,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
3774
3834
|
|
|
3775
3835
|
// map only names
|
|
3776
3836
|
let attr_sorted_values = lodash.map(values_names_arr, 'name');
|
|
3777
|
-
return {name: rowAttrs[0], values: attr_sorted_values};
|
|
3837
|
+
return {name: sortingOptions.field ? colAttrs[0] : rowAttrs[0], values: attr_sorted_values};
|
|
3778
3838
|
};
|
|
3779
3839
|
|
|
3780
3840
|
highchartsRenderer.generateSortingFunctionByValues = function (sortingOptions, pivotData, opts) {
|
|
@@ -7085,12 +7145,18 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
7085
7145
|
return data_row[field_with_variant.name] == variance_config.name && data_row[field_for_sorting.name] != undefined;
|
|
7086
7146
|
});
|
|
7087
7147
|
|
|
7148
|
+
const sorting_variance = widget.options.total_value_options.sorting_variance === '' ? 'asc' : 'desc';
|
|
7149
|
+
|
|
7088
7150
|
if (widget.options.chartOptions.delta_column.sort_by_absolute_variance) {
|
|
7089
7151
|
data_sorted = lodash.sortBy(data_sorted, function (o) {
|
|
7090
|
-
|
|
7152
|
+
if (sorting_variance === 'desc') {
|
|
7153
|
+
return Math.abs(o[val_field.name]) * -1;
|
|
7154
|
+
}
|
|
7155
|
+
|
|
7156
|
+
return Math.abs(o[val_field.name]) * 1;
|
|
7091
7157
|
});
|
|
7092
7158
|
} else {
|
|
7093
|
-
data_sorted = lodash.orderBy(data_sorted, [val_field.name], [
|
|
7159
|
+
data_sorted = lodash.orderBy(data_sorted, [val_field.name], [sorting_variance]);
|
|
7094
7160
|
}
|
|
7095
7161
|
|
|
7096
7162
|
let values_for_sort = lodash.map(data_sorted, function (data_row) {
|