Since you’re using Plotly, you can return the figure instead of the HTML. On my timings that takes the time for the showmap
server call from 5 seconds to 1 second (roughly). Then assign the figure to a plot component on the client:
@anvil.server.callable
def showmap(added_state):
state = added_state
fig = px.choropleth(locations=state, locationmode="USA-states", color_continuous_scale=[(0, 'yellow'), (0.5, 'orange'), (1, 'red')], scope="usa")
fig.update_layout(title_text="Coverage Map")
return fig
class Search_By_Zipcode(Search_By_ZipcodeTemplate):
def __init__(self, **properties):
# Set Form properties and Data Bindings.
self.init_components(**properties)
# Any code you write here will run before the form opens.
self.state = ["CA", "AZ"]
map_fig = anvil.server.call('showmap',self.state)
self.plot_1.figure = map_fig
Since I’m also not seeing the large amount of time you’re seeing, that may or may not have an impact on your situation.