import { Ref, defineComponent, reactive, ref } from 'vue'; import styles from '../index.module.less'; import { NNumberAnimation } from 'naive-ui'; import numeral from 'numeral'; import { useECharts } from '@/hooks/web/useECharts'; export default defineComponent({ name: 'home-trainData', setup() { const chartRef = ref(null); const { setOptions } = useECharts(chartRef as Ref); const qualifiedFlag = ref(true); const unqualifiedFlag = ref(true); const payForm = reactive({ height: '360px', width: '100%', studentNum: 0, paymentAmount: 0, dateList: [ '2022-10-10', '2022-10-11', '2022-10-12', '2022-10-13', '2022-10-14', '2022-10-15', '2022-10-16' ], studentList: [22, 23, 25, 26, 27, 6, 7], payInfoList: [100, 200, 300, 450, 330, 200, 10] }); const setChart = () => { setOptions({ tooltip: { trigger: 'axis', axisPointer: { lineStyle: { width: 2, color: '#A9C7FF' } } }, legend: { show: false, selected: { //在这里设置默认展示就ok了 合格人数: qualifiedFlag.value, 不合格人数: unqualifiedFlag.value } }, xAxis: { type: 'category', boundaryGap: false, axisLabel: { show: true, interval: 0 }, data: payForm.dateList // splitLine: { // show: true, // lineStyle: { // width: 2, // type: 'solid', // color: 'rgba(226,226,226,0.5)' // } // } // axisTick: { // show: false // } }, yAxis: [ { type: 'value', axisTick: { show: false }, splitArea: { show: false, areaStyle: { color: ['rgba(255,255,255,0.2)'] } } } ], grid: { left: '1%', right: '1%', top: '2 %', bottom: 0, containLabel: true }, series: [ { data: payForm.payInfoList, type: 'line', name: '合格人数', symbolSize: 10, symbol: 'circle', smooth: true, itemStyle: { color: '#198CFE', borderColor: '#fff', borderWidth: 3 }, lineStyle: { width: 2 //设置线条粗细 }, areaStyle: { color: { type: 'linear', x: 0, y: 0, x2: 0, y2: 1, colorStops: [ { offset: 0, color: 'rgba(212, 231, 255, 1)' // 0% 处的颜色 }, { offset: 1, color: 'rgba(221, 235, 254, 0)' // 100% 处的颜色 } ] } }, emphasis: { disabled: true } }, { // smooth: true, data: payForm.studentList, symbolSize: 10, type: 'line', name: '不合格人数', symbol: 'circle', smooth: true, itemStyle: { color: '#FF7AA7', borderColor: '#fff', borderWidth: 3 }, lineStyle: { width: 3 //设置线条粗细 }, areaStyle: { color: { type: 'linear', x: 0, y: 0, x2: 0, y2: 1, colorStops: [ { offset: 0, color: 'rgba(255, 243, 246, 1)' // 0% 处的颜色 }, { offset: 1, // 100% 处的颜色 color: 'rgba(255, 246, 248, 0)' } ] } }, emphasis: { disabled: true } } ], formatter: (item: any) => { if (Array.isArray(item)) { return [ item[0].axisValueLabel, ...item.map( (d: any) => `
${ d.marker }${d.seriesName}: ${ d.value }${'人'} ` ) ].join(''); } else { return item; } } // dataZoom: [ // { // type: 'slider', // start: 5, // end: 100, // filterMode: 'empty' // } // ] }); }; setChart(); return () => ( <>

训练次数

人次

应交总人次

人次

提交总人次

{' '} 人次

合格总人次

%

训练提交率

%

训练合格率

{ qualifiedFlag.value = !qualifiedFlag.value; setChart(); }} class={[ styles.DataTopRightItem, qualifiedFlag.value ? '' : styles.DataTopRightItemDis ]}>

合格人数

{ unqualifiedFlag.value = !unqualifiedFlag.value; setChart(); }} class={[ styles.DataTopRightItem, unqualifiedFlag.value ? '' : styles.DataTopRightItemDis ]}>

不合格人数

); } });