Genie Discord forum

Author Avatarpyplox
8/25/2023, 3:44:25 PM

I am new to Genie and have worked through the CSVAnalysis tutorial (https://learn.geniecloud.io/tutorials/written/csv-uploader). Currently, the app updates the histogram only if the chosen column is in the chosen data set.

if selected_column in columns
    irisplot = PlotData(x=data[!, selected_column], plot=StipplePlotly.Charts.PLOT_TYPE_HISTOGRAM)
end

Is it possible to instead change the value of selected_column to, say, the first entry in columns whenever the data set changes?

Thank you!

Author AvatarPere
8/28/2023, 10:03:12 AM

Yes, you would have to add a new handler for selected_file that does something like this

@onchange selected_file
  selected_column = names(data)[1]
end

Note that this would also trigger the previous handler and update the plot

Author Avatarpyplox
8/28/2023, 12:55:59 PM

Thanks a lot for your help! ๐Ÿ™‚

Author Avatarpyplox
8/28/2023, 1:46:00 PM

A short addition if someone else digs up this thread in the future: @onchange seems to introduce a local scope, and the tutorial defined data for the first time inside the other handler. With this architecture, setting up a new handler results in the second handler not finding data. I solved this by initialising data outside the @handlers block, like @out data = DataFrame(). Please correct me if this is not a good solution!