@oliasoft-open-source/charts-library 3.2.1 → 3.2.3-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
@@ -10,7 +10,7 @@ import React, { forwardRef, useRef, useEffect, useMemo, useCallback, useState, u
10
10
  import { round as round$2, toNum, displayNumber, isCloseTo } from "@oliasoft-open-source/units";
11
11
  import cx from "classnames";
12
12
  import { produce } from "immer";
13
- import { Icon, Tooltip as Tooltip$2, Button, Flex, Text, Menu, Popover, Field, InputGroup, NumberInput, InputGroupAddon, Select, ButtonGroup, Spacer } from "@oliasoft-open-source/react-ui-library";
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";
14
14
  import PropTypes from "prop-types";
15
15
  import { debounce as debounce$3, isEqual } from "lodash";
16
16
  /*!
@@ -32306,6 +32306,12 @@ AxesOptionsPopover.propTypes = {
32306
32306
  options: PropTypes.arrayOf(PropTypes.string)
32307
32307
  })
32308
32308
  };
32309
+ const ControlsPortal = ({ children, controlsPortalId }) => {
32310
+ if (controlsPortalId && document.getElementById(controlsPortalId)) {
32311
+ return /* @__PURE__ */ jsx(Portal, { id: controlsPortalId, children });
32312
+ }
32313
+ return children;
32314
+ };
32309
32315
  const Controls = ({
32310
32316
  props: { headerComponent, subheaderComponent, table: table2 },
32311
32317
  chartRef,
@@ -32313,7 +32319,8 @@ const Controls = ({
32313
32319
  options,
32314
32320
  dispatch,
32315
32321
  generatedDatasets,
32316
- translations
32322
+ translations,
32323
+ controlsPortalId
32317
32324
  }) => {
32318
32325
  const {
32319
32326
  enableDragPoints,
@@ -32353,7 +32360,7 @@ const Controls = ({
32353
32360
  /* @__PURE__ */ jsxs("div", { className: styles$2.controls, children: [
32354
32361
  !!options.title && /* @__PURE__ */ jsx(Text, { bold: true, children: options.title }),
32355
32362
  headerComponent,
32356
- /* @__PURE__ */ jsxs("div", { className: styles$2.buttons, children: [
32363
+ /* @__PURE__ */ jsx(ControlsPortal, { controlsPortalId, children: /* @__PURE__ */ jsxs("div", { className: styles$2.buttons, children: [
32357
32364
  !showTable && /* @__PURE__ */ jsxs(Fragment, { children: [
32358
32365
  /* @__PURE__ */ jsx(
32359
32366
  AxesOptions,
@@ -32385,17 +32392,24 @@ const Controls = ({
32385
32392
  translations
32386
32393
  }
32387
32394
  ),
32388
- /* @__PURE__ */ jsx(Tooltip$2, { text: translations.downloadAsPNG, placement: "bottom-end", children: /* @__PURE__ */ jsx(
32389
- Button,
32395
+ /* @__PURE__ */ jsx(
32396
+ Tooltip$2,
32390
32397
  {
32391
- small: true,
32392
- basic: true,
32393
- colored: "muted",
32394
- round: true,
32395
- icon: /* @__PURE__ */ jsx(RiFileDownloadLine, {}),
32396
- onClick: handleDownload
32398
+ text: translations.downloadAsPNG,
32399
+ placement: "bottom-end",
32400
+ children: /* @__PURE__ */ jsx(
32401
+ Button,
32402
+ {
32403
+ small: true,
32404
+ basic: true,
32405
+ colored: "muted",
32406
+ round: true,
32407
+ icon: /* @__PURE__ */ jsx(RiFileDownloadLine, {}),
32408
+ onClick: handleDownload
32409
+ }
32410
+ )
32397
32411
  }
32398
- ) }),
32412
+ ),
32399
32413
  /* @__PURE__ */ jsx(
32400
32414
  DragOptions,
32401
32415
  {
@@ -32429,7 +32443,7 @@ const Controls = ({
32429
32443
  )
32430
32444
  }
32431
32445
  ) : null
32432
- ] })
32446
+ ] }) })
32433
32447
  ] }),
32434
32448
  subheaderComponent
32435
32449
  ] });
@@ -32438,7 +32452,8 @@ Controls.defaultProps = {
32438
32452
  props: {
32439
32453
  headerComponent: null,
32440
32454
  subheaderComponent: null,
32441
- table: null
32455
+ table: null,
32456
+ controlsPortalId: null
32442
32457
  },
32443
32458
  state: {
32444
32459
  initialAxesRanges: []
@@ -32449,7 +32464,8 @@ Controls.propTypes = {
32449
32464
  props: PropTypes.shape({
32450
32465
  headerComponent: PropTypes.node,
32451
32466
  subheaderComponent: PropTypes.node,
32452
- table: PropTypes.node
32467
+ table: PropTypes.node,
32468
+ controlsPortalId: PropTypes.string
32453
32469
  }),
32454
32470
  chartRef: PropTypes.object.isRequired,
32455
32471
  state: PropTypes.shape({
@@ -32485,6 +32501,7 @@ const LineChartPropTypes = {
32485
32501
  table: PropTypes.node,
32486
32502
  chart: PropTypes.shape({
32487
32503
  persistenceId: PropTypes.string,
32504
+ controlsPortalId: PropTypes.string,
32488
32505
  testId: PropTypes.string,
32489
32506
  data: PropTypes.object.isRequired,
32490
32507
  options: PropTypes.shape({
@@ -32648,6 +32665,7 @@ const getDefaultProps$2 = (props) => {
32648
32665
  props.chart.options.dragData = props.chart.options.dragData || {};
32649
32666
  const chart2 = {
32650
32667
  persistenceId: props.chart.persistenceId ?? "",
32668
+ controlsPortalId: props.chart.controlsPortalId ?? null,
32651
32669
  testId: props.chart.testId ?? null,
32652
32670
  data: props.chart.data,
32653
32671
  options: {
@@ -32844,16 +32862,17 @@ const formatAxisLabelNumbers = (tickValue, ticks, locale = "en-gb") => {
32844
32862
  Math.abs(ticks[0].value),
32845
32863
  Math.abs(ticks[ticks.length - 1].value)
32846
32864
  );
32847
- if (maxTick < 1e-4 || maxTick > 1e15) {
32865
+ if (maxTick < 1e-4 || maxTick > 1e7) {
32848
32866
  notation = "scientific";
32849
32867
  }
32850
32868
  delta = calculateDelta(tickValue, ticks);
32851
32869
  }
32852
32870
  const logDelta = Math.log10(Math.abs(delta));
32853
32871
  const numDecimal = isNaN(logDelta) ? 1 : Math.max(Math.min(-1 * Math.floor(logDelta), 20), 0);
32872
+ const roundScientificCoefficient = numDecimal === 0 ? 1 : numDecimal;
32854
32873
  return displayNumber(round$2(tickValue, numDecimal), {
32855
32874
  scientific: notation === "scientific",
32856
- roundScientificCoefficientToNDecimals: numDecimal
32875
+ roundScientificCoefficient
32857
32876
  });
32858
32877
  };
32859
32878
  const getLineChartAxis = (options, axisType, state, currentScales, i2 = 0) => {
@@ -33776,7 +33795,8 @@ const LineChart = (props) => {
33776
33795
  data: { datasets },
33777
33796
  options,
33778
33797
  testId,
33779
- persistenceId
33798
+ persistenceId,
33799
+ controlsPortalId
33780
33800
  } = chart2;
33781
33801
  const { annotations, axes, chartStyling, graph } = options;
33782
33802
  const [state, dispatch] = useReducer(
@@ -33835,7 +33855,8 @@ const LineChart = (props) => {
33835
33855
  options,
33836
33856
  dispatch,
33837
33857
  generatedDatasets,
33838
- translations
33858
+ translations,
33859
+ controlsPortalId
33839
33860
  }
33840
33861
  ),
33841
33862
  table2 && state.showTable ? /* @__PURE__ */ jsx("div", { className: styles$3.table, children: table2 }) : /* @__PURE__ */ jsx("div", { className: styles$3.canvas, children: /* @__PURE__ */ jsx(