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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file PyNetworkD3-0.0.9.tar.gz.
File metadata
- Download URL: PyNetworkD3-0.0.9.tar.gz
- Upload date:
- Size: 14.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
791d3175edc59e8d5207493a8362d70eb9467a9c92ba7d1cc1057a93af05f13d
|
|
| MD5 |
1185f169ffb189b0c6e1e7f4741f0cc8
|
|
| BLAKE2b-256 |
2d16be104e432409b738b225d264881683b93f3dfaacf951387a7ab526a46043
|
File details
Details for the file PyNetworkD3-0.0.9-py3-none-any.whl.
File metadata
- Download URL: PyNetworkD3-0.0.9-py3-none-any.whl
- Upload date:
- Size: 20.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9eb9d51b8e014b87a592102d1919fb4cdb87be5d96aee80d2f90e201d02e29ae
|
|
| MD5 |
a837705d362724c95948ac205df735d9
|
|
| BLAKE2b-256 |
0de12cc4364416a64ca5d640985d49edaa38953adf9ef1017e84aed2100069a4
|