cats-charts 0.0.75 → 0.0.76

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.
@@ -1084,7 +1084,7 @@ class Charts {
1084
1084
  font-size: 12px;
1085
1085
  color: #434A51;
1086
1086
  ">
1087
- ${name}: <b style="color:#111; font-weight:600;">${config.valueFormatter ? config.valueFormatter(value) : value}</b> ${config.showTooltipPercent ? '(' + percent + '%)' : ''}
1087
+ ${name}: <b style="color:#111; font-weight:600;">${config.valueFormatter ? config.valueFormatter(value) : this.toMaxDecimals(value)}</b> ${config.showTooltipPercent ? '(' + percent + '%)' : ''}
1088
1088
  </span>
1089
1089
  </div>
1090
1090
  ${extraTooltipDataTemplate}
@@ -1134,7 +1134,7 @@ class Charts {
1134
1134
  display:inline-block;
1135
1135
  "></span>
1136
1136
 
1137
- <span>${name}: <b style="color:#111;font-weight:600;">${value}</b></span>
1137
+ <span>${name}: <b style="color:#111;font-weight:600;">${this.toMaxDecimals(value)}</b></span>
1138
1138
  </div>
1139
1139
  `;
1140
1140
  });
@@ -1163,7 +1163,7 @@ class Charts {
1163
1163
  color:#434A51;
1164
1164
  padding-top: 0.5rem;
1165
1165
  ">
1166
- Total: <b style="color:#111;font-weight:600;">${total}</b>
1166
+ Total: <b style="color:#111;font-weight:600;">${this.toMaxDecimals(total)}</b>
1167
1167
  ${extraTooltipDataTemplate}
1168
1168
  </div>
1169
1169
 
@@ -1413,6 +1413,12 @@ class Charts {
1413
1413
  maxHeight = Math.max(maxHeight, rect.height + verticalPadding);
1414
1414
  return maxHeight + 6;
1415
1415
  }
1416
+ toMaxDecimals(value, maxDecimal = 2) {
1417
+ if (!Number.isFinite(value)) {
1418
+ return value;
1419
+ }
1420
+ return Number(value.toFixed(maxDecimal));
1421
+ }
1416
1422
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: Charts, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1417
1423
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: Charts, providedIn: 'root' });
1418
1424
  }