Gentlemen, good afternoon.

The situation is the following, there is an adjacency graph of network devices (routers), which is drawn using: sigma.js
Information about the vertices is received from the database, after the PHP script is sent to the browser in the form of json .

Each vertex has the form:

 {id: host, label: host, x: Math.random(), y: Math.random(), size: 1, color: '#3399FF'} 

Where id and label is the hostname of a specific router.

Not understanding the situation, I had, regarding the position of the peaks:
In my case, the positions of x and y are calculated using the Math.random() function, which helps to scatter the vertices around the screen. In arbitrary order.

My goal is to save the position of the vertex after dragging it with the left mouse button. Ideally send this information to the database.

First of all, I had a total misunderstanding of how to implement it.

In the large Internet there are many ways that help to return the position of the cursor at the moment l.click. But regarding the position of the element and how to record the current position for debug, it is not clear to me yet.

If there are ideas in which direction to google / read, regarding the implementation of this functionality - I will be grateful.

  • As I understand it, you need to implement the mousedown and mouseup event handlers on the element where the grid is drawn. See developer.mozilla.org/ru/docs/Web/API/MouseEvent , and for example javascript.info/tutorial/mouse-events - pitersky
  • Thanks, in principle, also an option. The guys from the js forum also prompted to track the dragend event using the built-in tools sigma.js. In my case, this is a more suitable option. - Surf

0