What I’m trying to do:
I’m trying to get all the data out of a table more quickly so I can build a graph in plotly without the delay.
I currently have a table called ‘co2mlweekly’ that has 2 columns: ‘date’ & ‘average’. There are approximately 2,600 rows in the table.
I want to use all of the data from the table to build the graph. It does not need to be filtered in any way.
Under my current approach, it takes up to 5 seconds to build the graph.
Is there a way to pull all the data from the table at once, in one call? Or some other way of doing this?
Alternatively, is there a way for Anvil to cache the data or the graph?
Thanks.
What I’ve tried and what’s not working:
Currently my code builds two lists with:
datelist = [r['date'] for r in app_tables.co2mlweekly.search()]
co2list = [r['average'] for r in app_tables.co2mlweekly.search()]
then uses these lists to build the trace for the graph with
trace_co2 = go.Scatter(x=datelist,
y=co2list,
mode='lines',
)
Clone link: