@oliasoft-open-source/charts-library 3.5.4-beta-3 → 3.5.4-beta-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
@@ -22219,7 +22219,7 @@ const isPrimitiveValue = (value) => typeof value === "string" || typeof value ==
22219
22219
  const isRangeValid = (r2) => {
22220
22220
  if (!r2)
22221
22221
  return false;
22222
- return Object.values(r2).every((value) => !isNilOrEmpty(value));
22222
+ return Object.values(r2).some((value) => !isNilOrEmpty(value));
22223
22223
  };
22224
22224
  const getChartStateFromStorage = (persistenceId) => {
22225
22225
  if (!persistenceId)
@@ -23711,9 +23711,9 @@ const useChartFunctions = ({
23711
23711
  const onResetAxes = useCallback(() => {
23712
23712
  dispatch({ type: RESET_AXES_RANGES });
23713
23713
  }, []);
23714
- const onUpdateAxes = ({ axes: axes2 }) => {
23714
+ const onUpdateAxes = useCallback(({ axes: axes2 }) => {
23715
23715
  dispatch({ type: UPDATE_AXES_RANGES, payload: { axes: axes2 } });
23716
- };
23716
+ }, []);
23717
23717
  return {
23718
23718
  legendClick,
23719
23719
  resetZoom: resetZoom2,
@@ -23739,12 +23739,7 @@ const initializeFormState = ({
23739
23739
  axes = []
23740
23740
  }) => {
23741
23741
  return (initialAxesRanges == null ? void 0 : initialAxesRanges.map((initialAxisRange) => {
23742
- console.log("initializeFormState");
23743
- console.log("-------------------");
23744
23742
  const currentAxisRange = axes.find((a2) => a2.id === initialAxisRange.id);
23745
- console.log("currentAxisRange", currentAxisRange);
23746
- console.log("id: initialAxisRange.id,", initialAxisRange.id);
23747
- console.log("-------------------");
23748
23743
  return {
23749
23744
  id: initialAxisRange.id,
23750
23745
  min: (currentAxisRange == null ? void 0 : currentAxisRange.min) ?? (initialAxisRange == null ? void 0 : initialAxisRange.min),
@@ -23794,13 +23789,7 @@ const reducer = (state, action) => {
23794
23789
  return produce(state, (draft) => {
23795
23790
  const { name: name2, value, id } = action.payload;
23796
23791
  const axis = draft.find((a2) => a2.id === id);
23797
- console.log("actionTypes.ValueUpdated:");
23798
- console.log("1-----------------------");
23799
- console.log("axis", axis);
23800
- console.log("name", name2);
23801
- console.log("value", value);
23802
23792
  if (axis && value) {
23803
- console.log("2------------------------");
23804
23793
  axis[name2] = value;
23805
23794
  }
23806
23795
  });
@@ -24570,7 +24559,7 @@ const defaultChartStyling$2 = (options) => ({
24570
24559
  maintainAspectRatio: (options == null ? void 0 : options.maintainAspectRatio) ?? false,
24571
24560
  staticChartHeight: (options == null ? void 0 : options.staticChartHeight) ?? false,
24572
24561
  performanceMode: (options == null ? void 0 : options.performanceMode) ?? true,
24573
- squareAspectRatio: options == null ? void 0 : options.squareAspectRatio,
24562
+ squareAspectRatio: (options == null ? void 0 : options.squareAspectRatio) ?? false,
24574
24563
  layoutPadding: (options == null ? void 0 : options.layoutPadding) || {
24575
24564
  top: 0,
24576
24565
  bottom: 20,
@@ -25433,26 +25422,32 @@ const useStoreChartStateInStorage = (memoState, persistenceId) => {
25433
25422
  memoState.zoomEnabled
25434
25423
  ]);
25435
25424
  };
25436
- const useUpdateAxesRanges = (range, dispatch) => {
25437
- const prevRange = useRef();
25438
- const updateAxesRanges = useCallback(() => {
25439
- if (range && isRangeValid(range) && !isEqual(range, prevRange.current)) {
25440
- console.log("WRONG", range);
25441
- const axes = Object.entries(range).map(([key, { min, max }]) => ({
25425
+ const useUpdateAxesRanges = ({
25426
+ range,
25427
+ state,
25428
+ dispatch
25429
+ }) => {
25430
+ const prevAxes = useRef(state.axes);
25431
+ useEffect(() => {
25432
+ if (range && isRangeValid(range)) {
25433
+ const newAxes = Object.entries(range).map(([key, { min, max }]) => ({
25442
25434
  id: key,
25443
25435
  min: min ?? 0,
25444
25436
  max: max ?? 0
25445
25437
  }));
25446
- dispatch({
25447
- type: UPDATE_AXES_RANGES,
25448
- payload: { axes }
25438
+ const mergedAxes = [...prevAxes.current ?? []].map((axis) => {
25439
+ const newAxis = newAxes.find((a2) => a2.id === axis.id);
25440
+ return newAxis ? { ...axis, ...newAxis } : axis;
25449
25441
  });
25450
- prevRange.current = range;
25442
+ if (!isEqual(mergedAxes, prevAxes.current)) {
25443
+ dispatch({
25444
+ type: UPDATE_AXES_RANGES,
25445
+ payload: { axes: mergedAxes }
25446
+ });
25447
+ prevAxes.current = mergedAxes;
25448
+ }
25451
25449
  }
25452
25450
  }, [range]);
25453
- useEffect(() => {
25454
- updateAxesRanges();
25455
- }, [updateAxesRanges]);
25456
25451
  };
25457
25452
  const useSaveInitialAxesRanges = (chartRef, axes, generatedDatasets, dispatch) => {
25458
25453
  const prevGeneratedDatasets = useRef();
@@ -25486,7 +25481,7 @@ const useChartState = ({
25486
25481
  } = memoOptions;
25487
25482
  useStoreChartStateInStorage(memoState, persistenceId);
25488
25483
  useToggleCustomLegendVisibility(memoState, memoOptions);
25489
- useUpdateAxesRanges(range, dispatch);
25484
+ useUpdateAxesRanges({ range, state: memoState, dispatch });
25490
25485
  useSaveInitialAxesRanges(chartRef, axes, generatedDatasets, dispatch);
25491
25486
  };
25492
25487
  const WORD_SEPARATOR = " ";
@@ -25741,8 +25736,6 @@ const LineChart = (props) => {
25741
25736
  generatedDatasets
25742
25737
  });
25743
25738
  const usePlugins = useChartPlugins({ options, resetZoom: resetZoom2 });
25744
- console.log("State", state);
25745
- console.log("options", options);
25746
25739
  return /* @__PURE__ */ jsxs(
25747
25740
  "div",
25748
25741
  {