Skip to content

Commit

Permalink
fix the issue by inserting screenshots
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasprobst committed May 2, 2024
1 parent 181ef8d commit 9247bc9
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 70 deletions.
Binary file added docs/_static/Screenshot_pyvis_graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/Screenshot_pyvis_graph2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
96 changes: 28 additions & 68 deletions docs/practical_examples/knowledge_graph.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 7,
"id": "064a9e31-1fd0-429e-9189-663e950bc52f",
"metadata": {},
"outputs": [],
Expand All @@ -182,7 +182,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 8,
"id": "ce1a26f6-ad59-4014-b5b2-dcee38f11a26",
"metadata": {},
"outputs": [],
Expand All @@ -192,7 +192,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 9,
"id": "78c9adf7-43f0-4aa1-8740-149bf3a5f74f",
"metadata": {},
"outputs": [],
Expand All @@ -203,45 +203,31 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 10,
"id": "e8d13d2e-d66e-4028-8909-7192cfef1bf6",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Warning: When cdn_resources is 'local' jupyter notebook has issues displaying graphics on chrome/safari. Use cdn_resources='in_line' or cdn_resources='remote' if you have issues viewing graphics in a notebook.\n",
"graph.html\n"
"Warning: When cdn_resources is 'local' jupyter notebook has issues displaying graphics on chrome/safari. Use cdn_resources='in_line' or cdn_resources='remote' if you have issues viewing graphics in a notebook.\n"
]
},
{
"data": {
"text/html": [
"\n",
" <iframe\n",
" width=\"100%\"\n",
" height=\"600px\"\n",
" src=\"graph.html\"\n",
" frameborder=\"0\"\n",
" allowfullscreen\n",
" \n",
" ></iframe>\n",
" "
],
"text/plain": [
"<IPython.lib.display.IFrame at 0x1911e48ecd0>"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pyvis_graph= subgraph.build_pyvis_graph(notebook=True, style=VIS_STYLE)\n",
"pyvis_graph.cdn_resources = 'remote'\n",
"pyvis_graph.show('graph.html', local=False, notebook=True)"
"#pyvis_graph.show('graph.html', notebook=True)\n",
"# the above call fails in the readthedocs build process... we show an image of the result here:"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "c93fe042-3c77-4c00-9738-324d465213da",
"metadata": {},
"source": [
"![grafik.png](../_static/Screenshot_pyvis_graph.png)"
]
},
{
Expand All @@ -261,13 +247,13 @@
" },\n",
" \"@graph\": [\n",
" {\n",
" \"@id\": \"_:N14\",\n",
" \"http://www.w3.org/2004/02/skos/core#definition\": \"A hint\"\n",
" },\n",
" {\n",
" \"@id\": \"http://www.w3.org/ns/prov#Person\",\n",
" \"fname\": \"Matthias\",\n",
" \"lname\": \"Probst\"\n",
" },\n",
" {\n",
" \"@id\": \"_:N14\",\n",
" \"http://www.w3.org/2004/02/skos/core#definition\": \"A hint\"\n",
" }\n",
" ]\n",
"}\n"
Expand Down Expand Up @@ -326,31 +312,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Warning: When cdn_resources is 'local' jupyter notebook has issues displaying graphics on chrome/safari. Use cdn_resources='in_line' or cdn_resources='remote' if you have issues viewing graphics in a notebook.\n",
"tmp.grpah.html\n"
"Warning: When cdn_resources is 'local' jupyter notebook has issues displaying graphics on chrome/safari. Use cdn_resources='in_line' or cdn_resources='remote' if you have issues viewing graphics in a notebook.\n"
]
},
{
"data": {
"text/html": [
"\n",
" <iframe\n",
" width=\"100%\"\n",
" height=\"600px\"\n",
" src=\"tmp.grpah.html\"\n",
" frameborder=\"0\"\n",
" allowfullscreen\n",
" \n",
" ></iframe>\n",
" "
],
"text/plain": [
"<IPython.lib.display.IFrame at 0x1914309d220>"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
Expand All @@ -360,20 +323,17 @@
"pyvis_graph = subgraph.build_pyvis_graph(notebook=True, style=VIS_STYLE)\n",
"\n",
"pyvis_graph.force_atlas_2based(overlap=0)\n",
"pyvis_graph.show(\"tmp.grpah.html\", local=True, notebook=True)\n",
"\n",
"# subgraph = kglab.SubgraphTensor(kg)\n",
"# pyvis_graph= subgraph.build_pyvis_graph(notebook=True, style=VIS_STYLE)\n",
"# pyvis_graph.show('graph.html')"
"# pyvis_graph.show(\"tmp.grpah.html\", local=True, notebook=True)\n",
"# the above call fails in the readthedocs build process... we show an image of the result here:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9c3e4344-6d33-4577-bd48-888217af6139",
"cell_type": "markdown",
"id": "2d0d3238-7763-4734-9e34-29ae7caa5b4c",
"metadata": {},
"outputs": [],
"source": []
"source": [
"![grafik.png](../_static/Screenshot_pyvis_graph2.png)"
]
},
{
"cell_type": "code",
Expand Down
4 changes: 2 additions & 2 deletions docs/practical_examples/tmp.grpah.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ <h1></h1>


// parsing and collecting nodes and edges from the python
nodes = new vis.DataSet([{"color": "black", "id": 0, "label": "_:N25", "shape": "dot", "size": 20, "title": "_:N25"}, {"color": "#97c2fc", "id": 1, "label": "A hint", "shape": "dot", "title": "A hint"}, {"color": "#97c2fc", "id": 2, "label": "prov:Person", "shape": "dot", "title": "prov:Person"}, {"color": "#97c2fc", "id": 3, "label": "Probst", "shape": "dot", "title": "Probst"}, {"color": "#97c2fc", "id": 4, "label": "Matthias", "shape": "dot", "title": "Matthias"}]);
edges = new vis.DataSet([{"from": 0, "label": "skos:definition", "to": 1}, {"from": 2, "label": "foaf:lastName", "to": 3}, {"from": 2, "label": "foaf:firstName", "to": 4}]);
nodes = new vis.DataSet([{"color": "#97c2fc", "id": 0, "label": "prov:Person", "shape": "dot", "title": "prov:Person"}, {"color": "#97c2fc", "id": 1, "label": "Matthias", "shape": "dot", "title": "Matthias"}, {"color": "#97c2fc", "id": 2, "label": "Probst", "shape": "dot", "title": "Probst"}, {"color": "black", "id": 3, "label": "_:N41", "shape": "dot", "size": 20, "title": "_:N41"}, {"color": "#97c2fc", "id": 4, "label": "A hint", "shape": "dot", "title": "A hint"}]);
edges = new vis.DataSet([{"from": 0, "label": "foaf:firstName", "to": 1}, {"from": 0, "label": "foaf:lastName", "to": 2}, {"from": 3, "label": "skos:definition", "to": 4}]);

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

0 comments on commit 9247bc9

Please sign in to comment.