Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: ComboCombined layout crashes when combos.length === 1 #6779

Open
2 of 10 tasks
orzechowskid opened this issue Feb 17, 2025 · 0 comments
Open
2 of 10 tasks

[Bug]: ComboCombined layout crashes when combos.length === 1 #6779

orzechowskid opened this issue Feb 17, 2025 · 0 comments
Labels
waiting for maintainer Triage or intervention needed from a maintainer.

Comments

@orzechowskid
Copy link

Describe the bug / 问题描述

I am attempting to render a graph using the combo-combined layout, and I get an error when the number of combos is exactly 1. outerPositions is never calculated, so outerPositions.nodes.find() does not exist.

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'nodes')
    at chunk-ERQFASD5.js?v=e9fd4546:50194:48
    at Map.forEach (<anonymous>)
    at ComboCombinedLayout.<anonymous> (chunk-ERQFASD5.js?v=e9fd4546:50192:20)
    at Generator.next (<anonymous>)
    at fulfilled (tslib.es6.mjs:118:56)

in combo-combined.js a value for outerPositions is only yield'd when outerLayoutNodes.length !== 1:
code:

                if (outerLayoutNodes.length === 1) {
                    outerLayoutNodes[0].data.x = center[0];
                    outerLayoutNodes[0].data.y = center[1];
                }
                else {
                    const outerLayoutGraph = new GraphCore({
                        nodes: outerLayoutNodes,
                        edges: outerLayoutEdges,
                    });
                    const outerLayout = propsOuterLayout || new ForceLayout();
                    // preset the nodes if the outerLayout is a force family layout
                    if (allHaveNoPosition && FORCE_LAYOUT_TYPE_MAP[outerLayout.id]) {
                        const outerLayoutPreset = outerLayoutNodes.length < 100
                            ? new MDSLayout()
                            : new ConcentricLayout();
                        yield outerLayoutPreset.assign(outerLayoutGraph);
                    }
                    const options = Object.assign({ center, kg: 5, preventOverlap: true, animate: false }, (outerLayout.id === 'force'
                        ? {
                            gravity: 1,
                            factor: 4,
                            linkDistance: (edge, source, target) => {
                                const sourceSize = Math.max(...source.data.size) || 32;
                                const targetSize = Math.max(...target.data.size) || 32;
                                return sourceSize / 2 + targetSize / 2 + 200;
                            },
                        }
                        : {}));
-->                 outerPositions = yield executeLayout(outerLayout, outerLayoutGraph, options);
                }

Reproduction link / 复现链接

No response

Steps to Reproduce the Bug or Issue / 重现步骤

layout:

{
        type: "combo-combined",
        innerLayout: new CircularLayout({
          nodeSize: 60,
        }),
        outerLayout: new D3ForceLayout({
		collide: {
			radius: 150,
		},
		link: {
			distance: (edge) =>
				edge.id.startsWith("cross-platform") &&
					edge.source.platform !== edge.target.platform
					? 1000
					: 350,
		},
		preventOverlap: true,
	})
}

combos:

{
    "combos": [
        {
            "data": {
                "platform": "twitter"
            },
            "id": "e169b6d5-8272-49ed-84f6-f999a45ca797",
            "label": "",
            "collapsed": false,
        }
    ]
}

nodes:

[
        {
            "data": {
                "id": "12c1652e-39d6-4c8d-b6d5-cadfdc429d28",
                "platform": "twitter",
            },
            "combo": "e169b6d5-8272-49ed-84f6-f999a45ca797",
            "id": "12c1652e-39d6-4c8d-b6d5-cadfdc429d28",
        },
        {
            "data": {
                "id": "380f94e9-9156-454f-803b-d52ec2408382",
                "platform": "twitter",
            },
            "combo": "e169b6d5-8272-49ed-84f6-f999a45ca797",
            "id": "380f94e9-9156-454f-803b-d52ec2408382",
        },
        {
            "data": {
                "id": "44c7768f-01da-44cd-af68-01770ddc4a01",
                "platform": "twitter",
            },
            "combo": "e169b6d5-8272-49ed-84f6-f999a45ca797",
            "id": "44c7768f-01da-44cd-af68-01770ddc4a01",
        },
]

Version / 版本

Please select / 请选择

OS / 操作系统

  • macOS
  • Windows
  • Linux
  • Others / 其他

Browser / 浏览器

  • Chrome
  • Edge
  • Firefox
  • Safari (Limited support / 有限支持)
  • IE (Nonsupport / 不支持)
  • Others / 其他
@orzechowskid orzechowskid added the waiting for maintainer Triage or intervention needed from a maintainer. label Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting for maintainer Triage or intervention needed from a maintainer.
Projects
None yet
Development

No branches or pull requests

1 participant