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

Dynamically adding label configs from neo4j server to neovis config

Open Niveydhithaa opened this issue 3 years ago • 10 comments

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

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?

Niveydhithaa avatar Sep 15 '22 13:09 Niveydhithaa

You can use DEFAULT_CONFIG which gives the same config to apl labels that doesn't have a label config

thebestnom avatar Sep 15 '22 13:09 thebestnom

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?

image image

Niveydhithaa avatar Sep 15 '22 14:09 Niveydhithaa

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)

thebestnom avatar Sep 15 '22 14:09 thebestnom

Yeah sure. Ill look into it (the migration thing)

Niveydhithaa avatar Sep 16 '22 05:09 Niveydhithaa

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?

Niveydhithaa avatar Sep 16 '22 05:09 Niveydhithaa

Of course, but if you only want it to read from props put the name outside of the advanced

thebestnom avatar Sep 16 '22 06:09 thebestnom

Great. Thanks I'll try.

Niveydhithaa avatar Sep 16 '22 07:09 Niveydhithaa

Also I have another priority issue regarding, whether I can get the NODE ids of all nodes present in my current render? Thanks in

Niveydhithaa avatar Sep 16 '22 07:09 Niveydhithaa

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)

thebestnom avatar Sep 16 '22 09:09 thebestnom

Great. Thanks a lot

Niveydhithaa avatar Sep 16 '22 09:09 Niveydhithaa

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)

Niveydhithaa avatar Sep 22 '22 08:09 Niveydhithaa

Can you give the config here so I can see? 😅

thebestnom avatar Sep 22 '22 09:09 thebestnom

Yeah sure

Niveydhithaa avatar Sep 22 '22 09:09 Niveydhithaa

This is the place where I want to generalize the config for any existing or new label thats created image

Niveydhithaa avatar Sep 22 '22 09:09 Niveydhithaa

You want to put it in [NeoVis.DEFAULT_LABEL] and not in label_any for it to be used by all labels 😅

thebestnom avatar Sep 22 '22 09:09 thebestnom

Argh, okay ..

Niveydhithaa avatar Sep 22 '22 09:09 Niveydhithaa

Yep, tried it too image No progress, the graph is again without any styles we've applied image

Niveydhithaa avatar Sep 22 '22 09:09 Niveydhithaa

my bad, wrong name, import it like the advance confog and it's called NEOVIS_DEFAULT_CONFIG, didn't remembered the exact name

thebestnom avatar Sep 22 '22 09:09 thebestnom

ahh. okay okay got it

Niveydhithaa avatar Sep 22 '22 09:09 Niveydhithaa

wow. wonderful. thanks a lot, it has applied the config!

Niveydhithaa avatar Sep 22 '22 09:09 Niveydhithaa

image created a new label and checked for the color and label! worked like a charm

Niveydhithaa avatar Sep 22 '22 09:09 Niveydhithaa

thanks much. Also, is it possible for randomizing colors for each label ?

Niveydhithaa avatar Sep 22 '22 09:09 Niveydhithaa

Im pretty sure it is kinda randomized, Im not sure how vis.js choose color for group

thebestnom avatar Sep 22 '22 09:09 thebestnom

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 image

Niveydhithaa avatar Sep 22 '22 09:09 Niveydhithaa

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

Niveydhithaa avatar Sep 22 '22 09:09 Niveydhithaa

maybe if its fine for you, better we can open a new discussion based out of this

Niveydhithaa avatar Sep 22 '22 09:09 Niveydhithaa

focused issue on colors: https://github.com/neo4j-contrib/neovis.js/issues/293

Niveydhithaa avatar Sep 22 '22 09:09 Niveydhithaa