Network - canvas

Handles the HTML part of the canvas.

Options

This is a list of all the methods in the public API. They are collected here from all individual modules.

nametypedefaultdescription
widthString'100%'the width of the canvas. Can be in percentages or pixels (ie. '400px').
heightString'100%'the height of the canvas. Can be in percentages or pixels (ie. '400px').

Methods

This is a list of all the methods in the public API. Options can be set directly to the module or you can use the setOptions method of the network itself and use the module name as an object name.

namereturnsdescription
setSize(String, String)noneSet the size of the canvas. This is automatically done on a window resize.
canvasToDOM(Object) ObjectThis function converts canvas coordinates to coordinates on the DOM. Input and output are in the form of {x:Number,y:Number}. The DOM values are relative to the network container.
DOMtoCanvas(Object) ObjectThis function converts DOM coordinates to coordinates on the canvas. Input and output are in the form of {x:Number,y:Number}. The DOM values are relative to the network container.

Events

This is a list of all the events in the public API. They are collected here from all individual modules.

namepropertiesdescription
resize
{
  width: Number // the new width of the canvas
  height: Number // the new height of the canvas
  oldWidth: Number // the old width of the canvas
  oldHeight: Number // the old height of the canvas
}
Fired when the size of the canvas has been resized, either by a redraw call when the container div has changed in size, a setSize() call with new values or a setOptions() with new width and/or height values.