Skip to main content

defaults

Description

Optional. An object which sets the default configuration of a shape or a line

Usage

defaults?: {
[type: string]: object
};

Parameters

The defaults object can contain a set of key:value pairs where key is the type of a shape or line and value is a set of configuration settings of the shape or line correspondingly.

note

The type and id attributes can not be defined in the default configuration of a shape/line.

Example

const defaults = {
// the default settings for all shapes of the "rectangle" type
rectangle: {
fill: "#CEEFE1",
stroke: "#0AB169",
strokeWidth: 2,
width: 140,
height: 140,
text: "Default text"
},
// the default settings for all lines of the "line" type
line: {
strokeWidth: 3,
stroke: "#245CE0"
},
// the default settings for all lines of the "dash" type
dash: {
strokeWidth: 3,
stroke: "#245CE0"
}
};

const editor = new dhx.DiagramEditor("editor_container", {
type: "default",
defaults
});
info

After defining the default settings for the shape/line of separate types, you can either omit these properties or redefine their values while preparing a data set for the shapes/lines of these types.

Change log: The ability to set the default configuration for lines was added in v4.2

Related articles:

Related sample: Diagram editor. Setting the default line (connector) type. Try connecting shape A to shape B