fix: don't show nodes that are target of ignored edges
This commit is contained in:
parent
f94c3402c2
commit
c2d94c0400
@ -8,12 +8,14 @@ interface NetworkData {
|
||||
edges: GraphEdge[],
|
||||
}
|
||||
interface CustomSelectionProps extends SelectionProps {
|
||||
ignore: string[];
|
||||
ignore: (GraphEdge | undefined)[];
|
||||
}
|
||||
|
||||
const useCustomSelection = (props: CustomSelectionProps): SelectionResult => {
|
||||
var result = useSelection(props);
|
||||
result.actives = result.actives.filter((s) => !props.ignore.includes(s))
|
||||
result.actives = result.actives.filter((s) => !props.ignore.map((edge) => edge?.id).includes(s))
|
||||
const ignored_nodes = props.ignore.map((edge) => (edge && result.selections?.includes(edge.source) && !result.selections?.includes(edge.target)) ? edge.target : "")
|
||||
result.actives = result.actives.filter((s) => !ignored_nodes.includes(s))
|
||||
return result
|
||||
}
|
||||
|
||||
@ -65,7 +67,7 @@ export const GraphComponent = () => {
|
||||
ref: graphRef,
|
||||
nodes: data.nodes,
|
||||
edges: data.edges.filter((edge) => edge.data.relation === likes),
|
||||
ignore: data.edges.map((edge) => { return (likes === 1 && edge.data.relation !== 2) ? edge.id : "" }),
|
||||
ignore: data.edges.map((edge) => { if (likes === 1 && edge.data.relation !== 2) return edge }),
|
||||
pathSelectionType: 'out',
|
||||
type: 'multiModifier'
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user