@oliasoft-open-source/charts-library 3.6.6 → 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
@@ -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,13 +24886,7 @@ 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]);
24889
+ const items = useGeneratedLabels(chartRef, generatedDatasets);
24885
24890
  const style = createLegendStyle(legendPosition, chart2);
24886
24891
  return /* @__PURE__ */ jsxs(
24887
24892
  "div",