Search code examples
htmlstreamlitpyvis

the filter_menu option of the pyvis diagram does not work with streamlit


When I tried to load a html file of an pyvis graph and when i render with filter_menu = True option, it doesn't rendedr the graph leaving just the blank background.

But the graph.html work perfectly without opening inside the streamilit. pyvis streamlit filter_menu does not render

A solution or any tweaks to the setting that i can use to render the html pyvis graph properly.

Particular code for generating the plot

node_degree = dict(G.degree())

node_degree

net = Network(notebook = True ,
              width = '100%',
              height = '1000px',
              bgcolor  = '#222222',
              font_color = 'white',
              filter_menu=True) # bgcolor  = '#222222', font_color = 'white')

nx.set_node_attributes(G, node_degree , 'size')
nx.set_node_attributes(G, event_level1_dict,'group')

net.from_nx(G)
net.show_buttons()
net.show('witcher2.html')

Solution

  • Actually after passing some kwargs on the Network object of pyvis was able to get filter_menu to appear on streamlit as well as jupyter notebook

    cdn_resources='remote'

    net = Network(notebook = True ,width = '100%',height = '1000px',bgcolor ='#222222',font_color = 'white',filter_menu=True,cdn_resources='remote')
    
    node_degree = dict(G.degree())
    
    node_degree
    
    net = Network(notebook = True ,
                  width = '100%',
                  height = '1000px',
                  bgcolor  = '#222222',
                  font_color = 'white',
                  filter_menu=True,
                 cdn_resources='remote') # bgcolor  = '#222222', font_color = 'white')
    
    nx.set_node_attributes(G, node_degree , 'size')
    nx.set_node_attributes(G, event_level1_dict,'group')
    
    net.from_nx(G)
    net.show_buttons()
    net.show('witcher2.html')