Skip to content
Advertisement

Callback Error updating figure in Plotly Dash – Dropdown and Output Figure

so today, I’m trying to create a simple dahsboard with data from multiple dataframes. I use the dropdown to select the dataframe to show in the plot. However, when I run this code, I got callback error in the web page says

JavaScript

I don’t understand why this occurs, here is the code

JavaScript

and the input data used is in the form of many dataframes, one of which is like this for well 1

I tried to run defined function only, which build_graph, and it worked like a charm. The result of figure is shown here

Advertisement

Answer

I think I know what the problem is: the variable plot_chosen which is the argument in the function build_graph is a string. As a result you can not type y=plot_chosen['DEPTH_MD']. Although after choosing 15/9-13 on the Dropdown menu it has a value of well1, it does not represent the dataframe but a simple string. Try creating for example a dictionary with the dataframes

JavaScript

and then choose the appropriate DataFrame from the dictionary.
So for example when the user chooses 15/9-13 on the dropdown you will get plot_chosen=’well1′ and you can simply get the dataframe well1 by using dataframes[plot_chosen].

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement