Appearance
Ogma.view
View API: functions to manipulate the view of the graph.
ogma.view.afterNextFrame()
Returns a Promise that resolves after the next frame is rendered.
Returns
-
Promise<void>
ogma.view.animationInProgress()
Checks if any camera movement animations are currently in progress and returns true
if there are.
Returns
-
boolean
ogma.view.beforeNextFrame()
Returns a Promise that resolves before the next frame is rendered.
Returns
-
Promise<void>
ogma.view.forceResize()
Forces the canvas to be re-sized according to the container. Typically useful when the visibility of the Ogma container changes, to notify Ogma that it must refresh the scene.
ogma.view.get()
Retrieve the current view.
Returns
-
{x: number, y: number, zoom: number, angle: number, width: number, height: number}
ogma.view.getAngle()
Indicates the current angle of the view.
Returns
-
number
Angle, in radians.
ogma.view.getBounds()
Returns the bounds of the current view.
Returns
ogma.view.getCenter()
Indicates the center of the view.
Returns
-
{x: number, y: number}
ogma.view.getElementAt(pos)
Returns the element located at the specified screen coordinates.
Arguments
- pos
object
- x
number
Screen x - y
number
Screen y
- x
Returns
ogma.view.getElementsInView()
Returns the element currently visible in the viewport
Returns
ogma.view.getElementsInside(xmin, ymin, xmax, ymax, convertToScreenCoordinates)
Returns elements inside of the rectangle defined by the screen coordinates.
Arguments
- xmin
number
X coordinate of the bottom left corner - ymin
number
Y coordinate of the bottom left corner - xmax
number
X coordinate of the top right corner - ymax
number
Y coordinate of the top right corner - convertToScreenCoordinates
boolean = true
Whether or not the function will convert the coordinates to screen space before running the query
Returns
ogma.view.getGraphBoundingBox([options])
Returns the bounding box of the graph, in graph coordinates.
Arguments
- options(optional)
object
- includeTexts(optional)
boolean
[=false]
Wether or not take texts in account in the bouding box
- includeTexts(optional)
Returns
ogma.view.getImageData()
Returns a new ImageData
, containing the pixels that are displayed by the current renderer. If the current renderer is not canvas or WebGL, the method returns null
.
If the screen has a pixel density greater than one (for example, retina screen), the retrieved ImageData will not be rescaled and will have a bigger width and height than the view.
Note: since it's simply copying pixels, this method is way faster than an image export (ogma.export.png()
for example).
Returns
-
Promise<ImageData|null>
ogma.view.getNodeBadgeAt(node)
Returns which badge is under the specified point. Useful to know if a node badge is under the mouse cursor.
Arguments
Returns
-
topLeft|topRight|bottomLeft|bottomRight|undefined
The badge under the point, or undefined if none.
ogma.view.getSize()
Returns the view width and height.
Returns
-
{ width: number, height: number }
ogma.view.getTextBoundingBox(item)
Get screen coordinates of the axis-aligned bounding box of the specified node or edge.
Arguments
Returns
-
BoundingBox|null
ogma.view.getZoom()
Indicates the current zoom level.
Returns
-
number
ogma.view.graphToScreenCoordinates(coordinates)
Returns a position on the screen from graph coordinates (e.g a node's position).
Arguments
- coordinates
{x: number, y: number}
Returns
-
{x: number, y: number}
ogma.view.isFullScreen()
Indicates if the full screen mode is currently enabled.
Returns
-
boolean
ogma.view.locateGraph([options])
Centers the view on the graph.
Arguments
- options(optional)
LocateOptions
Returns
-
Promise<void>
ogma.view.locateRawGraph(graph[, options])
Centers the view on the specified raw graph.
Arguments
- graph
RawGraph
- options(optional)
LocateOptions
Returns
-
Promise<void>
ogma.view.move(offset[, options])
Move the center of the view by the specified amount of pixels (NOT graph coordinates).
Arguments
- offset
{x: number, y: number}
- options(optional)
CameraAnimationOptions
Returns
-
Promise<void>
ogma.view.moveTo(view[, options])
Smoothly animate to the particular view. If you don't provide the duration
option, the optimal animation duration is used based on the translation distance.
Arguments
view
object
- x
number
X coordinate of the center of the view. - y
number
Y coordinate of the center of the view. - zoom
number
Zoom level of the view.
- x
options(optional)
CameraAnimationOptions
For duration and easing
Returns
-
Promise<void>
ogma.view.moveToBounds(target[, options])
Animates the view to the bounding box. If you don't provide the duration
option, the optimal animation duration is used based on the translation distance.
Arguments
- target
BoundingBox | [number, number, number, number]
It can be aBoundingBox
or an Array ofminX
,minY
,maxX
,maxY
in graph coordinates - options(optional)
CameraAnimationOptions
For duration and easing
Returns
-
Promise<void>
ogma.view.rotate(angle[, options])
Rotate the view by the specified angle.
Arguments
- angle
number
Angle, in radians. - options(optional)
CameraAnimationOptions
Returns
-
Promise<void>
ogma.view.screenToGraphCoordinates(coordinates)
Returns graph coordinates from a position on the screen.
Arguments
- coordinates
{x: number, y: number}
Returns
-
{x: number, y: number}
ogma.view.set(view[, options])
Set the view.
Arguments
view
object
- angle(optional)
number
Angle of the view, in radians. - x(optional)
number
X coordinate of the center of the view. - y(optional)
number
Y coordinate of the center of the view. - zoom(optional)
number
Zoom level of the view.
- angle(optional)
options(optional)
CameraAnimationOptions
Returns
-
Promise<void>
ogma.view.setAngle(angle[, options])
Set the angle of the view.
Arguments
- angle
number
Angle, in radians. - options(optional)
CameraAnimationOptions
Returns
-
Promise<void>
ogma.view.setCenter(center[, options])
Set the center of the view, in graph coordinates.
Arguments
- center
{x: number, y: number}
- options(optional)
CameraAnimationOptions
Returns
-
Promise<void>
ogma.view.setFullScreen(value)
Enable or disable the full screen mode.
Arguments
- value
boolean
true
to enable the full screen mode,false
to disable it.
Returns
-
Promise<void>
ogma.view.setSize(size)
Set the size of the view. This method only has effect if this instance of Ogma has no container.
Arguments
- size
object
- height
number
- width
number
- height
Returns
-
Promise<void>
ogma.view.setZoom(zoom[, options])
Set the zoom level.
Arguments
- zoom
number
- options(optional)
CameraAnimationOptions
Returns
-
Promise<void>
ogma.view.zoomIn([options])
Multiply the current zoom level by the specified amount. If geo mode is on, it will fall back to ogma.geo.setZoom
and use the zoom modifier defined by the projection.
Arguments
- options(optional)
number|ZoomAnimationOptions
Zoom modifier or options. Ifmodifier
is not specified, it will be set toMath.sqrt(2)
.
Returns
-
Promise<void>
ogma.view.zoomOut([options])
Divide the current zoom level by the specified amount. If geo mode is on, it will fall back to ogma.geo.setZoom
and use the zoom modifier defined by the projection.
Arguments
- options(optional)
number|ZoomAnimationOptions
Zoom modifier or options. Ifmodifier
is not specified, it will be set toMath.sqrt(2)
.
Returns
-
Promise<void>