更新睡眠报告
This commit is contained in:
@@ -10,6 +10,7 @@ import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
|
||||
import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/chart/ScatterPlotChart.dart';
|
||||
import 'package:EasyDartModule/EasyDartModule.dart' as es;
|
||||
|
||||
class HeartPointWidget extends StatefulWidget {
|
||||
var sleepReport;
|
||||
@@ -37,125 +38,120 @@ class _HeartPointWidgetState extends State<HeartPointWidget> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
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,
|
||||
// );
|
||||
// });
|
||||
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);
|
||||
}
|
||||
if (widget.sleepReport == null ||
|
||||
widget.sleepReport['hrsp'] == null ||
|
||||
widget.sleepReport['hrsp'].isEmpty) {
|
||||
return Container();
|
||||
}
|
||||
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: themeController.currentColor.sc5,
|
||||
borderRadius: BorderRadius.circular(
|
||||
AppConstants().normal_container_radius), // 你可以按需调整圆角半径
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(26.rpx, 29.rpx, 26.rpx, 45.rpx),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Container(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"心率散点图".tr,
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontSize: AppConstants().title_text_fontSize),
|
||||
),
|
||||
ClickableContainer(
|
||||
backgroundColor: Colors.transparent,
|
||||
highlightColor: Colors.white, // 或设置为你需要的水波纹颜色
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
14.rpx, 0.rpx, 14.rpx, 0), //
|
||||
borderRadius: 0.rpx, // 圆形点击区域
|
||||
onTap: () {
|
||||
showTipDialog(
|
||||
context,
|
||||
Container(
|
||||
child: Text(
|
||||
"心率散点图介绍".tr,
|
||||
style: TextStyle(
|
||||
fontSize: 26.rpx,
|
||||
color: themeController.currentColor.sc3,
|
||||
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,
|
||||
decoration: BoxDecoration(
|
||||
color: themeController.currentColor.sc5,
|
||||
borderRadius: BorderRadius.circular(
|
||||
AppConstants().normal_container_radius), // 你可以按需调整圆角半径
|
||||
),
|
||||
child: Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(26.rpx, 29.rpx, 26.rpx, 45.rpx),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Container(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"心率散点图".tr,
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontSize: AppConstants().title_text_fontSize),
|
||||
),
|
||||
ClickableContainer(
|
||||
backgroundColor: Colors.transparent,
|
||||
highlightColor: Colors.white, // 或设置为你需要的水波纹颜色
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
14.rpx, 0.rpx, 14.rpx, 0), //
|
||||
borderRadius: 0.rpx, // 圆形点击区域
|
||||
onTap: () {
|
||||
showTipDialog(
|
||||
context,
|
||||
Container(
|
||||
child: Text(
|
||||
"心率散点图介绍".tr,
|
||||
style: TextStyle(
|
||||
fontSize: 26.rpx,
|
||||
color: themeController.currentColor.sc3,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
0, 0.rpx, 0.rpx, 0), // 外部 padding 移到内部
|
||||
width: 28.rpx,
|
||||
height: 28.rpx,
|
||||
child: SvgPicture.asset(
|
||||
'assets/img/icon/explain.svg',
|
||||
fit: BoxFit.cover,
|
||||
color: themeController.currentColor.sc4,
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
0, 0.rpx, 0.rpx, 0), // 外部 padding 移到内部
|
||||
width: 28.rpx,
|
||||
height: 28.rpx,
|
||||
child: SvgPicture.asset(
|
||||
'assets/img/icon/explain.svg',
|
||||
fit: BoxFit.cover,
|
||||
color: themeController.currentColor.sc4,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 31.rpx,
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
30.rpx, 0.rpx, 30.rpx, 0.rpx),
|
||||
child: Container(
|
||||
width: MediaQuery.of(context).size.width * 0.7,
|
||||
height: MediaQuery.of(context).size.width * 0.7,
|
||||
constraints: BoxConstraints(
|
||||
minWidth: 430.rpx,
|
||||
minHeight: 430.rpx,
|
||||
),
|
||||
child: ScatterPlotChart(
|
||||
points: data,
|
||||
xMax: maxX.toInt(), // x轴最大值
|
||||
yMax: maxY.toInt(), // y轴最大值
|
||||
pointColor: stringToColor("#00C1AA"), // 点的颜色
|
||||
divisions: 7, // 刻度分割数量
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 31.rpx,
|
||||
),
|
||||
Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(30.rpx, 0.rpx, 30.rpx, 0.rpx),
|
||||
child: Container(
|
||||
width: MediaQuery.of(context).size.width * 0.7,
|
||||
height: MediaQuery.of(context).size.width * 0.7,
|
||||
constraints: BoxConstraints(
|
||||
minWidth: 430.rpx,
|
||||
minHeight: 430.rpx,
|
||||
),
|
||||
child: ScatterPlotChart(
|
||||
points: data,
|
||||
xMax: maxX.toInt(), // x轴最大值
|
||||
yMax: maxY.toInt(), // y轴最大值
|
||||
pointColor: stringToColor("#00C1AA"), // 点的颜色
|
||||
divisions: 7, // 刻度分割数量
|
||||
),
|
||||
),
|
||||
),
|
||||
// SizedBox(
|
||||
// height: 31.rpx,
|
||||
// ),
|
||||
],
|
||||
// SizedBox(
|
||||
// height: 31.rpx,
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
} catch (e) {
|
||||
es.EasyDartModule.logger.error("打鼾监测绘制异常${e}");
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user