Class: Label

Konva. Label


new Label(config)

Label constructor.  Labels are groups that contain a Text and Tag shape

Parameters:
Name Type Description
config Object
Source:
konva.js
Example
// create label
var label = new Konva.Label({
  x: 100,
  y: 100,
  draggable: true
});

// add a tag to the label
label.add(new Konva.Tag({
  fill: '#bbb',
  stroke: '#333',
  shadowColor: 'black',
  shadowBlur: 10,
  shadowOffset: [10, 10],
  shadowOpacity: 0.2,
  lineJoin: 'round',
  pointerDirection: 'up',
  pointerWidth: 20,
  pointerHeight: 20,
  cornerRadius: 5
}));

// add text to the label
label.add(new Konva.Text({
  text: 'Hello World!',
  fontSize: 50,
  lineHeight: 1.2,
  padding: 10,
  fill: 'green'
 }));

Methods


getTag()

get Tag shape for the label. You need to access the Tag shape in order to update
the pointer properties and the corner radius

Source:
konva.js

getText()

get Text shape for the label. You need to access the Text shape in order to update
the text properties

Source:
konva.js
Example
label.getText().fill('red')