source: node_modules/recharts/es6/util/useReportScale.js@ a762898

Last change on this file since a762898 was a762898, checked in by istevanoska <ilinastevanoska@…>, 6 months ago

Added visualizations

  • Property mode set to 100644
File size: 767 bytes
RevLine 
[a762898]1import { useEffect, useState } from 'react';
2import { useAppDispatch, useAppSelector } from '../state/hooks';
3import { selectContainerScale } from '../state/selectors/containerSelectors';
4import { setScale } from '../state/layoutSlice';
5import { isWellBehavedNumber } from './isWellBehavedNumber';
6export function useReportScale() {
7 var dispatch = useAppDispatch();
8 var [ref, setRef] = useState(null);
9 var scale = useAppSelector(selectContainerScale);
10 useEffect(() => {
11 if (ref == null) {
12 return;
13 }
14 var rect = ref.getBoundingClientRect();
15 var newScale = rect.width / ref.offsetWidth;
16 if (isWellBehavedNumber(newScale) && newScale !== scale) {
17 dispatch(setScale(newScale));
18 }
19 }, [ref, dispatch, scale]);
20 return setRef;
21}
Note: See TracBrowser for help on using the repository browser.