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

Is it possible to build an entity-relationship diagram with table nodes using cytoscape.js? #1309

Closed
john-bai opened this issue Mar 18, 2016 · 3 comments

Comments

@john-bai
Copy link

Hi there! I really enjoy cytoscape.js and am interested in trying to use it to build an entity-relationship diagram with tables. There seems to be two features required in order to draw one:

  1. Source and target labels on edges (Source and target labels on edges #382, already implemented for 2.7.0)
  2. Ability to draw a table node.

In what ways could I explore drawing a table node in a cytoscape.js graph? Could it be a compound node, where the table header and columns would each be a child node? How about building a UI extension where I could introduce a specialized node type TableNode?

image

I built a POC using compound nodes: https://jsfiddle.net/do5qw18o/.
image

I'm a little confused about child node positioning as it doesn't appear to be relative to the parent node. Also, my attempt to set a position on parent nodes doesn't seem to work. Ideally I'd like to just mutate the parent node position and have the child nodes always positioned relative to the parent.

I'd appreciate it if the contributors could review the POC and let me know if this would be the ideal way of implementing this table node. Is the positioning for the nodes correct, or could the child nodes be relatively positioned?

@maxkfranz
Copy link
Member

A compound parent doesn't really have its own position. Its position is inferred from the dimensions of its children, because it must automatically accommodate its children.

To "move" a parent, you would alter the positions of all of its non-parent descendants. That's exactly how the drag gesture operates.

Further, it doesn't make sense to have model position defined relatively to a parent. That would confound model positions and especially rendered positions. If you want relative position, then use node.relativePosition().

@john-bai
Copy link
Author

Thanks for the explanation and parent "move" strategy @maxkfranz! I'll close this issue for now as it sounds like I'm on the right path.

@clement911
Copy link

Hi @john-bai
I'm facing the same need and I'm curious if you ever got it working?

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

3 participants