neovis.js
neovis.js copied to clipboard
Dynamically adding label configs from neo4j server to neovis config
Discussed in https://github.com/neo4j-contrib/neovis.js/discussions/289
Originally posted by Niveydhithaa September 15, 2022
Hi guys, I have defined a labels config for the existing nodes' labels like
.
TO my requirement, say I have new nodes with a different with a new label in neo4j, then my neovis render shows up just the new nodes empty without its name. I have no idea how to do this.
Can someone help me out?
You can use DEFAULT_CONFIG which gives the same config to apl labels that doesn't have a label config
Hi, thanks for the reply! So yeah I tried the DEFAULT_CONFIG, but just got the nodes without names with the same color (attached images).
Have I given the DEFAULT_CONFIG right?

Yeah, I got a problem that you can't use the label from mapped porp, you can still get it in function map and assign the group that way
ADVANCED_CONFIG: {
functions: {
group: (node) => node.label[0]
}
}
Or something like thta
(BTW Look at the migration guide, you are using old configs)
Yeah sure. Ill look into it (the migration thing)
In the advanced config, the "group" parameter can be changed into something else too right, like in my case can I give it as "name" as i want that to be displayed in the node?
Of course, but if you only want it to read from props put the name outside of the advanced
Great. Thanks I'll try.
Also I have another priority issue regarding, whether I can get the NODE ids of all nodes present in my current render? Thanks in
Umm. Yes, visObject.nodes is DataSet with all the nodes currently in view (and it's bound to the view so changing it change the view)
Great. Thanks a lot
Hi @thebestnom , I tried the above as well (labels config dynamic adding). So basically from a form I try to add new labels. But even after giving the advanced config we discussed here, the nodes created under new label aren't showing up with colors or names.
Is there any possibility for you to share the code along with the data you have? Thanks a lot in advance!
Yeah, I got a problem that you can't use the label from mapped porp, you can still get it in function map and assign the group that way
ADVANCED_CONFIG: { functions: { group: (node) => node.label[0] } }Or something like thta
(BTW Look at the migration guide, you are using old configs)
Can you give the config here so I can see? 😅
Yeah sure
This is the place where I want to generalize the config for any existing or new label thats created

You want to put it in [NeoVis.DEFAULT_LABEL] and not in label_any for it to be used by all labels 😅
Argh, okay ..
Yep, tried it too
No progress, the graph is again without any styles we've applied

my bad, wrong name, import it like the advance confog and it's called NEOVIS_DEFAULT_CONFIG, didn't remembered the exact name
ahh. okay okay got it
wow. wonderful. thanks a lot, it has applied the config!
created a new label and checked for the color and label! worked like a charm
thanks much. Also, is it possible for randomizing colors for each label ?
Im pretty sure it is kinda randomized, Im not sure how vis.js choose color for group
oh okay, by default its giving smewhat "skyblue" like the below one. and if i give color inside adavnced, it accordingly changes all nodes' colors

but it will be great if it could assign a color on random, like what neo4j does in its display cause colors aid the sense of discriminating node categories
maybe if its fine for you, better we can open a new discussion based out of this
focused issue on colors: https://github.com/neo4j-contrib/neovis.js/issues/293