Server calls are relatively slow. Meaning, if you do many anvil.server.call('your_server_module_code')
in order to load a Form, it can greatly decrease the load times of the page.
In your code, you make 5 calls to the server, in order to load the dashboard.
This could be optimized, by having a single server call, which gets retrieves the data on the server side, and returns the data to the client once.
Something like:
Server code: (Not tested code)
@anvil.server.callable
def get_plots():
result = {
"plot1": create_plots(),
"plot2": create_plots2(),
"plot3": create_plots3(),
"plot4": create_plots4(),
}
return result
Client code: (Not tested code)
# Client Dashboard Code
class dashboard(dashboardTemplate):
def __init__(self, **properties):
# Set Form properties and Data Bindings.
self.init_components(**properties)
self.ass()
# Any code you write here will run when the form opens.
plots = anvil.server.call('get_plots')
self.plot_1.figure=plots['plot1']
self.plot_2.figure=plots['plot2']
self.plot_3.figure=plots['plot3']
self.plot_4.figure=plots['plot4']
This should speed up the load time significantly.
The last call to dfa = anvil.server.call('get_dash')
could be included in the above code somehow, for even more optimization.
Some reading for more info and tips:
https://anvil.works/forum/t/suggestions-to-optimize-performance/3318