hugocxl / react-echarts

🐳 ECharts for React
https://hugocxl.github.io/react-echarts/
MIT License
87 stars 5 forks source link

Chart connect #5

Closed jskrajna closed 9 months ago

jskrajna commented 10 months ago

Subject

connect method

Description

Hi. From the documentation is not so clear for me how to connect charts. For example I have this implementation and Chart component used multiple times. How can I connect it ? I know theres a method 'connect' in echarts for group.

` import { Box } from '@mui/material'; import { EChart } from '@kbox-labs/react-echarts' import { forwardRef } from 'react';

const Chart = forwardRef(function Chart(props, ref) { const { options } = props;

return (
    <Box>
        <EChart {...options} ref={ref}
            style={{ height: '360px', width: '100%' }}
            renderer={'svg'}
            group="group1"
            notMerge={true}
            lazyUpdate={true}
        />
    </Box>
);

});

export default Chart; `

hugocxl commented 10 months ago

Hi @jskrajna! I'm currently working in the V1 version of the lib, where we'll add support to many more ECharts functionalities via React APIs.

For the case you're asking about, it should be done via the echarts object, which is not currently being accesible in the declarative component version. In v1 you'll have a useConnect hook that will solve it. use connect

In case you're in a hurry, you might import the connect function exported by echarts and copy the code from the hook.

Hope to deploy it in a few days ☺️

hugocxl commented 10 months ago

Hi @jskrajna, sorry that took longer than expected.

I have published a new major version with an improved API for the lib. It includes the hook useConnect. I updated the docs: useConnect

Hope that helps.

hugocxl commented 9 months ago

I am closing this issue as It appears to be solved with my previous comment.