@oliasoft-open-source/charts-library 3.6.6-beta-1 → 3.6.7

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
@@ -24834,7 +24834,7 @@ const useLegendState = ({
24834
24834
  };
24835
24835
  };
24836
24836
  const LEGEND_MARGIN = 4;
24837
- const createStyleObject = (legendPosition, chart2) => {
24837
+ const createLegendStyle = (legendPosition, chart2) => {
24838
24838
  const { height = 0, width = 0, chartArea } = chart2;
24839
24839
  const { top: top2, left: left2, bottom: bottom2, right: right2 } = chartArea;
24840
24840
  return {
@@ -24851,6 +24851,17 @@ const getGeneratedLabels = (chart2) => {
24851
24851
  var _a2, _b2, _c2, _d2, _e2;
24852
24852
  return ((_e2 = (_d2 = (_c2 = (_b2 = (_a2 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _a2.plugins) == null ? void 0 : _b2.legend) == null ? void 0 : _c2.labels) == null ? void 0 : _d2.generateLabels) == null ? void 0 : _e2.call(_d2, chart2)) ?? [];
24853
24853
  };
24854
+ const useGeneratedLabels = (chartRef, generatedDatasets) => {
24855
+ const [items, setItems] = useState([]);
24856
+ useEffect(() => {
24857
+ const chart2 = chartRef.current;
24858
+ if (!chart2)
24859
+ return;
24860
+ const newItems = getGeneratedLabels(chart2);
24861
+ setItems(newItems);
24862
+ }, [generatedDatasets, chartRef]);
24863
+ return items;
24864
+ };
24854
24865
  const LegendPanel = forwardRef((props, ref) => {
24855
24866
  const {
24856
24867
  legendPosition,
@@ -24862,7 +24873,7 @@ const LegendPanel = forwardRef((props, ref) => {
24862
24873
  isDragging: isDragging2
24863
24874
  } = props;
24864
24875
  const { legendEnabled } = state;
24865
- const chart2 = chartRef.current;
24876
+ const chart2 = chartRef == null ? void 0 : chartRef.current;
24866
24877
  if (!chart2)
24867
24878
  return null;
24868
24879
  const {
@@ -24875,17 +24886,8 @@ const LegendPanel = forwardRef((props, ref) => {
24875
24886
  dispatch
24876
24887
  });
24877
24888
  const { onToggleLegend } = useToggleHandlers(dispatch);
24878
- const [items, setItems] = useState([]);
24879
- useEffect(() => {
24880
- if (!chart2)
24881
- return;
24882
- const newItems = getGeneratedLabels(chart2);
24883
- setItems(newItems);
24884
- }, [generatedDatasets, chart2]);
24885
- const style = useMemo(
24886
- () => createStyleObject(legendPosition, chart2),
24887
- [chart2, legendPosition]
24888
- );
24889
+ const items = useGeneratedLabels(chartRef, generatedDatasets);
24890
+ const style = createLegendStyle(legendPosition, chart2);
24889
24891
  return /* @__PURE__ */ jsxs(
24890
24892
  "div",
24891
24893
  {