· Looking for a cofounder

Data preparation for bar chart - make 2 lists like with a "group by" + sum

Custom Code

I have been stuck on this for days and am turning to the community for help. I am very recent to flutterflow.

What I am trying to do

I want to add a bar chart to my page.

X-axis: dates

Y-axis: CO2 consumption

I have a collection named LogData in Firebase, which contains the fields date and co2. I can have several logs for a same day, therefore I need to sum for each date in order to get the right data for the graph.

What I tried

I tried manipulating the data directly within the chart widget but that didn't work. I understand now I need to pass 2 lists as input, one for date and one for SUM(CO2).

I tried creating 2 page state variables as lists (one for date, one for SUM(co2)) and setting their value from a custom function. I tried getting help from Copilot to write the function but no proposition was running and I couldn't debug.

My questions

  • What functions do I need to create the list?

  • If I create 2 custom functions making list, how can I ensure that the right sum is in front of the right date (coherence of indexes)?

  • Is there a better way to do this?

I come from the world of relational databases and this seems overly complicated to me when a simple groupby in SQL would have done the trick

What have you tried so far?

All above + flutterflow documentation + community knowledge base

Did you check FlutterFlow's Documentation for this topic?
Yes
1
1 reply