Browse Source

Merge remote-tracking branch 'origin/develop' into develop

css_transitions
jos 10 years ago
parent
commit
7a0c72a95d
3 changed files with 37 additions and 1 deletions
  1. +4
    -0
      HISTORY.md
  2. +12
    -1
      docs/graph.html
  3. +21
    -0
      src/graph/Graph.js

+ 4
- 0
HISTORY.md View File

@ -4,6 +4,10 @@ http://visjs.org
## not yet released, version 1.0.1 ## not yet released, version 1.0.1
### Graph
- added coordinate conversion from DOM to Canvas.
## 2014-05-02, version 1.0.0 ## 2014-05-02, version 1.0.0

+ 12
- 1
docs/graph.html View File

@ -1999,7 +1999,18 @@ var options: {
You can use this to stablize your graph once, then save the positions in a database so the next time you load the nodes, stabilization will be near instantaneous. You can use this to stablize your graph once, then save the positions in a database so the next time you load the nodes, stabilization will be near instantaneous.
</td> </td>
</tr> </tr>
<tr>
<td>DOMtoCanvas(pos)</td>
<td>object</td>
<td>This function converts DOM coordinates to coordinates on the canvas. Input and output are in the form of {x:xpos,y:ypos}. The DOM values are relative to the graph container.
</td>
</tr>
<tr>
<td>canvasToDOM(pos)</td>
<td>object</td>
<td>This function converts canvas coordinates to coordinates on the DOM. Input and output are in the form of {x:xpos,y:ypos}. The DOM values are relative to the graph container.
</td>
</tr>
<tr> <tr>
<td>on(event, callback)</td> <td>on(event, callback)</td>
<td>none</td> <td>none</td>

+ 21
- 0
src/graph/Graph.js View File

@ -1734,6 +1734,27 @@ Graph.prototype._yToCanvas = function(y) {
return y * this.scale + this.translation.y ; return y * this.scale + this.translation.y ;
}; };
/**
*
* @param {object} pos = {x: number, y: number}
* @returns {{x: number, y: number}}
* @constructor
*/
Graph.prototype.DOMtoCanvas = function(pos) {
return {x:this._xToCanvas(pos.x),y:this._yToCanvas(pos.y)};
}
/**
*
* @param {object} pos = {x: number, y: number}
* @returns {{x: number, y: number}}
* @constructor
*/
Graph.prototype.canvasToDOM = function(pos) {
return {x:this._canvasToX(pos.x),y:this._canvasToY(pos.y)};
}
/** /**
* Redraw all nodes * Redraw all nodes
* The 2d context of a HTML canvas can be retrieved by canvas.getContext('2d'); * The 2d context of a HTML canvas can be retrieved by canvas.getContext('2d');

Loading…
Cancel
Save