Closed ilanl closed 4 years ago
Hi, here's how I approached it. Suppose your structure is like this:
App
├-> Chart
└-> Table
const [highlightedDataIndex, setHighlightedDataIndex] = useState(null)
// The highlighted data via the table. Just the index, for performance.
const Chart = ({ data, highlightedDataIndex }) => { ... }
// Wait for highlighted data, and then highlight it in the chart.
if (highlightedDataIndex !== null) {
parcoords.highlight([data[highlightedDataIndex]])
} else {
parcoords.unhighlight()
}
<tr
onMouseEnter={() => {
// id is the id in the table.
// We do id-1 to get the real value.
setHighlightedDataIndex(row.values['id'] - 1)
}}
onMouseLeave={() => setHighlightedDataIndex(null)}
{...row.getRowProps()}
></tr>
Note that we pass the ID directly from the data. This ensures that it works even when the rows are filtered.
Thanks! perfect
First of all, thank you for this amazing library!
In react app: I'd like to know how to call highlight on pc chart from a react-table or similar 'mouseover' row action. App has 2 components:
How can the chart register to another component mouseover event. what's the best practice here so both component are not tightly coupled? any idea?