Chart.js grouping by month (timestamptz - Supabase)

I’m currently applying a filter using filterByKey() to get an array of values with many different keys/fields within them, one of them being the created_at column that is created by default for tables in Supabase.

However, I don’t see an obvious way to group by month (see screenshot below) - only a way to group by timestamp, which will never line up because it is as granular as by the second.

Is there a way to group by month?

Hi @michaeln :wave:

Are you using the graph in Advanced or Guided mode?

A couple of ideas:

  • you could manipulate the data with a function in Supabase so data that comes through WeWeb is by month
  • you could manipulate the data in WeWeb, for example iterate through the collection with a for loop in a workflow to format the created_at value in YYYYMM format

Does that make sense?

It was made in Guided mode - I’ll have to give Advanced mode a second pass.

This makes sense! We ended up just adding columns in Supabase to break down the date for future entries. In terms of migrating, using a for loop makes the most sense - thanks for the suggestion!

1 Like

You’re welcome!

Regarding my question about Advanced vs Guided, I think you could achieve what you’re trying to do in both modes.

The mode you choose will influence how your data needs to be formatted though:

  • the Guided mode expects a single array of objects so the data needs to be in the objects
  • whereas the Advanced mode allows you to bind multiple data sets that relate to each other BUT the related items need to be in the exact same order in each data set for it to work.

So in Advanced mode, you would need to have:

  • one array with the name of the event for example [event1, event 2, event3], and
  • one array with the date of the event [Jan1, Jan 6, Jan 9]

But if event 3 happened on Jan 6, the first array would need to be [event1, event 3, event2]

In Guided mode, you would need only one array and could rearrange it at will, for example:
[{"event_name":"event1", "event_date":"Jan1"},{"event_name":"event3", "event_date":"Jan6"},{"event_name":"event2", "event_date":"Jan9"}]

It wouldn’t matter that event3 comes before event2.

For me, Advanced mode is way easier to mess up but some people prefer it. Whatever works for you!