@oliasoft-open-source/charts-library 3.4.9 → 3.4.10-beta-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
@@ -7,7 +7,7 @@ var __publicField = (obj, key, value) => {
7
7
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
8
8
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
9
9
  import React, { forwardRef, useRef, useEffect, createContext as createContext$2, memo, isValidElement, cloneElement, useLayoutEffect, useMemo, useContext, useState, useCallback, useReducer } from "react";
10
- import { round as round$2, toNum, displayNumber, isCloseTo } from "@oliasoft-open-source/units";
10
+ import { round as round$2, toNum, displayNumber, isCloseTo, roundByMagnitude } from "@oliasoft-open-source/units";
11
11
  import cx from "classnames";
12
12
  import { produce } from "immer";
13
13
  import { Icon, Tooltip as Tooltip$2, Button, Flex, Text, Menu, Popover, Field, InputGroup, NumberInput, InputGroupAddon, Select, ButtonGroup, Spacer, Portal } from "@oliasoft-open-source/react-ui-library";
@@ -25096,6 +25096,13 @@ const getUnitsFromLabel = (label) => {
25096
25096
  const units = matches && matches.length > 0 ? matches[0] : "";
25097
25097
  return units;
25098
25098
  };
25099
+ const customFormatNumber = (labelNumber) => {
25100
+ let roundOptions = {};
25101
+ if (Math.abs(labelNumber) < 1e-4 || Math.abs(labelNumber) > 1e7) {
25102
+ roundOptions = { roundScientificCoefficient: 4 };
25103
+ }
25104
+ return displayNumber(roundByMagnitude(labelNumber), roundOptions);
25105
+ };
25099
25106
  const getLineChartToolTips = (options) => {
25100
25107
  const getTooltipLabels = (dataset) => {
25101
25108
  var _a2, _b2, _c2, _d2, _e2;
@@ -25123,10 +25130,7 @@ const getLineChartToolTips = (options) => {
25123
25130
  const labels = getTooltipLabels(tooltipItem[0].dataset);
25124
25131
  const { titleLabel, titleAxisLabel } = labels;
25125
25132
  const formattedValue = titleLabel === TooltipLabel.Y ? tooltipItem[0].parsed.y : tooltipItem[0].parsed.x;
25126
- const roundedValue = Math.abs(formattedValue) < 1 ? displayNumber(formattedValue, {
25127
- scientific: true,
25128
- roundScientificCoefficient: 4
25129
- }) : displayNumber(formattedValue);
25133
+ const roundedValue = customFormatNumber(formattedValue);
25130
25134
  return `${roundedValue} ${titleAxisLabel}`;
25131
25135
  };
25132
25136
  const labelCallback = (tooltipItem) => {
@@ -25136,10 +25140,7 @@ const getLineChartToolTips = (options) => {
25136
25140
  const { valueLabel, valueAxisLabel } = labels;
25137
25141
  const getTooltipItemValue = () => {
25138
25142
  const labelNumber = valueLabel === TooltipLabel.X ? tooltipItem.parsed.x : tooltipItem.parsed.y;
25139
- return Math.abs(labelNumber) < 1 ? displayNumber(labelNumber, {
25140
- scientific: true,
25141
- roundScientificCoefficient: 4
25142
- }) : displayNumber(labelNumber);
25143
+ return customFormatNumber(labelNumber);
25143
25144
  };
25144
25145
  const tooltipItemValue = getTooltipItemValue();
25145
25146
  const units = getUnitsFromLabel(valueAxisLabel);