@datarailsshared/dr_renderer 1.2.371 → 1.2.373
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 +19 -29
package/package.json
CHANGED
@@ -3184,40 +3184,30 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
3184
3184
|
stackLabels: {
|
3185
3185
|
enabled: additionOptions && additionOptions.label ? additionOptions.label.show : true,
|
3186
3186
|
formatter: function () {
|
3187
|
-
|
3188
|
-
|
3189
|
-
|
3187
|
+
const showTotal = additionOptions && additionOptions.label && additionOptions.label.present_total;
|
3188
|
+
const hideSubtotals = additionOptions && additionOptions.label && additionOptions.label.hide_subtotals;
|
3189
|
+
const showTotalsPercentage = additionOptions && additionOptions.label && additionOptions.label.show_percentage;
|
3190
3190
|
|
3191
|
-
if (hideSubtotals
|
3192
|
-
|
3193
|
-
}
|
3191
|
+
if (!hideSubtotals || showTotal) {
|
3192
|
+
const agg = pivotData.getAggregator([], pivotData.colKeys[this.x]);
|
3194
3193
|
|
3195
|
-
|
3196
|
-
|
3197
|
-
var agg = pivotData.getAggregator([], presentTotal ? pivotData.colKeys[this.x] : []);
|
3194
|
+
if (agg && agg.sum) {
|
3195
|
+
const isNeedToDisplayLabel = agg.sum > 0 && !this.isNegative || agg.sum < 0 && this.isNegative;
|
3198
3196
|
|
3199
|
-
|
3200
|
-
|
3201
|
-
|
3202
|
-
result = presentTotal ? this.total > 0 ? agg.sum : '' : total;
|
3197
|
+
if (isNeedToDisplayLabel) {
|
3198
|
+
const subtotalValue = agg.sum;
|
3199
|
+
let percentages = '';
|
3203
3200
|
|
3204
|
-
|
3205
|
-
|
3206
|
-
|
3207
|
-
|
3208
|
-
|
3209
|
-
|
3210
|
-
let aggTotalValue = aggTotal.value();
|
3211
|
-
percentages = aggTotalValue ? ' (' + Math.round(result/aggTotalValue * 100) + '%)' : '';
|
3201
|
+
if (showTotalsPercentage) {
|
3202
|
+
const aggTotal = pivotData.getAggregator([], []);
|
3203
|
+
const aggTotalValue = aggTotal.value();
|
3204
|
+
percentages = aggTotalValue ? ' (' + Math.round(subtotalValue/aggTotalValue * 100) + '%)' : '';
|
3205
|
+
}
|
3206
|
+
return (showTotal ? agg.format(subtotalValue, true) : '') + percentages;
|
3212
3207
|
}
|
3213
|
-
|
3214
|
-
result = (presentTotal ? agg.format(result, true) : '') + percentages;
|
3215
|
-
} else {
|
3216
|
-
result = total.toLocaleString();
|
3217
3208
|
}
|
3218
|
-
return result;
|
3219
3209
|
}
|
3220
|
-
return
|
3210
|
+
return '';
|
3221
3211
|
},
|
3222
3212
|
style: highchartsRenderer.getDataLabelsStyle(additionOptions),
|
3223
3213
|
},
|
@@ -9707,7 +9697,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
9707
9697
|
lodash.forEach(res, (dataRow) => {
|
9708
9698
|
if (!lodash.isNil(dataRow.row_keys) || !lodash.isNil(dataRow.col_keys)) {
|
9709
9699
|
if (!sortingObjectToReturn) {
|
9710
|
-
sortingObjectToReturn =
|
9700
|
+
sortingObjectToReturn = lodash.clone(dataRow);
|
9711
9701
|
} else {
|
9712
9702
|
sortingObjectToReturn.row_keys = lodash.concat(sortingObjectToReturn.row_keys, dataRow.row_keys || []);
|
9713
9703
|
}
|
@@ -9718,7 +9708,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
9718
9708
|
if (sortingObjectToReturn) {
|
9719
9709
|
const resWithoutSortObjects = lodash.filter(res, (dataRow) => !dataRow.isSortingObject);
|
9720
9710
|
res.length = 0;
|
9721
|
-
|
9711
|
+
lodash.assign(res, resWithoutSortObjects);
|
9722
9712
|
}
|
9723
9713
|
|
9724
9714
|
return sortingObjectToReturn;
|