diff --git a/src/components/Graph/index.tsx b/src/components/Graph/index.tsx
index 9c2b69c..9ec1a64 100644
--- a/src/components/Graph/index.tsx
+++ b/src/components/Graph/index.tsx
@@ -41,17 +41,14 @@ const StyledEditorWrapper = styled.div<{ isWidget: boolean }>`
`;
const GraphComponent = ({ isWidget, openModal, setSelectedNode }: LayoutProps) => {
+ const [minScale, setMinScale] = React.useState(0.3);
const setGraphValue = useGraph(state => state.setGraphValue);
const setConfig = useConfig(state => state.setConfig);
- const canvasRef = React.useRef(null);
- const setCanvasRef = useConfig(state => state.setCanvasRef);
const loading = useGraph(state => state.loading);
const layout = useConfig(state => state.layout);
const nodes = useGraph(state => state.nodes);
const edges = useGraph(state => state.edges);
-
-
const [size, setSize] = React.useState({
width: 2000,
height: 2000,
@@ -75,7 +72,11 @@ const GraphComponent = ({ isWidget, openModal, setSelectedNode }: LayoutProps) =
const onLayoutChange = React.useCallback(
(layout: ElkRoot) => {
if (layout.width && layout.height) {
+ const areaSize = layout.width * layout.height;
+
+ setMinScale((1_000_000 * 0.5) / areaSize);
setSize({ width: layout.width + 400, height: layout.height + 400 });
+
requestAnimationFrame(() => {
setTimeout(() => {
setGraphValue("loading", false);
@@ -91,10 +92,6 @@ const GraphComponent = ({ isWidget, openModal, setSelectedNode }: LayoutProps) =
if (input) input.blur();
}, []);
- React.useEffect(()=>{
- setCanvasRef(canvasRef)
- })
-
if (nodes.length > 8_000) return ;
return (
@@ -102,9 +99,9 @@ const GraphComponent = ({ isWidget, openModal, setSelectedNode }: LayoutProps) =
{loading && }