Genie Discord forum
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.
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
@page("/", "app.jl.html") end
ERROR: [ Info: 2023-07-13 07:15:58 Watching "/Users/stef/.julia/geniebuilder/apps/happonomycockpit"
df not defined
in expression starting at /Users/stef/.julia/geniebuilder/apps/happonomycockpit/app.jl:20
1 top-level scope
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?
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
The above error is generated when the nocode window opens.
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.
I've made a note to clarify this in the docs, and explain the reasoning behind as well 🙂
Thanks! Got it working now 🙂