Hello,
below I’ve implemented a graph in which I want to change two graph attributes based on a selection in a dynamic map.
For illustration purposes, I’ve used a graph with two nodes and one connecting edge. I want to be able to change the edge- and node color freely between green and black.
The issue is the following:
When the node color is set to ‘green’ then changing the edge color in the selection menu does not change the graph at all. Strangly, if the node color is set to ‘black’ then switching between edge colors works perfectly.
Note that the same effect occurs if you use a Holomap instead of a dynamic map or chose other graph attributes.
If you have any ideas why the bug occurs or how I could solve, it would be a great help.
import numpy as np
import holoviews as hv
hv.extension('bokeh')
# function that creates a graph with two nodes and one connecting edge and sets its edge and node color to the given
# function parameters
def hv_graph(edge_color, node_color):
node_indices = np.arange(2, dtype=np.int32)
source = np.zeros(2, dtype=np.int32)
target = node_indices
graph = hv.Graph(((source, target),)).opts(edge_color=edge_color, node_color=node_color)
return graph
def main():
# create the dynamic map
dmap = hv.DynamicMap(hv_graph, kdims=["edge_color", "node_color"])
dmap = dmap.redim.values(edge_color=["green", "black"], node_color=["green", "black"])
# save the dynamic map
hv.save(dmap, 'dmap.html', backend='bokeh')
return
if __name__ == '__main__':
main()