import { useState, useEffect, useRef } from 'react' import ReactEChartsCore from 'echarts-for-react/lib/core' import { echarts } from '../echarts' import { LineChart } from 'echarts/charts' import { TitleComponent, TooltipComponent, GridComponent, LegendComponent, LegendScrollComponent, MarkLineComponent, MarkPointComponent, } from 'echarts/components' import { CanvasRenderer } from 'echarts/renderers' import numbro from 'numbro' import merge from 'lodash/merge' import { polylineSeriesMapping } from '../preset' import { defineConfig } from '@/utils/common' import type { EChartsOption, DefaultLabelFormatterCallbackParams } from 'echarts' import type { MyEChartProps } from '../types' // 注册 echarts 组件 echarts.use([ // charts LineChart, // components TitleComponent, TooltipComponent, GridComponent, LegendComponent, LegendScrollComponent, MarkLineComponent, MarkPointComponent, // render CanvasRenderer, ]) function genDefaultOptions(): EChartsOption { const options = { title: { show: false, }, grid: { top: 30, left: '8%', right: '8%', bottom: 30, }, legend: { show: true, type: 'scroll', orient: 'horizontal', textStyle: { fontSize: 10, }, pageIconSize: 12, }, tooltip: { show: true, trigger: 'axis', axisPointer: { type: 'shadow', }, appendToBody: true, confine: true, padding: [8, 12], textStyle: { fontSize: 12, lineHeight: 18, fontWeight: 300, fontFamily: `'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif`, }, formatter: (lines: any) => { const newLines = [...lines] const str: string[] = [] newLines.sort((a, b) => { return b.value - a.value }) newLines.forEach((p) => { const val = typeof p.value === 'number' || p.value ? p.value : '-' const cont = `