I have created some nodes with Dash Cytoscapes. My final goal is that there should appear a Slider after clicking on a node. By selecting a value with this Slider the label of the node should be updated with the selected value. Since Im not able to display the slider after clicking a node I made it be displayed permanently below the nodes. Hopefully you got some ideas to reach my desire.
import dash
from dash import dcc
from dash import html
from dash.dependencies import Input, Output
import dash_cytoscape as cyto
app = dash.Dash(__name__)
app.layout = html.Div([
cyto.Cytoscape(
id='node-callback-event',
layout={'name': 'preset'},
style={'width': '100%', 'height': '2000px', 'display': 'block'},
elements=[
{
'data': {'id': 'root', 'label': 'test label'},
'position': {'x': 750, 'y': 750},
'locked': True
}
]
),
html.Label('Slider'),
dcc.Slider(
id='slider-update-value',
min=0,
max=100,
value=0,
step=0.01,
tooltip = {"placement": "bottom", 'always_visible': False },
included=False,
updatemode='drag',
),
],
style={'padding': 1, 'flex': 1})
@app.callback(Output('node-callback-event', 'elements'),
Input('node-callback-event', 'tapNodeData'),
Input('slider-update-value', 'value'))
def displayTapNodeData(node, probability):
if node:
node['label'] += str(probability)
# how to assign the value to the nodes label?
if __name__ == '__main__':
app.run_server(debug=True)