组件 - PieChart.tsx
import * as echarts from 'echarts'
import { px2vh } from '@/utils/styleUtils'
import styled from 'styled-components/macro'
import { useEffect, useMemo, useRef, useState } from 'react'
export function PieChart({ chartId, height = 180, legendList, colorlist, optionData }) {
const myChart = useRef(null)
const [currentIndex, setCurrentIndex] = useState<number>(0)
useEffect(() => {
drawChart()
setTimeout(() => {
window.onresize = () => {
myChart.current.resize()
}
}, 200)
}, [])
const option = useMemo(() => {
return {
legend: {
show: false,
},
color: colorlist,
series: [
//外层圆
{
name: '圆圈',
type: 'pie',
zlevel: 0,
radius: ['0', '0'],
center: ['50%', '50