更新睡眠的心率基准图不显示

This commit is contained in:
wyf
2025-07-17 10:06:13 +08:00
parent 80d6670ad9
commit f8cecba68b
95 changed files with 8859 additions and 9047 deletions

View File

@@ -214,7 +214,7 @@ class BarChartPainter extends CustomPainter {
// 缓存 tip 信息
if (selectedBar == d) {
tipText =
'${d.name}\n${d.value.toStringAsFixed(1)}\n${MyUtils.formatToHHmm(d.st)}';
'${d.name}\n${d.value.toStringAsFixed(1)}\n${MyUtils.formatToHHmm(d.st)}';
final tp = TextPainter(
text: TextSpan(

View File

@@ -84,9 +84,28 @@ class TimeSeriesChart extends StatelessWidget {
final xLabels = _generateXLabels();
final midY = (yMin + yMax) / 2;
List<FlSpot> spots = dataPoints.map((p) {
return FlSpot(_timeToX(p.timestamp.toDouble(), xLabels), p.value);
}).toList();
// 将数据点分割成多个连续段遇到value=-1时断开
List<List<FlSpot>> lineSegments = [];
List<FlSpot> currentSegment = [];
for (var point in dataPoints) {
if (point.value != -1) {
// 有效数据点,添加到当前段
currentSegment.add(FlSpot(
_timeToX(point.timestamp.toDouble(), xLabels),
point.value,
));
} else if (currentSegment.isNotEmpty) {
// 遇到无效点且当前段不为空,结束当前段
lineSegments.add(currentSegment);
currentSegment = [];
}
}
// 添加最后一个段(如果有)
if (currentSegment.isNotEmpty) {
lineSegments.add(currentSegment);
}
return AspectRatio(
aspectRatio: 2,
@@ -204,15 +223,16 @@ class TimeSeriesChart extends StatelessWidget {
top: BorderSide.none,
),
),
lineBarsData: [
LineChartBarData(
spots: spots,
lineBarsData: lineSegments.map((segment) {
return LineChartBarData(
spots: segment,
isCurved: false,
color: themeController.currentColor.sc2,
barWidth: 2,
dotData: FlDotData(show: false),
)
],
preventCurveOverShooting: true,
);
}).toList(),
),
),
);