Create D3 visualization networks with Python
Project description
PyNetworkD3
Create D3 visualization networks with Python
Installation
Install using pip
!
$ pip install pynetworkd3
Input JSON syntax
{
"nodes": [
{
"id": "id1",
"attribute 1": "value attribute 1",
"attribute 2": "value attribute 2",
(...)
"attribute N": "value attribute N",
},
{
"id": "id2",
"attribute 1": "value attribute 1",
"attribute 2": "value attribute 2",
(...)
"attribute N": "value attribute N",
},
(...)
],
"links": [
{
"source": "id1",
"target": "id2",
"attribute 1": "value attribute 1",
"attribute 2": "value attribute 2",
(...)
"attribute N": "value attribute N",
},
(...)
]
}
-
Every dictionary in "nodes" must have the id key. The other keys are optionals.
-
Every dictionary in "links" must have the source and target key. The other keys are optionals. Also, each id in source and target must redirect to an existing node in "nodes".
Usage
To use the library, import the Graph
object directly and use the export
method
to create a .html
with the visualization.
from PyNetworkD3 import Graph
dataset = {
"nodes": [{"id": 1},{"id": 2},{"id": 3},{"id": 4},{"id": 5}],
"links": [
{"source": 1, "target": 3},
{"source": 2, "target": 3},
{"source": 1, "target": 3},
{"source": 5, "target": 3},
{"source": 4, "target": 1},
]
}
graph = Graph(dataset, width=300, height=200, radio=10, tooltip=["id"])
graph.export("output.html)
Also you can write the instance in the last line of the notebook's cell (ckeck the example in colab) to view the visualization.
Developing
This library uses PyTest
as the test suite runner, and PyLint
, Flake8
, Black
, ISort
and MyPy
as linters. It also uses Poetry
as the default package manager.
The library includes a Makefile
that has every command you need to start developing. If you don't have it, install Poetry
using:
make get-poetry
Then, create a virtualenv to use throughout the development process, using:
make build-env
Activate the virtualenv using:
. .venv/bin/activate
Deactivate it using:
deactivate
To add a new package, use Poetry
:
poetry add <new-package>
To run the linters, you can use:
# The following commands auto-fix the code
make black!
make isort!
# The following commands just review the code
make black
make isort
make flake8
make mypy
make pylint
To run the tests, you can use:
make tests
Releasing
To make a new release of the library, git switch
to the master
branch and execute:
make bump! minor
The word minor
can be replaced with patch
or major
, depending on the type of release. The bump!
command will bump the versions of the library, create a new branch, add and commit the changes. Then, just merge that branch to master
. Finally, execute a merge to the stable
branch. Make sure to update the version before merging into stable
, as PyPi
will reject packages with duplicated versions.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for PyNetworkD3-0.0.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9eb9d51b8e014b87a592102d1919fb4cdb87be5d96aee80d2f90e201d02e29ae |
|
MD5 | a837705d362724c95948ac205df735d9 |
|
BLAKE2b-256 | 0de12cc4364416a64ca5d640985d49edaa38953adf9ef1017e84aed2100069a4 |