Skip to content

Commit

Permalink
minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
YouGuessedMyName committed Sep 10, 2024
1 parent c53f5f9 commit b2d1c75
Show file tree
Hide file tree
Showing 10 changed files with 496 additions and 115 deletions.
80 changes: 64 additions & 16 deletions notebooks/bond.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 38,
"execution_count": 39,
"id": "ecbc3f07-50a9-4f4a-9df2-4a95527e6db6",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -52,24 +52,46 @@
" nodes: nodes,\n",
" edges: edges,\n",
" };\n",
" var options = {\"physics\": false, \"fixed\": true};\n",
" var options = {\"physics\": true};\n",
" var network = new vis.Network(container, data, options);\n",
"\n",
" network.on( 'click', function(properties) {\n",
" var nodeId = network.getNodeAt({x:properties.event.srcEvent.offsetX, y:properties.event.srcEvent.offsetY});\n",
" var update_array = [{id: nodeId, hidden: true}]\n",
" nodes.update(update_arrvay)\n",
" var nodeId = network.getNodeAt({x:properties.event.srcEvent.offsetX, y:properties.event.srcEvent.offsetY});\n",
" makeNeighborsVisible(nodeId);\n",
" });\n",
"\n",
" function myFunction() {\n",
" var new_options = {\"nodes\": {\"color\": {\"background\": \"red\"}}}\n",
" var update_array = [{id: 1, hidden: false}]\n",
" var update_array = [{id: 2, hidden: false}]\n",
" nodes.update(update_array)\n",
" network.setOptions(new_options)\n",
" }\n",
" alert(JSON.stringify(network.getPositions(2)))\n",
" function disappear() {\n",
" ids = nodes.getIds();\n",
" for (let i = 0; i < ids.length; i++) {\n",
" var nodeId = ids[i];\n",
" var node = nodes.get(nodeId);\n",
" node[\"hidden\"] = true;\n",
" nodes.update(node);\n",
" } \n",
" }\n",
" function makeVisible(nodeId) {\n",
" var node = nodes.get(nodeId);\n",
" node[\"hidden\"] = false;\n",
" nodes.update(node);\n",
" }\n",
" \n",
" function makeNeighborsVisible(myNode) {\n",
" var ids = network.getConnectedNodes(myNode, 'to');\n",
" for (let i = 0; i < ids.length; i++) {\n",
" var nodeId = ids[i];\n",
" makeVisible(nodeId);\n",
" }\n",
" }\n",
" disappear();\n",
" makeVisible(1);\n",
" </script>\n",
" <button type=\"button\" onclick=\"myFunction()\">Click Me!</button> \n",
" <button type=\"button\" onclick=\"makeNeighborsVisible(2)\">Click Me!</button> \n",
" </body>\n",
"</html>"
],
Expand Down Expand Up @@ -129,24 +151,46 @@
" nodes: nodes,\n",
" edges: edges,\n",
" };\n",
" var options = {\"physics\": false, \"fixed\": true};\n",
" var options = {\"physics\": true};\n",
" var network = new vis.Network(container, data, options);\n",
"\n",
" network.on( 'click', function(properties) {\n",
" var nodeId = network.getNodeAt({x:properties.event.srcEvent.offsetX, y:properties.event.srcEvent.offsetY});\n",
" var update_array = [{id: nodeId, hidden: true}]\n",
" nodes.update(update_arrvay)\n",
" var nodeId = network.getNodeAt({x:properties.event.srcEvent.offsetX, y:properties.event.srcEvent.offsetY});\n",
" makeNeighborsVisible(nodeId);\n",
" });\n",
"\n",
" function myFunction() {\n",
" var new_options = {\"nodes\": {\"color\": {\"background\": \"red\"}}}\n",
" var update_array = [{id: 1, hidden: false}]\n",
" var update_array = [{id: 2, hidden: false}]\n",
" nodes.update(update_array)\n",
" network.setOptions(new_options)\n",
" }\n",
" alert(JSON.stringify(network.getPositions(2)))\n",
" function disappear() {\n",
" ids = nodes.getIds();\n",
" for (let i = 0; i < ids.length; i++) {\n",
" var nodeId = ids[i];\n",
" var node = nodes.get(nodeId);\n",
" node[\"hidden\"] = true;\n",
" nodes.update(node);\n",
" } \n",
" }\n",
" function makeVisible(nodeId) {\n",
" var node = nodes.get(nodeId);\n",
" node[\"hidden\"] = false;\n",
" nodes.update(node);\n",
" }\n",
" \n",
" function makeNeighborsVisible(myNode) {\n",
" var ids = network.getConnectedNodes(myNode, 'to');\n",
" for (let i = 0; i < ids.length; i++) {\n",
" var nodeId = ids[i];\n",
" makeVisible(nodeId);\n",
" }\n",
" }\n",
" disappear();\n",
" makeVisible(1);\n",
" </script>\n",
" <button type=\"button\" onclick=\"myFunction()\">Click Me!</button> \n",
" <button type=\"button\" onclick=\"makeNeighborsVisible(2)\">Click Me!</button> \n",
" </body>\n",
"</html>\"\"\"\n",
"\n",
Expand Down Expand Up @@ -206,7 +250,11 @@
"output_type": "display_data"
}
],
"source": []
"source": [
" \n",
" \n",
" "
]
},
{
"cell_type": "code",
Expand Down
131 changes: 131 additions & 0 deletions notebooks/layouts/borange.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
{
"__fake_macros": {
"__group_macro": {
"borderWidth": 1,
"color": {
"background": "white",
"border": "black",
"highlight": {
"background": "white",
"border": "red"
}
},
"shape": "ellipse",
"mass": 1,
"font": {
"color": "black",
"size": 14
}
}
},
"groups": {
"states": {
"borderWidth": 1,
"color": {
"background": "#ffa348",
"border": "#9141ac",
"highlight": {
"background": "white",
"border": "red"
}
},
"shape": "ellipse",
"mass": 1,
"font": {
"color": "black",
"size": 14
}
},
"actions": {
"borderWidth": 1,
"color": {
"background": "lightblue",
"border": "black",
"highlight": {
"background": "white",
"border": "red"
}
},
"shape": "box",
"mass": 1,
"font": {
"color": "black",
"size": 14
}
},
"scheduled_actions": {
"borderWidth": 1,
"color": {
"background": "pink",
"border": "black",
"highlight": {
"background": "white",
"border": "red"
}
},
"shape": "box",
"mass": 1,
"font": {
"color": "black",
"size": 14
},
"schedColor": false
},
"init": {
"borderWidth": 1,
"color": {
"background": "#613583",
"border": "black",
"highlight": {
"background": "white",
"border": "red"
}
},
"shape": "ellipse",
"mass": 1,
"font": {
"color": "black",
"size": 14
}
}
},
"reload_button": false,
"edges": {
"arrows": "to",
"font": {
"color": "black",
"size": 14
},
"color": {
"color": "#000000"
}
},
"numbers": {
"fractions": true,
"digits": 5
},
"results_and_rewards": {
"show_results": true,
"resultSymbol": "\u2606",
"show_rewards": true
},
"layout": {
"randomSeed": 5
},
"misc": {
"enable_physics": true,
"width": 800,
"height": 600,
"explore": true
},
"saving": {
"relative_path": true,
"filename": "layouts/borange.json",
"save_button": false,
"load_button": false
},
"positions": {},
"width": 800,
"height": 600,
"physics": true
}
Loading

0 comments on commit b2d1c75

Please sign in to comment.