Hello! Is it possible to dynamically adjust the t...
# gooddata-cloud
j
Hello! Is it possible to dynamically adjust the time granularity of a line chart based on the selected date filter range? e.g. If I use a "Trend By" date, grouped by month, this works great for date filter periods of months or years. However if I select "Last Week", I get one data point, but I would instead prefer to have it group by day. Is there a "best fit" option, or a way to automatically (or even manually) adjust the "Trend By" grouping based on the selected date filter? See thread for example
k
GoodData does not currently support automatic or "best fit" adjustment of the time granularity ("Trend By") in a line chart based on the selected date filter range. This means that if you set your chart to group by month, and then select a short date range (like "Last Week"), you may end up with only a single data point, rather than the chart automatically switching to group by day for that range. This limitation is confirmed by GoodData support staff, who have stated that dynamic adjustment of the x-axis date dimension based on the applied date range is not available, but this feedback has been passed to the Product team for consideration in future development [Community Slack](https://gooddataconnect.slack.com/archives/C04S1MSLEAW/p1737714283714999?thread_ts=1737714283.714999&cid=C04S1MSLEAW). Manual Adjustment: You can manually change the granularity by updating the "Trend By" attribute in your visualization. In custom dashboard plugins, you can implement a dropdown or similar UI to let users select the desired granularity (e.g., day, week, month) and update the chart accordingly. This is typically done by managing the
trendBy
prop in your chart component and updating it based on user selection [Community Slack](https://gooddataconnect.slack.com/archives/C01UR5BGAHY/p1724859800020409?thread_ts=1724859800.020409&cid=C01UR5BGAHY). Example (React/GoodData.UI):
Copy code
javascript const ExampleLineChart = () => {     const [trendBy, setTrendBy] = useState(Md.DateMonth.Short);     // ...dropdown to select trendBy (day, week, month, etc.)     return (         <LineChart             measures={[/* your measures */]}             trendBy={trendBy}             // other props         />     ); };
You would need to provide the logic for the dropdown and update
trendBy
accordingly. Summary: - There is no built-in "auto" or "best fit" granularity switch based on the date filter. - Manual adjustment is possible, and you can build a plugin or UI control to let users select the granularity themselves. - This feature has been requested and is under consideration for future releases. For more details, see the relevant community discussions and documentation: - [Community Slack discussion on dynamic granularity](https://gooddataconnect.slack.com/archives/C04S1MSLEAW/p1737714283714999?thread_ts=1737714283.714999&amp;cid=C04S1MSLEAW) - [Plugin implementation advice](https://gooddataconnect.slack.com/archives/C01UR5BGAHY/p1724859800020409?thread_ts=1724859800.020409&amp;cid=C01UR5BGAHY)