@oliasoft-open-source/charts-library 3.4.5-beta-2 → 3.4.5

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
@@ -13161,7 +13161,9 @@ const ANNOTATION_DASH = [10, 2];
13161
13161
  const DEFAULT_FONT_SIZE = 13;
13162
13162
  const DEFAULT_FONT_FAMILY = '"Lato", sans-serif';
13163
13163
  const DEFAULT_COLOR = "rgba(0,0,0,.87)";
13164
- const LEGEND_LABEL_BOX_SIZE = 6;
13164
+ const LEGEND_LABEL_BOX_SIZE = 12;
13165
+ const TOOLTIP_PADDING = 8;
13166
+ const TOOLTIP_BOX_PADDING = 4;
13165
13167
  const LOGARITHMIC_STEPS = [1, 10, 100, 1e3, 1e4];
13166
13168
  const COLORS = [
13167
13169
  "#3366cc",
@@ -23734,17 +23736,18 @@ const reducer = (state, action) => {
23734
23736
  return state;
23735
23737
  }
23736
23738
  };
23737
- const AxesOptionsPopover = ({
23738
- initialAxesRanges,
23739
- axes,
23740
- controlsAxesLabels,
23741
- onUpdateAxes,
23742
- onResetAxes,
23743
- close,
23744
- depthType,
23745
- translations
23746
- }) => {
23739
+ const AxesOptionsPopover = (optionsPopover) => {
23747
23740
  var _a2;
23741
+ const {
23742
+ initialAxesRanges,
23743
+ axes,
23744
+ controlsAxesLabels,
23745
+ onUpdateAxes,
23746
+ onResetAxes,
23747
+ close,
23748
+ depthType,
23749
+ translations
23750
+ } = optionsPopover;
23748
23751
  const [depthTypeState, setDepthTypeState] = useState(
23749
23752
  depthType == null ? void 0 : depthType.selectedDepthType
23750
23753
  );
@@ -23759,14 +23762,20 @@ const AxesOptionsPopover = ({
23759
23762
  const { errors, valid } = validateAxes(formState);
23760
23763
  const onEditValue = ({ name: name2, value, id }) => {
23761
23764
  dispatch({
23762
- type: actionTypes.valueUpdated,
23765
+ type: actionTypes.ValueUpdated,
23766
+ payload: { name: name2, value, id }
23767
+ });
23768
+ };
23769
+ const onEditUnit = ({ name: name2, value, id }) => {
23770
+ dispatch({
23771
+ type: actionTypes.UnitUpdated,
23763
23772
  payload: { name: name2, value, id }
23764
23773
  });
23765
23774
  };
23766
23775
  const onDone = (e2) => {
23767
23776
  e2.preventDefault();
23768
23777
  if (valid) {
23769
- const sanitizedFormState = formState.map((axis, i2) => ({
23778
+ const sanitizedFormState = formState.map((axis) => ({
23770
23779
  ...axis,
23771
23780
  min: toNum(axis.min),
23772
23781
  max: toNum(axis.max)
@@ -23774,6 +23783,13 @@ const AxesOptionsPopover = ({
23774
23783
  onUpdateAxes({
23775
23784
  axes: sanitizedFormState
23776
23785
  });
23786
+ sanitizedFormState.forEach((el, i2) => {
23787
+ var _a3, _b2, _c2;
23788
+ const selectedUnit = (_a3 = el.unit) == null ? void 0 : _a3.selectedUnit;
23789
+ if (selectedUnit) {
23790
+ (_c2 = (_b2 = axes == null ? void 0 : axes[i2]) == null ? void 0 : _b2.unit) == null ? void 0 : _c2.setSelectedUnit(selectedUnit);
23791
+ }
23792
+ });
23777
23793
  if (depthType) {
23778
23794
  depthType.setSelectedDepthType(depthTypeState);
23779
23795
  }
@@ -23782,13 +23798,14 @@ const AxesOptionsPopover = ({
23782
23798
  };
23783
23799
  const onReset = () => {
23784
23800
  dispatch({
23785
- type: actionTypes.reset,
23801
+ type: actionTypes.Reset,
23786
23802
  payload: { axes, initialAxesRanges }
23787
23803
  });
23788
- initialAxesRanges.map((el, i2) => {
23789
- var _a3;
23790
- if ((_a3 = el == null ? void 0 : el.unit) == null ? void 0 : _a3.selectedUnit) {
23791
- axes[i2].unit.setSelectedUnit(el.unit.selectedUnit);
23804
+ initialAxesRanges.forEach((el, i2) => {
23805
+ var _a3, _b2, _c2;
23806
+ const selectedUnit = (_a3 = el == null ? void 0 : el.unit) == null ? void 0 : _a3.selectedUnit;
23807
+ if (selectedUnit) {
23808
+ (_c2 = (_b2 = axes == null ? void 0 : axes[i2]) == null ? void 0 : _b2.unit) == null ? void 0 : _c2.setSelectedUnit(selectedUnit);
23792
23809
  }
23793
23810
  });
23794
23811
  onResetAxes();
@@ -23847,10 +23864,15 @@ const AxesOptionsPopover = ({
23847
23864
  name: "selectedUnit",
23848
23865
  options: (_i2 = axis == null ? void 0 : axis.unit) == null ? void 0 : _i2.options,
23849
23866
  value: unit == null ? void 0 : unit.selectedUnit,
23850
- onChange: unit == null ? void 0 : unit.setSelectedUnit,
23867
+ onChange: (e2) => {
23868
+ onEditUnit({
23869
+ name: e2.target.name,
23870
+ value: e2.target.value,
23871
+ id: axis.id
23872
+ });
23873
+ },
23851
23874
  autoLayerWidth: true,
23852
- width: "15%",
23853
- native: true
23875
+ width: "15%"
23854
23876
  }
23855
23877
  ) : null
23856
23878
  ] }) }, i2);
@@ -23897,15 +23919,16 @@ const AxesOptionsPopover = ({
23897
23919
  ] })
23898
23920
  ] });
23899
23921
  };
23900
- const AxesOptions = ({
23901
- initialAxesRanges,
23902
- axes,
23903
- controlsAxesLabels,
23904
- onUpdateAxes,
23905
- onResetAxes,
23906
- depthType,
23907
- translations
23908
- }) => {
23922
+ const AxesOptions = (optionsPopover) => {
23923
+ const {
23924
+ initialAxesRanges,
23925
+ axes,
23926
+ controlsAxesLabels,
23927
+ onUpdateAxes,
23928
+ onResetAxes,
23929
+ depthType,
23930
+ translations
23931
+ } = optionsPopover;
23909
23932
  return /* @__PURE__ */ jsx(
23910
23933
  Popover,
23911
23934
  {
@@ -25037,6 +25060,11 @@ const getAnnotation = (options, state) => {
25037
25060
  const annotations = shouldGenerateAnnotations ? generateAnnotations(options, state) : null;
25038
25061
  return { annotations };
25039
25062
  };
25063
+ const getUnitsFromLabel = (label) => {
25064
+ const matches = label.match(/\[(.*)\]/g);
25065
+ const units = matches && matches.length > 0 ? matches[0] : "";
25066
+ return units;
25067
+ };
25040
25068
  const getLineChartToolTips = (options) => {
25041
25069
  const getTooltipLabels = (dataset) => {
25042
25070
  var _a2, _b2;
@@ -25071,7 +25099,7 @@ const getLineChartToolTips = (options) => {
25071
25099
  return `${roundedValue} ${titleAxisLabel}`;
25072
25100
  };
25073
25101
  const labelCallback = (tooltipItem) => {
25074
- const { showLabelsInTooltips, hideSimulationName } = options.tooltip;
25102
+ const { showLabelsInTooltips } = options.tooltip;
25075
25103
  let label = tooltipItem.dataset.label || "";
25076
25104
  const labels = getTooltipLabels(tooltipItem.dataset);
25077
25105
  const { valueLabel, valueAxisLabel } = labels;
@@ -25082,18 +25110,20 @@ const getLineChartToolTips = (options) => {
25082
25110
  roundScientificCoefficient: 4
25083
25111
  }) : displayNumber(labelNumber);
25084
25112
  };
25085
- const splitValueAxisLabel = valueAxisLabel.split(" ");
25086
- const newValueAxisLabel = hideSimulationName ? splitValueAxisLabel[splitValueAxisLabel.length - 1] : valueAxisLabel;
25087
25113
  const tooltipItemValue = getTooltipItemValue();
25088
- const valAxisLabel = label === valueAxisLabel || valueAxisLabel.includes(label) ? "" : newValueAxisLabel;
25114
+ const units = getUnitsFromLabel(valueAxisLabel);
25089
25115
  const tooltipLabel = getTooltipLabel(tooltipItem, showLabelsInTooltips);
25090
- return `${label}: ${tooltipItemValue} ${valAxisLabel}${tooltipLabel}`;
25116
+ return `${label}: ${tooltipItemValue} ${units} ${tooltipLabel}`;
25091
25117
  };
25092
25118
  return {
25093
25119
  enabled: options.tooltip.tooltips,
25094
25120
  mode: ChartHoverMode.Nearest,
25095
25121
  intersect: true,
25096
- padding: 8,
25122
+ padding: TOOLTIP_PADDING,
25123
+ usePointStyle: true,
25124
+ boxWidth: LEGEND_LABEL_BOX_SIZE,
25125
+ boxHeight: LEGEND_LABEL_BOX_SIZE,
25126
+ boxPadding: TOOLTIP_BOX_PADDING,
25097
25127
  callbacks: {
25098
25128
  title: titleCallback,
25099
25129
  label: labelCallback,
@@ -26075,7 +26105,12 @@ const PieChart = (props) => {
26075
26105
  const formattedValue = Math.abs(labelValue) < 1 ? roundNumberToPrecision(labelValue, { n: 3 }) : round$2(labelValue, 3);
26076
26106
  return `${dataLabel} ${formattedValue} ${unit}`;
26077
26107
  }
26078
- }
26108
+ },
26109
+ padding: TOOLTIP_PADDING,
26110
+ boxWidth: LEGEND_LABEL_BOX_SIZE,
26111
+ boxHeight: LEGEND_LABEL_BOX_SIZE,
26112
+ boxPadding: TOOLTIP_BOX_PADDING,
26113
+ usePointStyle: true
26079
26114
  };
26080
26115
  };
26081
26116
  return /* @__PURE__ */ jsx(
@@ -38753,7 +38788,10 @@ const getBarChartToolTips = (options) => {
38753
38788
  enabled: options.tooltip.tooltips,
38754
38789
  mode: ChartHoverMode.Nearest,
38755
38790
  intersect: true,
38756
- padding: 8,
38791
+ padding: TOOLTIP_PADDING,
38792
+ boxWidth: LEGEND_LABEL_BOX_SIZE,
38793
+ boxHeight: LEGEND_LABEL_BOX_SIZE,
38794
+ boxPadding: TOOLTIP_BOX_PADDING,
38757
38795
  callbacks: {
38758
38796
  title: titleCallback,
38759
38797
  label: labelCallback,