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

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

Open
joylix opened this issue Jul 8, 2024 · 1 comment
Open

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

joylix opened this issue Jul 8, 2024 · 1 comment

Comments

@joylix
Copy link

joylix commented Jul 8, 2024

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?

@joylix joylix changed the title How to fix the node at the top of the canvas node can not be fixed to the top of the canvas Jul 9, 2024
@desean1625
Copy link

Try setting the camera position.

network.moveTo({position:{x:0,y:0},scale:1})

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