The Chart widget has difficulties handling date/time values -- which are typically used for the horizontal axis for plotting data (on y axis) against time stamps.
If naively used, DateTime
values cause the Chart widget to simply appear to hang, with no error or exception - just, apparently, stalled.
DateTime
values are in practice numerical values (microsecond counts since epoch time) so in principle, should work as legitimate Chart data values. However, they are relatively large numbers - eg 1713121740000000 is the DateTime
for 2024-04-14 20:09:00.000.
In the Chart no-code GUI design interface, if you enable the Show Labels
setting for an (eg x-) axis of DateTime
values, the default setting for the axis Label Interval
is 10. Thus, if you simply use this default setting as the intervals to be used on an axis of DateTime
values, then the Chart widget will attempt to set axis label values at 10 microsecond intervals: 171312174000000, 1713121740000010, 1713121740000020.... This cause the Chart widget to go into a very long long loop and, so, your application hangs and is apparently stalled....
If you increase the Label Interval
to be a more suitable very large number -- such as 10000000000 -- then the Chart application no longer hangs, and works ... well, sort-of.
The problem now of course is that although the Chart widget no longer hangs, but instead it displays numerical DateTime
values on your axis -- such as 1713121740000000 rather than maybe what you really want, like 14/4/2024.
The workaround which I use is to suppress/disable the Show Labels
setting for the DateTime
axis, and (in the case of the x-axis) instead to append a Row immediately below the Chart widget, whose children are a list of Text widgets, each containing appropriately formatted DateTime
strings.
A minor challenge is that Flutterflow does not easily seem to support you building a Row widget with a (dynamically-sized, at run-time) list of (Text) widgets as children, in which only some subset of the child widgets are displayed. Since there may be too many values to fit neatly into the available horizontal space, you almost certainly want to filter the full list of date stamp values (eg only 5, equally spaced, date/time values from a full list of say 20 values). Sure, you can use a ListView with a horizontal layout and some carefully crafted conditional visibility on the generated child widgets. But coming from a Flutter/Dart background into Flutterflow, I instead wrote my own custom widget which takes a list of DateTime
values, and returns a Row widget with a subset list of Text children, each holding formatted date/time strings.
A demo version of my code (including the custom widget) is published at here