Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Max width for edges and nodes #65

Open
Famondir opened this issue Nov 7, 2023 · 3 comments
Open

Max width for edges and nodes #65

Famondir opened this issue Nov 7, 2023 · 3 comments

Comments

@Famondir
Copy link

Famondir commented Nov 7, 2023

Hi,
I have problems setting the max width for edges. I tried many of the visjs-settings like value, width, widthConstrain resulting in a common width for all edges or without any effect. I find the default max width to big.

I also tried Jaal(edge_df, node_df).plot(directed=True, vis_opts={'physics':{'stabilization':{'iterations': 100}, 'solver' : 'repulsion'}, 'edges': {'scaling': {'min': 1, 'max': 2}}}) with no result (taken from layout.py.

Same would be good for node size as well. Especially if you have only few different values (e. g. 1 and 2) it becomes really obscure:

image

As a work around for the edges I found the posibility to add an edge that connects two non existent nodes and has higher value in the size determing column. E.g. a 10. It won't show up.

For nodes this is not so easy, because the node will show up anywaay. But you can filter it out. If you add a node that you filter out anyway you can use its id as from and to in the edge_df as well:

image

then becomes

image

Sincerely Simon

@Famondir Famondir changed the title Max width for edges Max width for edges and nodes Nov 8, 2023
@Famondir
Copy link
Author

Famondir commented Nov 8, 2023

I tried passing visjs options like this as well:

'edges': {'scaling': {'customScalingFunction': 'function (min, max, total, value) {return value / total;}', 'min': 5, 'max': 150}}

I took it from this example.

@Famondir
Copy link
Author

Famondir commented Nov 8, 2023

You can disable the dummy node by accessing the Jaal objects data entry and setting the hidden and physics attributes there:

node_df.loc[len(node_df)] = ['dummy', '', '', 100, 100] # last node is the dummy node
edge_df.loc[len(edge_df)] = ['dummy', 'dummy', 'NA', 10, 10]

j = Jaal(edge_df, node_df)
j.data['nodes'][-1]['hidden'] = True # last node is the dummy node
j.data['nodes'][-1]['physics'] = False # last node is the dummy node
j.plot(directed=True, vis_opts={'physics': {'stabilization':{'iterations': 100}, 'barnesHut': {'centralGravity': 1, 'springConstant': 0.01}}})

@imohitmayank
Copy link
Owner

Hey @Famondir thanks for reporting this.
This seems to be happening due to coded scaling which in your case is making the scaled weights 0 and 20 respectively for the original 1 and 2 defined weights. Need to find a better way to handle corner cases. Will get back here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants