Guilhem Soulas
Guilhem Soulas

Reputation: 1995

vis.js network: nodes z-index

Is there an equivalent of the CSS z-index for vis.js nodes?

Suppose that I have 2 kinds of nodes (in a graph with physics disabled): Circles and rectangles. I would like the rectangles to always be displayed over the circles when they are overlapping.

Upvotes: 3

Views: 1351

Answers (2)

YakovL
YakovL

Reputation: 8316

Judging by the mentioned issue, a more precise answer would be: there's no documented way to set z-index (and there's no such concept), but what you can use (with a risk of getting this broken at some update) is nodes are drawn in the same order they are defined. From comment:

I used the following test nodes:

var nodes = [
    {id: 'a', label: 'a', shape: 'dot'},
    {id: 'b', label: 'b', shape: 'dot'},
    {id: 'c', label: 'c', shape: 'dot'},
    {id: 'd', label: 'd', shape: 'dot'}
];

When not selected, these will draw in the node order:

enter image description here

Now, let's change the order:

var nodes = [
    {id: 'c', label: 'c', shape: 'dot'},
    {id: 'b', label: 'b', shape: 'dot'},
    {id: 'd', label: 'd', shape: 'dot'},
    {id: 'a', label: 'a', shape: 'dot'}
];

enter image description here

Upvotes: 0

cityy
cityy

Reputation: 163

Kind of a late reply but the short answer is: no

See this issue: https://github.com/almende/vis/issues/3146

Upvotes: 3

Related Questions