# Graph Callback Exeption

**URL:** <https://community.plotly.com/t/graph-callback-exeption/29624>\
**Category:** Dash Python\
**Created:** [October 5, 2019, 3:28pm UTC](https://community.plotly.com/t/graph-callback-exeption/29624 "2019-10-05T15:28:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cenguidanos](https://avatars.discourse-cdn.com/v4/letter/c/7c8e57/32.png) [@cenguidanos](https://community.plotly.com/u/cenguidanos)\
**Post date:** [October 5, 2019, 3:28pm UTC](https://community.plotly.com/t/graph-callback-exeption/29624/1 "2019-10-05T15:28:33Z")

</div>

Hi guys,

I’m trying to, in advance, write a really simple code with callbacks, but not yet.

The code is pretty but useless. I have this elocuency exception from Dash:

> _ **TypeError: Cannot read property ‘data’ of null** _

- Imports:

```auto
import dash
import dash_auth
import dash_html_components as html
import plotly.graph_objs as go
import dash_bootstrap_components as dbc

```

- App

```auto
app = dash.Dash( __name__ ,
                external_stylesheets = external_stylesheets)

app.layout = html.Div([navbar, tablas, graficos, graph_selldata])

server = app.server
if __name__ == ' __main__':
    app.run_server(debug = True)

```

- Database

```auto
...
df_contacts = pd.read_sql_query(query_contacts, conn)
df_studies = pd.read_sql_query(query_studies, conn)
df_operations = pd.read_sql_query(query_operations, conn)
...

```

- Graphs and Dropdown

```auto
graph_selldata = dbc.Container([
    dcc.Dropdown(
        id = 'selldropdown',
        options = [
            {'label': 'Observador de meteorología', 'value': 'OBS'},
            {'label': 'Curso básico climatología', 'value': 'CBC'}

        ],
        value = 'Todos los cursos'
    ),
    dcc.Graph(id = 'sellgraph')
])

```

- Callbacks

```auto
@app.callback(
    dash.dependencies.Output('sellgraph', 'figure'),
    [dash.dependencies.Input('selldropdown', 'value')])
def update_output(value):
    if value == 'OBS':
        figure = {
            'data': [
                {
                    'x': df_operations['date'], #Column of de database table 'date'
                    'y': df_operations['countobservador'] #Column of de database table 'countobservador'
                }
            ]
        }
        return figure
    elif value == 'CBC':
        figure = {
            'data': [
                {
                    'x': df_operations['date'],
                    'y': df_operations['countbasico']
                }
            ]
        }
        return figure

```

I’m trying tu update the graph data with a Dropdown but…This. The problem is with de JavaSript but i can’t recognize the cause of the problem.

With simple Graph i not have a problem but if i entry this callback…you see.

Thanks for your time,

Cristian
