vis-network
vis-network copied to clipboard
How to avoid overlapping text labels?
The labels of the nodes of my graph is long. I want to make them not overlap to each other. It's more efficient than tweaking the repulsion physics. Is it possible?
In the physics configuration, the barnesHut
solver has avoidOverlap
property which prevents overlapping. However this only applies to nodes, not note labels.
Also asked on Stack Overflow: How to avoid overlapping text labels in vis.js?
Not an expert here, but I had the same question some time ago and I think it is not possible. Take a look at this issue in the archived vis repository https://github.com/almende/vis/issues/1964
Size of the label is not taken into account for any of the positioning code
and
Maybe it should be taken into account, sure. Similarly, the drawn size of the node is not taken into account. This is for performance reasons really. It would give very different results from the expectation if we let the physics depend on drawn size.
I'd prefer not to label things as bugs unless it really IS a bug: a mistake in the code. A feature request could be a solution here, though it's a tricky one. I'm not sure what the best way for this would be. Probably automatic linebreaking but it'd be computationally expensive for a bit of a cornercase.
So I think it is unlikely to be implemented anytime soon, if at all.