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

Dynamically adding label configs from neo4j server to neovis config #290

Closed Niveydhithaa closed 1 year ago

Niveydhithaa commented 2 years ago

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](https://user-images.githubusercontent.com/108443521/190408530-ae8c426b-599f-4802-9706-db9ba743d1dc.png) . 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?
thebestnom commented 2 years ago

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

Niveydhithaa commented 2 years ago

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

thebestnom commented 2 years ago

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 commented 2 years ago

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

Niveydhithaa commented 2 years ago

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?

thebestnom commented 2 years ago

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

Niveydhithaa commented 2 years ago

Great. Thanks I'll try.

Niveydhithaa commented 2 years ago

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

thebestnom commented 2 years ago

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)

Niveydhithaa commented 2 years ago

Great. Thanks a lot

Niveydhithaa commented 1 year ago

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)

thebestnom commented 1 year ago

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

Niveydhithaa commented 1 year ago

Yeah sure

Niveydhithaa commented 1 year ago

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

thebestnom commented 1 year ago

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

Niveydhithaa commented 1 year ago

Argh, okay ..

Niveydhithaa commented 1 year ago

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

thebestnom commented 1 year ago

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

Niveydhithaa commented 1 year ago

ahh. okay okay got it

Niveydhithaa commented 1 year ago

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

Niveydhithaa commented 1 year ago

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

Niveydhithaa commented 1 year ago

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

thebestnom commented 1 year ago

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

Niveydhithaa commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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

Niveydhithaa commented 1 year ago

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