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[],
|
edges: GraphEdge[],
|
||||||
}
|
}
|
||||||
interface CustomSelectionProps extends SelectionProps {
|
interface CustomSelectionProps extends SelectionProps {
|
||||||
ignore: string[];
|
ignore: (GraphEdge | undefined)[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const useCustomSelection = (props: CustomSelectionProps): SelectionResult => {
|
const useCustomSelection = (props: CustomSelectionProps): SelectionResult => {
|
||||||
var result = useSelection(props);
|
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
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,7 +67,7 @@ export const GraphComponent = () => {
|
|||||||
ref: graphRef,
|
ref: graphRef,
|
||||||
nodes: data.nodes,
|
nodes: data.nodes,
|
||||||
edges: data.edges.filter((edge) => edge.data.relation === likes),
|
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',
|
pathSelectionType: 'out',
|
||||||
type: 'multiModifier'
|
type: 'multiModifier'
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user