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

Whether dynamic loading of node labels is supported in neovis.js #374

Closed SeXyTeA-x closed 9 months ago

SeXyTeA-x commented 9 months ago

Since many of the node names in my data are too long, I use the following method to label nodes with '... 'carry on representation:

GcjsLot:{
                                label: "name",
                                value: "pagerank",
                                group: "GcjsLot",
                                [NeoVis.NEOVIS_ADVANCED_CONFIG]: {
                                    function:{
                                        label:(node)=>{
                                            if(node.properties.name.length>=10)
                                                return (node,node.properties.name.substr(0,5)+"..."+node.properties.name.substr(-5));
                                        },
                                    },
                                    static: {
                                        image: 'dist/pic/gongcheng.png',
                                        shape: 'circularImage',
                                    }
                                }
                            },

However, I hope that when the user's mouse selects a node, the name of this node can be fully displayed, may I ask whether this effect can be achieved

thebestnom commented 9 months ago

Hmm... You can do it with click event that change the label based on the node.raw data and remember to do the same when it's deslected

SeXyTeA-x commented 9 months ago

Emmm... I use this,But it doesn't seem to work.

this.viz.registerOnEvent('clickNode',(e) => {
    this.viz.updateWithFunction(function(){
        e.node.raw.properties.name = 'aaa';
    })
});
thebestnom commented 9 months ago
this.viz.registerOnEvent('clickNode',(e) => {
    e.node.label = 'aaa';
});

No need the other stuff

SeXyTeA-x commented 9 months ago

I tried this method, but the label of the node didn't change

thebestnom commented 9 months ago

Yes, my bad

this.viz.registerOnEvent('clickNode',(e) => {
    vis.nodes.update({id: e.node.id, label: 'aaa'})
});
SeXyTeA-x commented 9 months ago

Thank you. Problem solved