feat: AI 对话支持 A2UI 表单/审查/图表与 Excel 读取
This commit is contained in:
@@ -1,11 +1,22 @@
|
||||
import React, { useEffect, useRef } from 'react';
|
||||
import * as echarts from 'echarts/core';
|
||||
import type { EChartsType } from 'echarts/core';
|
||||
export type EChartsOption = Record<string, unknown>;
|
||||
import { BarChart, CustomChart, LineChart, PieChart } from 'echarts/charts';
|
||||
import {
|
||||
BarChart,
|
||||
CustomChart,
|
||||
FunnelChart,
|
||||
GaugeChart,
|
||||
LineChart,
|
||||
PieChart,
|
||||
RadarChart,
|
||||
ScatterChart,
|
||||
} from 'echarts/charts';
|
||||
import {
|
||||
DataZoomComponent,
|
||||
GridComponent,
|
||||
LegendComponent,
|
||||
RadarComponent,
|
||||
TooltipComponent,
|
||||
VisualMapComponent,
|
||||
} from 'echarts/components';
|
||||
@@ -14,11 +25,16 @@ import { CanvasRenderer } from 'echarts/renderers';
|
||||
echarts.use([
|
||||
BarChart,
|
||||
CustomChart,
|
||||
FunnelChart,
|
||||
GaugeChart,
|
||||
LineChart,
|
||||
PieChart,
|
||||
RadarChart,
|
||||
ScatterChart,
|
||||
DataZoomComponent,
|
||||
GridComponent,
|
||||
LegendComponent,
|
||||
RadarComponent,
|
||||
TooltipComponent,
|
||||
VisualMapComponent,
|
||||
CanvasRenderer,
|
||||
@@ -28,15 +44,20 @@ interface EChartsProps {
|
||||
option: EChartsOption;
|
||||
style?: React.CSSProperties;
|
||||
className?: string;
|
||||
/** 图表实例就绪回调(用于导出图片等场景) */
|
||||
onReady?: (chart: EChartsType) => void;
|
||||
}
|
||||
|
||||
const ECharts: React.FC<EChartsProps> = ({ option, style, className }) => {
|
||||
const ECharts: React.FC<EChartsProps> = ({ option, style, className, onReady }) => {
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
const onReadyRef = useRef(onReady);
|
||||
onReadyRef.current = onReady;
|
||||
|
||||
useEffect(() => {
|
||||
if (!containerRef.current) return;
|
||||
const chart = echarts.init(containerRef.current);
|
||||
chart.setOption(option);
|
||||
onReadyRef.current?.(chart);
|
||||
const observer = new ResizeObserver(() => chart.resize());
|
||||
observer.observe(containerRef.current);
|
||||
return () => {
|
||||
|
||||
Reference in New Issue
Block a user