Hello everyone,
I would like to use embedding to save the following application to an html file (or something similar), but I’m a beginner when it comes to using Embedding and don’t quite know how. Could you help me with that? What line of code would I need to add?
By the way, the code highlights a node in a small network graph and was taken from an answer by @Marc to my question in https://discourse.holoviz.org/t/scrolldown-window-where-multiple-options-can-be-selected/4092/2
import panel as pn
import numpy as np
import holoviews as hv
pn.extension()
# produces a small graph and colors one of the nodes red and the others black
# Ideally, I would like to select multiple nodes from the given node set to be colored red
def hv_graph(color_these_nodes):
# set up the graph
color_these_nodes = list(color_these_nodes)
node_indices = np.arange(3, dtype=np.int32)
source = np.zeros(3, dtype=np.int32)
target = node_indices
# color all given nodes
node_colors = []
for node in node_indices:
# below the squared brackets are required as this example only allows one node to be colored
if node in color_these_nodes: # color the chosen node red
node_colors.append("red")
else:
node_colors.append("black") # color all other nodes with any other color
# create graph
x, y = [0, 1, 1], [0, 1, 2] # some coordinates
nodes = hv.Nodes((x, y, node_indices, node_colors), vdims="color")
graph = hv.Graph(((source, target), nodes)).opts(node_color="color")
return graph
all_nodes = pn.widgets.MultiSelect(options=[0, 1, 2], name="Node(s)")
h = pn.bind(hv_graph, color_these_nodes=all_nodes)
layout = pn.Column(all_nodes, h).servable()