Skip to content

set_options() not working #81

@yutxie

Description

@yutxie

Hi! I'm trying to use the set_options(...) function to set default configurations. However, the visualization fails to be loaded after this function is called.

Below is my testing code.

import networkx as nx
from pyvis.network import Network

net = Network()
net.from_nx(nx.complete_graph(5))
net.show_buttons()
net.set_options('''
var options = {
  "edges": {
    "color": {
      "inherit": true
    },
    "smooth": false
  },
  "physics": {
    "minVelocity": 0.75
  }
}
''')
net.show("ex.html")

I have also tried to remove the set_options(...) part as below, and found the desired figure can be shown immediately after net.show("ex.html").

import networkx as nx
from pyvis.network import Network

net = Network()
net.from_nx(nx.complete_graph(5))
net.show_buttons()
net.show("ex.html")

I printed out the default net.options. It goes like this:

{'interaction': {'hideEdgesOnDrag': False, 'hideNodesOnDrag': False, 'dragNodes': True}, 'configure': {'enabled': True}, 'physics': {'enabled': True, 'stabilization': <pyvis.physics.Physics.Stabilization object at 0x000001548026A280>}, 'edges': {'smooth': {'enabled': False, 'type': 'continuous'}, 'color': {'inherit': True}}}

I was wondering whether some essential elements (e.g., pyvis.physics.Physics.Stabilization object) were lost during modifying net.options, so that the figure could not be loaded as expected.

Hope you could help me with this! Thank you so much!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions