Skip to content

Commit 569e1a3

Browse files
committed
chore: polish
1 parent 5269e19 commit 569e1a3

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/charts.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import React, { forwardRef, useLayoutEffect, useRef } from 'react';
1+
import React from 'react';
2+
import type { ComposeOption, GridComponentOption } from 'echarts';
23
import {
34
LineChart as EChartLineChart,
45
PieChart as EChartPieChart,
56
type LineSeriesOption,
67
type PieSeriesOption,
78
} from 'echarts/charts';
8-
import type { ComposeOption } from 'echarts/core';
9-
import { GridComponent, type GridComponentOption } from 'echarts/components';
9+
import { GridComponent } from 'echarts/components';
1010
import type { ComponentOption } from 'echarts/types/src/util/types.js';
1111
import {
1212
ChartContext,
@@ -48,20 +48,20 @@ interface ChartComponentType<T extends ComponentOption> {
4848
}
4949

5050
function defineChart<T extends ComponentOption>(ext: EChartExt) {
51-
const ChartComponent = forwardRef(
51+
const ChartComponent = React.forwardRef(
5252
(
5353
{ className, style, containerProps, compose, children, ...props }: ChartBaseProps<any>,
5454
ref: React.ForwardedRef<echarts.ECharts>
5555
) => {
56-
const containerRef = useRef<HTMLDivElement>(null);
57-
const chartRef = useRef<echarts.ECharts | null>(null);
56+
const containerRef = React.useRef<HTMLDivElement>(null);
57+
const chartRef = React.useRef<echarts.ECharts | null>(null);
5858
const ctx = useInitialChartContext();
5959

6060
useRegister((echarts) => {
6161
echarts.use([ext, compose?.map((comp) => comp.ext).flat() || []].flat());
6262
});
6363

64-
useLayoutEffect(() => {
64+
React.useLayoutEffect(() => {
6565
const chart = (chartRef.current = echarts.init(containerRef.current, null));
6666
assignForwardedRef(ref, chart);
6767
return () => {
@@ -70,7 +70,7 @@ function defineChart<T extends ComponentOption>(ext: EChartExt) {
7070
};
7171
}, []);
7272

73-
useLayoutEffect(() => {
73+
React.useLayoutEffect(() => {
7474
const chart = chartRef.current;
7575
if (!chart) return;
7676
for (const opt of ctx.options) chart.setOption(opt, defaultSetOptionOpt);

0 commit comments

Comments
 (0)