GithubHelp home page GithubHelp logo

Comments (6)

dmoore247 avatar dmoore247 commented on August 30, 2024 3

Found the answer... pretty clever library, the options are dictionaries mirroring the JS code.

import pandas as pd

net = Network(height="400px", width="400px", bgcolor="#222222", font_color="white", notebook=True, directed=True)
net.options.groups = {
            "users": {
                "shape": 'icon',
                "icon": {
                    "face": 'FontAwesome',
                    "code": '\uf0c0',
                    "size": 50,
                    "color": 'orange'
                }
            },
            "table": {                 
              "shape": 'icon',
              "icon": {
                  "face": 'FontAwesome',
                  "code": '\uf0ce',
                  "size": 50,
                  "color": 'green'
                }
            }
        }

net.add_node("a", shape="icon", group="users")
net.add_node("b", shape="icon", group="table")
net.add_edge("a","b")
net.show("net.html")

# patch in font-awesome css
# replace https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css
html_str = net.html.replace(
  '<head>',
  '<head><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" type="text/css"/>'
)
#print(html_str)
displayHTML(html_str)```

from pyvis.

dmoore247 avatar dmoore247 commented on August 30, 2024

image

from pyvis.

dmoore247 avatar dmoore247 commented on August 30, 2024

The answer lies in https://pyvis.readthedocs.io/en/latest/documentation.html#pyvis.network.Network.add_node and the 'group' optional parameter to the node.

from pyvis.

dmoore247 avatar dmoore247 commented on August 30, 2024

Please note I still have to hack in the font-awesome CSS...

# replace https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css
html_str = net.html.replace(
  '<head>',
  '<head><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" type="text/css"/>'
)```

from pyvis.

wjbmattingly avatar wjbmattingly commented on August 30, 2024

Elegant solution. I spent the evening trying to figure this out.

from pyvis.

BerserkerGaruk avatar BerserkerGaruk commented on August 30, 2024

Answered: #53 (comment)
Closing, but might add an example using this method.

from pyvis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.