TablePlus / diagram-plugin

111 stars 10 forks source link

[enhancement] Better layout algorithm #15

Open thien-do opened 4 years ago

thien-do commented 4 years ago

There was this another issue in the previous version (which I have previously installed) where the line was overlapped by table.

Maybe it might have been fixed in the newer version.

CleanShot 2020-10-20 at 06 37 20@2x

Originally posted by @mittalyashu in https://github.com/TablePlus/diagram-plugin/issues/5#issuecomment-714471708

At the moment we choose to place the Tables over the References.

As far I understand the canvas (well, I don't even know how this plugin is build) has infinite space so just push the table bit further away so that the references doesn't over lap the tables.

And I mean by the above image.

NOTE: The above image was taken after the table arrangement was done by plugin automatically, I didn't change their positions.

CleanShot 2020-10-23 at 09 18 49@2x

Not this 👆

Originally posted by @mittalyashu in https://github.com/TablePlus/diagram-plugin/issues/5#issuecomment-714892046

As far I understand the canvas (well, I don't even know how this plugin is build) has infinite space so just push the table bit further away so that the references doesn't over lap the tables.

This is a very reasonable approach :D Unfortunately our current "layout" algorithm is not quite as good. Let us improve it. You are right that the layout should put the tables to minimize the overlaps

Originally posted by @dvkndn in https://github.com/TablePlus/diagram-plugin/issues/5#issuecomment-714893168

mittalyashu commented 3 years ago

@dvkndn That's not really an infinite canvas, it only expands to X+ and Y+ axis

CleanShot 2020-12-04 at 09 54 23

thien-do commented 3 years ago

Yes :( The fact that it is not an infinite canvas is causing many issues now. Basically we need to make it infinite first (or just that it's really really big)

migueltorrescosta commented 3 years ago

Another layout issue: When plotting huge databases we might get connected tables on opposite ends of the layout. Is there a way to find better layouts? I used different layout algorithms when facing the same issue using NetworkX , I would be happy to do a MR for this if you can give me some guidance as to where / how the current calculations are done

thien-do commented 3 years ago

oh great @migueltorrescosta !

Is there a way to find better layouts?

We are looking into this. But the biggest issue is that we need to support the infinite canvas first. It would make all of these things much easier. To be specific, the (0, 0) should be the center, not at top left like this

I would be happy to do a MR for this if you can give me some guidance as to where / how the current calculations are done

Unfortunately at the moment the original source code is not completely open :(

migueltorrescosta commented 3 years ago

I understand. If there's anything I could do to speed up the process do ask, it would make the generator that much more valuable :)

s2k commented 2 years ago

I'd also appreciate an improved layout algorithm. I wonder if it's possible to reduce the number of line crossings (as much as possible). For example GraphViz (https://www.graphviz.org) does it, other libraries can surely do it as well. (I only mention this one, because I'm comfortable with it.)

This super simple example shows what I mean:

table-diagram

The connections line_items âž™ orders and line_items âž™ carts cross each other, even though it's (topologically) not necessary.