documentationfor yFiles for HTML 2.6

StringTemplatePortStyle

An IPortStyle that uses an SVG snippet as template for the visualization of IPorts.

Inheritance Hierarchy
TemplatePortStyleBase
StringTemplatePortStyle
Implemented Interfaces

Remarks

In contrast to TemplatePortStyle, the SVG template used by this style must be encoded as string and assigned to the svgContent property. Note that the renderSize should be specified to match the size of the visual's template.

It is vital that the SVG snippet does not declare the SVG namespace itself. Its content is parsed in a dummy namespace in order to avoid immediate validation of the result. The resulting SVG elements are automatically created in the SVG namespace before they are added to the DOM.

The SVG template snippet can contain bindings in the form attribute="{Binding propertyName}" that bind the attribute value to the value of the property with the given name in the port's tag. The tag itself can be bound with attribute="{Binding}". If the bound object provides the function addPropertyChangedListener(listener) or implements IPropertyObservable, bindings to properties of the business object are dynamically updated if the registered listeners are called on property change. Business objects can be made observable by calling makeObservable.

TemplateBindings in the form attribute="{TemplateBinding propertyName}" bind the attribute value to one of the properties of the port that are exposed by the ITemplateStyleBindingContext interface.

Bindings can specify converters and converter parameters. Converters are simple functions with the signature function(value:object, parameter:object):object. A converter has to be registered under its name either in the converter store or with the window object before it can be used.

TextWrapConverter is a built-in converter function which emits wrapped text as SVG elements. It can be used to display wrapped text in a template style. To use the TextWrapConverter the template style must include a <g> element that binds a property containing the text to be wrapped to data-content. TextWrapConverter must be specified as the converter function. The converter’s parameters are passed using a shorthand notation for width, height, font, trimming and color. See Text Wrapping in a Template Style for more details.

Depending on the current state, the following CSS classes are added to the root element of the template depending:

  • yfiles-selected
  • yfiles-focused
  • yfiles-highlighted

Related Programming Samples

Organization Chart
An interactive viewer for organization charts with adaptive styles and automatic layout.

Type Details

yfiles module
styles-template
yfiles-umd modules
All view modules
Legacy UMD name
yfiles.styles.StringTemplatePortStyle

See Also

Constructors

Properties

Methods

Events

Constants

Default Properties

Static Methods