@oliasoft-open-source/charts-library 4.5.0-beta-1 → 4.5.1-beta-1

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
@@ -13,7 +13,6 @@ import { round as round$2, displayNumber, isCloseTo, roundByMagnitude } from "@o
13
13
  import cx from "classnames";
14
14
  import { Portal, Icon, Tooltip as Tooltip$2, Button, Flex, Text, Menu, Popover, Field, InputGroup, NumberInput, InputGroupAddon, Select, ButtonGroup, Spacer } from "@oliasoft-open-source/react-ui-library";
15
15
  import { isEmpty, isArray as isArray$2, some, has, cloneDeep, defaultTo, findIndex, set as set$2, debounce as debounce$3, isNil, map as map$3, find, get as get$1 } from "lodash";
16
- import { roundNumberToPrecision } from "@oliasoft-open-source/units/dist/rounding/rounding";
17
16
  /*!
18
17
  * @kurkle/color v0.3.2
19
18
  * https://github.com/kurkle/color#readme
@@ -22174,139 +22173,6 @@ class HTML5BackendImpl {
22174
22173
  const HTML5Backend = function createBackend(manager, context, options) {
22175
22174
  return new HTML5BackendImpl(manager, context, options);
22176
22175
  };
22177
- const BORDER_WIDTH = {
22178
- INITIAL: 2,
22179
- HOVERED: 6,
22180
- POINT_HOVERED: 8
22181
- };
22182
- const BORDER_COLOR = "rgba(0,0,0,0.1)";
22183
- const ANNOTATION_DASH = [10, 2];
22184
- const DEFAULT_FONT_SIZE = 12;
22185
- const DEFAULT_FONT_FAMILY = '"Roobert", "Noto Sans", sans-serif';
22186
- const DEFAULT_COLOR = "hsl(60, 10.34482759%, 12.5%)";
22187
- const LEGEND_LABEL_BOX_SIZE = 12;
22188
- const TOOLTIP_PADDING = 8;
22189
- const TOOLTIP_BOX_PADDING = 4;
22190
- const TRANSPARENT = "transparent";
22191
- const LOGARITHMIC_STEPS = [1, 10, 100, 1e3, 1e4];
22192
- const COLORS = [
22193
- "#3366cc",
22194
- "#dc3912",
22195
- "#ff9900",
22196
- "#109618",
22197
- "#990099",
22198
- "#0099c6",
22199
- "#dd4477",
22200
- "#66aa00",
22201
- "#b82e2e",
22202
- "#316395",
22203
- "#994499",
22204
- "#22aa99",
22205
- "#aaaa11",
22206
- "#6633cc",
22207
- "#e67300",
22208
- "#8b0707",
22209
- "#651067",
22210
- "#329262",
22211
- "#5574a6",
22212
- "#3b3eac"
22213
- ];
22214
- const ALPHA_CHANEL = "99";
22215
- const WHITE_COLOR_AS_DECIMAL = 16777215;
22216
- const AUTO = "auto";
22217
- const ANIMATION_DURATION = {
22218
- NO: 0,
22219
- SLOW: 400,
22220
- FAST: 1e3
22221
- };
22222
- const DEFAULT_CHART_NAME = "new_chart";
22223
- const CUSTOM_LEGEND_PLUGIN_NAME = "htmlLegend";
22224
- const DECIMAL_POINT_TOLERANCE = 9;
22225
- const MAX_DECIMAL_DIFF = 1 / 10 ** DECIMAL_POINT_TOLERANCE;
22226
- const GRADIENT_COLORS = [
22227
- { offset: 0, color: "rgba(144,238,144,0.8)" },
22228
- // Light green
22229
- { offset: 0.6, color: "rgba(255,255,224,0.8)" },
22230
- // Light yellow
22231
- { offset: 0.8, color: "rgba(255,255,224,0.8)" },
22232
- // Light yellow
22233
- { offset: 0.92, color: "rgba(255,182,193,0.5)" },
22234
- // Light red
22235
- { offset: 0.99, color: "rgba(255,182,193,0.8)" }
22236
- // Light red
22237
- ];
22238
- const findRadii = (points, mainPoint, isXReverse, isYReverse) => {
22239
- if ((points == null ? void 0 : points.length) === 0) {
22240
- throw new Error("Array of points is empty");
22241
- }
22242
- let top2 = mainPoint;
22243
- let bottom2 = mainPoint;
22244
- let left2 = mainPoint;
22245
- let right2 = mainPoint;
22246
- for (const point of points) {
22247
- if (isYReverse ? point.y < top2.y : point.y > top2.y) {
22248
- top2 = point;
22249
- }
22250
- if (isYReverse ? point.y > bottom2.y : point.y < bottom2.y) {
22251
- bottom2 = point;
22252
- }
22253
- if (isXReverse ? point.x > left2.x : point.x < left2.x) {
22254
- left2 = point;
22255
- }
22256
- if (isXReverse ? point.x < right2.x : point.x > right2.x) {
22257
- right2 = point;
22258
- }
22259
- }
22260
- const radiusX = Math.abs(right2.x - left2.x) / 2;
22261
- const radiusY = Math.abs(bottom2.y - top2.y) / 2;
22262
- return { radiusX, radiusY };
22263
- };
22264
- const ellipsisAnnotationPlugin = {
22265
- id: "ellipsisAnnotationPlugin",
22266
- afterDraw: (chart2) => {
22267
- var _a2, _b2, _c2, _d2;
22268
- const {
22269
- ctx,
22270
- scales: { x: x2, y: y2 },
22271
- data: { datasets },
22272
- options
22273
- } = chart2;
22274
- const isXReverse = ((_b2 = (_a2 = options == null ? void 0 : options.scales) == null ? void 0 : _a2.x) == null ? void 0 : _b2.reverse) || false;
22275
- const isYReverse = ((_d2 = (_c2 = options == null ? void 0 : options.scales) == null ? void 0 : _c2.y) == null ? void 0 : _d2.reverse) || false;
22276
- datasets.forEach((dataset) => {
22277
- dataset.data.forEach((item) => {
22278
- if (item.ellipsePoints && item.ellipsePoints.length) {
22279
- const centerX = x2.getPixelForValue(item.x);
22280
- const centerY = y2.getPixelForValue(item.y);
22281
- const points = item.ellipsePoints.map((point) => ({
22282
- x: x2.getPixelForValue(point.x),
22283
- y: y2.getPixelForValue(point.y)
22284
- }));
22285
- const mainPoint = { x: centerX, y: centerY };
22286
- const { radiusX, radiusY } = findRadii(
22287
- points,
22288
- mainPoint,
22289
- isXReverse,
22290
- isYReverse
22291
- );
22292
- const rotationAngle = item.ellipseRotation * Math.PI / 180;
22293
- ctx.beginPath();
22294
- ctx.ellipse(
22295
- centerX,
22296
- centerY,
22297
- radiusX,
22298
- radiusY,
22299
- rotationAngle,
22300
- 0,
22301
- 2 * Math.PI
22302
- );
22303
- ctx.strokeStyle = (dataset == null ? void 0 : dataset.borderColor) ?? DEFAULT_COLOR;
22304
- ctx.stroke();
22305
- }
22306
- });
22307
- });
22308
- }
22309
- };
22310
22176
  const chart$3 = "_chart_e3qdd_1";
22311
22177
  const canvas$1 = "_canvas_e3qdd_11";
22312
22178
  const fixedHeight$3 = "_fixedHeight_e3qdd_20";
@@ -22600,6 +22466,67 @@ const chartMinorGridlinesPlugin = {
22600
22466
  Object.keys(scales).forEach((id) => drawMinorTicksForScale(scales[id]));
22601
22467
  }
22602
22468
  };
22469
+ const BORDER_WIDTH = {
22470
+ INITIAL: 2,
22471
+ HOVERED: 6,
22472
+ POINT_HOVERED: 8
22473
+ };
22474
+ const BORDER_COLOR = "rgba(0,0,0,0.1)";
22475
+ const ANNOTATION_DASH = [10, 2];
22476
+ const DEFAULT_FONT_SIZE = 12;
22477
+ const DEFAULT_FONT_FAMILY = '"Roobert", "Noto Sans", sans-serif';
22478
+ const DEFAULT_COLOR = "hsl(60, 10.34482759%, 12.5%)";
22479
+ const LEGEND_LABEL_BOX_SIZE = 12;
22480
+ const TOOLTIP_PADDING = 8;
22481
+ const TOOLTIP_BOX_PADDING = 4;
22482
+ const TRANSPARENT = "transparent";
22483
+ const LOGARITHMIC_STEPS = [1, 10, 100, 1e3, 1e4];
22484
+ const COLORS = [
22485
+ "#3366cc",
22486
+ "#dc3912",
22487
+ "#ff9900",
22488
+ "#109618",
22489
+ "#990099",
22490
+ "#0099c6",
22491
+ "#dd4477",
22492
+ "#66aa00",
22493
+ "#b82e2e",
22494
+ "#316395",
22495
+ "#994499",
22496
+ "#22aa99",
22497
+ "#aaaa11",
22498
+ "#6633cc",
22499
+ "#e67300",
22500
+ "#8b0707",
22501
+ "#651067",
22502
+ "#329262",
22503
+ "#5574a6",
22504
+ "#3b3eac"
22505
+ ];
22506
+ const ALPHA_CHANEL = "99";
22507
+ const WHITE_COLOR_AS_DECIMAL = 16777215;
22508
+ const AUTO = "auto";
22509
+ const ANIMATION_DURATION = {
22510
+ NO: 0,
22511
+ SLOW: 400,
22512
+ FAST: 1e3
22513
+ };
22514
+ const DEFAULT_CHART_NAME = "new_chart";
22515
+ const CUSTOM_LEGEND_PLUGIN_NAME = "htmlLegend";
22516
+ const DECIMAL_POINT_TOLERANCE = 9;
22517
+ const MAX_DECIMAL_DIFF = 1 / 10 ** DECIMAL_POINT_TOLERANCE;
22518
+ const GRADIENT_COLORS = [
22519
+ { offset: 0, color: "rgba(144,238,144,0.8)" },
22520
+ // Light green
22521
+ { offset: 0.6, color: "rgba(255,255,224,0.8)" },
22522
+ // Light yellow
22523
+ { offset: 0.8, color: "rgba(255,255,224,0.8)" },
22524
+ // Light yellow
22525
+ { offset: 0.92, color: "rgba(255,182,193,0.5)" },
22526
+ // Light red
22527
+ { offset: 0.99, color: "rgba(255,182,193,0.8)" }
22528
+ // Light red
22529
+ ];
22603
22530
  const chartAreaBorderPlugin = {
22604
22531
  id: "chartAreaBorder",
22605
22532
  beforeDraw(chart2, _2, options) {
@@ -25413,6 +25340,12 @@ var AnnotationType = /* @__PURE__ */ ((AnnotationType2) => {
25413
25340
  AnnotationType2["ELLIPSE"] = "ellipse";
25414
25341
  return AnnotationType2;
25415
25342
  })(AnnotationType || {});
