@oliasoft-open-source/charts-library 3.4.10 → 3.4.12-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
@@ -24642,7 +24642,6 @@ const DEFAULT_POINT_RADIUS = 2;
24642
24642
  const DEFAULT_HOVER_RADIUS = 5;
24643
24643
  const DEFAULT_BORDER_WIDTH = 1;
24644
24644
  const BORDER_JOIN_STYLE = "round";
24645
- const DEFAULT_LINE_POINT_RADIUS = 0;
24646
24645
  const DEFAULT_BACKGROUND_COLOR = "transparent";
24647
24646
  const ZOOM_BOX_BACKGROUND_COLOR = "rgba(0, 0, 0, 0.1)";
24648
24647
  const DOUBLE_CLICK = "dblclick";
@@ -24687,7 +24686,7 @@ const generateLineChartDatasets = (datasets, state, options, { label }) => {
24687
24686
  const {
24688
24687
  formation,
24689
24688
  data = [],
24690
- pointRadius,
24689
+ pointRadius: pointRadiusProp,
24691
24690
  pointHoverRadius,
24692
24691
  borderWidth,
24693
24692
  borderColor,
@@ -24709,7 +24708,9 @@ const generateLineChartDatasets = (datasets, state, options, { label }) => {
24709
24708
  }
24710
24709
  }
24711
24710
  const filteredData = data.filter(Boolean) || [];
24712
- const linePointRadius = parseFloat(pointRadius) || DEFAULT_POINT_RADIUS;
24711
+ const isSinglePoint = (filteredData == null ? void 0 : filteredData.length) === 1;
24712
+ const linePointRadius = parseFloat(pointRadiusProp) || DEFAULT_POINT_RADIUS;
24713
+ const pointRadius = pointsEnabled || isSinglePoint ? linePointRadius : 0;
24713
24714
  const hoverRadius = parseFloat(pointHoverRadius) || DEFAULT_HOVER_RADIUS;
24714
24715
  const indexedColor = COLORS[i2];
24715
24716
  return {
@@ -24725,7 +24726,7 @@ const generateLineChartDatasets = (datasets, state, options, { label }) => {
24725
24726
  borderColor: borderColor ?? indexedColor ?? generateRandomColor(COLORS),
24726
24727
  backgroundColor: backgroundColor ?? DEFAULT_BACKGROUND_COLOR,
24727
24728
  pointBackgroundColor: pointBackgroundColor ?? indexedColor ?? generateRandomColor(COLORS),
24728
- pointRadius: pointsEnabled ? linePointRadius : DEFAULT_LINE_POINT_RADIUS,
24729
+ pointRadius,
24729
24730
  pointHoverRadius: hoverRadius,
24730
24731
  pointHitRadius: line.pointHitRadius ?? hoverRadius
24731
24732
  };
@@ -25403,22 +25404,42 @@ const useStoreChartStateInStorage = (memoState, persistenceId) => {
25403
25404
  memoState.zoomEnabled
25404
25405
  ]);
25405
25406
  };
25406
- const useUpdateAxesRanges = (range, dispatch) => {
25407
- const prevRange = useRef(null);
25407
+ const useUpdateAxesRanges = (range, dispatch, generatedDatasets, chartRef, options) => {
25408
+ const prevProps = useRef({
25409
+ range: null,
25410
+ datasets: null
25411
+ });
25412
+ const { annotations: { annotationsData = [] } = {} } = options || {};
25408
25413
  const updateAxesRanges = useCallback(() => {
25409
- if (range && range.x && range.y && !isEqual(range, prevRange.current)) {
25410
- const axes = Object.entries(range).map(([key, { min, max }]) => ({
25414
+ let axes = null;
25415
+ if (range && range.x && range.y && !isEqual(range, prevProps.current.range)) {
25416
+ axes = Object.entries(range).map(([key, { min, max }]) => ({
25411
25417
  id: key,
25412
25418
  min: min ?? 0,
25413
25419
  max: max ?? 0
25414
25420
  }));
25421
+ prevProps.current.range = range;
25422
+ } else if (range && !isEqual(generatedDatasets, prevProps.current.datasets)) {
25423
+ const scalesKeys = Object.keys(range) ?? [];
25424
+ const data = getAxesDataFromMetasets(
25425
+ chartRef,
25426
+ scalesKeys,
25427
+ annotationsData
25428
+ );
25429
+ axes = Object.keys(range).map((key) => ({
25430
+ id: key,
25431
+ min: Math.min(...data[key]) ?? 0,
25432
+ max: Math.max(...data[key]) ?? 0
25433
+ }));
25434
+ prevProps.current.datasets = generatedDatasets;
25435
+ }
25436
+ if (axes) {
25415
25437
  dispatch({
25416
25438
  type: UPDATE_AXES_RANGES,
25417
25439
  payload: { axes }
25418
25440
  });
25419
- prevRange.current = range;
25420
25441
  }
25421
- }, [range]);
25442
+ }, [range, generatedDatasets, dispatch]);
25422
25443
  useEffect(() => {
25423
25444
  updateAxesRanges();
25424
25445
  }, [updateAxesRanges]);
@@ -25455,7 +25476,13 @@ const useChartState = ({
25455
25476
  } = memoOptions;
25456
25477
  useStoreChartStateInStorage(memoState, persistenceId);
25457
25478
  useToggleCustomLegendVisibility(memoState, memoOptions);
25458
- useUpdateAxesRanges(range, dispatch);
25479
+ useUpdateAxesRanges(
25480
+ range,
25481
+ dispatch,
25482
+ generatedDatasets,
25483
+ chartRef,
25484
+ memoOptions
25485
+ );
25459
25486
  useSaveInitialAxesRanges(chartRef, axes, generatedDatasets, dispatch);
25460
25487
  };
25461
25488
  const WORD_SEPARATOR = " ";