@teja_m19 wrote:
I am trying to create a network graph which updates when user makes changes in slider. I am getting
Invalid argumentfigure
passed into Graph with ID “n-graph”.
Expectedobject
.
Was supplied typearray
.
Any help would be appreciated . . Thankshtml.Div(
[dcc.Graph(id='n-graph') ] ), html.Div( className='twelve-columns', children=[ html.Div([ dcc.Markdown(d(""" ***Graph Parameters*** """)), html.Pre(id='hover-data',style=styles['pre']) ],className='n-columns'), ])
])
@app.callback(
dash.dependencies.Output(‘n-graph’,‘figure’),
[dash.dependencies.Input(‘year_slider’,‘value’)
])
def update_graph(year_value):
return network_graph(year_value)def network_graph(year_value):
A=format(year_value) G=nx.Graph() G.add_node('CHINA') wb_obj= xl.load_workbook(path) sheet_obj=wb_obj.active max_col = sheet_obj.max_column countries=[] max_r=sheet_obj.max_row yr=[] for i in range(1,max_r-1): year_obj=sheet_obj.cell(row = i+1,column = 1) yr.append(year_obj.value) return(yr) indx = yr.index(A) r=indx+2 for i in range(2,max_col-1): x=sheet_obj.cell(row=r,column=i) y=sheet_obj.cell(row=1,column=i) z=y.value if x.value!=0: G.add_edge('CHINA',z) nx.Graph(G,with_labels=1), plt.show()
if name == ‘main’:
app.run_server(debug=True)
Posts: 1
Participants: 1