This seems like a match made in heaven for parameters and dynamic dimensions. Try looking at this discourse thread Great Use Cases for Parameter Fields to understand a bit better. Essentially, you’ll want to create a parameter for your users (or your API) to select from allowed values, corresponding to the date buckets you require. From there, create a dimension (selected_period) with CASE WHENs in the SQL to select the appropriate date period you’re after, and make sure that’s your x-axis dimension. To make the dimension dynamic, it’s as simple as referencing the parameter’s value with Liquid tags. Hope I answered your question alright!
As an aside - since your UI appears to force the selection of one of your date buckets, this won’t be a problem, but typically I’d populate the ELSE clause of your parameter with whatever default dimension your business users would like to see (i.e. week, etc.) for the situation when the parameter isn’t populated. Alternatively, you could apply a default_value to your parameter.
EDIT: Scrolling further down in the Discourse thread yields more gold. Check out brettg’s post on on using the liquid conditions and _parameter_value instead of CASE WHEN, though I can’t comment on the performance difference.