visjs / vis-network

:dizzy: Display dynamic, automatically organised, customizable network views.
https://visjs.github.io/vis-network/
Apache License 2.0
2.99k stars 365 forks source link

node can not be fixed to the top of the canvas #2170

Open joylix opened 2 months ago

joylix commented 2 months ago

I want to fix the nodes at the top position of the canvas, but no matter how I adjust the node.y value, they are always positioned closer to the middle of the canvas. Below is my page code:

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF8" />
    <title>Vis Network Example Applications </title>   
    <script type="text/javascript" src="js/vis-network.min.js"></script>
    <style type="text/css">
     #mynetwork {
      width: 100px;
      height: 600px;
      border: 1px solid lightgray;
    } 
    </style>
  </head>
<body>
<div id="mynetwork"></div>

<script type="text/javascript">
  var nodes = new vis.DataSet([
    {id: 1, label: 'Node 1', fixed: true,  x:-140, y:-180},
    {id: 2, label: 'Node 2', fixed: true,  x:-140, y:-120},
  ]);
  var edges = new vis.DataSet([]);
  var options = { physics: false};

  var container = document.getElementById('mynetwork');
  var data = {  nodes: nodes,  edges: edges  };
  var network = new vis.Network(container, data, options);

</script>
</body>
</html>  

How can I modify it so that the node be placed at the top of the canvas?