The error you get is because somewhere you're trying to access something like a data frame while it isn't
data = c(1:5)
data$number
Error in data$number : $ operator is invalid for atomic vectors
Could you please again create a reprex. We need to be able to reproduce the error in order to be able to solve the issue.
Let me remind you that we don't need the full app, just a slimmed down version of the app that runs only the plot of interest. Also make sure that you provide a data frame instead of the database lookup, we won't have access to it.