Skip to content

@linkurious/ogma-annotations

Classes

ClassDescription
ControlMain controller class for managing annotations. It manages rendering and editing of annotations.

Interfaces

InterfaceDescription
AnnotationCollectionCollection of Annotations, GeoJSON FeatureCollection
AnnotationFeatureBase interface for all annotation features.
AnnotationPropsBase properties for all annotations.
ArrowArrow annotation feature. Represents a directed line between two points, can connect a textbox to a shape.
ArrowPropertiesBase properties for all annotations.
ArrowStylesStyles specific to arrow annotations.
BoxBox annotation feature
BoxPropertiesProperties specific to box annotations.
BoxStyleStyles specific to box annotations.
ClickEventEvent related to a single annotation feature
CommentComment annotation type Geometry: Point (center position of comment box/icon)
CommentPropsProperties for Comment annotations
CommentStyleStyle configuration for Comment annotations
DragEventEvent related to a single annotation feature
FeatureEventEvent related to a single annotation feature
FeaturesEventEvent related to multiple annotation features
HistoryEventHistory stack change event
LinkLink between an arrow and a text or node
PolygonPolygon placed on the graph, use it to highlight areas
PolygonPropertiesBase properties for all annotations.
PolygonStyleStyles specific to box annotations.
TextText annotation feature, represents a text box at a specific position
TextProperties-
TextStyleStyles specific to box annotations.

Type Aliases

Type AliasDescription
AnnotationUnion type of all Annotation features
AnnotationGetterFunction type to get an Annotation by its id
AnnotationOptions-
AnnotationTypeTypes of annotations supported
BoundsBounding box object, with the following properties: - [0]: min x - [1]: min y - [2]: max x - [3]: max y
BoxMagnetArrow snapped to a rectangular annotation (text, box, comment). nx/ny are center-relative fractions multiplied by width/height: left-center = { nx: -0.5, ny: 0 } right-center = { nx: 0.5, ny: 0 } center =
ClientMouseEvent-
ColorAny valid color format
ControllerOptionsOptions for the annotations control
DeepPartial-
EdgeMagnetArrow snapped at parametric position t (0–1) along an edge path.
ExportedLinkSerialized link stored inside arrow.properties.link. Uses plain { x, y } for backward compatibility with saved annotations. Converted to the internal Magnet type by Links.add().
ExtremityExtremity types for arrow annotations.
FeatureEvents-
HexColorHex color string in format #RGB or #RRGGBB
IdUnique identifier type for annotations
Magnet-
NodeMagnetArrow snapped to the center or perimeter of a node.
Point2D coordinate
PolygonMagnetArrow snapped to a polygon annotation. rx/ry are 0–1 fractions of the polygon's bounding box from its top-left corner.
RgbaColorRGBA color string in format rgba(r, g, b, a)
RgbColorRGB color string in format rgb(r, g, b)
Side-
StrokeStroke style for arrow annotations
StrokeOptionsStroke style options for annotations
StrokeStyle-
StrokeTypeStroke types available for annotations
TargetType-

Variables

VariableDescription
COMMENT_MODE_COLLAPSED-
COMMENT_MODE_EXPANDED-
DATA_ATTR-
DEFAULT_EDIT_ICON-
DEFAULT_SEND_ICONDefault send button icon (paper plane)
defaultArrowOptionsDefault options for creating new Arrow annotations. Contains the default arrow structure with defaultArrowStyle.
defaultArrowStyleDefault style configuration for arrow annotations.
defaultBoxOptionsDefault options for creating new Box annotations. Contains the default box structure with defaultBoxStyle.
defaultBoxStyleDefault style configuration for box annotations.
defaultCommentOptionsDefault options for creating new Comments. Contains the default comment configuration with defaultCommentStyle.
defaultCommentStyleDefault style for Comment annotations
defaultPolygonPropertiesDefault polygon properties for creating new Polygon annotations. Contains the default polygon configuration with defaultPolygonStyle.
defaultPolygonStyleDefault style configuration for polygon annotations.
defaultTextOptionsDefault options for creating new Text annotations. Contains the default text structure with defaultTextStyle.
defaultTextStyleDefault style configuration for text annotations.
EVT_ADD-
EVT_CANCEL_DRAWING-
EVT_CLICK-
EVT_COMPLETE_DRAWING-
EVT_DRAG-
EVT_DRAG_END-
EVT_DRAG_START-
EVT_HISTORY-
EVT_HOVER-
EVT_LINK-
EVT_REMOVE-
EVT_SELECT-
EVT_UNHOVER-
EVT_UNSELECT-
EVT_UPDATE-
handleDetectionThreshold-
handleRadius-
HL_BRIGHTEN-
NONE-
SIDE_END-
SIDE_START-
TEXT_LINE_HEIGHT-

