Skip to main content

NiceDag

NiceDag defines a set of API which can control the DAG diagram.

Properties

PropertyDescriptionType
idId of DAG diagramstring
configDAG diagram configurationNiceDagConfig

API

setScale

(scale:number) => void

The api can set scale of the diagram. The scale range is from 0 to 1.

center

(size: Size) => NiceDag

The api can make the diagram be the center position of its parent container.

Arguments

NameOptionalDescriptionType
sizeNoSize of its parent containerSize

Returns

NameDescriptionType
NiceDagitselfNiceDag

scrollTo

(id: string) => void

The api make the main layer scroll to the target id element.

setDirection

(direction: NiceDagDirection) => void

The api can set the direction of the DAG diagram.

Arguments

NameOptionalDescriptionType
directionNoDirection of the diagramNiceDagDirection

getScrollPosition

() => Point

The api can get the scroll distance of the main layer.

Return

NameDescriptionType
PointPoint positionPoint

getAllNodes

() => IViewNode[]

The api can get all nodes and return an array of IViewNode.

Return

NameDescriptionType
IViewNode[]An array of IViewNodeIViewNode []

getAllEdges

() => IEdge[]

The api can gey all edges and return an array of IEdge.

Return

NameDescriptionType
IEdgeIEdgeIEdge

withNodes

(nodes: Node[]) => NiceDag

The api deal with init nodes and generate model and view.

Arguments

NameOptionalDescriptionType
nodesNoNodes arrayNode[]

Return

NameDescriptionType
NiceDagitselfNiceDag

API (Editable DAG)

The follow APIs are only applicable for editable DAG diagram.

startEditing

() => void

The api can make a DAG diagram editable. Usually, it is used to swipe editing feature (read-only vs editable).

stopEditing

() => void

The api can disable a DAG diagram editing feature.

prettify

() => void

The api can re-layout the DAG diagram according to the nodes and nodes' dependencies. If a node is editing, the node won't be impacted by the API.

addNode

(node: Node, point: Point, targetNodeId?: string) => void

The api can add a node to the target position. If targetNodeId is set, it will add a child node of targetNodeId.

Arguments

NameOptionalDescriptionType
nodeNoNodeIViewNode
pointYesTarget positonPoint
targetNodeIdYesParent node idstring

addJointNode

(node: Node, point: Point, targetNodeId?: string) => void

The api can add a joint node to the target position. If targetNodeId is set, it will add a joint child node of targetNodeId.

Arguments

NameOptionalDescriptionType
nodeNoNodeIViewNode
pointYesTarget positonPoint
targetNodeIdYesParent node idstring