Skip to content
This repository was archived by the owner on Jul 29, 2019. It is now read-only.

Commit 2e5c620

Browse files
eymihamojoaxel
authored andcommitted
fix(network): #2589 vertically center label in network circle node (#2593)
1 parent 100f47a commit 2e5c620

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

examples/network/edgeStyles/colors.html

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@
3030
<script type="text/javascript">
3131
// create an array with nodes
3232
var nodes = new vis.DataSet([
33-
{id: 1, label: 1, color:'#97C2FC'},
34-
{id: 2, label: 2, color:'#FFFF00'},
35-
{id: 3, label: 3, color:'#FB7E81'},
36-
{id: 4, label: 4, color:'#7BE141'},
37-
{id: 5, label: 5, color:'#6E6EFD'},
38-
{id: 6, label: 6, color:'#C2FABC'},
39-
{id: 7, label: 7, color:'#FFA807'},
40-
{id: 8, label: 8, color:'#6E6EFD'}
33+
{id: 1, label: 'node\none', shape: 'box', color:'#97C2FC'},
34+
{id: 2, label: 'node\ntwo', shape: 'circle', color:'#FFFF00'},
35+
{id: 3, label: 'node\nthree', shape: 'diamond', color:'#FB7E81'},
36+
{id: 4, label: 'node\nfour', shape: 'dot', size: 10, color:'#7BE141'},
37+
{id: 5, label: 'node\nfive', shape: 'ellipse', color:'#6E6EFD'},
38+
{id: 6, label: 'node\nsix', shape: 'star', color:'#C2FABC'},
39+
{id: 7, label: 'node\nseven', shape: 'triangle', color:'#FFA807'},
40+
{id: 8, label: 'node\neight', shape: 'triangleDown', color:'#6E6EFD'}
4141
]);
4242

4343
// create an array with edges
@@ -58,7 +58,11 @@
5858
nodes: nodes,
5959
edges: edges
6060
};
61-
var options = {};
61+
var options = {
62+
nodes: {
63+
shape: 'circle'
64+
}
65+
};
6266
var network = new vis.Network(container, data, options);
6367
</script>
6468

lib/network/modules/components/nodes/shapes/Circle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Circle extends CircleImageBase {
3535

3636
this.updateBoundingBox(x,y);
3737
this.labelModule.draw(ctx, this.left + this.textSize.width / 2 + this.margin.left,
38-
this.top + this.textSize.height / 2 + this.margin.top, selected, hover);
38+
y, selected, hover);
3939
}
4040

4141
updateBoundingBox(x,y) {

0 commit comments

Comments
 (0)