1.0.2 • Published 3 years ago

netv-label v1.0.2

Weekly downloads
15
License
MIT
Repository
github
Last release
3 years ago

NetV-label

Label plugin for NetV.js(http://netv.zjuvag.org/)

label

API reference

label = new Label(netv)

Constructor, create label handler

label.dispose()

Dispose label handler, remove related DOM element

getLabel(node: Node)

Get label for given node.

draw(node: Node | Node[], drawFunc?: (node: Node) => HTMLSVGElement)

Draw label for given node(s).

User can specify custom drawFunc, we provide several build-in drawFuncs:

  • Label.template.rightText: label will show at node's right, horizontal center aligned.
  • Label.template.topText: label will show at node's top, vertical center aligned.

Default drawFunc is rightText.

User can also write customized drawFunc to draw any svg elements, like draw an image:

const element = document.createElementNS('http://www.w3.org/2000/svg', 'image')
element.setAttribute('href', 'http://netv.zjuvag.org/logo.svg')
element.setAttribute('width', '100')
labelManager.draw(node, (node) => { return element })

updatePosition(node: Node | Node[])

Update label's position for given node(s).

The label's position will not sync with node when drag or manually change node's position. User may call this function manually.

remove(node: Node | Node[])

Rmove node's label.

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago