Open selvavm opened 10 months ago
Did you ever figure this out, @selvavm ? I'm having a similar problem
I had the same problem, I did a POC to validate my idea and it worked.
I created a wrapper for ReactECharts that looked like this:
import ReactECharts from 'echarts-for-react';
import * as echarts from 'echarts';
type Props = {
options: echarts.EChartsOption,
groupToConnect?: string
}
export const EchartContainer = ({options, groupToConnect}: Props) => {
return (
<div
style={{
display: "flex",
width: "100%"
}}
>
<ReactECharts
option={options}
onChartReady={(instance) => {
if (groupToConnect !== undefined) {
instance.group = groupToConnect
echarts.connect(groupToConnect)
}
}}
style={{
width: '100%',
height: '500px',
}}
/>
</div>
)
}
and the usage was as follows:
// first-chart.tsx
export const FirstChart = () => {
const options = {
// component implementation
// ...
return <EchartContainer options={options} groupToConnect="SAME-GROUP-CONNECT-ID" />
}
// second-chart.tsx
export const SecondChart = () => {
const options = {
// component implementation
// ...
return <EchartContainer options={options} groupToConnect="SAME-GROUP-CONNECT-ID" />
}
result:
https://github.com/hustcc/echarts-for-react/assets/71678283/bae7bbb2-5996-4107-add8-c43ca89df3fe
I am trying to develop a plugin for Grafana and I need to connect the charts. I cannot modify the source code so I need to add echart.connect on load of the charts?
I saw #9 and would like to know how can I do this?
Something like below,
other panel,