Skip to content

Commit

Permalink
Graphviewer: Make rankdir configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
thvitt committed Jul 22, 2020
1 parent 4c84f74 commit 0b16fce
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/graphviewer/graphviewer.py
Expand Up @@ -3,7 +3,7 @@
from pathlib import Path

import networkx as nx
from flask import Flask, render_template, request, Response, flash
from flask import Flask, render_template, request, Response, flash, jsonify
from markupsafe import Markup
from networkx import DiGraph

Expand Down Expand Up @@ -53,6 +53,9 @@ def prepare_agraph():
syn = request.values.get('syn', False)
order = request.values.get('order', False)
collapse = request.values.get('collapse', False)
direction = request.values.get('dir', 'LR').upper()
if direction not in {'LR', 'RL', 'TB', 'BT'}:
direction = 'LR'
if nodes:
g = info.subgraph(*nodes, context=context, abs_dates=abs_dates, paths=extra, keep_timeline=True,
paths_without_timeline=paths_wo_timeline,
Expand All @@ -79,6 +82,8 @@ def prepare_agraph():
g = info.order_graph(g)
agraph = write_dot(g, target=None, highlight=None if nohl else nodes, edge_labels=not no_edge_labels)
agraph.graph_attr['basename'] = ",".join([str(node.filename.stem if hasattr(node, 'filename') else node) for node in nodes])
agraph.graph_attr['bgcolor'] = 'transparent'
agraph.graph_attr['rankdir'] = direction
if order:
agraph.graph_attr['ranksep'] = '0.2'
return agraph
Expand Down
8 changes: 7 additions & 1 deletion src/graphviewer/templates/form.html
Expand Up @@ -77,7 +77,13 @@ <h3>Zentrale Knoten
{% endfor %}
</select>
</p>
</section>
<p><label for="dir">Richtung: </label>
<select id="dir" name="dir" value="{{ direction }}">
<option value="LR"></option>
<option value="TB"></option>
<option value="RL"></option>
<option value="BT"></option>
</select></p>
</section>
<section class="pure-u-1-3">
<h3>Zusätzliche Pfade</h3>
Expand Down

0 comments on commit 0b16fce

Please sign in to comment.