|
@@ -0,0 +1,197 @@
|
|
|
|
+<!-- 五维雷达图 -->
|
|
|
|
+<template>
|
|
|
|
+ <div :id="id" :class="className" :style="{ height, width }" />
|
|
|
|
+</template>
|
|
|
|
+
|
|
|
|
+<script setup lang="ts">
|
|
|
|
+import * as echarts from "echarts";
|
|
|
|
+
|
|
|
|
+const props = defineProps({
|
|
|
|
+ id: {
|
|
|
|
+ type: String,
|
|
|
|
+ default: "radarSingle",
|
|
|
|
+ required: true,
|
|
|
|
+ },
|
|
|
|
+ className: {
|
|
|
|
+ type: String,
|
|
|
|
+ default: "",
|
|
|
|
+ },
|
|
|
|
+ width: {
|
|
|
|
+ type: String,
|
|
|
|
+ default: "160px",
|
|
|
|
+ },
|
|
|
|
+ height: {
|
|
|
|
+ type: String,
|
|
|
|
+ default: "160px",
|
|
|
|
+ },
|
|
|
|
+ color: {
|
|
|
|
+ type: String,
|
|
|
|
+ default: "#2f539b",
|
|
|
|
+ },
|
|
|
|
+ bgColor: {
|
|
|
|
+ type: String,
|
|
|
|
+ default: "#e6e8f9",
|
|
|
|
+ },
|
|
|
|
+ beforeData: {
|
|
|
|
+ type: String,
|
|
|
|
+ default: "0,0,0,0,0",
|
|
|
|
+ required: true,
|
|
|
|
+ },
|
|
|
|
+ afterData: {
|
|
|
|
+ type: String,
|
|
|
|
+ default: "0,0,0,0,0",
|
|
|
|
+ required: true,
|
|
|
|
+ },
|
|
|
|
+});
|
|
|
|
+function test(params) {
|
|
|
|
+ let tag = "";
|
|
|
|
+ let tagType = "";
|
|
|
|
+ if (params.dimensionIndex == 0) {
|
|
|
|
+ // 专注力平均值
|
|
|
|
+ if (params.value > 62.82) {
|
|
|
|
+ tag = "优秀";
|
|
|
|
+ tagType = "t1";
|
|
|
|
+ } else if (params.value <= 62.82 && params.value > 55.49) {
|
|
|
|
+ tag = "良好";
|
|
|
|
+ tagType = "t2";
|
|
|
|
+ } else if (params.value <= 55.49 && params.value > 48.91) {
|
|
|
|
+ tag = "轻度不足";
|
|
|
|
+ tagType = 2;
|
|
|
|
+ } else if (params.value <= 48.91 && params.value > 41.58) {
|
|
|
|
+ tag = "中等不足";
|
|
|
|
+ } else {
|
|
|
|
+ tag = "重度不足";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (params.dimensionIndex == 1) {
|
|
|
|
+ // 高专注占比
|
|
|
|
+ if (params.value > 62.82) {
|
|
|
|
+ tag = "优秀";
|
|
|
|
+ } else if (params.value <= 62.82 && params.value > 55.49) {
|
|
|
|
+ tag = "良好";
|
|
|
|
+ } else if (params.value <= 55.49 && params.value > 48.91) {
|
|
|
|
+ tag = "轻度不足";
|
|
|
|
+ } else if (params.value <= 48.91 && params.value > 41.58) {
|
|
|
|
+ tag = "中等不足";
|
|
|
|
+ } else {
|
|
|
|
+ tag = "重度不足";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ console.log(params.dimensionIndex);
|
|
|
|
+ return ["{title|" + params.value + "}", "{flag|" + tag + "}"].join("");
|
|
|
|
+}
|
|
|
|
+const options = {
|
|
|
|
+ color: ["#937dff", "#ffb72d"],
|
|
|
|
+ legend: {
|
|
|
|
+ right: "5%",
|
|
|
|
+ top: "5%",
|
|
|
|
+ data: [
|
|
|
|
+ { name: "训练前", icon: "circle" },
|
|
|
|
+ { name: "训练后", icon: "circle" },
|
|
|
|
+ ],
|
|
|
|
+ textStyle: {
|
|
|
|
+ fontSize: 15,
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ radar: {
|
|
|
|
+ radius: "50%",
|
|
|
|
+ center: ["50%", "56%"],
|
|
|
|
+ indicator: [
|
|
|
|
+ { name: "专注力平均值", max: 100 },
|
|
|
|
+ { name: "高专注占比", max: 100 },
|
|
|
|
+ { name: "专注唤醒效率", max: 100 },
|
|
|
|
+ { name: "整体和谐度", max: 100 },
|
|
|
|
+ { name: "专注力稳定度", max: 100 },
|
|
|
|
+ ],
|
|
|
|
+ axisName: {
|
|
|
|
+ color: "#2456a3",
|
|
|
|
+ fontSize: 15,
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ series: [
|
|
|
|
+ {
|
|
|
|
+ name: "训练前 vs 训练后",
|
|
|
|
+ type: "radar",
|
|
|
|
+ symbolSize: 8,
|
|
|
|
+ data: [
|
|
|
|
+ {
|
|
|
|
+ value: props.beforeData?.split(","),
|
|
|
|
+ name: "训练前",
|
|
|
|
+ label: {
|
|
|
|
+ show: true,
|
|
|
|
+ position: "right",
|
|
|
|
+ color: "#937dff",
|
|
|
|
+ fontSize: 12,
|
|
|
|
+ formatter: function (params) {
|
|
|
|
+ return params.value > 0 ? params.value : "";
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ areaStyle: {
|
|
|
|
+ color: "rgba(147, 125, 255, .8)",
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ value: props.afterData?.split(","),
|
|
|
|
+ name: "训练后",
|
|
|
|
+ label: {
|
|
|
|
+ show: true,
|
|
|
|
+ // 在文本中,可以对部分文本采用 rich 中定义样式。
|
|
|
|
+ // 这里需要在文本中使用标记符号:
|
|
|
|
+ // `{styleName|text content text content}` 标记样式名。
|
|
|
|
+ // 注意,换行仍是使用 '\n'。
|
|
|
|
+ // formatter: (a, b) => {
|
|
|
|
+ // i++;
|
|
|
|
+ // return `{title|${a}}\n{flag|${params[i]}}`
|
|
|
|
+ // }
|
|
|
|
+ formatter: function (params) {
|
|
|
|
+ return test(params);
|
|
|
|
+ },
|
|
|
|
+ rich: {
|
|
|
|
+ t0: { color: "#247eff" },
|
|
|
|
+ t1: {
|
|
|
|
+ backgroundColor: "#03c5ec",
|
|
|
|
+ padding: [2, 10, 2, 10],
|
|
|
|
+ borderRadius: 5,
|
|
|
|
+ },
|
|
|
|
+ t2: {
|
|
|
|
+ backgroundColor: "#53be07",
|
|
|
|
+ padding: [2, 10, 2, 10],
|
|
|
|
+ borderRadius: 5,
|
|
|
|
+ },
|
|
|
|
+ t3: {
|
|
|
|
+ backgroundColor: "#edcb00",
|
|
|
|
+ padding: [2, 5, 2, 5],
|
|
|
|
+ borderRadius: 5,
|
|
|
|
+ },
|
|
|
|
+ t4: {
|
|
|
|
+ backgroundColor: "#ff9f29",
|
|
|
|
+ padding: [2, 5, 2, 5],
|
|
|
|
+ borderRadius: 5,
|
|
|
|
+ },
|
|
|
|
+ t5: {
|
|
|
|
+ backgroundColor: "#f45028",
|
|
|
|
+ padding: [2, 5, 2, 5],
|
|
|
|
+ borderRadius: 5,
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ areaStyle: {
|
|
|
|
+ color: "rgba(255, 183, 45, .5)",
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+onMounted(() => {
|
|
|
|
+ const chart = echarts.init(
|
|
|
|
+ document.getElementById(<string>props.id) as HTMLDivElement
|
|
|
|
+ );
|
|
|
|
+ chart.setOption(options);
|
|
|
|
+
|
|
|
|
+ window.addEventListener("resize", () => {
|
|
|
|
+ chart.resize();
|
|
|
|
+ });
|
|
|
|
+});
|
|
|
|
+</script>
|