25343
+ var DragAxis = /* @__PURE__ */ ((DragAxis2) => {
25344
+ DragAxis2["X"] = "x";
25345
+ DragAxis2["Y"] = "y";
25346
+ DragAxis2["Both"] = "both";
25347
+ return DragAxis2;
25348
+ })(DragAxis || {});
25416
25349
  const handleLineEnter = (element, chart2, annotation2) => {
25417
25350
  var _a2;
25418
25351
  chart2.canvas.style.cursor = CursorStyle.Pointer;
@@ -25492,13 +25425,9 @@ const generateAnnotations = (annotationsData) => {
25492
25425
  const borderColor = {
25493
25426
  [AnnotationType.LINE]: color2,
25494
25427
  [AnnotationType.POINT]: color2,
25495
- [AnnotationType.BOX]: color2,
25496
- [AnnotationType.ELLIPSE]: color2
25428
+ [AnnotationType.BOX]: color2
25497
25429
  }[type] || TRANSPARENT;
25498
- const borderWidth = {
25499
- [AnnotationType.LINE]: BORDER_WIDTH.INITIAL,
25500
- [AnnotationType.ELLIPSE]: (ann == null ? void 0 : ann.borderWidth) ?? 0
25501
- }[type] ?? 0;
25430
+ const borderWidth = type === AnnotationType.LINE ? BORDER_WIDTH.INITIAL : 0;
25502
25431
  const borderDash = type === AnnotationType.LINE ? ANNOTATION_DASH : void 0;
25503
25432
  const defLabel = {
25504
25433
  content: ann == null ? void 0 : ann.label,
@@ -25564,17 +25493,15 @@ const generateAnnotations = (annotationsData) => {
25564
25493
  const onDragStart = () => (cord, annotation2) => (ann == null ? void 0 : ann.onDragStart) ? ann == null ? void 0 : ann.onDragStart(cord, annotation2) : void 0;
25565
25494
  const onDrag = () => (cord, annotation2) => (ann == null ? void 0 : ann.onDrag) ? ann == null ? void 0 : ann.onDrag(cord, annotation2) : void 0;
25566
25495
  const onDragEnd = () => (cord, annotation2) => (ann == null ? void 0 : ann.onDragEnd) ? ann == null ? void 0 : ann.onDragEnd(cord, annotation2) : void 0;
25567
- const rotation = ann.rotation * Math.PI / 180;
25568
25496
  return {
25569
25497
  ...ann,
25570
25498
  drawTime: "afterDraw",
25571
25499
  display: ann == null ? void 0 : ann.display,
25572
25500
  annotationIndex: idx,
25573
25501
  id: `${ann == null ? void 0 : ann.label}-${ann == null ? void 0 : ann.value}-${idx}`,
25574
- rotation,
25575
25502
  scaleID,
25576
25503
  label,
25577
- backgroundColor: (ann == null ? void 0 : ann.backgroundColor) ?? color2,
25504
+ backgroundColor: color2,
25578
25505
  borderColor,
25579
25506
  borderWidth,
25580
25507
  borderDash,
@@ -26222,21 +26149,29 @@ const handleAnnotationMouseDown = (event, canvas2, scales, annotations, setDragg
26222
26149
  const handleAnnotationMouseMove = (event, canvas2, scales, isDragging2, activeAnnotation, dragStartX, dragStartY, chart2) => {
26223
26150
  if (isDragging2 && activeAnnotation) {
26224
26151
  canvas2.style.cursor = CursorStyle.Move;
26152
+ const dragAxis = (activeAnnotation == null ? void 0 : activeAnnotation.dragAxis) ?? DragAxis.Both;
26225
26153
  const { x: x2, y: y2 } = getMousePositionInCoordinates(event, canvas2, scales);
26226
26154
  const metrics = calculateAnnotationMetricsInValues(activeAnnotation);
26227
26155
  let newCenterX = x2 - dragStartX;
26228
26156
  let newCenterY = y2 - dragStartY;
26229
- if ((activeAnnotation == null ? void 0 : activeAnnotation.type) === AnnotationType.POINT) {
26230
- newCenterX = x2 - dragStartX;
26231
- newCenterY = y2 - dragStartY;
26232
- activeAnnotation.xValue = newCenterX;
26233
- activeAnnotation.yValue = newCenterY;
26234
- } else if ((activeAnnotation == null ? void 0 : activeAnnotation.type) === AnnotationType.BOX) {
26235
- if (!isNil(metrics == null ? void 0 : metrics.width) && !isNil(metrics.height)) {
26236
- activeAnnotation.xMin = newCenterX - metrics.width / 2;
26237
- activeAnnotation.xMax = newCenterX + metrics.width / 2;
26238
- activeAnnotation.yMin = newCenterY - metrics.height / 2;
26239
- activeAnnotation.yMax = newCenterY + metrics.height / 2;
26157
+ if (dragAxis !== DragAxis.Y) {
26158
+ if ((activeAnnotation == null ? void 0 : activeAnnotation.type) === AnnotationType.POINT) {
26159
+ activeAnnotation.xValue = newCenterX;
26160
+ } else if ((activeAnnotation == null ? void 0 : activeAnnotation.type) === AnnotationType.BOX) {
26161
+ if (!isNil(metrics == null ? void 0 : metrics.width)) {
26162
+ activeAnnotation.xMin = newCenterX - metrics.width / 2;
26163
+ activeAnnotation.xMax = newCenterX + metrics.width / 2;
26164
+ }
26165
+ }
26166
+ }
26167
+ if (dragAxis !== DragAxis.X) {
26168
+ if ((activeAnnotation == null ? void 0 : activeAnnotation.type) === AnnotationType.POINT) {
26169
+ activeAnnotation.yValue = newCenterY;
26170
+ } else if ((activeAnnotation == null ? void 0 : activeAnnotation.type) === AnnotationType.BOX) {
26171
+ if (!isNil(metrics == null ? void 0 : metrics.height)) {
26172
+ activeAnnotation.yMin = newCenterY - metrics.height / 2;
26173
+ activeAnnotation.yMax = newCenterY + metrics.height / 2;
26174
+ }
26240
26175
  }
26241
26176
  }
26242
26177
  chart2.update();
@@ -26628,16 +26563,22 @@ const LegendItemLine = ({ dataset }) => {
26628
26563
  }
26629
26564
  };
26630
26565
  const LEGEND_SYMBOL_SIZE = 16;
26631
- const renderLegendItemSymbol = (dataset, chartType) => {
26566
+ const renderLegendItemSymbol = (dataset, chartType, index2) => {
26632
26567
  switch (chartType) {
26633
26568
  case ChartType.LINE:
26634
26569
  return /* @__PURE__ */ jsx(LegendItemLine, { dataset });
26635
- case ChartType.BAR:
26636
- return /* @__PURE__ */ jsx("span", { className: styles$3.legendItemBox, children: /* @__PURE__ */ jsx(TbSquareFilled, { color: dataset.borderColor }) });
26570
+ case ChartType.BAR: {
26571
+ const { backgroundColor } = dataset;
26572
+ const color2 = backgroundColor instanceof Array ? backgroundColor[index2] : backgroundColor;
26573
+ return /* @__PURE__ */ jsx("span", { className: styles$3.legendItemBox, children: /* @__PURE__ */ jsx(TbSquareFilled, { color: color2 }) });
26574
+ }
26637
26575
  case ChartType.PIE:
26638
26576
  return /* @__PURE__ */ jsx("span", { className: styles$3.legendItemPoint, children: /* @__PURE__ */ jsx(Icon, { icon: /* @__PURE__ */ jsx(SvgCircle, {}) }) });
26639
- case ChartType.SCATTER:
26640
- return /* @__PURE__ */ jsx("span", { className: styles$3.legendItemPoint, children: /* @__PURE__ */ jsx(TbCircleFilled, { color: dataset.borderColor }) });
26577
+ case ChartType.SCATTER: {
26578
+ const { backgroundColor, borderColor } = dataset;
26579
+ const color2 = backgroundColor instanceof Array ? backgroundColor[index2] : backgroundColor;
26580
+ return /* @__PURE__ */ jsx("span", { className: styles$3.legendItemPoint, children: /* @__PURE__ */ jsx(TbCircleFilled, { color: color2 ?? borderColor }) });
26581
+ }
26641
26582
  default:
26642
26583
  return null;
26643
26584
  }
@@ -26646,7 +26587,8 @@ const LegendItem = ({
26646
26587
  hidden,
26647
26588
  dataset,
26648
26589
  handleClick,
26649
- chartType
26590
+ chartType,
26591
+ index: index2
26650
26592
  }) => {
26651
26593
  return /* @__PURE__ */ jsxs(
26652
26594
  "div",
@@ -26659,7 +26601,7 @@ const LegendItem = ({
26659
26601
  {
26660
26602
  className: styles$3.legendItemSymbol,
26661
26603
  style: { width: LEGEND_SYMBOL_SIZE },
26662
- children: renderLegendItemSymbol(dataset, chartType)
26604
+ children: renderLegendItemSymbol(dataset, chartType, index2)
26663
26605
  }
26664
26606
  ),
26665
26607
  /* @__PURE__ */ jsx("span", { className: styles$3.legendItemText, children: dataset.label })
@@ -26731,13 +26673,14 @@ const LegendItems = ({
26731
26673
  datasets,
26732
26674
  legendClick,
26733
26675
  chartType
26734
- }) => /* @__PURE__ */ jsx("div", { className: styles$3.legendItems, children: items.map((item) => {
26676
+ }) => /* @__PURE__ */ jsx("div", { className: styles$3.legendItems, children: items.map((item, index2) => {
26735
26677
  if (datasets[item.datasetIndex].hideLegend) {
26736
26678
  return null;
26737
26679
  }
26738
26680
  return /* @__PURE__ */ jsx(
26739
26681
  LegendItem,
26740
26682
  {
26683
+ index: index2,
26741
26684
  hidden: item.hidden,
26742
26685
  dataset: datasets[item.datasetIndex],
26743
26686
  handleClick: (_2) => legendClick(_2, item),
@@ -26919,8 +26862,7 @@ Chart$2.register(
26919
26862
  plugin,
26920
26863
  annotation,
26921
26864
  chartAreaTextPlugin,
26922
- annotationDraggerPlugin,
26923
- ellipsisAnnotationPlugin
26865
+ annotationDraggerPlugin
26924
26866
  );
26925
26867
  const LineChart = (props) => {
26926
26868
  var _a2, _b2;
@@ -27073,7 +27015,8 @@ const defaultChartStyling$2 = (styling) => ({
27073
27015
  });
27074
27016
  const defaultTooltip$2 = (tooltip) => ({
27075
27017
  tooltips: (tooltip == null ? void 0 : tooltip.tooltips) ?? true,
27076
- showLabelsInTooltips: (tooltip == null ? void 0 : tooltip.showLabelsInTooltips) || false
27018
+ showLabelsInTooltips: (tooltip == null ? void 0 : tooltip.showLabelsInTooltips) || false,
27019
+ scientificNotation: (tooltip == null ? void 0 : tooltip.scientificNotation) ?? true
27077
27020
  });
27078
27021
  const defaultGraph$2 = (graph) => ({
27079
27022
  showDataLabels: (graph == null ? void 0 : graph.showDataLabels) || false,
@@ -27118,6 +27061,8 @@ const getDefaultProps$2 = (props) => {
27118
27061
  }
27119
27062
  };
27120
27063
  };
27064
+ const DISPLAY_SCIENTIFIC_LOWER_BOUND = 1e-4;
27065
+ const DISPLAY_SCIENTIFIC_UPPER_BOUND = 1e7;
27121
27066
  const usePieChartConfig = (chart2) => {
27122
27067
  const [pointHover, setPointHover] = useState(false);
27123
27068
  const { data, options } = chart2;
@@ -27250,6 +27195,16 @@ const usePieChartConfig = (chart2) => {
27250
27195
  };
27251
27196
  };
27252
27197
  const getToolTips = () => {
27198
+ const customFormatNumber2 = (labelNumber) => {
27199
+ var _a2;
27200
+ let roundOptions = {};
27201
+ if (!((_a2 = options == null ? void 0 : options.tooltip) == null ? void 0 : _a2.scientificNotation)) {
27202
+ roundOptions = { scientific: false };
27203
+ } else if (Math.abs(labelNumber) < DISPLAY_SCIENTIFIC_LOWER_BOUND || Math.abs(labelNumber) > DISPLAY_SCIENTIFIC_UPPER_BOUND) {
27204
+ roundOptions = { roundScientificCoefficient: 3 };
27205
+ }
27206
+ return displayNumber(roundByMagnitude(labelNumber), roundOptions);
27207
+ };
27253
27208
  return {
27254
27209
  callbacks: {
27255
27210
  title: (tooltipItem) => {
@@ -27266,8 +27221,7 @@ const usePieChartConfig = (chart2) => {
27266
27221
  const value = tooltipItem.dataset.data[dataIndex];
27267
27222
  const labelValue = typeof value === "object" ? `${value.value || ""} ${options.tooltip.showLabelsInTooltips && value.label ? "(" + value.label + ")" : ""}` : value;
27268
27223
  const unit = (data == null ? void 0 : data.yUnit) ? `[${data == null ? void 0 : data.yUnit}]` : "";
27269
- const formattedValue = Math.abs(labelValue) < 1 ? roundNumberToPrecision(labelValue, 3) : round$2(labelValue, 3);
27270
- return `${dataLabel} ${formattedValue} ${unit}`;
27224
+ return `${dataLabel} ${customFormatNumber2(labelValue)} ${unit}`;
27271
27225
  }
27272
27226
  },
27273
27227
  padding: TOOLTIP_PADDING,
@@ -39938,8 +39892,6 @@ const getBarChartDataLabels = (options) => {
39938
39892
  formatter: formatterCallback
39939
39893
  } : { display: false };
39940
39894
  };
39941
- const DISPLAY_SCIENTIFIC_LOWER_BOUND = 1e-4;
39942
- const DISPLAY_SCIENTIFIC_UPPER_BOUND = 1e7;
39943
39895
  const getBarChartToolTips = (options) => {
39944
39896
  var _a2;
39945
39897
  const getTooltipLabels = (dataset) => {
@@ -39975,8 +39927,11 @@ const getBarChartToolTips = (options) => {
39975
39927
  return axisLabel + barLabel;
39976
39928
  };
39977
39929
  const customFormatNumber2 = (labelNumber) => {
39930
+ var _a3;
39978
39931
  let roundOptions = {};
39979
- if (Math.abs(labelNumber) < DISPLAY_SCIENTIFIC_LOWER_BOUND || Math.abs(labelNumber) > DISPLAY_SCIENTIFIC_UPPER_BOUND) {
39932
+ if (!((_a3 = options == null ? void 0 : options.tooltip) == null ? void 0 : _a3.scientificNotation)) {
39933
+ roundOptions = { scientific: false };
39934
+ } else if (Math.abs(labelNumber) < DISPLAY_SCIENTIFIC_LOWER_BOUND || Math.abs(labelNumber) > DISPLAY_SCIENTIFIC_UPPER_BOUND) {
39980
39935
  roundOptions = { roundScientificCoefficient: 3 };
39981
39936
  }
39982
39937
  return displayNumber(roundByMagnitude(labelNumber), roundOptions);
@@ -40112,7 +40067,8 @@ const defaultChartStyling$1 = (styling) => ({
40112
40067
  });
40113
40068
  const defaultTooltip$1 = (tooltip) => ({
40114
40069
  tooltips: (tooltip == null ? void 0 : tooltip.tooltips) ?? true,
40115
- showLabelsInTooltips: (tooltip == null ? void 0 : tooltip.showLabelsInTooltips) || false
40070
+ showLabelsInTooltips: (tooltip == null ? void 0 : tooltip.showLabelsInTooltips) || false,
40071
+ scientificNotation: (tooltip == null ? void 0 : tooltip.scientificNotation) ?? true
40116
40072
  });
40117
40073
  const defaultGraph$1 = (graph) => ({
40118
40074
  showDataLabels: (graph == null ? void 0 : graph.showDataLabels) || false,
@@ -40261,9 +40217,11 @@ const BarChartWithLegend = (props) => {
40261
40217
  const { options } = getDefaultProps$1(props);
40262
40218
  return /* @__PURE__ */ jsx(LegendProvider, { options, children: /* @__PURE__ */ jsx(BarChart, { ...props }) });
40263
40219
  };
40264
- const customFormatNumber = (labelNumber) => {
40220
+ const customFormatNumber = (labelNumber, scientificNotation) => {
40265
40221
  let roundOptions = {};
40266
- if (Math.abs(labelNumber) < DISPLAY_SCIENTIFIC_LOWER_BOUND || Math.abs(labelNumber) > DISPLAY_SCIENTIFIC_UPPER_BOUND) {
40222
+ if (!scientificNotation) {
40223
+ roundOptions = { scientific: false };
40224
+ } else if (Math.abs(labelNumber) < DISPLAY_SCIENTIFIC_LOWER_BOUND || Math.abs(labelNumber) > DISPLAY_SCIENTIFIC_UPPER_BOUND) {
40267
40225
  roundOptions = { roundScientificCoefficient: 3 };
40268
40226
  }
40269
40227
  return displayNumber(roundByMagnitude(labelNumber), roundOptions);
@@ -40276,12 +40234,15 @@ const titleCallback = (tooltipItems, options) => {
40276
40234
  return label;
40277
40235
  }
40278
40236
  };
40279
- const labelCallback = (tooltipItem) => {
40237
+ const labelCallback = (tooltipItem, options) => {
40238
+ var _a2;
40280
40239
  const { raw, dataset } = tooltipItem ?? {};
40281
40240
  const datapointLabel = raw == null ? void 0 : raw.label;
40241
+ const scientificNotation = (_a2 = options == null ? void 0 : options.tooltip) == null ? void 0 : _a2.scientificNotation;
40282
40242
  return `${datapointLabel ?? (dataset == null ? void 0 : dataset.label)} ( x: ${customFormatNumber(
40283
- raw == null ? void 0 : raw.x
40284
- )} , y: ${customFormatNumber(raw == null ? void 0 : raw.y)} )`;
40243
+ raw == null ? void 0 : raw.x,
40244
+ scientificNotation
40245
+ )} , y: ${customFormatNumber(raw == null ? void 0 : raw.y, scientificNotation)} )`;
40285
40246
  };
40286
40247
  const getTooltipsConfig = (options) => {
40287
40248
  var _a2, _b2, _c2;
@@ -40289,7 +40250,7 @@ const getTooltipsConfig = (options) => {
40289
40250
  enabled: (_a2 = options == null ? void 0 : options.tooltip) == null ? void 0 : _a2.enabled,
40290
40251
  callbacks: {
40291
40252
  title: (tooltipItems) => titleCallback(tooltipItems, options),
40292
- label: labelCallback
40253
+ label: (tooltipItems) => labelCallback(tooltipItems, options)
40293
40254
  },
40294
40255
  backgroundColor: (_b2 = options == null ? void 0 : options.tooltip) == null ? void 0 : _b2.backgroundColor,
40295
40256
  displayColors: (_c2 = options == null ? void 0 : options.tooltip) == null ? void 0 : _c2.displayColors,
@@ -40465,7 +40426,8 @@ const defaultTooltip = (tooltip) => ({
40465
40426
  tooltips: (tooltip == null ? void 0 : tooltip.tooltips) ?? true,
40466
40427
  showLabelsInTooltips: (tooltip == null ? void 0 : tooltip.showLabelsInTooltips) || false,
40467
40428
  backgroundColor: (tooltip == null ? void 0 : tooltip.backgroundColor) || "#333",
40468
- displayColors: (tooltip == null ? void 0 : tooltip.displayColors) || false
40429
+ displayColors: (tooltip == null ? void 0 : tooltip.displayColors) || false,
40430
+ scientificNotation: (tooltip == null ? void 0 : tooltip.scientificNotation) ?? true
40469
40431
  });
40470
40432
  const defaultGraph = (graph) => ({
40471
40433
  showMinorGridlines: (graph == null ? void 0 : graph.showMinorGridlines) ?? false,