I'm starting to experiment with Flask and Sigma js node graphics and I'm struggling with even displaying the simplest node graph.
The network.json data is taken directly from Sigmajs.org front-page.
The current structure is
I've tried a lot of different approaches and lately I've tried to only follow "Get started tutorial" from Sigmajs.org, which doesn't work.
The code for main routes:
def load_json(): #Function to try and pass json data
filename = os.path.join(os.path.dirname(__file__), '../static', 'network.json')
print(filename)
with open(filename) as node_graph:
data = json.load(node_graph)
return data
@bp.route('/')
def index():
node_data = load_json()
print(node_data)
return render_template("index.html", node_data=node_data)
The code for index.html:
<style type="text/css">
#container {
max-width: 400px;
height: 400px;
margin: auto;
}
</style>
<div id="container"></div>
<script src="../static/js/sigma.parsers.json.min.js"></script>
<script src="../static/js/sigma.min.js"></script>
<script src="../static/js/sigma.layout.forceAtlas2.min.js"></script>
<script>
sigma.parser.json('../static/network.json', {
container: 'container',
settings: {
defaultNodeColor: '#ec5148'
}
});
</script>
Running this does nothing, no error message and especially no node graph. I'm thinking that I'm using an url-path instead of a file-path in the json parser but no luck in fixing that. Any help is appreciated and sorry if this is lacking in necessary information.