protected createVisual(
context: IRenderContext,
label: ILabel
): CustomLabelStyleVisual {
const textElement = document.createElementNS(
'http://www.w3.org/2000/svg',
'text'
)
const labelSize = label.layout.toSize()
TextRenderSupport.addText(textElement, label.text, font)
textElement.setAttribute('transform', `translate(${padding} ${padding})`)
const backgroundPathElement = document.createElementNS(
'http://www.w3.org/2000/svg',
'path'
)
backgroundPathElement.setAttribute(
'd',
this.createBackgroundShapeData(labelSize)
)
backgroundPathElement.setAttribute('stroke', '#aaa')
backgroundPathElement.setAttribute('fill', '#fffecd')
const gElement = document.createElementNS('http://www.w3.org/2000/svg', 'g')
gElement.appendChild(backgroundPathElement)
gElement.appendChild(textElement)
const transform = LabelStyleBase.createLayoutTransform(
context,
label.layout,
true
)
transform.applyTo(gElement)
const cache = {
width: labelSize.width,
height: labelSize.height,
text: label.text
}
return SvgVisual.from(gElement, cache)