Bokeh+NetworkX Legend

Hey guys,

Recently started using bokeh to create some network graphs (just nodes connected with edges), with the goal of eventually being able to have pretty interactive graphs.

I’m running into issue though trying to build a feature that seems like it should be doable. The nodes I have represent different “types” of entities. I categorize them be simply assigning unique node_color attribute per node type. I am able to map them just fine using from_networkx.

However, I’d like to now be able to create a legend that shows the various types and a user can select which types they want to see by picking from the legend.

I can create the legend by doing:

items = []
    for type in device_types:
        legend_item = LegendItem(label=type)

    legend = Legend(items=items)

But I’m not sure how to use the renderers key given I’m simply converting from networkx and I haven’t been able to make any progress on the interaction part. Any help would be appreciated! Thank you!