!!!###!!!title=Background——VisActor/VGraph tutorial documents!!!###!!!!!!###!!!description=In graph editing scenarios, a grid background is usually needed for auxiliary editing. The Background component has two built-in background styles: 'dot' and 'grid'.The following is an example of how to use the Background component. You can also experience it in the demo.```javascriptimport { Graph, Background } from "@visactor/vgraph";const background = new Background(graph, { type: 'dot' });```!!!###!!!

Background

In graph editing scenarios, a grid background is usually needed for auxiliary editing. The Background component has two built-in background styles: 'dot' and 'grid'.

The following is an example of how to use the Background component. You can also experience it in the demo.

import { Graph, Background } from "@visactor/vgraph";
const background = new Background(graph, { type: 'dot' });

Configuration Items

BackgroundOptions is defined as follows.

FieldTypeDescription
type'grid' | 'dot'Grid style type. Default is 'grid'.
stepnumberStep size. By default, it is consistent with the step size of the Grid component.
backgroundColorstringBackground color. Default is pure white '#FFFFFF'.
opacitynumberBackground opacity.
colorstringForeground color. Depending on the type, it is either the grid line color or the dot fill color.
imgUrlstringCustom background image. Default is empty.

Instance Methods

Instance MethodReturn ValueDescription
enable()voidEnable the component.
disable()voidDisable the component.
changeSize()voidChange the width and height to fit the width and height of the Graph.
update()voidUpdate the background image position.
destroy()voidDestroy the component.