Creating interactive graphs using slider

I am trying to create a network graph which updates when user makes changes in slider. I am getting
Invalid argument figure passed into Graph with ID “n-graph”.
Expected object.
Was supplied type array.
Any help would be appreciated . . Thanks :slight_smile:

html.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)

Hi, maybe you find some inspiration from the tutorial about callbacks: https://dash.plot.ly/getting-started-part-2. Since I don’t use Python I can’t help more. I hope it still helps.