WestHealth / pyvis

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

I'cant apply editNode function in pyvis's set_options function #226

Open louisyu1234 opened 1 year ago

louisyu1234 commented 1 year ago

from pyvis.network import Network net = Network('500', '50%',notebook=True,cdn_resources='remote') net.toggle_physics(True) net.set_options("""var options = { "manipulation": { "enabled": true, "initiallyActive": false "editNode": true } net.add_node(1, label="Node 1",color='green') net.add_node(2, label="Node 2",color='red') net.add_edge(1,2) net.show('mygraph.html')

when I run it, it throw a error:

net.set_options("""var options = { self.options = self.options.set(options) options = json.loads(options) return _default_decoder.decode(s) obj, end = self.raw_decode(s, idx=_w(s, 0).end()) obj, end = self.scan_once(s, idx) json.decoder.JSONDecodeError: Expecting ',' delimiter: line 1 column 56 (char 55)

Who can help me? Thx

FrostyFrost commented 1 year ago

Looks like you missed comma in line with "initiallyActive" and some brackets. Try this:

net.set_options("""var options = {
"manipulation": {
"enabled": true,
"initiallyActive": false,
"editNode": true
}
}
""")