erase isolated node from graph

This commit is contained in:
moririn2528
2023-09-14 17:39:06 +09:00
parent 4d15b79e9b
commit eb6234eabc
@@ -181,6 +181,7 @@ export const PreferentialGraph: FC<{
if (!studyDetail.is_preferential || studyDetail.preferences === undefined)
return
const preferences = reductionPreference(studyDetail.preferences)
const trialNodes = Array.from(new Set(preferences.flat()))
const graph: ElkNode = {
id: "root",
layoutOptions: {
@@ -189,8 +190,8 @@ export const PreferentialGraph: FC<{
"elk.layered.spacing.nodeNodeBetweenLayers": nodeMargin.toString(),
"elk.spacing.nodeNode": nodeMargin.toString(),
},
children: studyDetail.trials.map((trial) => ({
id: `${trial.number}`,
children: trialNodes.map((trial) => ({
id: `${trial}`,
targetPosition: "top",
sourcePosition: "bottom",
width: nodeWidth,
@@ -207,7 +208,7 @@ export const PreferentialGraph: FC<{
.then((layoutedGraph) => {
setNodes(
layoutedGraph.children?.map((node, index) => {
const trial = studyDetail.trials[index]
const trial = studyDetail.trials[trialNodes[index]]
return {
id: `${trial.number}`,
type: "note",