A CanvasComponents theme is used to configure the general look and feel of its interaction visualization.
While there are other means to customize each of those visualizations individually, setting a custom Theme allows you to switch to another visualization style or different color set in a one-liner:
graphComponent.theme = new Theme(
'simple-round',
'#ff6c00',
'#a4f0ff',
'#242265',
2
)
The variant defines the general visualization style. While the CLASSIC variant uses the well-known styling of previous yFiles for HTML versions, the SIMPLE_SQUARE and SIMPLE_ROUND variants use a more simplistic approach in a rectangular or round fashion.
The primaryColor, secondaryColor, and backgroundColor are used in different combinations by the interaction visualizations. The usage of each color is explained in its property description.
The scale is a factor used to scale the size of IHandles and IPortCandidates.
- yfiles module
- view-component
- yfiles-umd modules
- All view modules
- Legacy UMD name
- yfiles.view.Theme
Creates a new instance with the given variant
, colors and scale.
options - Object
A map of options to pass to the method.
- variant - ThemeVariant
The
ThemeVariant used in this theme that defines its general look and feel. Defaults to
CLASSIC.
- primaryColor - Color
- secondaryColor - Color
The
secondaryColor used for interaction visualization. Defaults to a blue-ish
#3399ff
.
- backgroundColor - Color
- scale - number
A third color used for interaction visualization.
This color is used for the following visualizations:
- As alternative color to primaryColor in the hatch brushes used for node selection, edge selection and edge highlight when CLASSIC is used.
- As fill color for bends of selected edges.
- As stroke color of port selection.
- As in-between color of the double-stroked border for node and stripe highlights when CLASSIC is used.
- As stroke color for IHandles with VARIANT1 (with the exception of RESIZE handles for SIMPLE_ROUND and SIMPLE_SQUARE, which use it as fill color).
- As fill color for IHandles with VARIANT2.
- As outline color for IPortCandidates.
An IVisualTemplate that can be used to resemble the classic variant rectangle selection for nodes and labels.
The hatching utilizes the theme's primaryColor
and backgroundColor
.
graphComponent.resources.set(
RectangleIndicatorInstaller.SELECTION_TEMPLATE_KEY,
theme.hatchRectangle
)
graphComponent.resources.set(
OrientedRectangleIndicatorInstaller.SELECTION_TEMPLATE_KEY,
theme.hatchRectangle
)
A hatch Stroke that can be used to resemble the classic variant selection stroke for edges.
The hatching utilizes the theme's primaryColor
and backgroundColor
.
graphComponent.resources.set(
EdgeSelectionIndicatorInstaller.STROKE_KEY,
theme.hatchStroke
)
The primary color used for interaction visualization.
This color is used for the following visualizations:
The secondary color used for interaction visualization.
This color is used for the following visualizations:
The variant used in this theme that defines its general look and feel.