Skip to content

Commit

Permalink
feat: add group for Eacharts
Browse files Browse the repository at this point in the history
  • Loading branch information
Gumichocopengin8 committed Aug 13, 2023
1 parent 0c314f0 commit 0f11012
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions web/src/components/echarts/ReactEChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ interface Props {
option: EChartsOption;
settings?: SetOptionOpts;
style?: CSSProperties;
group?: string;
}

const ReactECharts: React.FC<Props> = ({ option, style, settings = {}, onClick }: Props) => {
const ReactECharts: React.FC<Props> = ({ option, style, group, settings = {}, onClick }: Props) => {
const chartRef = useRef<HTMLDivElement>(null);
const [width, height] = useResize(chartRef);
const [echart, setEchart] = useState<echarts.ECharts | undefined>(undefined);
Expand All @@ -61,13 +62,17 @@ const ReactECharts: React.FC<Props> = ({ option, style, settings = {}, onClick }
chart.getZr().on('dblclick', () => {
chart.dispatchAction({ type: 'dataZoom', start: 0, end: 100 });
});
if (group) {
chart.group = group;
echarts.connect(group);
}
setEchart(chart);
}

return () => {
echart?.dispose();
};
}, [echart, onClick]);
}, [echart, onClick, group]);

useEffect(() => {
echart?.resize({ width, height });
Expand Down

0 comments on commit 0f11012

Please sign in to comment.