esterpantaleo / etymology

This repository contains code behind the visualization of the Wikimedia tool etytree at http://tools.wmflabs.org/etytree/
https://esterpantaleo.github.io/etymology/
50 stars 9 forks source link

Reorganize dagre.js into OOP style code #24

Closed xferguson closed 7 years ago

xferguson commented 7 years ago

As I said in issue #22

Right now, the process of drawing out a graph is one long chain of events. Everything will get easier if we have each function alter the graph and update the state of the graph so the next function can read the state. This is similar to what you were talking about with width/height and how you needed to make them global.

The approach I am suggesting is Object Oriented Programming, like they do in this d3 snippet.

This will make it easier to check and assign values.

Not only am I not sure there is a good way to handle this collapsibility issue without switching to an OOP model, but I think this will speed up everything else we need to do.

xferguson commented 7 years ago

It makes sense to me that you have the code separated, as they are mostly separated by function. Though we may want to rearrange it a little, the general separation is good. I think we would do best to implement a (Module based)[http://www.adequatelygood.com/JavaScript-Module-Pattern-In-Depth.html] approach.

This will let us:

  1. Build up the graph object in pieces, so that the process of stringing this together isn't a massive undertaking, but can happen in steps
  2. Keep the various parts separated in case we need to swap out or change segments of the code
  3. Start using OOP right away, so we an use it to solve other problems.

I will go ahead and start with the sparql.js, as it is pretty well segmented by itself anyway, and we can start there.

xferguson commented 7 years ago

I think this is basically done. Closing issue.