@oliasoft-open-source/charts-library 4.8.3-beta-4 → 4.8.3-beta-6

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
@@ -5,11 +5,11 @@ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
5
5
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
6
6
  import * as React from "react";
7
7
  import React__default, { forwardRef, useRef, useEffect, createContext as createContext$2, memo, useLayoutEffect, useState, useCallback, useMemo, isValidElement, cloneElement, useContext, useReducer } from "react";
8
- import { produce } from "immer";
9
8
  import { round as round$2, displayNumber, isCloseTo, roundByMagnitude } from "@oliasoft-open-source/units";
10
9
  import cx from "classnames";
10
+ import { produce } from "immer";
11
11
  import { Portal, Icon, Menu, Tooltip as Tooltip$2, Button, Popover, Field, InputGroup, NumberInput, InputGroupAddon, Select, ButtonGroup, Spacer, Flex, Text } from "@oliasoft-open-source/react-ui-library";
12
- import { isEmpty, isArray as isArray$2, some, has, isNil, cloneDeep, defaultTo, findIndex, set as set$2, debounce as debounce$3, map as map$3, find, get as get$1, noop as noop$2 } from "lodash";
12
+ import { startCase, isEmpty, isArray as isArray$2, some, has, isNil, cloneDeep, defaultTo, findIndex, set as set$2, debounce as debounce$3, map as map$3, find, get as get$1, noop as noop$2 } from "lodash";
13
13
  /*!
14
14
  * @kurkle/color v0.3.4
15
15
  * https://github.com/kurkle/color#readme
@@ -22511,218 +22511,6 @@ class HTML5BackendImpl {
22511
22511
  const HTML5Backend = function createBackend(manager, context, options) {
22512
22512
  return new HTML5BackendImpl(manager, context, options);
22513
22513
  };
22514
- const chart$3 = "_chart_e3qdd_1";
22515
- const canvas$2 = "_canvas_e3qdd_11";
22516
- const fixedHeight$3 = "_fixedHeight_e3qdd_20";
22517
- const stretchHeight$3 = "_stretchHeight_e3qdd_26";
22518
- const squareAspectRatio$1 = "_squareAspectRatio_e3qdd_32";
22519
- const table = "_table_e3qdd_62";
22520
- const styles$5 = {
22521
- chart: chart$3,
22522
- canvas: canvas$2,
22523
- fixedHeight: fixedHeight$3,
22524
- stretchHeight: stretchHeight$3,
22525
- squareAspectRatio: squareAspectRatio$1,
22526
- table
22527
- };
22528
- const TOGGLE_ZOOM = "TOGGLE_ZOOM";
22529
- const TOGGLE_PAN = "TOGGLE_PAN";
22530
- const TOGGLE_POINTS = "TOGGLE_POINTS";
22531
- const TOGGLE_LINE = "TOGGLE_LINE";
22532
- const TOGGLE_LEGEND = "TOGGLE_LEGEND";
22533
- const TOGGLE_TABLE = "TOGGLE_TABLE";
22534
- const SAVE_INITIAL_AXES_RANGES = "SAVE_INITIAL_AXES_RANGES";
22535
- const RESET_AXES_RANGES = "RESET_AXES_RANGES";
22536
- const UPDATE_AXES_RANGES = "UPDATE_AXES_RANGES";
22537
- const TOGGLE_DRAG_POINTS = "TOGGLE_DRAG_POINTS";
22538
- const TOGGLE_DRAG_ANNOTATION = "TOGGLE_DRAG_ANNOTATION";
22539
- const DISABLE_DRAG_OPTIONS = "DISABLE_DRAG_OPTIONS";
22540
- const reducer$1 = (state, action) => {
22541
- return produce(state, (draft) => {
22542
- switch (action.type) {
22543
- case TOGGLE_ZOOM: {
22544
- draft.zoomEnabled = !draft.zoomEnabled;
22545
- if (draft.panEnabled) {
22546
- draft.panEnabled = false;
22547
- }
22548
- if (draft.enableDragPoints) {
22549
- draft.enableDragPoints = false;
22550
- }
22551
- if (draft.enableDragAnnotation) {
22552
- draft.enableDragAnnotation = false;
22553
- }
22554
- break;
22555
- }
22556
- case TOGGLE_PAN: {
22557
- draft.panEnabled = !draft.panEnabled;
22558
- if (draft.zoomEnabled) {
22559
- draft.zoomEnabled = false;
22560
- }
22561
- if (draft.enableDragPoints) {
22562
- draft.enableDragPoints = false;
22563
- }
22564
- if (draft.enableDragAnnotation) {
22565
- draft.enableDragAnnotation = false;
22566
- }
22567
- break;
22568
- }
22569
- case TOGGLE_POINTS: {
22570
- draft.pointsEnabled = !draft.pointsEnabled;
22571
- break;
22572
- }
22573
- case TOGGLE_LINE: {
22574
- draft.lineEnabled = !draft.lineEnabled;
22575
- break;
22576
- }
22577
- case TOGGLE_LEGEND: {
22578
- draft.legendEnabled = !draft.legendEnabled;
22579
- break;
22580
- }
22581
- case TOGGLE_TABLE: {
22582
- draft.showTable = !draft.showTable;
22583
- break;
22584
- }
22585
- case SAVE_INITIAL_AXES_RANGES: {
22586
- const { initialAxesRanges } = action.payload;
22587
- draft.initialAxesRanges = initialAxesRanges;
22588
- break;
22589
- }
22590
- case UPDATE_AXES_RANGES: {
22591
- const { axes } = action.payload;
22592
- draft.axes = axes;
22593
- break;
22594
- }
22595
- case RESET_AXES_RANGES: {
22596
- const { initialAxesRanges } = draft;
22597
- draft.axes = [...initialAxesRanges];
22598
- break;
22599
- }
22600
- case TOGGLE_DRAG_POINTS: {
22601
- draft.enableDragPoints = !draft.enableDragPoints;
22602
- if (draft.panEnabled) {
22603
- draft.panEnabled = false;
22604
- }
22605
- if (draft.zoomEnabled) {
22606
- draft.zoomEnabled = false;
22607
- }
22608
- if (draft.enableDragAnnotation) {
22609
- draft.enableDragAnnotation = false;
22610
- }
22611
- break;
22612
- }
22613
- case TOGGLE_DRAG_ANNOTATION: {
22614
- draft.enableDragAnnotation = !draft.enableDragAnnotation;
22615
- if (draft.panEnabled) {
22616
- draft.panEnabled = false;
22617
- }
22618
- if (draft.zoomEnabled) {
22619
- draft.zoomEnabled = false;
22620
- }
22621
- break;
22622
- }
22623
- case DISABLE_DRAG_OPTIONS: {
22624
- if (draft.enableDragAnnotation || draft.enableDragPoints || draft.panEnabled || draft.zoomEnabled) {
22625
- draft.enableDragAnnotation = false;
22626
- draft.enableDragPoints = false;
22627
- draft.panEnabled = false;
22628
- draft.zoomEnabled = false;
22629
- }
22630
- break;
22631
- }
22632
- }
22633
- });
22634
- };
22635
- var AxisType = /* @__PURE__ */ ((AxisType2) => {
22636
- AxisType2["X"] = "x";
22637
- AxisType2["Y"] = "y";
22638
- return AxisType2;
22639
- })(AxisType || {});
22640
- var Position = /* @__PURE__ */ ((Position2) => {
22641
- Position2["Bottom"] = "bottom";
22642
- Position2["Top"] = "top";
22643
- Position2["Left"] = "left";
22644
- Position2["Right"] = "right";
22645
- Position2["TopRight"] = "top-right";
22646
- Position2["TopLeft"] = "top-left";
22647
- Position2["BottomLeft"] = "bottom-left";
22648
- Position2["BottomRight"] = "bottom-right";
22649
- return Position2;
22650
- })(Position || {});
22651
- var ChartType$1 = /* @__PURE__ */ ((ChartType2) => {
22652
- ChartType2["Line"] = "line";
22653
- ChartType2["Bar"] = "bar";
22654
- return ChartType2;
22655
- })(ChartType$1 || {});
22656
- var CursorStyle = /* @__PURE__ */ ((CursorStyle2) => {
22657
- CursorStyle2["Pointer"] = "pointer";
22658
- CursorStyle2["Initial"] = "initial";
22659
- CursorStyle2["Grab"] = "grab";
22660
- CursorStyle2["Grabbing"] = "grabbing";
22661
- CursorStyle2["Crosshair"] = "crosshair";
22662
- CursorStyle2["Move"] = "move";
22663
- return CursorStyle2;
22664
- })(CursorStyle || {});
22665
- var ScaleType = /* @__PURE__ */ ((ScaleType2) => {
22666
- ScaleType2["Category"] = "category";
22667
- ScaleType2["Linear"] = "linear";
22668
- ScaleType2["Logarithmic"] = "logarithmic";
22669
- return ScaleType2;
22670
- })(ScaleType || {});
22671
- var ChartDirection$1 = /* @__PURE__ */ ((ChartDirection2) => {
22672
- ChartDirection2["Vertical"] = "vertical";
22673
- return ChartDirection2;
22674
- })(ChartDirection$1 || {});
22675
- var TooltipLabel = /* @__PURE__ */ ((TooltipLabel2) => {
22676
- TooltipLabel2["Y"] = "yLabel";
22677
- TooltipLabel2["X"] = "xLabel";
22678
- return TooltipLabel2;
22679
- })(TooltipLabel || {});
22680
- var AlignOptions = /* @__PURE__ */ ((AlignOptions2) => {
22681
- AlignOptions2["End"] = "end";
22682
- AlignOptions2["Start"] = "start";
22683
- AlignOptions2["Center"] = "center";
22684
- AlignOptions2["Right"] = "right";
22685
- AlignOptions2["Left"] = "left";
22686
- return AlignOptions2;
22687
- })(AlignOptions || {});
22688
- var AnnotationType$1 = /* @__PURE__ */ ((AnnotationType2) => {
22689
- AnnotationType2["Box"] = "box";
22690
- AnnotationType2["Ellipse"] = "ellipse";
22691
- AnnotationType2["Line"] = "line";
22692
- AnnotationType2["Text"] = "text";
22693
- return AnnotationType2;
22694
- })(AnnotationType$1 || {});
22695
- var PointStyle = /* @__PURE__ */ ((PointStyle2) => {
22696
- PointStyle2["Circle"] = "circle";
22697
- PointStyle2["Square"] = "rect";
22698
- PointStyle2["Diamond"] = "rectRot";
22699
- PointStyle2["Triangle"] = "triangle";
22700
- return PointStyle2;
22701
- })(PointStyle || {});
22702
- var ChartHoverMode = /* @__PURE__ */ ((ChartHoverMode2) => {
22703
- ChartHoverMode2["Nearest"] = "nearest";
22704
- return ChartHoverMode2;
22705
- })(ChartHoverMode || {});
22706
- var PanZoomMode = /* @__PURE__ */ ((PanZoomMode2) => {
22707
- PanZoomMode2["X"] = "x";
22708
- PanZoomMode2["Y"] = "y";
22709
- PanZoomMode2["XY"] = "xy";
22710
- PanZoomMode2["Z"] = "z";
22711
- return PanZoomMode2;
22712
- })(PanZoomMode || {});
22713
- var Key = /* @__PURE__ */ ((Key2) => {
22714
- Key2["Shift"] = "Shift";
22715
- return Key2;
22716
- })(Key || {});
22717
- var Events = /* @__PURE__ */ ((Events2) => {
22718
- Events2["Mousemove"] = "mousemove";
22719
- Events2["Mouseout"] = "mouseout";
22720
- Events2["Click"] = "click";
22721
- Events2["Touchstart"] = "touchstart";
22722
- Events2["Touchmove"] = "touchmove";
22723
- Events2["Dblclick"] = "dblclick";
22724
- return Events2;
22725
- })(Events || {});
22726
22514
  const MINOR_TICKS_PER_MAJOR = 10;
