Genie Discord forum

Author AvatarMordegai
7/13/2023, 5:32:44 AM

I'm building an app where I want to display some data from a DataFrame. The plot can be drawn when the app starts up so I wanted to create the DataFrame and then use one column for the x-axis and the other for the y-axis of the plot but when I execute the following code I get the error below.

include("overshoot.jl")

set up Genie development environmet <- There is also a typo in the generated comment

using GenieFramework using Dates using .Overshoot @genietools

@app begin @in consumption_date = today()

@out consumed_on = string(calculate_used_date(today()))
@out consuming = string(calculate_using_date(today()))

df = create_df()
@out day_weights = PlotData[PlotData(x = df.year, y = df.weight)]

@onchange consumption_date begin
    consumed_on = string(calculate_used_date(consumption_date))
    consuming = string(calculate_using_date(consumption_date))
end

end

@page("/", "app.jl.html") end

ERROR: [ Info: 2023-07-13 07:15:58 Watching "/Users/stef/.julia/geniebuilder/apps/happonomycockpit" LoadError: UndefVarError: df not defined in expression starting at /Users/stef/.julia/geniebuilder/apps/happonomycockpit/app.jl:20 Stacktrace: 1 top-level scope @ none:1 in expression starting at /Users/stef/.julia/geniebuilder/apps/happonomycockpit/app.jl:12

I'm guessing I can not just use variables like I normally would?

Author AvatarMordegai
7/13/2023, 6:50:01 AM

When I change the code so that I use the create_df() function instead of the df variable, it displays the plot but I still get an error: Error: 2023-07-13 08:47:42 GET /stippleui.jl/master/assets/css/quasar.min.css 404 โ”” @ Genie.Router ~/.julia/packages/Genie/XpFvB/src/Router.jl:202

Author AvatarMordegai
7/13/2023, 8:09:26 AM

The above error is generated when the nocode window opens.

Author AvatarPere
7/13/2023, 9:10:14 AM

The issue is that the df variable needs to be defined outside of the @app block. Any function or variable that is used to initialize a reactive @in or @out variable must be previously defined before @app.

As for the Router.jl error, we're aware of it but it should not impact your app in any way.

Author AvatarPere
7/13/2023, 9:20:28 AM

I've made a note to clarify this in the docs, and explain the reasoning behind as well ๐Ÿ™‚

Author AvatarMordegai
7/13/2023, 9:21:34 AM

Thanks! Got it working now ๐Ÿ™‚