mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
fixed datetimes in occupancy heatmap. (#301)
<!-- Thanks for contributing! Provide a description of your changes below and a general summary in the title Please look at the following checklist to ensure that your PR can be accepted quickly: --> ## Description <!--- Describe your changes in detail --> ## Type of Change <!--- Put an `x` in all the boxes that apply: --> - [ ] ✨ New feature (non-breaking change which adds functionality) - [ ] 🛠️ Bug fix (non-breaking change which fixes an issue) - [ ] ❌ Breaking change (fix or feature that would cause existing functionality to change) - [ ] 🧹 Code refactor - [ ] ✅ Build configuration change - [ ] 📝 Documentation - [ ] 🗑️ Chore
This commit is contained in:
@ -14,14 +14,18 @@ class OccupancyHeatMapModel extends Equatable {
|
||||
});
|
||||
|
||||
factory OccupancyHeatMapModel.fromJson(Map<String, dynamic> json) {
|
||||
final eventDate = json['event_date'] as String? ?? '${DateTime.now()}';
|
||||
final year = eventDate.split('-')[0];
|
||||
final month = eventDate.split('-')[1];
|
||||
final day = eventDate.split('-')[2];
|
||||
final eventDate = json['event_date'] as String?;
|
||||
final year = eventDate?.split('-')[0];
|
||||
final month = eventDate?.split('-')[1];
|
||||
final day = eventDate?.split('-')[2];
|
||||
|
||||
return OccupancyHeatMapModel(
|
||||
uuid: json['uuid'] as String? ?? '',
|
||||
eventDate: DateTime(int.parse(year), int.parse(month), int.parse(day)),
|
||||
eventDate: DateTime(
|
||||
int.parse(year ?? '2025'),
|
||||
int.parse(month ?? '1'),
|
||||
int.parse(day ?? '1'),
|
||||
).toUtc(),
|
||||
countTotalPresenceDetected: num.parse(
|
||||
json['count_total_presence_detected']?.toString() ?? '0',
|
||||
).toInt(),
|
||||
|
@ -52,7 +52,7 @@ class _InteractiveHeatMapState extends State<InteractiveHeatMap> {
|
||||
color: Colors.transparent,
|
||||
child: Transform.translate(
|
||||
offset: Offset(-(widget.cellSize * 2.5), -50),
|
||||
child: HeatMapTooltip(date: item.date, value: item.value),
|
||||
child: HeatMapTooltip(date: item.date.toUtc(), value: item.value),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -20,14 +20,14 @@ class OccupancyHeatMap extends StatelessWidget {
|
||||
: 0;
|
||||
|
||||
DateTime _getStartingDate() {
|
||||
final jan1 = DateTime(DateTime.now().year, 1, 1);
|
||||
final jan1 = DateTime(DateTime.now().year, 1, 1).toUtc();
|
||||
final startOfWeek = jan1.subtract(Duration(days: jan1.weekday - 1));
|
||||
return startOfWeek;
|
||||
}
|
||||
|
||||
List<OccupancyPaintItem> _generatePaintItems(DateTime startDate) {
|
||||
return List.generate(_totalWeeks * 7, (index) {
|
||||
final date = startDate.add(Duration(days: index));
|
||||
final date = startDate.toUtc().add(Duration(days: index));
|
||||
final value = heatMapData[date] ?? 0;
|
||||
return OccupancyPaintItem(index: index, value: value, date: date);
|
||||
});
|
||||
|
Reference in New Issue
Block a user