/* //y轴显示数据 Data:{ type:number, 0(实线) 1虚线(预测) 2(填充) name:string, yIndex:number, //yName的下标索引(第几个y坐标轴) data:string[], } props:{ yName:string || string[], //y轴名称 一个或多个 xData:string[], //x轴时间数据 dataList:Data[], //折线的数据列表 currentType:string, //当前选择那个tabs 需要外部更新当前选中type时传入 typeList:string[], //图表下的选择类型列表 onChange:(id:number)=>{} } */ import { Empty } from 'antd'; import * as echarts from 'echarts'; import { useEffect, useRef } from 'react'; import styles from './index.less'; //图表模块 const RadarChartModule = (props) => { const chartDomRef = useRef(); const chartRef = useRef(); const { indicator, data, name = '' } = props; useEffect(() => { chartRef.current = echarts.init(chartDomRef.current); window.addEventListener('resize', resetChart); return () => window.removeEventListener('resize', resetChart); }, []); useEffect(() => { if (!chartRef.current) return; const option = { ...defaultOption }; option.radar.indicator = indicator; option.series = [{ ...option.series[0], data: data, name }]; console.log(JSON.stringify(option)); chartRef.current.clear(); chartRef.current.setOption(option); chartRef.current.resize(); }, [indicator, data]); const resetChart = () => { if (chartRef.current) chartRef.current.resize(); }; const getStyle = () => { if (data && data.length != 0) return { width: '100%', height: '100%' }; else return { width: '100%', height: '100%', display: 'none' }; }; return (