# Graphs are not automatically updated after dropdown value selection when \`animate=True\`

**URL:** https://community.plotly.com/t/graphs-are-not-automatically-updated-after-dropdown-value-selection-when-animate-true/4644
**Category:** Dash Python
**Created:** [June 27, 2017, 7:59am UTC](https://community.plotly.com/t/graphs-are-not-automatically-updated-after-dropdown-value-selection-when-animate-true/4644 "2017-06-27T07:59:50Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![romain](https://avatars.discourse-cdn.com/v4/letter/r/c2a13f/32.png) [@romain](https://community.plotly.com/u/romain)
#### Post date: [June 27, 2017, 7:59am UTC](https://community.plotly.com/t/graphs-are-not-automatically-updated-after-dropdown-value-selection-when-animate-true/4644/1 "2017-06-27T07:59:50Z")

</div>

Hi !  
I’m building a dashboard using Dash (love it by the way) and started to use interactivity with dropdowns.  
The logic works perfectly, however I need to double-click on all my graphs to update them after I selected a value (they get empty otherwise).\

Looks like graphs update is not automated either in the example here with multiple inputs : [https://plot.ly/dash/getting-started-part-2](https://plot.ly/dash/getting-started-part-2) (although it does refresh sometimes).

Is this something you noticed too?  
Thanks !

---

<div class="post-metadata">

### Author: ![chriddyp](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/chriddyp/32/16855_2.png) [@chriddyp](https://community.plotly.com/u/chriddyp)
#### Post date: [June 27, 2017, 2:17pm UTC](https://community.plotly.com/t/graphs-are-not-automatically-updated-after-dropdown-value-selection-when-animate-true/4644/2 "2017-06-27T14:17:02Z")

</div>

Thanks for reporting @romain! I’m actually not sure what you are referring to in this case. Could you:

- Take a screencast GIF or video and post it here? (I luse [LICEcap](http://www.cockos.com/licecap/) to take gifs)
- Paste a very simple code example

Thanks!

---

<div class="post-metadata">

### Author: ![romain](https://avatars.discourse-cdn.com/v4/letter/r/c2a13f/32.png) [@romain](https://community.plotly.com/u/romain)
#### Post date: [June 27, 2017, 4:17pm UTC](https://community.plotly.com/t/graphs-are-not-automatically-updated-after-dropdown-value-selection-when-animate-true/4644/3 "2017-06-27T16:17:35Z")

</div>

Thanks for the quick reply @chriddyp !  
Here’s a quick demo of what I meant:

 ![](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/b/b0952ea3ffca9ec62fa093bb23066e33a3acc44b.gif)

Also adding my code below :

```
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import plotly.graph_objs as go
import pandas as pd
import pickle

df = pd.DataFrame(pickle.load(open(data.pickle","rb")))

app = dash.Dash()

app.layout = html.Div([
	html.H4('Select:'),
dcc.Dropdown(
	id='dd-select',
options=[
     {'label': label, 'value': label} for label in df.dropdown.unique()
],
   value= "AAAAA"
),
	dcc.Graph(id='graph1', animate=True),
	dcc.Graph(id='graph2', animate=True),
	dcc.Graph(id='graph3', animate=True)
], style={'width': '50%','margin':'0 auto'})

def generate_callback_box(graph):
 @app.callback(
dash.dependencies.Output(graph, 'figure'),
[dash.dependencies.Input('dd-select', 'value')])

	def update_figure(dd):
		filtered_df = df[df.dropdown == dd]
		traces = []
		for i in ['top','bottom']:
			df_by_rank = filtered_df[filtered_df['rank'] == i]
			traces.append(go.Box(
				x = df_by_rank[graph],
				opacity=0.7,
				marker={
					'size': 15,
					'line': {'width': 0.5, 'color': 'white'}
				},
				name=i,
				boxpoints = False
			))

		return {
			'data': traces,
			'layout': go.Layout(
				title=column_meta[graph]["title"],
				yaxis={'title': '', 'autorange' : 'reversed'},
				legend={'x': 0, 'y': 1},
				hovermode='closest'
			)
		}

	

for col in ["graph1","graph2","graph3"]:
	generate_callback_box(col)
	
	
if __name__ == ' __main__':
app.run_server(debug=True)
```

---

<div class="post-metadata">

### Author: ![romain](https://avatars.discourse-cdn.com/v4/letter/r/c2a13f/32.png) [@romain](https://community.plotly.com/u/romain)
#### Post date: [June 29, 2017, 8:14am UTC](https://community.plotly.com/t/graphs-are-not-automatically-updated-after-dropdown-value-selection-when-animate-true/4644/4 "2017-06-29T08:14:07Z")

</div>

Hi !  
Any further ideas on how to fix this ?  
Thanks !

---

<div class="post-metadata">

### Author: ![raghunath](https://avatars.discourse-cdn.com/v4/letter/r/7993a0/32.png) [@raghunath](https://community.plotly.com/u/raghunath)
#### Post date: [June 29, 2017, 10:24am UTC](https://community.plotly.com/t/graphs-are-not-automatically-updated-after-dropdown-value-selection-when-animate-true/4644/5 "2017-06-29T10:24:33Z")

</div>

Hi @romain

I’ve made few dashboards wit dash comprising of selecting values from drop-downs. So far no issues, works fine.

I can help you if you post link to a csv file of your data.

-R

---

<div class="post-metadata">

### Author: ![chriddyp](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/chriddyp/32/16855_2.png) [@chriddyp](https://community.plotly.com/u/chriddyp)
#### Post date: [June 29, 2017, 2:51pm UTC](https://community.plotly.com/t/graphs-are-not-automatically-updated-after-dropdown-value-selection-when-animate-true/4644/6 "2017-06-29T14:51:05Z")

</div>

Thanks for posting the code @romain! As @raghunath pointed out, we’ll need the actual data or some example data so that we can run this example on our own machines.

---

<div class="post-metadata">

### Author: ![flouvet](https://avatars.discourse-cdn.com/v4/letter/f/b38774/32.png) [@flouvet](https://community.plotly.com/u/flouvet)
#### Post date: [June 30, 2017, 7:36pm UTC](https://community.plotly.com/t/graphs-are-not-automatically-updated-after-dropdown-value-selection-when-animate-true/4644/7 "2017-06-30T19:36:28Z")

</div>

Hi there, I’ve had the same problem.

My code:

```
  # -*-coding:utf-8-*-
import dash
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd

app = dash.Dash()

df = pd.read_csv('extract.csv')

categories = df['cat'].unique()

app.layout = html.Div([
    html.Div([
        dcc.Dropdown(
            id='cats',
            options=[{'label': category, 'value': category}
                     for category in categories],
            multi=True,
        ),
        dcc.Graph(id='graph', animate=True),
    ]),
])

@app.callback(
    dash.dependencies.Output(component_id='graph',
                             component_property='figure'),
    [dash.dependencies.Input(component_id='cats', component_property='value')])
def update_graph(cat_list):
    if not cat_list:
        cat_list = categories
    level_data = df[df.cat.isin(cat_list)]\
        .groupby('date')['level1', 'level2']\
        .sum()\
        .sort_index()\
        .iloc[-30:, :]
    print(level_data)
    return {
        'data': [{'x': level_data.index, 'y': level_data.level1, 'type': 'bar'},
                 {'x': level_data.index, 'y': level_data.level2, 'type': 'bar'}],
        'layout': {'barmode': 'stack'}
    }

if __name__ == ' __main__':
    app.run_server()

```

I’ve found with a little of experimenting that the problem only occur when **animate** is set to True on the dcc Graph component. I"ve not tested all type of graphs, but the problem does not occur when setting the chart type to **scatter**.

If you wanna test with the data file here it is: [https://github.com/FlorianLouvetRN/data\_up/blob/master/extract.csv](https://github.com/FlorianLouvetRN/data_up/blob/master/extract.csv)

Thanks,  
Florian

---

<div class="post-metadata">

### Author: ![romain](https://avatars.discourse-cdn.com/v4/letter/r/c2a13f/32.png) [@romain](https://community.plotly.com/u/romain)
#### Post date: [July 3, 2017, 7:13am UTC](https://community.plotly.com/t/graphs-are-not-automatically-updated-after-dropdown-value-selection-when-animate-true/4644/8 "2017-07-03T07:13:23Z")

</div>

Indeed, this gets fixed when changing animate=True to none.  
Thanks !

---

<div class="post-metadata">

### Author: ![chriddyp](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/chriddyp/32/16855_2.png) [@chriddyp](https://community.plotly.com/u/chriddyp)
#### Post date: [July 3, 2017, 8:37pm UTC](https://community.plotly.com/t/graphs-are-not-automatically-updated-after-dropdown-value-selection-when-animate-true/4644/9 "2017-07-03T20:37:18Z")

</div>

Ahhhh. Thanks for reporting @romain and @fllouvent!

Indeed, `animate=True` isn’t super well supported now. It will be better supported soon. Perhaps I’ll remove it from the docs for now.
