What I’m trying to do:
I have a column in the data table that has values of say 1,2,3,4,5,6… each row can have one of these values.
I would like to plot these values in the pie graph that would represent the amount of time they show up.
The curve ball is these values are not set is the number or value.
Is there a clean way to search the amount of unique items in a data table column and count each item?
note my code below works, it is just slowwwww.
What I’ve tried and what’s not working:
Code Sample:
# this is a formatted code snippet.
# paste your code between ```
# Server side code
@anvil.server.callable
def make_product_select_plot():
plot_data = get_df()
prod_list = [r['filler_product'] for r in app_tables.iosense1.search()]
prod_set = set(prod_list)
prod_count = []
prod_name = []
x = range1(1, len(prod_set))
for n in x:
count = prod_list.count(n)
prod_count.append(count)
prod_name.append(f'Product{n}')
print(prod_count)
print(prod_name)
fig = go.Figure(data= [go.Pie(labels=prod_name, values=prod_count)])
return fig