@oliasoft-open-source/charts-library 4.1.1 → 4.1.2

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/dist/index.js CHANGED
@@ -39259,6 +39259,8 @@ const getBarChartDataLabels = (options) => {
39259
39259
  formatter: formatterCallback
39260
39260
  } : { display: false };
39261
39261
  };
39262
+ const DISPLAY_SCIENTIFIC_LOWER_BOUND = 1e-4;
39263
+ const DISPLAY_SCIENTIFIC_UPPER_BOUND = 1e7;
39262
39264
  const getBarChartToolTips = (options) => {
39263
39265
  var _a2;
39264
39266
  const getTooltipLabels = (dataset) => {
@@ -39293,6 +39295,13 @@ const getBarChartToolTips = (options) => {
39293
39295
  const axisLabel = !titleAxisLabel && !titleUnit ? "" : `${titleAxisLabel || titleUnit}: `;
39294
39296
  return axisLabel + barLabel;
39295
39297
  };
39298
+ const customFormatNumber2 = (labelNumber) => {
39299
+ let roundOptions = {};
39300
+ if (Math.abs(labelNumber) < DISPLAY_SCIENTIFIC_LOWER_BOUND || Math.abs(labelNumber) > DISPLAY_SCIENTIFIC_UPPER_BOUND) {
39301
+ roundOptions = { roundScientificCoefficient: 3 };
39302
+ }
39303
+ return displayNumber(roundByMagnitude(labelNumber), roundOptions);
39304
+ };
39296
39305
  const labelCallback = (tooltipItem) => {
39297
39306
  var _a3;
39298
39307
  const { showLabelsInTooltips = false } = (options == null ? void 0 : options.tooltip) || {};
@@ -39303,12 +39312,7 @@ const getBarChartToolTips = (options) => {
39303
39312
  const { formattedValue } = tooltipItem;
39304
39313
  const formattedValueWithDotSeparator = formattedValue.replace(",", ".");
39305
39314
  const labelNumber = toNum(formattedValueWithDotSeparator);
39306
- let labelNumberFormatted;
39307
- if (Math.abs(labelNumber) < 1) {
39308
- labelNumberFormatted = labelNumber.toPrecision(3);
39309
- } else {
39310
- labelNumberFormatted = Number.isInteger(labelNumber) ? labelNumber : labelNumber.toFixed(3);
39311
- }
39315
+ const labelNumberFormatted = customFormatNumber2(labelNumber);
39312
39316
  let tooltipItemValue2 = "";
39313
39317
  if (typeof tooltipItem.raw === "number") {
39314
39318
  tooltipItemValue2 = labelNumberFormatted;