The objective is to have a dropdown menu that, when a certain item is selected, the edge colors of the graph object (networkx) are changed to a specified color that is built into the callback. The way I am attempting to achieve this is by first setting the glyph color to be derived from the edge attribute “edge_color”
The callback essentially loops over each element of “edge_color” from the data source and replaces it with a corresponding color.
def color_edges(arg: dict):
callback = CustomJS(args=arg, code="""
var edge_data = source.edge_renderer.data_source.data;
var f = this.item
var c = edge_data['start']
for (var i = 0; i < c.length; i++)
{
if (f == "cnv_color")
{
edge_data['edge_color'][i] = edge_data['edge_color_cnv'][i]
}
else if (f == "grey")
{
edge_data['edge_color'][i] = "grey"
}
else if (f == "black")
{
edge_data['edge_color'][i] = "black"
}
else if (f == "chrm_color")
{
edge_data['edge_color'][i] = edge_data['edge_color_chrm'][i]
}
}
source.change.emit();
""")
return callback
I can confirm through the console that indeed the color value is being changed in the data source. Is there something about setting the edge color with MultiLine that prevents the color from being updated?
@mapQzero It’s not really possible to speculate with only the information given. If you can provide a simpler Minimal Reproducible Example then we could investigate.