Hi, I’m working with dash cytoscape.
For some reason the inputs work if I use them singularly, but when I try to use them both in the same callback neither of them works.
Here’s the code:
app.layout = html.Div([ dash_dangerously_set_inner_html.DangerouslySetInnerHTML("{}".format(index_html)), html.Br(), html.Div([ html.Br(), html.Div([ cyto.Cytoscape( id='cytoscape_net', elements=nodes+edges, zoomingEnabled=False, zoom=0.8, layout={'name': 'klay'}, style={'width': '80%', 'height': '700px', 'float': 'left'}, stylesheet=stylesheet_base_node_selector + stylesheet_base_node_image + stylesheet_nodes_filter + stylesheet_base_edge_selector ), html.Div([ html.H3("EDGE FILTER"), dcc.Checklist( id='edge_filter', options=[ {'label': 'type 1', 'value': 'type_1'}, {'label': 'type 2', 'value': 'type_2'} ], value=['type_1', 'type_2'], labelStyle={'display': 'block'}, style={'display': 'block', 'border': '2px white solid', 'width': '70px', 'fontSize': '12px' } ), html.Br(), html.H3(“FILTER NODES“), dcc.Checklist( id=‘node_filter’, options=[ {'label': ‘filter nodes’, 'value': ‘node_filter’} ], value=[‘node_filter’], labelStyle={'display': 'block'}, style={'display': 'block', 'border': '2px white solid', 'width': '70px','fontSize': '12px' } )
])
], style = {‘margin-right’: ‘5%’, ‘display’ : ‘flex’}),
,
]),@app.callback(Output('cytoscape_net', 'stylesheet'), [Input('edge_filter', 'value'), Input(‘node_filter’, 'value') ]) def update_stylesheet(edges, nodes ): out_edges = [] if 'type_1' in edges: out_edges.append(stylesheet_keep_type_1) else: out_edges.append(stylesheet_remove_type_1) if 'type_2' in edges: out_edges.append(stylesheet_keep_type_2) else: out_edges.append(stylesheet_remove_type_2) out_nodes = [] if ‘nodes_filter’ in nodes: out_nodes.append(stylesheet_nodes_filter) else: out_nodes.append(stylesheet_base_node_image) return stylesheet_base_node_selector + out_nodes + out_edges
I can add also the stylesheet selectors, if you ask