I am not getting the graph on my webpage with this code.
The update_graph1 function is intended to plot the graph on dcc.Graph(id=‘graph1’), it needs no input just output. Please help.
[quote="sharmaji, post:1, topic:13665, full:true"]
I am not getting the graph on my webpage with this code
app = dash.Dash()
app.layout = html.Div([
html.Div([
html.Label(children='Enter keyword to track')]),
dcc.Input(id ='keyword-in',placeholder='Enter Keyword'),
dcc.Input(id ='number-of-tweets',placeholder='Number of tweets'),
html.Button(id='submit-button',children='Analyze', n_clicks=0),
dcc.Graph(id='graph1'),
html.Div(id='temp')
])
@app.callback(Output('temp','children'),
[Input('submit-button','n_clicks')],
[State('keyword-in','value'),
State('number-of-tweets','value')])
def update_value(n_clicks,query,number_of_tweets):
if n_clicks>0:
get_data(query,int(number_of_tweets))
update_graph1()
@app.callback(Output('graph1','figure'))
def update_graph1():
temp = df.groupby('created_at').count()
print()
data = [go.Scatter(
x=temp.index.values,
y= temp.tweet_id,
mode='lines+markers')]
return {'data':data,
'layout':go.Layout(title='Tweets per day',
xaxis={'title':'Dates'},
yaxis={'title':'Number of Tweets'},
hovermode='closest')
}
[/quote]