更新睡眠报告

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

@@ -12,7 +12,8 @@ import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
import 'package:vbvs_app/pages/sleep_report/chart/ScatterPlotChart.dart';
class HeartPointWidget extends StatefulWidget {
HeartPointWidget({super.key});
var sleepReport;
HeartPointWidget({super.key, required this.sleepReport});
@override
State<HeartPointWidget> createState() => _HeartPointWidgetState();
@@ -36,17 +37,39 @@ class _HeartPointWidgetState extends State<HeartPointWidget> {
@override
Widget build(BuildContext context) {
List<ScatterSpot> data = List.generate(200, (index) {
// 随机生成 x 和 y 值,范围都在 0-1400 之间
double x = Random().nextDouble() * 1400; // x 值在 0-1400 范围
double y = Random().nextDouble() * 1400; // y 值也在 0-1400 范围
if (widget.sleepReport == null ||
widget.sleepReport['hrsp'] == null ||
widget.sleepReport['hrsp'].isEmpty) {
return Container();
}
// List rawData = widget.sleepReport['hrsp'];
// List<ScatterSpot> data = List.generate(200, (index) {
// // 随机生成 x 和 y 值,范围都在 0-1400 之间
// double x = Random().nextDouble() * 1400; // x 值在 0-1400 范围
// double y = Random().nextDouble() * 1400; // y 值也在 0-1400 范围
// 返回 ScatterSpot使用圆点绘制器自定义大小和颜色
return ScatterSpot(
x,
y,
);
});
// // 返回 ScatterSpot使用圆点绘制器自定义大小和颜色
// return ScatterSpot(
// x,
// y,
// );
// });
double maxX = 0;
double maxY = 0;
List<ScatterSpot> data = [];
List rawData = widget.sleepReport['hrsp'];
try {
data = rawData.map<ScatterSpot>((item) {
double x = (item['st'] ?? 0).toDouble();
double y = (item['value'] ?? 0).toDouble();
if (x > maxX) maxX = x;
if (y > maxY) maxY = y;
return ScatterSpot(x, y);
}).toList();
} catch (e) {
print(e);
}
return Container(
width: double.infinity,
@@ -120,8 +143,8 @@ class _HeartPointWidgetState extends State<HeartPointWidget> {
),
child: ScatterPlotChart(
points: data,
xMax: 1400, // x轴最大值
yMax: 1400, // y轴最大值
xMax: maxX.toInt(), // x轴最大值
yMax: maxY.toInt(), // y轴最大值
pointColor: stringToColor("#00C1AA"), // 点的颜色
divisions: 7, // 刻度分割数量
),