0

I have a DB table which refers to itself. For example let's say I have a list of employees, some of them are other employees' bosses. Of course I have SQLAlchemy objects of this table.
I want to visualize the connections with a graph - each employee is a node, and a line is connecting each employee to his boss.
Is there a way to do it using flask? Or any other python or web framework?

Siguza
  • 21,155
  • 6
  • 52
  • 89
Aviad Nissel
  • 337
  • 3
  • 14

1 Answers1

1

You could render this client-side using a JavaScript graphing library like D3 or Google Charts. Retrieve and process your records using SQLAlchemy and Python, structure the data as per your graphing library's specifications, set up your element with a little JS, send your data over, and then render it in HTML. You'll get a pretty, interactive, and mutable graph of your choosing.

Still, this is a Python question. If you're allergic to JavaScript, you could use a Python library, such as the ones recommended here. A lot of those are more geared towards generating static plots, though. That's fine if you want to embed an image into your page or prepare it for a presentation, but it isn't very lively.

If you want to go interactive in the browser, but really don't want to touch any JS, you could conceivably use a Python wrapper for one of the aforementioned graphing libraries and let the wrapper write the JS for you. You're going to run into some JS at one point or another, whether you're the one generating it or not. Why not have the satisfaction and flexibility of doing it yourself? :)

Community
  • 1
  • 1
Cole Kettler
  • 481
  • 4
  • 11