# Callback error updating live-graph.figure

**URL:** <https://community.plotly.com/t/callback-error-updating-live-graph-figure/40652>\
**Category:** Dash Python\
**Created:** [June 5, 2020, 3:30pm UTC](https://community.plotly.com/t/callback-error-updating-live-graph-figure/40652 "2020-06-05T15:30:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nikusingh](https://avatars.discourse-cdn.com/v4/letter/n/13edae/32.png) [@Nikusingh](https://community.plotly.com/u/Nikusingh)\
**Post date:** [June 5, 2020, 3:30pm UTC](https://community.plotly.com/t/callback-error-updating-live-graph-figure/40652/1 "2020-06-05T15:30:23Z")

</div>

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:

```auto
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),
        dcc.Interval(
            id='graph-update',
            interval=100 * 1000,
            n_intervals=0
        ),
    ]
)

@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)
    df.dropna(inplace=True)
    X = df.index
    Y = df.sentiment_smoothed

    data = plotly.graph_objs.Scatter(
        x=X,
        y=Y,
        name='Scatter',
        mode='lines+markers'
    )

    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__':
    app.run_server(debug=True)

```

---

<div class="post-metadata">

**Author:** ![AnnMarieW](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@AnnMarieW](https://community.plotly.com/u/AnnMarieW)\
**Post date:** [June 5, 2020, 6:20pm UTC](https://community.plotly.com/t/callback-error-updating-live-graph-figure/40652/2 "2020-06-05T18:20:17Z")

</div>

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):

---

<div class="post-metadata">

**Author:** ![Nikusingh](https://avatars.discourse-cdn.com/v4/letter/n/13edae/32.png) [@Nikusingh](https://community.plotly.com/u/Nikusingh)\
**Post date:** [June 5, 2020, 7:30pm UTC](https://community.plotly.com/t/callback-error-updating-live-graph-figure/40652/3 "2020-06-05T19:30:55Z")

</div>

> [@AnnMarieW](#):
>
> pdate\_graph\_scatter(n

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!
