Skip to content

Commit

Permalink
pyvis path explored
Browse files Browse the repository at this point in the history
  • Loading branch information
parthi2929 committed Apr 26, 2024
1 parent b4e21e2 commit f856037
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
50 changes: 49 additions & 1 deletion content/Sujan-03.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,54 @@
"# %matplotlib inline"
]
},
{
"cell_type": "markdown",
"id": "ede68041-a0fd-413b-aea0-fbfafa41aac4",
"metadata": {},
"source": [
"checking if template.html file is available in local system for pyvis to use.. "
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "bd33ca52-8283-4760-929d-5cadff7a5a30",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"'template.html' found at: C:\\Users\\Parthiban-HP-IAC\\miniconda3\\envs\\dataviz2\\Lib\\site-packages\\pyvis\\templates\\template.html\n"
]
}
],
"source": [
"import importlib.resources as pkg_resources\n",
"from pathlib import Path\n",
"\n",
"def find_template_in_package(package, filename=\"template.html\"):\n",
" # Access the package's resources\n",
" package_files = pkg_resources.files(package)\n",
" # Convert to a Path object to use pathlib operations\n",
" directory = Path(package_files)\n",
" # Search recursively for the file\n",
" for path in directory.rglob(filename):\n",
" return path\n",
" return None\n",
"\n",
"# Package from which to find the file\n",
"package = __import__('pyvis')\n",
"\n",
"# Search for the 'template.html' file\n",
"template_path = find_template_in_package(package)\n",
"\n",
"if template_path:\n",
" print(f\"'template.html' found at: {template_path}\")\n",
"else:\n",
" print(\"No 'template.html' file found in the pyvis package.\")\n"
]
},
{
"cell_type": "markdown",
"id": "3db54c12-88f9-4f79-b521-28503e893816",
Expand Down Expand Up @@ -186,7 +234,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "aad1942796af470a9c35c22493c9b23b",
"model_id": "075206cb8c314924aff26a5231b2c42d",
"version_major": 2,
"version_minor": 0
},
Expand Down
2 changes: 1 addition & 1 deletion content/tmp3.html
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ <h1></h1>

// parsing and collecting nodes and edges from the python
nodes = new vis.DataSet([{"color": "violet", "fixed": true, "font": {"color": "white"}, "id": "JAIPRAKASH KHANCHAND VASDANI", "label": "JAIPRAKASH KHANCHAND VASDANI", "shape": "dot", "value": 18, "x": -108, "y": -40}, {"color": "#87dfff", "fixed": true, "font": {"color": "white"}, "id": "Harish Rewachand Sujan", "label": "Harish Rewachand Sujan", "shape": "dot", "value": 4, "x": 297, "y": 19}, {"color": "orange", "fixed": true, "font": {"color": "white"}, "id": "MAGNUM ELASTOMERS PVT LTD", "label": "MAGNUM ELASTOMERS PVT LTD", "shape": "dot", "value": 6, "x": 209, "y": -151}]);
edges = new vis.DataSet([{"color": "#87dfff", "from": "JAIPRAKASH KHANCHAND VASDANI", "to": "MAGNUM ELASTOMERS PVT LTD", "width": 1}, {"color": "#87dfff", "from": "Harish Rewachand Sujan", "to": "MAGNUM ELASTOMERS PVT LTD", "width": 1}]);
edges = new vis.DataSet([{"color": "yellow", "from": "JAIPRAKASH KHANCHAND VASDANI", "to": "MAGNUM ELASTOMERS PVT LTD", "width": 5}, {"color": "yellow", "from": "Harish Rewachand Sujan", "to": "MAGNUM ELASTOMERS PVT LTD", "width": 5}]);

nodeColors = {};
allNodes = nodes.get({ returnType: "Object" });
Expand Down

0 comments on commit f856037

Please sign in to comment.