diff --git a/src/patchmap.js b/src/patchmap.js index 1e6f6d87..b2ce6073 100644 --- a/src/patchmap.js +++ b/src/patchmap.js @@ -145,6 +145,12 @@ class Patchmap { event.removeAllEvent(this.viewport); this.initSelectState(); draw(context, validatedData); + + // Force a refresh of all relation elements after the initial draw. This ensures + // that all link targets exist in the scene graph before the relations + // attempt to draw their links. + this.update({ path: '$..children[?(@.type=="relations")]', refresh: true }); + this.app.start(); return validatedData; diff --git a/src/utils/convert.js b/src/utils/convert.js index dfad52dd..5ee0890c 100644 --- a/src/utils/convert.js +++ b/src/utils/convert.js @@ -65,6 +65,7 @@ export const convertLegacyData = (data) => { } } else if (key === 'strings') { objs[key].show = false; + objs[key].attrs = { zIndex: 20 }; for (const value of values) { objs[key].children.push({ type: 'relations', @@ -96,8 +97,7 @@ export const convertLegacyData = (data) => { }); } } else { - objs[key].attrs = {}; - objs[key].attrs.zIndex = 10; + objs[key].attrs = { zIndex: 10 }; for (const value of values) { const { transform, ...props } = value.properties; objs[key].children.push({