@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datarailsshared/dr_renderer",
3
- "version": "1.2.371",
3
+ "version": "1.2.372",
4
4
  "description": "DataRails charts and tables renderer",
5
5
  "keywords": [
6
6
  "datarails",
@@ -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
- var presentTotal = additionOptions && additionOptions.label && additionOptions.label.present_total;
3188
- var hideSubtotals = additionOptions && additionOptions.label && additionOptions.label.hide_subtotals;
3189
- var showTotalsPercentage = additionOptions && additionOptions.label && additionOptions.label.show_percentage;
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 && !presentTotal) {
3192
- return '';
3193
- }
3191
+ if (!hideSubtotals || showTotal) {
3192
+ const agg = pivotData.getAggregator([], pivotData.colKeys[this.x]);
3194
3193
 
3195
- if (this.total) {
3196
- var total = parseFloat(this.total);
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
- let result = '';
3200
- if (agg) {
3201
- let percentages = '';
3202
- result = presentTotal ? this.total > 0 ? agg.sum : '' : total;
3197
+ if (isNeedToDisplayLabel) {
3198
+ const subtotalValue = agg.sum;
3199
+ let percentages = '';
3203
3200
 
3204
- if (!result) {
3205
- return '';
3206
- }
3207
-
3208
- if (showTotalsPercentage) {
3209
- let aggTotal = pivotData.getAggregator([], []);
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
  },