auchenberg / dependo

Visualize your CommonJS or AMD module dependencies in a force directed graph report.
MIT License
484 stars 50 forks source link

Persist hand-made layout #16

Open naugtur opened 9 years ago

naugtur commented 9 years ago

Moving a node makes it stick in one place.

Maybe there's a way to store that information, JSON.stringifyand put in the local storage. From there there's only one step to printing the string to console and allowing user to put it in a file which would be loaded and interpreted every time the graph is drawn, so you can have some of the graph nodes maintain order between browsers and machines (assuming the file goes to the repository as documentation)

auchenberg commented 9 years ago

Makes good sense. Would be great if someone had time to hack a prototype of this.

naugtur commented 9 years ago

That's what I plan to do, but I might need you to point me to where the fixed position data is.

auchenberg commented 9 years ago

Dumping the coordinates in local storage would be just fine. Maybe a JSON blob for each "report", so we would need to generate a unique id for each report.

naugtur commented 9 years ago

I get it, but I was asking where to look for the data. If you could point me to a method that fetches the coords of nodes that would be a nice kickstart for my work.

naugtur commented 9 years ago

I've got a proof of concept. I know how to do that. Now the question is: what should be the unique-enough id of a graph? My initial idea was to use a hash of all module names, but then you lose the layout if dependencies change. So the code that generates html should say what the identification is. Project folder maybe?

auchenberg commented 9 years ago

Yeah, I would hash the folder-path, and use that as the key?