neo4j-contrib / neovis.js

Neo4j + vis.js = neovis.js. Graph visualizations in the browser with data from Neo4j.
Apache License 2.0
1.59k stars 324 forks source link

Problems about neoViz.reinit(config) [physics] #338

Open XinyeYang opened 1 year ago

XinyeYang commented 1 year ago

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).

thebestnom commented 1 year ago

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