Functions

FunctionDescription
adjustColorBrightnessAdjusts the brightness of a color (hex or rgba) based on its perceived luminance. For bright colors, the adjustment is applied as darkening; for dark colors, as lightening.
asColorSafely cast a string to a Color type with runtime validation
asHexColorSafely cast a string to a HexColor type with runtime validation
asRgbaColorSafely cast a string to an RgbaColor type with runtime validation
asRgbColorSafely cast a string to an RgbColor type with runtime validation
brightenBrighten a color for highlight purposes.
bringToTopMove el to the end of root's children. SVG paint order is DOM order, so this is how a shape gets raised to the top of its group. Safe to call every render even when el is already last - appendChild on an existing child just re-positions it, it doesn't clone or re-trigger insertion.
calculateCommentZoomThresholdCalculate optimal zoom threshold for auto-collapse based on comment dimensions
canDetachArrowEndCheck if arrow endpoint can be detached from its target
canDetachArrowStartCheck if arrow start point can be detached from its source
clientToContainerPosition-
colorToRgba-
createArrow-
createBox-
createCommentCreate a new Comment annotation
createCommentWithArrowCreate a comment with an arrow pointing to a target location
createPolygonCreate a polygon annotation
createText-
darkenDarken a color for highlight purposes.
getAnnotationsBoundsCalculate the bounds of a collection of annotations
getArrowEnd-
getArrowEndPoints-
getArrowSide-
getArrowStart-
getAttachmentPointOnNode-
getBbox-
getBoxCenter-
getBoxPosition-
getBoxSize-
getCascadeDeleteIdsIds that removing id should take with it: id itself, plus every arrow attached to it when it's a comment or text annotation - deleting the anchor takes its connectors along, since a detached comment-arrow has nothing to point at.
getCommentLeftOrphanedByComments must always keep at least one arrow. Returns the comment's id when deleting arrowId would leave it with none, so the caller can block the deletion instead - or null when it's safe to proceed.
getCommentLinkIdGet the id of the comment an arrow is connected to, if any.
getCommentPositionGet the position (center) of a comment
getCommentSizeGet the dimensions of a comment based on its mode
getCommentZoomThresholdGet the effective zoom threshold for a comment Uses explicit threshold if set, otherwise calculates from dimensions
getCoordinates-
getHandleId-
getPolygonBoundsGet bounding box of a polygon
getPolygonCenterGet centroid (geometric center) of a polygon
hexShortToLong-
hexToRgbaAdds alpha channel to a hex color
isAnnotationCollectionHelper to check if a feature collection is an annotation collection
isArrow-
isBox-
isColorType guard to check if a string is a valid color
isCommentType guard to check if an annotation is a Comment
isCommentArrowCheck if an arrow is connected to a comment
isHexColorType guard to check if a string is a valid hex color
isPolygon-
isRgbaColorType guard to check if a string is a valid RGBA color
isRgbColorType guard to check if a string is a valid RGB color
isRigidConnectorWhether a comment's connector line should rigidly follow its attachment point (translate the comment by the same offset) rather than elastically re-anchoring to the nearest point on the comment box.
isText-
parseColor-
rgbToRgbaAdds alpha channel to an rgb color
scaleGeometry-
scalePolygonScale polygon around an origin point
setArrowEnd-
setArrowEndPoint-
setArrowStart-
setBbox-
simplifyPolygonPolyline simplification using a combination of the Radial Distance and the Douglas-Peucker algorithms See https://github.com/mourner/simplify-js for more details
toggleCommentModeToggle comment mode between collapsed and expanded
translatePolygonTranslate (move) a polygon by dx, dy
updateBbox-
updatePolygonBboxUpdate bbox for a polygon

References

getTextBbox

Renames and re-exports getBbox


getTextPosition

Renames and re-exports getBoxPosition


getTextSize

Renames and re-exports getBoxSize


setTextBbox

Renames and re-exports setBbox


updateTextBbox

Renames and re-exports updateBbox