✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🐇 Announcing Dash VTK for 3d simulation graphics. Check out the March webinar.

Callback error updating live-graph.figure

Hi all,

I am trying to make a relatively simple sentiment analysis web app w/ python, tweepy, Textblob and dash.
I’m trying to allow for dynamic searching of a given term.

I know that the event module from dash.dependencies would have worked, but is now depreciated and removed from current version of dash – I really don’t understand why?!!

I suppose my issue is that I have two inputs going to one output, which should be fine.

The error I get when loading up the page is: Callback error updating live-graph.figure
TypeError: update_graph_scatter() takes 1 positional argument but 2 were given

I’ve tried two separate @app.callback functions, but I can’t seem to work out what belong where!

Any advice would be greatly appreciated!!

Project Code:

import dash
from dash.dependencies import Output, Input, State
import dash_core_components as dcc
import dash_html_components as html
import plotly
import random
import plotly.graph_objs as go
from collections import deque
import sqlite3
import pandas as pd

# popular topics: google, olympics, trump, gun, usa

app = dash.Dash(__name__)
app.layout = html.Div(
        html.H2('Live Twitter Sentiment[testing-new]'),
        dcc.Input(id='sentiment_term', value='olympic', type='text'),
        dcc.Graph(id='live-graph', animate=True),
            interval=100 * 1000,

@app.callback(Output('live-graph', 'figure'),
              [Input('graph-update', 'n_intervals'),
              Input(component_id='sentiment_term', component_property='value')])

def update_graph_scatter(sentiment_term):
    conn = sqlite3.connect('twitter.db')
    c = conn.cursor()
    df = pd.read_sql("SELECT * FROM sentiment WHERE tweet LIKE ? ORDER BY unix DESC LIMIT 200", conn, params=('%' + sentiment_term + '%',))
    df.sort_values('unix', inplace=True)
    df['sentiment_smoothed'] = df['sentiment'].rolling(int(len(df) / 2)).mean()

    df['date'] = pd.to_datetime(df['unix'], unit='ms')
    df.set_index('date', inplace=True)
    X = df.index
    Y = df.sentiment_smoothed

    data = plotly.graph_objs.Scatter(

    return {'data': [data], 'layout': go.Layout(xaxis=dict(range=[min(X), max(X)]),
                                                yaxis=dict(range=[min(Y), max(Y)]),
                                                title='Term: {}'.format(sentiment_term))}

if __name__ == '__main__':

Hi @Nikusingh and welcome to the Dash forum!

Try adding a variable name for n_intervals. It’s still required even if you don’t use it.

def update_graph_scatter(n, sentiment_term):

I tried this and it worked like a charm!
I managed to get there by myself but that you so much, I was genuinely about to end my laptop haha!

1 Like