Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use AutoArrangePlugin with Angular 17 as schemes mismatch #696

Open
gundupatil opened this issue Feb 27, 2024 · 6 comments
Open

Comments

@gundupatil
Copy link

gundupatil commented Feb 27, 2024

Is it possible to use the auto Arrange plugin for the below mentioned scheme. Auto Arrange only works when nodes have fixed height and width

type Schemes = GetSchemes<
  ClassicPreset.Node,
  ClassicPreset.Connection<ClassicPreset.Node, ClassicPreset.Node>
>;

Scheme given for AutoArrange plugin

class Node extends ClassicPreset.Node {
  width = 180;
  height = 120;
}

class Connection<N extends Node> extends ClassicPreset.Connection<N, N> {}
type Schemes = GetSchemes<Node, Connection<Node>>;

Is there a efficient way I can re arrange all the nodes having different schemes tried with zoom functionality area.area.transform.k also area.area.zoom()

dragged values will not be repositioned to initial state
Help is appreciated

@Ni55aN
Copy link
Member

Ni55aN commented Mar 6, 2024

what TS error do you receive?

The app generated via Rete Kit doesn't throw any error on build

npx rete-kit app -n ang17 -s angular -v 17 -f "Angular render,Order nodes,Zoom at,Auto arrange,Dataflow engine,Selectable nodes"

@gundupatil
Copy link
Author

what TS error do you receive?

The app generated via Rete Kit doesn't throw any error on build

npx rete-kit app -n ang17 -s angular -v 17 -f "Angular render,Order nodes,Zoom at,Auto arrange,Dataflow engine,Selectable nodes"

Sorry my question was Is it possible to use the auto Arrange plugin for the below mentioned scheme. Auto Arrange only works when nodes have fixed height and width?

@gundupatil
Copy link
Author

Trying the hack around to get the height and width of the node after the autoArrange

setTimeout(async () => {
        editor.getNodes().forEach(async (node) => {
          const nodes: NodeListOf<HTMLElement> = document.querySelectorAll(`node-${node.id}`);
          nodes.forEach(node => {
            node.style.height = 'auto';
            node.style.width = ' 288px';
          })
        })
      
    },500);
    await arrange.layout({ applier: animate ? applier : undefined });
      AreaExtensions.zoomAt(area, editor.getNodes());
    },

@Ni55aN
Copy link
Member

Ni55aN commented Mar 27, 2024

only works when nodes have fixed height and width?

yes, because Elk.js (the library it's based on) needs width/height to be available before rendering the graph (in most cases).

after the autoArrange

why can't you specify/calculate width/height based on node type and content? Like this https://github.com/retejs/rete-studio/blob/abd5d890c56a748d501ef7c027671dcea3d37908/core/src/nodes.ts#L219

@gundupatil
Copy link
Author

assigning node height and width directly did not work.. need to modify node style height and width only.

@Ni55aN
Copy link
Member

Ni55aN commented Apr 14, 2024

height and width directly did not work

this works if you don't use arrange.layout (or call area,resize directly)

Otherwise, after updating these properties, you need to call resize explicitly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants