学员学习折线图样式

This commit is contained in:
禺狨 2023-04-20 11:03:16 +08:00
parent 43abf5c1cb
commit 41ef729b3f
2 changed files with 14 additions and 3 deletions

View File

@ -11,5 +11,4 @@
width: 100%; width: 100%;
height: 320px; height: 320px;
box-sizing: border-box; box-sizing: border-box;
padding-top: 24px;
} }

View File

@ -7,6 +7,7 @@ import { dateFormat } from "../../utils/index";
import { user as member } from "../../api/index"; import { user as member } from "../../api/index";
import * as echarts from "echarts"; import * as echarts from "echarts";
import type { ColumnsType } from "antd/es/table"; import type { ColumnsType } from "antd/es/table";
import { duration } from "moment";
interface DataType { interface DataType {
id: React.Key; id: React.Key;
@ -58,10 +59,21 @@ const MemberLearnPage = () => {
}); });
}; };
const minuteFormat = (duration: number) => {
if (duration === 0) {
return 0;
}
let h = Math.trunc(duration / 3600);
let m = Math.trunc((duration % 3600) / 60);
let s = Math.trunc((duration % 3600) % 60);
return h + "小时" + m + "分";
};
const renderView = (params: any) => { const renderView = (params: any) => {
const timeData: any = []; const timeData: any = [];
const valueData: any = []; const valueData: any = [];
params.map((item: any) => { params.map((item: any) => {
let time = minuteFormat(item.value / 1000);
timeData.push(item.key); timeData.push(item.key);
valueData.push(item.value / 1000); valueData.push(item.value / 1000);
}); });
@ -91,9 +103,10 @@ const MemberLearnPage = () => {
}, },
series: [ series: [
{ {
name: "每日学习时长(秒)", name: "每日学习时长",
type: "line", type: "line",
data: valueData, data: valueData,
color: "#ff4d4f",
}, },
], ],
}); });
@ -278,7 +291,6 @@ const MemberLearnPage = () => {
<div className="float-left mb-24"> <div className="float-left mb-24">
<BackBartment title="学员学习" /> <BackBartment title="学员学习" />
</div> </div>
<div className={styles["large-title"]}></div>
<div className={styles["charts"]}> <div className={styles["charts"]}>
<div <div
ref={chartRef} ref={chartRef}