Initial CMPP frontend prototype

This commit is contained in:
hectorzhao
2026-06-30 16:09:46 +08:00
commit 2f3c274a30
98 changed files with 25255 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
import { useEffect, useRef } from 'react';
import type { EChartsOption } from 'echarts';
import * as echarts from 'echarts';
type ChartProps = {
option: EChartsOption;
height?: number;
};
export function Chart({ option, height = 280 }: ChartProps) {
const chartRef = useRef<HTMLDivElement | null>(null);
useEffect(() => {
if (!chartRef.current) {
return undefined;
}
const chart = echarts.init(chartRef.current);
chart.setOption(option);
const resizeObserver = new ResizeObserver(() => chart.resize());
resizeObserver.observe(chartRef.current);
return () => {
resizeObserver.disconnect();
chart.dispose();
};
}, [option]);
return <div className="ui-chart" ref={chartRef} style={{ height }} />;
}