Multi-output callback error in tutorial
jfb-h opened this issue · comments
On running the tutorial example on callbacks, I run into the following error:
┌ Error: error handling request │ exception = │ Invalid callback return value: The callback graph.figure is a multi-output. │ Expected the output type to be a list or tuple but got: │ {"layout":{"xaxis1":{"type":"log","title":"GDP Per Capita", [truncated because of long output] │ Stacktrace: │ [1] validate_callback_return(::Array{NamedTuple{(:id, :property),Tuple{String,String}},1}, ::Plot{Array{AbstractTrace,1},Layout{Dict{Symbol,Any}},Array{PlotlyFrame,1}}, ::Symbol) at C:\Users\Jakob\.julia\packages\Dash\OP7s2\src\handler\processors\callback.jl:81
Here's the code:
using DataFrames, Dash, DashHtmlComponents, DashCoreComponents, PlotlyJS, UrlDownload
df1 = DataFrame(urldownload("https://raw.githubusercontent.com/plotly/datasets/master/gapminderDataFiveYear.csv"))
years = unique(df1[!, :year])
app = dash()
app.layout = html_div() do
dcc_graph(id = "graph"),
dcc_slider(
id = "year-slider-1",
min = minimum(years),
max = maximum(years),
marks = Dict([Symbol(v) => Symbol(v) for v in years]),
value = minimum(years),
step = nothing,
)
end
callback!(
app,
Output("graph", "figure"),
Input("year-slider-1", "value"),
) do selected_year
return Plot(
df1[df1.year .== selected_year, :],
Layout(
xaxis_type = "log",
xaxis_title = "GDP Per Capita",
yaxis_title = "Life Expectancy",
legend_x = 0,
legend_y = 1,
hovermode = "closest",
transition_duration = 500
),
x = :gdpPercap,
y = :lifeExp,
text = :country,
group = :continent,
mode = "markers",
marker_size = 15,
marker_line_color = "white",
)
end
run_server(app, "0.0.0.0", debug = true)
I'm on Julia 1.5 and here's my environment status:
[1b08a953] Dash v0.1.3 [a03496cd] PlotlyBase v0.4.1 [f0f68f2c] PlotlyJS v0.14.0
So on a fresh session and after restarting the computer the issues are gone - the package versions are the same, so not sure what caused it. Sorry for the false alarm!
the issues are gone
@jfb-h This is good, because I have been trying to reproduce this error for several days now
Thank you for using Dash!
Thanks for looking into it. If it happens again I'll try to narrow down the cause and let you know.