Implementation
Future<List<BarDataDay>?> fetchGraphData() async {
currentStartAt = selectedDateTime.subtract(Duration(days: _selectedGraphViewType.subDays));
currentEndAt = selectedDateTime;
List<CowData>? cowData = await ApiService().fetchCowData(queryParameters: {
"cow_ids": '["${report.cow?.id}"]',
"start_at": DateFormat(StringConstants.timeYMDDashFormat).format(selectedDateTime.subtract(Duration(days: _selectedGraphViewType.subDays))),
"end_at": DateFormat(StringConstants.timeYMDDashFormat).format(selectedDateTime),
"hour_unit": _selectedGraphViewType.hourUnit.toString(),
});
barItemsDay = Helper().convertCowDataToGraphData(
cowData: cowData,
targetDateTime: selectedDateTime,
continuedDays: report.continuedDays == null ? 0 : report.continuedDays!,
graphViewType: _selectedGraphViewType,
actionType: selectedAction,
);
return barItemsDay;
}