更新睡眠报告

This commit is contained in:
wyf
2025-05-27 23:09:31 +08:00
parent e0fef11b33
commit 98cd7f4e6a
54 changed files with 4450 additions and 1160 deletions

View File

@@ -1,17 +1,20 @@
import 'package:flutter/material.dart';
import 'package:ef/ef.dart';
import 'package:fl_chart/fl_chart.dart';
import 'package:flutter/material.dart';
import 'package:vbvs_app/common/color/appConstants.dart';
import 'package:vbvs_app/common/util/FitTool.dart';
import 'package:vbvs_app/common/util/MyUtils.dart';
class SleepRadarChart extends StatelessWidget {
final Map<String, double> today;
final Map<String, double> yesterday;
final List<Map<String, dynamic>> data;
const SleepRadarChart({
Key? key,
required this.today,
required this.yesterday,
}) : super(key: key);
const SleepRadarChart({Key? key, required this.data}) : super(key: key);
// const SleepRadarChart({
// Key? key,
// required this.today,
// required this.yesterday,
// }) : super(key: key);
@override
Widget build(BuildContext context) {
@@ -27,74 +30,48 @@ class SleepRadarChart extends StatelessWidget {
}
Widget _buildRadarChart() {
return AspectRatio(
aspectRatio: 1.3,
child: RadarChart(
RadarChartData(
dataSets: [
// 今日数据
RadarDataSet(
dataEntries: [
RadarEntry(value: today['type1']!), // 呼吸暂停
RadarEntry(value: today['type2']!), // 入睡时间
RadarEntry(value: today['type3']!), // 离床次数
RadarEntry(value: today['type4']!), // 深睡比例
RadarEntry(value: today['type5']!), // 睡眠时长
],
borderColor: stringToColor("#00C1AA"),
borderWidth: 2,
fillColor: Colors.transparent,
entryRadius: 0,
),
// 昨日数据
RadarDataSet(
dataEntries: [
RadarEntry(value: yesterday['type1']!), // 呼吸暂停
RadarEntry(value: yesterday['type2']!), // 入睡时间
RadarEntry(value: yesterday['type3']!), // 离床次数
RadarEntry(value: yesterday['type4']!), // 深睡比例
RadarEntry(value: yesterday['type5']!), // 睡眠时长
],
borderColor: stringToColor("#FFD251"),
borderWidth: 2,
fillColor: Colors.transparent,
entryRadius: 0,
),
],
radarBackgroundColor: stringToColor("#343844"),
radarBorderData:
BorderSide(color: themeController.currentColor.sc4, width: 1),
radarShape: RadarShape.polygon,
titlePositionPercentageOffset: 0.2,
titleTextStyle: TextStyle(
fontSize: AppConstants().normal_text_fontSize,
color: themeController.currentColor.sc3),
getTitle: (index, angle) {
switch (index) {
case 0:
return RadarChartTitle(text: '呼吸暂停');
case 1:
return RadarChartTitle(text: '入睡时间');
case 2:
return RadarChartTitle(text: '离床次数');
case 3:
return RadarChartTitle(text: '深睡比例');
case 4:
return RadarChartTitle(text: '睡眠时长');
default:
return const RadarChartTitle(text: '');
}
},
tickCount: 5,
ticksTextStyle:
const TextStyle(color: Colors.transparent, fontSize: 10),
// ticksColor: Colors.grey.shade300,
gridBorderData: BorderSide(color: Colors.transparent, width: 1),
tickBorderData:
BorderSide(color: themeController.currentColor.sc4, width: 1),
),
swapAnimationDuration: const Duration(milliseconds: 400),
return AspectRatio(
aspectRatio: 1.3,
child: RadarChart(
RadarChartData(
dataSets: [
// 今日数据
RadarDataSet(
dataEntries: data.map((e) => RadarEntry(value: (e['t'] as num).toDouble())).toList(),
borderColor: stringToColor("#00C1AA"),
borderWidth: 2,
fillColor: Colors.transparent,
entryRadius: 0,
),
// 昨日数据
RadarDataSet(
dataEntries: data.map((e) => RadarEntry(value: (e['y'] as num).toDouble())).toList(),
borderColor: stringToColor("#FFD251"),
borderWidth: 2,
fillColor: Colors.transparent,
entryRadius: 0,
),
],
radarBackgroundColor: stringToColor("#343844"),
radarBorderData: BorderSide(
color: themeController.currentColor.sc4, width: 0.5.rpx),
radarShape: RadarShape.polygon,
titlePositionPercentageOffset: 0.2,
titleTextStyle: TextStyle(
fontSize: AppConstants().normal_text_fontSize,
color: themeController.currentColor.sc3),
getTitle: (index, angle) {
return RadarChartTitle(text: data[index]['name'] ?? '未知'.tr);
},
tickCount: 5,
ticksTextStyle: const TextStyle(color: Colors.transparent, fontSize: 10),
gridBorderData: BorderSide(color: Colors.transparent, width: 1),
tickBorderData: BorderSide(
color: themeController.currentColor.sc4, width: 0.5.rpx),
),
);
}
swapAnimationDuration: const Duration(milliseconds: 400),
),
);
}
}