4 plots communication #2469
Unanswered
SafwanMakeTheWay
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I just started studying React and found your beautiful tool.
Based on your example (Association filter), I tried to create 4 plots where each one will communicate with the rest of the plots. Is that possible?
If yes, could you please guide me on how to do this?
Below is my attempt:
import React, { useState, useEffect } from 'react';
import { Mix } from '@ant-design/plots';
const BarInteraction = () => {
const [data, setData] = useState({});
useEffect(() => {
asyncFetch();
}, []);
const asyncFetch = () => {
// const file='https://gw.alipayobjects.com/os/antfincdn/HkxWvFrZuC/association-data.json';
const file='/DATA/data_1.json';
fetch(file)
.then((response) => response.json())
.then((json) => {
console.log('Fetched Data:', json); // Print fetched data to console
setData(json);
})
.catch((error) => {
console.log('Fetch data failed:', error);
});
};
if (!Object.keys(data).length) {
return null;
}
const config = {
tooltip: false,
plots: [
// ==== Plot 1 occupies the top-left quadrant (0,0) to (0.5,0.5).====
{
type: 'area',
region: {
start: {
x: 0,
y: 0,
},
end: {
x: 0.5,
y: 0.5,
},
},
options: {
data: data.line,
xField: 'time',
yField: 'value',
seriesField: 'area',
line: {},
point: {
style: {
r: 2.5,
},
},
meta: {
time: {
range: [0, 1],
},
},
smooth: true,
tooltip: {
showCrosshairs: true,
shared: true,
},
interactions: [
{
type: 'association-highlight',
},
{
type: 'element-click',
},
{
type: 'custom-association-filter',
},
],
};
return (
<Mix
{...config}
style={{ width: '100vw', height: '800px' }} // Adjust width and height as needed
/>
);
};
export default BarInteraction;
Beta Was this translation helpful? Give feedback.
All reactions