22727
22515
  const getLargestMajorTickWidth = (majorTickPositions) => {
22728
22516
  return majorTickPositions.reduce(
@@ -22854,55 +22642,146 @@ const GRADIENT_COLORS = [
22854
22642
  { offset: 0.99, color: "rgba(255,182,193,0.8)" }
22855
22643
  // Light red
22856
22644
  ];
22857
- const chartAreaBorderPlugin = {
22858
- id: "chartAreaBorder",
22859
- beforeDraw(chart2, _2, options) {
22860
- const {
22861
- ctx,
22862
- chartArea: { left: left2, top: top2, width, height }
22863
- } = chart2;
22864
- ctx.save();
22865
- ctx.strokeStyle = options.borderColor;
22866
- ctx.lineWidth = options.borderWidth;
22867
- ctx.setLineDash(options.borderDash || []);
22868
- ctx.lineDashOffset = options.borderDashOffset ?? 0;
22869
- ctx.strokeRect(left2, top2, width, height);
22870
- ctx.restore();
22871
- }
22872
- };
22873
- const getPlugins = (graph, legend2) => {
22874
- var _a2;
22875
- let plugins = [];
22876
- if (graph.showMinorGridlines) {
22877
- plugins.push(chartMinorGridlinesPlugin);
22878
- }
22879
- const customLegend = legend2 == null ? void 0 : legend2.customLegend;
22880
- if ((customLegend == null ? void 0 : customLegend.customLegendPlugin) && (customLegend == null ? void 0 : customLegend.customLegendContainerID)) {
22881
- plugins.push({
22882
- id: CUSTOM_LEGEND_PLUGIN_NAME,
22883
- ...(_a2 = legend2 == null ? void 0 : legend2.customLegend) == null ? void 0 : _a2.customLegendPlugin
22884
- });
22885
- }
22886
- plugins.push(chartAreaBorderPlugin);
22887
- return plugins;
22888
- };
22889
- const generateRandomColor = (colors2) => {
22890
- const color2 = `#${Math.floor(Math.random() * WHITE_COLOR_AS_DECIMAL).toString(
22891
- 16
22892
- )}`;
22893
- if (colors2.includes(color2)) {
22894
- return generateRandomColor(colors2);
22895
- } else {
22896
- colors2.push(color2);
22897
- return colors2;
22898
- }
22899
- };
22900
- const getTitle = (options) => {
22901
- return options.title !== "" ? {
22902
- display: true,
22903
- text: options.title
22904
- } : {};
22905
- };
22645
+ var AxisType = /* @__PURE__ */ ((AxisType2) => {
22646
+ AxisType2["X"] = "x";
22647
+ AxisType2["Y"] = "y";
22648
+ return AxisType2;
22649
+ })(AxisType || {});
22650
+ var Position = /* @__PURE__ */ ((Position2) => {
22651
+ Position2["Bottom"] = "bottom";
22652
+ Position2["Top"] = "top";
22653
+ Position2["Left"] = "left";
22654
+ Position2["Right"] = "right";
22655
+ Position2["TopRight"] = "top-right";
22656
+ Position2["TopLeft"] = "top-left";
22657
+ Position2["BottomLeft"] = "bottom-left";
22658
+ Position2["BottomRight"] = "bottom-right";
22659
+ return Position2;
22660
+ })(Position || {});
22661
+ var ChartType$1 = /* @__PURE__ */ ((ChartType2) => {
22662
+ ChartType2["Line"] = "line";
22663
+ ChartType2["Bar"] = "bar";
22664
+ return ChartType2;
22665
+ })(ChartType$1 || {});
22666
+ var CursorStyle = /* @__PURE__ */ ((CursorStyle2) => {
22667
+ CursorStyle2["Pointer"] = "pointer";
22668
+ CursorStyle2["Initial"] = "initial";
22669
+ CursorStyle2["Grab"] = "grab";
22670
+ CursorStyle2["Grabbing"] = "grabbing";
22671
+ CursorStyle2["Crosshair"] = "crosshair";
22672
+ CursorStyle2["Move"] = "move";
22673
+ return CursorStyle2;
22674
+ })(CursorStyle || {});
22675
+ var ScaleType = /* @__PURE__ */ ((ScaleType2) => {
22676
+ ScaleType2["Category"] = "category";
22677
+ ScaleType2["Linear"] = "linear";
22678
+ ScaleType2["Logarithmic"] = "logarithmic";
22679
+ return ScaleType2;
22680
+ })(ScaleType || {});
22681
+ var ChartDirection$1 = /* @__PURE__ */ ((ChartDirection2) => {
22682
+ ChartDirection2["Vertical"] = "vertical";
22683
+ return ChartDirection2;
22684
+ })(ChartDirection$1 || {});
22685
+ var TooltipLabel = /* @__PURE__ */ ((TooltipLabel2) => {
22686
+ TooltipLabel2["Y"] = "yLabel";
22687
+ TooltipLabel2["X"] = "xLabel";
22688
+ return TooltipLabel2;
22689
+ })(TooltipLabel || {});
22690
+ var AlignOptions = /* @__PURE__ */ ((AlignOptions2) => {
22691
+ AlignOptions2["End"] = "end";
22692
+ AlignOptions2["Start"] = "start";
22693
+ AlignOptions2["Center"] = "center";
22694
+ AlignOptions2["Right"] = "right";
22695
+ AlignOptions2["Left"] = "left";
22696
+ return AlignOptions2;
22697
+ })(AlignOptions || {});
22698
+ var AnnotationType$1 = /* @__PURE__ */ ((AnnotationType2) => {
22699
+ AnnotationType2["Box"] = "box";
22700
+ AnnotationType2["Ellipse"] = "ellipse";
22701
+ AnnotationType2["Line"] = "line";
22702
+ AnnotationType2["Text"] = "text";
22703
+ return AnnotationType2;
22704
+ })(AnnotationType$1 || {});
22705
+ var PointStyle = /* @__PURE__ */ ((PointStyle2) => {
22706
+ PointStyle2["Circle"] = "circle";
22707
+ PointStyle2["Square"] = "rect";
22708
+ PointStyle2["Diamond"] = "rectRot";
22709
+ PointStyle2["Triangle"] = "triangle";
22710
+ return PointStyle2;
22711
+ })(PointStyle || {});
22712
+ var ChartHoverMode = /* @__PURE__ */ ((ChartHoverMode2) => {
22713
+ ChartHoverMode2["Nearest"] = "nearest";
22714
+ return ChartHoverMode2;
22715
+ })(ChartHoverMode || {});
22716
+ var PanZoomMode = /* @__PURE__ */ ((PanZoomMode2) => {
22717
+ PanZoomMode2["X"] = "x";
22718
+ PanZoomMode2["Y"] = "y";
22719
+ PanZoomMode2["XY"] = "xy";
22720
+ PanZoomMode2["Z"] = "z";
22721
+ return PanZoomMode2;
22722
+ })(PanZoomMode || {});
22723
+ var Key = /* @__PURE__ */ ((Key2) => {
22724
+ Key2["Shift"] = "Shift";
22725
+ return Key2;
22726
+ })(Key || {});
22727
+ var Events = /* @__PURE__ */ ((Events2) => {
22728
+ Events2["Mousemove"] = "mousemove";
22729
+ Events2["Mouseout"] = "mouseout";
22730
+ Events2["Click"] = "click";
22731
+ Events2["Touchstart"] = "touchstart";
22732
+ Events2["Touchmove"] = "touchmove";
22733
+ Events2["Dblclick"] = "dblclick";
22734
+ return Events2;
22735
+ })(Events || {});
22736
+ const chartAreaBorderPlugin = {
22737
+ id: "chartAreaBorder",
22738
+ beforeDraw(chart2, _2, options) {
22739
+ const {
22740
+ ctx,
22741
+ chartArea: { left: left2, top: top2, width, height }
22742
+ } = chart2;
22743
+ ctx.save();
22744
+ ctx.strokeStyle = options.borderColor;
22745
+ ctx.lineWidth = options.borderWidth;
22746
+ ctx.setLineDash(options.borderDash || []);
22747
+ ctx.lineDashOffset = options.borderDashOffset ?? 0;
22748
+ ctx.strokeRect(left2, top2, width, height);
22749
+ ctx.restore();
22750
+ }
22751
+ };
22752
+ const getPlugins = (graph, legend2) => {
22753
+ var _a2;
22754
+ let plugins = [];
22755
+ if (graph.showMinorGridlines) {
22756
+ plugins.push(chartMinorGridlinesPlugin);
22757
+ }
22758
+ const customLegend = legend2 == null ? void 0 : legend2.customLegend;
22759
+ if ((customLegend == null ? void 0 : customLegend.customLegendPlugin) && (customLegend == null ? void 0 : customLegend.customLegendContainerID)) {
22760
+ plugins.push({
22761
+ id: CUSTOM_LEGEND_PLUGIN_NAME,
22762
+ ...(_a2 = legend2 == null ? void 0 : legend2.customLegend) == null ? void 0 : _a2.customLegendPlugin
22763
+ });
22764
+ }
22765
+ plugins.push(chartAreaBorderPlugin);
22766
+ return plugins;
22767
+ };
22768
+ const generateRandomColor = (colors2) => {
22769
+ const color2 = `#${Math.floor(Math.random() * WHITE_COLOR_AS_DECIMAL).toString(
22770
+ 16
22771
+ )}`;
22772
+ if (colors2.includes(color2)) {
22773
+ return generateRandomColor(colors2);
22774
+ } else {
22775
+ colors2.push(color2);
22776
+ return colors2;
22777
+ }
22778
+ };
22779
+ const getTitle = (options) => {
22780
+ return options.title !== "" ? {
22781
+ display: true,
22782
+ text: options.title
22783
+ } : {};
22784
+ };
22906
22785
  const isVertical = (direction) => {
22907
22786
  return direction === ChartDirection$1.Vertical;
22908
22787
  };
@@ -22985,32 +22864,121 @@ const isNilOrEmpty = (value) => {
22985
22864
  }
22986
22865
  return false;
22987
22866
  };
22988
- const generateRandomKey = () => {
22989
- var _a2, _b2;
22990
- return (_b2 = (_a2 = Math.random()) == null ? void 0 : _a2.toString(36)) == null ? void 0 : _b2.substring(2, 10);
22991
- };
22992
- const isLessThanMax = (value, max) => {
22993
- return value === void 0 || max === void 0 || Number(value) < Number(max);
22994
- };
22995
- const isGreaterThanMin = (value, min) => {
22996
- return value === void 0 || min === void 0 || Number(value) > Number(min);
22997
- };
22998
- const generateAxisId = (axisType, index2 = 0, hasMultiAxes = false) => {
22999
- const i2 = hasMultiAxes && index2 !== 0 ? index2 + 1 : "";
23000
- return `${axisType}${i2}`;
23001
- };
23002
- const getAxisTypeFromKey = (string) => {
23003
- var _a2;
23004
- return ((_a2 = string == null ? void 0 : string.match(/[^0-9/]+/gi)) == null ? void 0 : _a2[0]) ?? "";
23005
- };
23006
- const generateKey = (values) => {
23007
- const key = values.join("");
23008
- return key;
22867
+ const isEmptyString = (value) => value === "";
22868
+ const chart$3 = "_chart_e3qdd_1";
22869
+ const canvas$2 = "_canvas_e3qdd_11";
22870
+ const fixedHeight$3 = "_fixedHeight_e3qdd_20";
22871
+ const stretchHeight$3 = "_stretchHeight_e3qdd_26";
22872
+ const squareAspectRatio$1 = "_squareAspectRatio_e3qdd_32";
22873
+ const table = "_table_e3qdd_62";
22874
+ const styles$5 = {
22875
+ chart: chart$3,
22876
+ canvas: canvas$2,
22877
+ fixedHeight: fixedHeight$3,
22878
+ stretchHeight: stretchHeight$3,
22879
+ squareAspectRatio: squareAspectRatio$1,
22880
+ table
23009
22881
  };
23010
- const isPrimitiveValue = (value) => typeof value === "string" || typeof value === "number" || typeof value === "boolean" || value === null;
23011
- const isRangeValid = (r2) => {
23012
- if (!r2) return false;
23013
- return Object.values(r2).some((value) => !isNilOrEmpty(value));
22882
+ const TOGGLE_ZOOM = "TOGGLE_ZOOM";
22883
+ const TOGGLE_PAN = "TOGGLE_PAN";
22884
+ const TOGGLE_POINTS = "TOGGLE_POINTS";
22885
+ const TOGGLE_LINE = "TOGGLE_LINE";
22886
+ const TOGGLE_LEGEND = "TOGGLE_LEGEND";
22887
+ const TOGGLE_TABLE = "TOGGLE_TABLE";
22888
+ const RESET_AXES_RANGES = "RESET_AXES_RANGES";
22889
+ const UPDATE_AXES_RANGES = "UPDATE_AXES_RANGES";
22890
+ const TOGGLE_DRAG_POINTS = "TOGGLE_DRAG_POINTS";
22891
+ const TOGGLE_DRAG_ANNOTATION = "TOGGLE_DRAG_ANNOTATION";
22892
+ const DISABLE_DRAG_OPTIONS = "DISABLE_DRAG_OPTIONS";
22893
+ const reducer = (state, action) => {
22894
+ return produce(state, (draft) => {
22895
+ switch (action.type) {
22896
+ case TOGGLE_ZOOM: {
22897
+ draft.zoomEnabled = !draft.zoomEnabled;
22898
+ if (draft.panEnabled) {
22899
+ draft.panEnabled = false;
22900
+ }
22901
+ if (draft.enableDragPoints) {
22902
+ draft.enableDragPoints = false;
22903
+ }
22904
+ if (draft.enableDragAnnotation) {
22905
+ draft.enableDragAnnotation = false;
22906
+ }
22907
+ break;
22908
+ }
22909
+ case TOGGLE_PAN: {
22910
+ draft.panEnabled = !draft.panEnabled;
22911
+ if (draft.zoomEnabled) {
22912
+ draft.zoomEnabled = false;
22913
+ }
22914
+ if (draft.enableDragPoints) {
22915
+ draft.enableDragPoints = false;
22916
+ }
22917
+ if (draft.enableDragAnnotation) {
22918
+ draft.enableDragAnnotation = false;
22919
+ }
22920
+ break;
22921
+ }
22922
+ case TOGGLE_POINTS: {
22923
+ draft.pointsEnabled = !draft.pointsEnabled;
22924
+ break;
22925
+ }
22926
+ case TOGGLE_LINE: {
22927
+ draft.lineEnabled = !draft.lineEnabled;
22928
+ break;
22929
+ }
22930
+ case TOGGLE_LEGEND: {
22931
+ draft.legendEnabled = !draft.legendEnabled;
22932
+ break;
22933
+ }
22934
+ case TOGGLE_TABLE: {
22935
+ draft.showTable = !draft.showTable;
22936
+ break;
22937
+ }
22938
+ case UPDATE_AXES_RANGES: {
22939
+ const { axes } = action.payload;
22940
+ draft.axes = axes;
22941
+ break;
22942
+ }
22943
+ case RESET_AXES_RANGES: {
22944
+ const { axes } = action.payload;
22945
+ draft.axes = axes;
22946
+ break;
22947
+ }
22948
+ case TOGGLE_DRAG_POINTS: {
22949
+ draft.enableDragPoints = !draft.enableDragPoints;
22950
+ if (draft.panEnabled) {
22951
+ draft.panEnabled = false;
22952
+ }
22953
+ if (draft.zoomEnabled) {
22954
+ draft.zoomEnabled = false;
22955
+ }
22956
+ if (draft.enableDragAnnotation) {
22957
+ draft.enableDragAnnotation = false;
22958
+ }
22959
+ break;
22960
+ }
22961
+ case TOGGLE_DRAG_ANNOTATION: {
22962
+ draft.enableDragAnnotation = !draft.enableDragAnnotation;
22963
+ if (draft.panEnabled) {
22964
+ draft.panEnabled = false;
22965
+ }
22966
+ if (draft.zoomEnabled) {
22967
+ draft.zoomEnabled = false;
22968
+ }
22969
+ break;
22970
+ }
22971
+ case DISABLE_DRAG_OPTIONS: {
22972
+ if (draft.enableDragAnnotation || draft.enableDragPoints || draft.panEnabled || draft.zoomEnabled) {
22973
+ draft.enableDragAnnotation = false;
22974
+ draft.enableDragPoints = false;
22975
+ draft.panEnabled = false;
22976
+ draft.zoomEnabled = false;
22977
+ }
22978
+ break;
22979
+ }
22980
+ }
22981
+ });
23014
22982
  };
23015
22983
  const getChartStateFromStorage = (persistenceId) => {
23016
22984
  if (!persistenceId) return null;
@@ -23055,8 +23023,6 @@ const storeChartStateInStorage = (state, persistenceId) => {
23055
23023
  };
23056
23024
  const initialState = ({ options, persistenceId }) => {
23057
23025
  const {
23058
- additionalAxesOptions: { range: customAxesRange = {} },
23059
- axes,
23060
23026
  chartOptions: {
23061
23027
  enableZoom,
23062
23028
  enablePan,
@@ -23067,45 +23033,6 @@ const initialState = ({ options, persistenceId }) => {
23067
23033
  legend: { display },
23068
23034
  dragData
23069
23035
  } = options;
23070
- const getStateAxesByType = (axisType, customAxesRange2) => {
23071
- var _a2, _b2, _c2, _d2, _e2;
23072
- if (!axes[axisType]) {
23073
- return [];
23074
- }
23075
- if (((_a2 = axes[axisType]) == null ? void 0 : _a2.length) > 1) {
23076
- return axes[axisType].map((axisObj, index2) => {
23077
- var _a3, _b3;
23078
- const id = generateAxisId(axisType, index2, axes[axisType].length > 1);
23079
- const customMin = (_a3 = customAxesRange2 == null ? void 0 : customAxesRange2[id]) == null ? void 0 : _a3.min;
23080
- const customMax = (_b3 = customAxesRange2 == null ? void 0 : customAxesRange2[id]) == null ? void 0 : _b3.max;
23081
- const { unit } = axisObj;
23082
- return {
23083
- id,
23084
- //only add custom axis ranges if defined:
23085
- ...customMin ? { min: customMin } : {},
23086
- ...customMax ? { max: customMax } : {},
23087
- ...unit ? { unit } : {}
23088
- };
23089
- });
23090
- } else {
23091
- const id = generateAxisId(axisType);
23092
- const customMin = (_b2 = customAxesRange2 == null ? void 0 : customAxesRange2[id]) == null ? void 0 : _b2.min;
23093
- const customMax = (_c2 = customAxesRange2 == null ? void 0 : customAxesRange2[id]) == null ? void 0 : _c2.max;
23094
- const unit = (_e2 = (_d2 = axes == null ? void 0 : axes[id]) == null ? void 0 : _d2[0]) == null ? void 0 : _e2.unit;
23095
- return [
23096
- {
23097
- id,
23098
- //only add custom axis ranges if defined:
23099
- ...customMin ? { min: customMin } : {},
23100
- ...customMax ? { max: customMax } : {},
23101
- ...unit ? { unit } : {}
23102
- }
23103
- ];
23104
- }
23105
- };
23106
- const xStateAxes = getStateAxesByType(AxisType.X, customAxesRange);
23107
- const yStateAxes = getStateAxesByType(AxisType.Y, customAxesRange);
23108
- const stateAxes = [...xStateAxes, ...yStateAxes];
23109
23036
  const {
23110
23037
  zoomEnabled,
23111
23038
  panEnabled,
@@ -23121,11 +23048,10 @@ const initialState = ({ options, persistenceId }) => {
23121
23048
  pointsEnabled: pointsEnabled ?? showPoints,
23122
23049
  lineEnabled: lineEnabled ?? showLine,
23123
23050
  legendEnabled: legendEnabled ?? display,
23124
- axes: stateAxes,
23051
+ axes: [],
23125
23052
  showTable: false,
23126
23053
  enableDragPoints: (dragData == null ? void 0 : dragData.enableDragData) && enableDragPoints,
23127
- enableDragAnnotation: enableDragAnnotation ?? enableDragAnnotationStorage,
23128
- initialAxesRanges: []
23054
+ enableDragAnnotation: enableDragAnnotation ?? enableDragAnnotationStorage
23129
23055
  };
23130
23056
  };
23131
23057
  const ControlsPortal = ({
@@ -24441,6 +24367,29 @@ const downloadPgn = (chartRef, state) => {
24441
24367
  distExports.triggerBase64Download(dataUrl, fileName);
24442
24368
  });
24443
24369
  };
24370
+ const isLessThanMax = (value, max) => {
24371
+ return value === void 0 || max === void 0 || Number(value) < Number(max);
24372
+ };
24373
+ const isGreaterThanMin = (value, min) => {
24374
+ return value === void 0 || min === void 0 || Number(value) > Number(min);
24375
+ };
24376
+ const generateAxisId = (axisType, index2 = 0, hasMultiAxes = false) => {
24377
+ const i2 = hasMultiAxes && index2 !== 0 ? index2 + 1 : "";
24378
+ return `${axisType}${i2}`;
24379
+ };
24380
+ const getAxisTypeFromKey = (string) => {
24381
+ var _a2;
24382
+ return ((_a2 = string == null ? void 0 : string.match(/[^0-9/]+/gi)) == null ? void 0 : _a2[0]) ?? "";
24383
+ };
24384
+ const generateKey = (values) => {
24385
+ const key = values.join("");
24386
+ return key;
24387
+ };
24388
+ const isPrimitiveValue = (value) => typeof value === "string" || typeof value === "number" || typeof value === "boolean" || value === null;
24389
+ const isRangeValid = (r2) => {
24390
+ if (!r2) return false;
24391
+ return Object.values(r2).some((value) => !isNilOrEmpty(value));
24392
+ };
24444
24393
  const useChartFunctions = ({
24445
24394
  chartRef,
24446
24395
  state,
@@ -24456,8 +24405,8 @@ const useChartFunctions = ({
24456
24405
  const chartInstance = chartRef == null ? void 0 : chartRef.current;
24457
24406
  chartInstance == null ? void 0 : chartInstance.resetZoom();
24458
24407
  chartInstance == null ? void 0 : chartInstance.reset();
24459
- dispatch({ type: "RESET_AXES_RANGES" });
24460
- }, [chartRef]);
24408
+ dispatch({ type: "RESET_AXES_RANGES", payload: { axes: state.axes } });
24409
+ }, [chartRef == null ? void 0 : chartRef.current, dispatch]);
24461
24410
  const onHover = useCallback(
24462
24411
  (hoveredPoint, setHoveredPoint) => {
24463
24412
  return (evt, hoveredItems) => {
@@ -24480,7 +24429,7 @@ const useChartFunctions = ({
24480
24429
  );
24481
24430
  const handleDownload = useCallback(
24482
24431
  () => downloadPgn(chartRef, state),
24483
- [chartRef, state.axes]
24432
+ [chartRef == null ? void 0 : chartRef.current, state.axes]
24484
24433
  );
24485
24434
  const handleKeyDown = useCallback(
24486
24435
  (event) => {
@@ -24495,7 +24444,7 @@ const useChartFunctions = ({
24495
24444
  }
24496
24445
  }
24497
24446
  },
24498
- [chartRef]
24447
+ [chartRef == null ? void 0 : chartRef.current]
24499
24448
  );
24500
24449
  const handleKeyUp = useCallback(
24501
24450
  (event) => {
@@ -24510,7 +24459,7 @@ const useChartFunctions = ({
24510
24459
  }
24511
24460
  }
24512
24461
  },
24513
- [chartRef]
24462
+ [chartRef == null ? void 0 : chartRef.current]
24514
24463
  );
24515
24464
  const getControlsAxesLabels = useCallback(
24516
24465
  (propsAxes) => {
@@ -24531,11 +24480,10 @@ const useChartFunctions = ({
24531
24480
  });
24532
24481
  }
24533
24482
  };
24534
- const axesLabels = [
24483
+ return [
24535
24484
  ...getAxesLabels(propsAxes, AxisType.X),
24536
24485
  ...getAxesLabels(propsAxes, AxisType.Y)
24537
24486
  ];
24538
- return axesLabels;
24539
24487
  },
24540
24488
  [axes]
24541
24489
  );
@@ -24555,8 +24503,11 @@ const useChartFunctions = ({
24555
24503
  });
24556
24504
  }, [axes]);
24557
24505
  const onResetAxes = useCallback(() => {
24558
- dispatch({ type: RESET_AXES_RANGES });
24559
- }, []);
24506
+ const chartInstance = chartRef == null ? void 0 : chartRef.current;
24507
+ chartInstance == null ? void 0 : chartInstance.resetZoom();
24508
+ chartInstance == null ? void 0 : chartInstance.reset();
24509
+ dispatch({ type: RESET_AXES_RANGES, payload: { axes: state.axes } });
24510
+ }, [chartRef == null ? void 0 : chartRef.current]);
24560
24511
  const onUpdateAxes = useCallback(({ axes: axes2 }) => {
24561
24512
  dispatch({ type: UPDATE_AXES_RANGES, payload: { axes: axes2 } });
24562
24513
  }, []);
@@ -24572,30 +24523,6 @@ const useChartFunctions = ({
24572
24523
  onUpdateAxes
24573
24524
  };
24574
24525
  };
24575
- var actionTypes = /* @__PURE__ */ ((actionTypes2) => {
24576
- actionTypes2["Reset"] = "reset";
24577
- actionTypes2["ValueUpdated"] = "valueUpdated";
24578
- actionTypes2["UnitUpdated"] = "unitUpdated";
24579
- return actionTypes2;
24580
- })(actionTypes || {});
24581
- const initializeFormState = ({
24582
- chartRef,
24583
- axes = []
24584
- }) => {
24585
- const chart2 = chartRef == null ? void 0 : chartRef.current;
24586
- if (!chart2) return [];
24587
- const initScales = (chart2 == null ? void 0 : chart2.getInitialScaleBounds()) ?? {};
24588
- return Object.entries(initScales).map(([id, { min = "", max = "" }]) => {
24589
- const { unit } = (axes == null ? void 0 : axes.find((axis) => axis.id === id)) ?? {};
24590
- return {
24591
- id,
24592
- min,
24593
- max,
24594
- unit
24595
- };
24596
- }) || [];
24597
- };
24598
- const isEmptyString = (value) => value === "";
24599
24526
  const createErrorMessages = (value, compareTo, type) => {
24600
24527
  const errors = [];
24601
24528
  if (isEmptyString(value)) errors.push("mustHaveAValue");
@@ -24606,144 +24533,114 @@ const createErrorMessages = (value, compareTo, type) => {
24606
24533
  }
24607
24534
  return errors;
24608
24535
  };
24609
- const validateAxes = (formState) => {
24610
- return formState.reduce(
24611
- (acc, { id, min, max }) => {
24612
- return produce(acc, (draft) => {
24613
- var _a2;
24614
- const errors = {
24615
- min: createErrorMessages(String(min), String(max), "min"),
24616
- max: createErrorMessages(String(max), String(min), "max")
24617
- };
24618
- (_a2 = draft == null ? void 0 : draft.errors) == null ? void 0 : _a2.push({
24619
- id,
24620
- ...errors
24621
- });
24622
- draft.valid = !(!acc.valid || !!errors.min.length || !!errors.max.length);
24623
- });
24624
- },
24625
- { errors: [], valid: true }
24536
+ const validateAxes = (axes) => {
24537
+ const errors = axes.map(({ id, min, max }) => ({
24538
+ id,
24539
+ min: createErrorMessages(String(min), String(max), "min"),
24540
+ max: createErrorMessages(String(max), String(min), "max")
24541
+ }));
24542
+ const valid = errors.every(
24543
+ (error) => error.min.length === 0 && error.max.length === 0
24626
24544
  );
24545
+ return { errors, valid };
24627
24546
  };
24628
- const reducer = (state, action) => {
24629
- switch (action.type) {
24630
- case actionTypes.Reset: {
24631
- const { chartRef, axes } = action.payload;
24632
- return initializeFormState({ chartRef, axes });
24633
- }
24634
- case actionTypes.ValueUpdated:
24635
- return produce(state, (draft) => {
24636
- const { name, value, id } = action.payload;
24637
- const axis = draft.find((a2) => a2.id === id);
24638
- if (axis && value) {
24639
- axis[name] = value;
24640
- }
24641
- });
24642
- case actionTypes.UnitUpdated:
24643
- return produce(state, (draft) => {
24644
- var _a2;
24645
- const { name, value, id } = action.payload;
24646
- const unit = (_a2 = draft.find((a2) => a2.id === id)) == null ? void 0 : _a2.unit;
24647
- if (unit && name) {
24648
- unit[name] = value;
24649
- }
24650
- });
24651
- default:
24652
- return state;
24653
- }
24547
+ const RANGE_GAP$1 = 1;
24548
+ const getInitAxes = ({ chartRef, state }) => {
24549
+ const chart2 = chartRef == null ? void 0 : chartRef.current;
24550
+ if (!chart2) return [];
24551
+ const initScales = (chart2 == null ? void 0 : chart2.getInitialScaleBounds()) ?? {};
24552
+ return Object.entries(initScales).map(([id, { min = "", max = "" }]) => {
24553
+ var _a2;
24554
+ let adjustedMin = Number(min);
24555
+ let adjustedMax = Number(max);
24556
+ if (isNaN(adjustedMin)) adjustedMin = 0;
24557
+ if (isNaN(adjustedMax)) adjustedMax = adjustedMin + RANGE_GAP$1;
24558
+ if (adjustedMin === adjustedMax) {
24559
+ adjustedMax += RANGE_GAP$1;
24560
+ }
24561
+ const { unit } = ((_a2 = state == null ? void 0 : state.axes) == null ? void 0 : _a2.find((axis) => axis.id === id)) ?? {};
24562
+ return {
24563
+ id,
24564
+ min: adjustedMin,
24565
+ max: adjustedMax,
24566
+ unit
24567
+ };
24568
+ });
24654
24569
  };
24655
24570
  const AxesOptionsPopover = (optionsPopover) => {
24656
24571
  var _a2;
24657
24572
  const {
24658
- chartRef,
24659
- axes,
24573
+ state,
24660
24574
  controlsAxesLabels,
24661
24575
  onUpdateAxes,
24662
24576
  onResetAxes,
24663
24577
  depthType,
24664
24578
  translations,
24665
- close
24666
- } = optionsPopover;
24667
- const [depthTypeState, setDepthTypeState] = useState(
24668
- depthType == null ? void 0 : depthType.selectedDepthType
24669
- );
24670
- const [formState, dispatch] = useReducer(
24671
- reducer,
24672
- {
24673
- chartRef,
24674
- axes
24675
- },
24676
- initializeFormState
24677
- );
24678
- const { errors, valid } = validateAxes(formState);
24579
+ close,
24580
+ chartRef
24581
+ } = optionsPopover ?? {};
24582
+ const [formState, setFormState] = useState({
24583
+ localAxes: getInitAxes({ chartRef, state }),
24584
+ depthType: depthType == null ? void 0 : depthType.selectedDepthType,
24585
+ edited: false
24586
+ });
24587
+ const { errors, valid } = validateAxes(formState.localAxes);
24679
24588
  const onEditValue = ({ name, value, id }) => {
24680
- dispatch({
24681
- type: actionTypes.ValueUpdated,
24682
- payload: { name, value, id }
24683
- });
24589
+ setFormState((prevState) => ({
24590
+ ...prevState,
24591
+ localAxes: prevState.localAxes.map(
24592
+ (axis) => axis.id === id ? { ...axis, [name]: value } : axis
24593
+ ),
24594
+ edited: true
24595
+ }));
24684
24596
  };
24685
24597
  const onEditUnit = ({ name, value, id }) => {
24686
- dispatch({
24687
- type: actionTypes.UnitUpdated,
24688
- payload: { name, value, id }
24689
- });
24598
+ setFormState((prevState) => ({
24599
+ ...prevState,
24600
+ localAxes: prevState.localAxes.map(
24601
+ (axis) => axis.id === id && typeof axis.unit === "object" ? {
24602
+ ...axis,
24603
+ unit: {
24604
+ ...axis.unit,
24605
+ [name]: value
24606
+ }
24607
+ } : axis
24608
+ ),
24609
+ edited: true
24610
+ }));
24690
24611
  };
24691
24612
  const onDone = (e2) => {
24692
24613
  e2.preventDefault();
24693
24614
  if (valid) {
24694
- const sanitizedFormState = formState.map((axis) => ({
24695
- ...axis,
24696
- min: typeof axis.min === "string" ? Number(axis.min) : axis.min,
24697
- max: typeof axis.max === "string" ? Number(axis.max) : axis.max
24698
- }));
24699
- onUpdateAxes({
24700
- axes: sanitizedFormState
24701
- });
24702
- sanitizedFormState.map((el, i2) => {
24703
- var _a3, _b2, _c2;
24704
- const selectedUnit = (_a3 = el.unit) == null ? void 0 : _a3.selectedUnit;
24705
- if (selectedUnit) {
24706
- (_c2 = (_b2 = axes == null ? void 0 : axes[i2]) == null ? void 0 : _b2.unit) == null ? void 0 : _c2.setSelectedUnit(selectedUnit);
24707
- }
24708
- });
24709
- if (depthType && (depthType == null ? void 0 : depthType.setSelectedDepthType)) {
24710
- depthType == null ? void 0 : depthType.setSelectedDepthType(depthTypeState);
24711
- }
24615
+ onUpdateAxes({ axes: formState.localAxes });
24616
+ close == null ? void 0 : close();
24712
24617
  }
24713
- close == null ? void 0 : close();
24714
24618
  };
24715
24619
  const onReset = () => {
24716
- dispatch({
24717
- type: actionTypes.Reset,
24718
- payload: { axes, chartRef }
24620
+ setFormState({
24621
+ localAxes: getInitAxes({ chartRef, state }),
24622
+ depthType: depthType == null ? void 0 : depthType.selectedDepthType,
24623
+ edited: false
24719
24624
  });
24720
24625
  onResetAxes();
24721
24626
  close == null ? void 0 : close();
24722
24627
  };
24723
- const isCustomValue = axes.filter((axis) => axis.max || axis.min).length > 0;
24724
24628
  const handleInputFocus = (e2) => e2.target.select();
24725
24629
  return /* @__PURE__ */ jsxs("form", { onSubmit: onDone, children: [
24726
- formState.map((axis) => {
24727
- var _a3, _b2, _c2;
24728
- const key = generateRandomKey();
24630
+ formState.localAxes.map((axis) => {
24631
+ var _a3, _b2;
24729
24632
  const axisControl = controlsAxesLabels.find(
24730
24633
  (el) => el.id === axis.id
24731
24634
  );
24732
- const axisLabel = axisControl == null ? void 0 : axisControl.label;
24733
- const axisState = formState.find(
24734
- (a2) => a2.id === axis.id
24735
- );
24736
- const axisErrors = errors == null ? void 0 : errors.find((a2) => a2.id === axis.id);
24737
- const { min, max, unit } = axisState || {};
24738
- const minErrorMsg = ((_a3 = axisErrors == null ? void 0 : axisErrors.min) == null ? void 0 : _a3[0]) ? translations[axisErrors.min[0]] : null;
24739
- const maxErrorMsg = ((_b2 = axisErrors == null ? void 0 : axisErrors.max) == null ? void 0 : _b2[0]) ? translations[axisErrors.max[0]] : null;
24740
- return /* @__PURE__ */ jsx(Field, { label: axisLabel || axis.id || "", children: /* @__PURE__ */ jsxs(InputGroup, { small: true, width: "300px", children: [
24635
+ const axisLabel = (axisControl == null ? void 0 : axisControl.label) || startCase(axis.id);
24636
+ const axisErrors = errors.find((err) => err.id === axis.id);
24637
+ return /* @__PURE__ */ jsx(Field, { label: axisLabel, children: /* @__PURE__ */ jsxs(InputGroup, { small: true, width: "300px", children: [
24741
24638
  /* @__PURE__ */ jsx(
24742
24639
  NumberInput,
24743
24640
  {
24744
24641
  name: "min",
24745
- value: min,
24746
- error: minErrorMsg,
24642
+ value: axis.min,
24643
+ error: ((_a3 = axisErrors == null ? void 0 : axisErrors.min) == null ? void 0 : _a3[0]) ? translations[axisErrors.min[0]] : null,
24747
24644
  width: "100%",
24748
24645
  onChange: (evt) => onEditValue({
24749
24646
  name: evt.target.name,
@@ -24758,8 +24655,8 @@ const AxesOptionsPopover = (optionsPopover) => {
24758
24655
  NumberInput,
24759
24656
  {
24760
24657
  name: "max",
24761
- value: max,
24762
- error: maxErrorMsg,
24658
+ value: axis.max,
24659
+ error: ((_b2 = axisErrors == null ? void 0 : axisErrors.max) == null ? void 0 : _b2[0]) ? translations[axisErrors.max[0]] : null,
24763
24660
  width: "100%",
24764
24661
  onChange: (evt) => onEditValue({
24765
24662
  name: evt.target.name,
@@ -24773,22 +24670,20 @@ const AxesOptionsPopover = (optionsPopover) => {
24773
24670
  Select,
24774
24671
  {
24775
24672
  name: "selectedUnit",
24776
- options: (_c2 = axis == null ? void 0 : axis.unit) == null ? void 0 : _c2.options,
24777
- value: typeof unit !== "string" ? unit == null ? void 0 : unit.selectedUnit : void 0,
24778
- onChange: (e2) => {
24779
- onEditUnit({
24780
- name: e2.target.name,
24781
- value: e2.target.value,
24782
- id: axis.id
24783
- });
24784
- },
24673
+ options: typeof axis.unit !== "string" ? axis.unit.options : [],
24674
+ value: typeof axis.unit !== "string" ? axis.unit.selectedUnit : void 0,
24675
+ onChange: (e2) => onEditUnit({
24676
+ name: e2.target.name,
24677
+ value: e2.target.value,
24678
+ id: axis.id
24679
+ }),
24785
24680
  autoLayerWidth: true,
24786
24681
  width: "15%"
24787
24682
  }
24788
24683
  ) : null
24789
- ] }) }, key);
24684
+ ] }) }, axis.id);
24790
24685
  }),
24791
- ((_a2 = depthType == null ? void 0 : depthType.options) == null ? void 0 : _a2.length) > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
24686
+ ((_a2 = depthType == null ? void 0 : depthType.options) == null ? void 0 : _a2.length) > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
24792
24687
  /* @__PURE__ */ jsx(
24793
24688
  ButtonGroup,
24794
24689
  {
@@ -24796,15 +24691,16 @@ const AxesOptionsPopover = (optionsPopover) => {
24796
24691
  key: i2,
24797
24692
  label: depth
24798
24693
  })),
24799
- onSelected: (key) => {
24800
- setDepthTypeState(depthType.options[key]);
24801
- },
24694
+ onSelected: (key) => setFormState((prevState) => ({
24695
+ ...prevState,
24696
+ depthType: depthType.options[key]
24697
+ })),
24802
24698
  small: true,
24803
- value: depthType.options.indexOf(depthTypeState)
24699
+ value: depthType.options.indexOf(formState.depthType)
24804
24700
  }
24805
24701
  ),
24806
24702
  /* @__PURE__ */ jsx(Spacer, {})
24807
- ] }) : null,
24703
+ ] }),
24808
24704
  /* @__PURE__ */ jsxs(Flex, { gap: "8px", alignItems: "center", children: [
24809
24705
  /* @__PURE__ */ jsx(
24810
24706
  Button,
@@ -24813,7 +24709,7 @@ const AxesOptionsPopover = (optionsPopover) => {
24813
24709
  small: true,
24814
24710
  colored: true,
24815
24711
  label: translations.done,
24816
- disabled: !valid
24712
+ disabled: !valid || !formState.edited
24817
24713
  }
24818
24714
  ),
24819
24715
  /* @__PURE__ */ jsx(
@@ -24822,8 +24718,7 @@ const AxesOptionsPopover = (optionsPopover) => {
24822
24718
  small: true,
24823
24719
  name: "resetAxes",
24824
24720
  label: translations.resetAxes,
24825
- onClick: onReset,
24826
- disabled: !isCustomValue
24721
+ onClick: onReset
24827
24722
  }
24828
24723
  ),
24829
24724
  /* @__PURE__ */ jsx(Text, { small: true, muted: true, children: translations.orDoubleClickToCanvas })
@@ -24831,36 +24726,16 @@ const AxesOptionsPopover = (optionsPopover) => {
24831
24726
  ] });
24832
24727
  };
24833
24728
  const AxesOptions = (optionsPopover) => {
24834
- const {
24835
- chartRef,
24836
- axes,
24837
- controlsAxesLabels,
24838
- onUpdateAxes,
24839
- onResetAxes,
24840
- depthType,
24841
- translations
24842
- } = optionsPopover;
24843
24729
  return /* @__PURE__ */ jsx(
24844
24730
  Popover,
24845
24731
  {
24846
24732
  placement: "bottom-start",
24847
24733
  overflowContainer: true,
24848
- content: /* @__PURE__ */ jsx(
24849
- AxesOptionsPopover,
24850
- {
24851
- chartRef,
24852
- axes,
24853
- controlsAxesLabels,
24854
- onUpdateAxes,
24855
- onResetAxes,
24856
- depthType,
24857
- translations
24858
- }
24859
- ),
24734
+ content: /* @__PURE__ */ jsx(AxesOptionsPopover, { ...optionsPopover }),
24860
24735
  children: /* @__PURE__ */ jsx(
24861
24736
  Tooltip$2,
24862
24737
  {
24863
- text: translations.axesOptions,
24738
+ text: optionsPopover.translations.axesOptions,
24864
24739
  placement: "bottom-start",
24865
24740
  display: "inline-flex",
24866
24741
  children: /* @__PURE__ */ jsx(Button, { small: true, basic: true, colored: "muted", round: true, icon: /* @__PURE__ */ jsx(TbRuler, {}) })
@@ -24870,9 +24745,9 @@ const AxesOptions = (optionsPopover) => {
24870
24745
  );
24871
24746
  };
24872
24747
  const Controls = ({
24748
+ table: table2,
24873
24749
  headerComponent,
24874
24750
  subheaderComponent,
24875
- table: table2,
24876
24751
  chartRef,
24877
24752
  state,
24878
24753
  options,
@@ -24958,7 +24833,7 @@ const Controls = ({
24958
24833
  AxesOptions,
24959
24834
  {
24960
24835
  chartRef,
24961
- axes: state.axes,
24836
+ state,
24962
24837
  controlsAxesLabels,
24963
24838
  onUpdateAxes,
24964
24839
  onResetAxes,
@@ -25272,8 +25147,8 @@ const generateLineChartDatasets = (datasets, state, options, { label }) => {
25272
25147
  const { lineEnabled, pointsEnabled, axes = [] } = state ?? {};
25273
25148
  const { lineTension, spanGaps } = graph ?? {};
25274
25149
  if (formation) {
25275
- const axesMin = (_a2 = axes[0]) == null ? void 0 : _a2.min;
25276
- const axesMax = (_b2 = axes[0]) == null ? void 0 : _b2.max;
25150
+ const axesMin = Number((_a2 = axes[0]) == null ? void 0 : _a2.min);
25151
+ const axesMax = Number((_b2 = axes[0]) == null ? void 0 : _b2.max);
25277
25152
  const [startPoint, endPoint] = data;
25278
25153
  if (axesMin && (startPoint == null ? void 0 : startPoint.x)) {
25279
25154
  data[0].x = Math.max(axesMin, startPoint.x);
@@ -27405,7 +27280,7 @@ const LineChart = (props) => {
27405
27280
  var _a2, _b2;
27406
27281
  setDefaultTheme();
27407
27282
  const chartRef = useRef(null);
27408
- const { table: table2 } = props ?? {};
27283
+ const { table: table2, headerComponent, subheaderComponent } = props ?? {};
27409
27284
  const { translations, languageKey } = getConfig();
27410
27285
  const chart2 = getDefaultProps$3(props);
27411
27286
  const {
@@ -27418,10 +27293,11 @@ const LineChart = (props) => {
27418
27293
  const { annotations, axes, chartStyling, graph } = options ?? {};
27419
27294
  const showCustomLegend = !((_b2 = (_a2 = options == null ? void 0 : options.legend) == null ? void 0 : _a2.customLegend) == null ? void 0 : _b2.customLegendContainerID);
27420
27295
  const [state, dispatch] = useReducer(
27421
- reducer$1,
27296
+ reducer,
27422
27297
  {
27423
27298
  options,
27424
- persistenceId
27299
+ persistenceId,
27300
+ chartRef
27425
27301
  },
27426
27302
  initialState
27427
27303
  );
@@ -27473,7 +27349,9 @@ const LineChart = (props) => {
27473
27349
  /* @__PURE__ */ jsx(
27474
27350
  Controls,
27475
27351
  {
27476
- ...props,
27352
+ table: table2,
27353
+ headerComponent,
27354
+ subheaderComponent,
27477
27355
  chartRef,
27478
27356
  state,
27479
27357
  options,