fix(健康检测-用户数据): 睡眠折线图按阶段分段显示,各段间不再连续连线
每段睡眠数据(深睡/浅睡/清醒/零星小睡)之间插入 null 断点, ECharts 折线图在 null 处自动断开,使不同睡眠阶段呈现为独立线段。
This commit is contained in:
@@ -168,32 +168,30 @@
|
||||
let xArr: any[] = [];
|
||||
let yArr: any[] = [];
|
||||
res.timePeriods &&
|
||||
res.timePeriods.map((item) => {
|
||||
res.timePeriods.forEach((item) => {
|
||||
switch (item.flag) {
|
||||
case 1:
|
||||
// 浅睡
|
||||
yArr.push(1);
|
||||
yArr.push(1);
|
||||
yArr.push(1, 1, null);
|
||||
break;
|
||||
case 3:
|
||||
// 深睡
|
||||
yArr.push(0);
|
||||
yArr.push(0);
|
||||
yArr.push(0, 0, null);
|
||||
break;
|
||||
case 4:
|
||||
// 清醒
|
||||
yArr.push(3);
|
||||
yArr.push(3);
|
||||
yArr.push(3, 3, null);
|
||||
break;
|
||||
case 5:
|
||||
// 零星小睡
|
||||
yArr.push(2);
|
||||
yArr.push(2);
|
||||
yArr.push(2, 2, null);
|
||||
break;
|
||||
}
|
||||
xArr.push(dayjs(item.start).format('HH:mm'));
|
||||
xArr.push(dayjs(item.end).format('HH:mm'));
|
||||
xArr.push(dayjs(item.start).format('HH:mm'), dayjs(item.end).format('HH:mm'), '');
|
||||
});
|
||||
// 去掉最后多余的 null
|
||||
if (yArr.length > 0) yArr.pop();
|
||||
if (xArr.length > 0) xArr.pop();
|
||||
const option = {
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
|
||||
Reference in New Issue
Block a user