Closed chinobing closed 6 years ago
my bad. It works like a charm!
Now I encounter another issue. The graph will be reset whenever I select a node.
html.Div([visdcc.Network(id = 'net-holders',
selection = {'nodes':[], 'edges':[]},
options = dict(height= '1000px',
width= '100%',
physics={'barnesHut': {'avoidOverlap': 0.1}},
))], style={'padding-right':'10px','padding-left':'10px'}),
@app.callback(
Output('net-holders', 'data'),
[Input('stock-ticker', 'value'),
Input('net-holders', 'selection')])
def shareholders_vis(ticker,select):
data = {}
data_nodes = []
data_edges = []
data={'nodes':data_nodes,
'edges':data_edges}
return data
But what if I put the data_nodes = [] and data_edges = []
outside the def shareholders_vis
function, It will be considered as global variable in DASH and it works. But it wont reset at all as I refresh my browser.
data = {}
data_nodes = []
data_edges = []
@app.callback(
Output('net-holders', 'data'),
[Input('stock-ticker', 'value'),
Input('net-holders', 'selection')])
def shareholders_vis(ticker,select):
data={'nodes':data_nodes,
'edges':data_edges}
return data
Here is how my web app looks like:
and here is the code:
here is the result:
My problem is that it wont show up the nodes and edges with corresponding names or ID when I select the nodes on the network? Do you know why?