@datarailsshared/dr_renderer 1.2.371 → 1.2.372
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 +17 -27
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
|
},
|