WestHealth / pyvis

Python package for creating and visualizing interactive network graphs.
http://pyvis.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
970 stars 163 forks source link

Pyvis No Longer Generates Correct Graph Height #180

Open ksm0009 opened 1 year ago

ksm0009 commented 1 year ago

When setting the "height" value of the graph when creating a network, using a percentage value no longer functions and results in a very small graph.

Ex: nt = Network(directed=True, height="100%", width="100%", bgcolor='#222222', font_color='white') in pyvis 0.2.1 results in a graph that takes up the entire webpage, while in 3.0 results in a graph that takes up the entire webpage width wise but only a sliver height wise.

standby24x7 commented 1 year ago

Environment pyvis version 0.3.0 to 0.3.2 Browser: chrome or firefox. Notebook setting , notebook = False.

Symptom: Starting from pyvis 0.3.0, following configuration makes no difference.

case1 g = Network(height="100%") case2 g = Network(height="50%")

In case 1 and 2, always the height of the window is same length. (about 180px in my case.) And always the width is 100% of the browser window width (This is OK for me).

===== case3 g = Network(width="50%") In case3 , the width is shrink to 50% of the browser window width.

Request: If pyvis 0.3.0 and later can not specify % value to the height, then developer should document it .

Workaround Specify fixed height value in px. (Ex. height="1000px" )

Additional information. I am not using jupyter notebook. I make my python script on Linux console and run it.

Weaver-Arch commented 1 month ago

A little bit late to the party but I ran into this issue today. I found the issue doesn't occur in older versions on Internet Explorer, but happens in Google Chrome and Edge. I fix this by changing height="100%" to height="100vh" (for viewport height). That seems to be compliant with old versions of IE along with modern browsers.

So I changed: net = Network(notebook=True, cdn_resources="in_line", width="100%", height="100%", directed=True)

To: net = Network(notebook=True, cdn_resources="in_line", width="100%", height="100vh", directed=True)

Pretty sure you can ignore most of my args there, just height is the only important one here I think. Hope this helps anyone else that stops by! :)