Skip to content

Commit

Permalink
Merge pull request #44 from Nanoseb/master
Browse files Browse the repository at this point in the history
Fix #25: Show loading bar only when physics is enabled
  • Loading branch information
Giancarlo Perrone committed Aug 29, 2019
2 parents 6b4434a + 742c126 commit b6a3d4d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
11 changes: 11 additions & 0 deletions pyvis/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,11 +428,22 @@ def write_html(self, name, notebook=False):
template = self.template

nodes, edges, height, width, options = self.get_network_data()

# check if physics is enabled
if isinstance(self.options, dict):
if 'physics' in self.options and 'enabled' in self.options['physics']:
physics_enabled = self.options['physics']['enabled']
else:
physics_enabled = True
else:
physics_enabled = self.options.physics.enabled

self.html = template.render(height=height,
width=width,
nodes=nodes,
edges=edges,
options=options,
physics_enabled=physics_enabled,
use_DOT=self.use_DOT,
dot_lang=self.dot_lang,
widget=self.widget,
Expand Down
8 changes: 4 additions & 4 deletions pyvis/templates/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
float: left;
}

{% if nodes|length > 100 %}
{% if nodes|length > 100 and physics_enabled %}
#loadingBar {
position:absolute;
top:0px;
Expand Down Expand Up @@ -122,7 +122,7 @@

<body>
<div id = "mynetwork"></div>
{% if nodes|length > 100 %}
{% if nodes|length > 100 and physics_enabled %}
<div id="loadingBar">
<div class="outerBorder">
<div id="text">0%</div>
Expand Down Expand Up @@ -251,7 +251,7 @@
{% endif %}


{% if nodes|length > 100 %}
{% if nodes|length > 100 and physics_enabled %}
network.on("stabilizationProgress", function(params) {
document.getElementById('loadingBar').removeAttribute("style");
var maxWidth = 496;
Expand Down Expand Up @@ -279,4 +279,4 @@

</script>
</body>
</html>
</html>

0 comments on commit b6a3d4d

Please sign in to comment.