neovis.js icon indicating copy to clipboard operation
neovis.js copied to clipboard

Problems about neoViz.reinit(config) [physics]

Open XinyeYang opened this issue 2 years ago • 1 comments

Expected Behavior (Mandatory)

I changed the physic theta property in config from 10 to 0.5, then call neoViz.reinit(config), the render speed should be slower and the graph should be more accurate.

Actual Behavior (Mandatory)

The behavior before and after changing the theta parameters is the same, without any changes.

How to Reproduce the Problem

config = {
    containerId: "viz",
    neo4j: {
        serverUrl: "bolt://localhost:7687",
        serverUser: "neo4j",
        serverPassword: "12345",
    },
    visConfig: {
        nodes: {
            shape: 'dot',
            size: 10
        },
        edges: {
            arrows: {
                to: { enabled: false }
            },
            selectionWidth: 3,
            color: {
                color: "#00ffff",
                highlight: "#bac295",
            },
        },
        physics: {
            barnesHut: {
                theta: 2,
                gravitationalConstant: -6000,
                centralGravity: 0.3,

                springLength: 10,
                springConstant: 0.04,
                damping: 0.8,
                avoidOverlap: 0.6
            },
            solver: "barnesHut",
            timestep: 0.15,
            minVelocity: 0.01
        },
    },
    labels: {
        NEW_DCYD: {
            // label: ["CWE_ID"],
            [NeoVis.NEOVIS_ADVANCED_CONFIG]: {
                static: {
                    color: {
                        border: "#ffffff",
                        background: "#ffffff",
                        highlight: {
                            border: "#ffffff",
                            background: "#000000"
                        }
                    },
                    shape: "dot",
                    size: 50,
                    borderWidth: "1",
                    font: {
                        "background": "none",
                        "strokeWidth": "0",
                        "size": 30,
                        "color": "#464646"
                    }
                },
                function: {
                    color: {
                        background: (node) => node.properties.CVE_ID ? "#bd6962" : node.properties.CWE_ID ? "#a4cbfa" : node.properties.PUBLISH_DATE ? "#f7ce46" : "#a4cb9d",
                    }, 
                    title: (node) => NeoVis.objectToTitleString(node, ["CVE_ID", "YEAR", "CWE_ID", "CAUSE", "LOCATION", "VERSION", "ATTACKER", "CONSEQUENCE", "OPERATION"])
                }
            }
        }
    },
    relationships: {
        CWE_NUMBER: {
            [NeoVis.NEOVIS_ADVANCED_CONFIG]: {
                static: {
                    label: "CWE NUMBER", 
                    color: "#ffffff",
                    font: {
                        "background": "none",
                        "strokeWidth": "0",
                        "size": edgeFontSize,
                        "color": "#f9dc73"
                    }
                }
            }
        },
        LOCATION: {
            [NeoVis.NEOVIS_ADVANCED_CONFIG]: {
                static: {
                    label: "LOCATION", 
                    color: "#ff0000",
                    font: {
                        "background": "none",
                        "strokeWidth": "0",
                        "size": edgeFontSize,
                        "color": "#437ce5"
                    }
                }
            }
        }
    },
    initialCypher: "MATCH (n:NEW_DCYD)-[r]->(m) WHERE n.YEAR >= '2022' RETURN *"
};
config.visConfig.physics.barnesHut.theta = 0.5;
neoViz.reinit(config);

Screenshots (where it's possibile)

It should look like the right picture when I call reinit(config).

XinyeYang avatar Apr 17 '23 04:04 XinyeYang

You are correct, I didn't update network config on reinit!

thebestnom avatar Apr 23 '23 17:04 thebestnom