Page settings in JavaScript Diagram control
18 Nov 20182 minutes to read
Page settings allow customization of the appearance, size, and orientation of the diagram page.
Page size and appearance
The width and height properties in page settings determine the size of the page. Additionally, the background property allows customization of the page’s appearance. The color property of background is used to define the color of the page. The margin property defines the page margins.
To explore those properties, refer to Page Settings.
The following example shows the customization of page settings.
Set background image
A background image can be attached to the page by using the source property of background. The scale property adjusts how the background image stretches, while the align property aligns the image within the diagram page.
The following code illustrates how to set background image to the diagram page.
Page orientation
There are two types of page orientations:
- Landscape
- Portrait
Depending on the orientation selected, the width and height properties are adjusted accordingly. By default, the orientation is set to Landscape. In the following example, the height and width properties of pageSettings are swapped when setting the orientation to Portrait.
Multiple page and page breaks
When multiple pages are enabled, the page size dynamically adjusts in multiples of the specified width and height, ensuring the entire diagram fits within the page boundaries. Page breaks serve as visual guides indicating how pages are split.
The multiplePage and showPageBreak properties in page settings control the ability to enable multiple pages and display page break lines, respectively.
The color of the page break lines can be customized by overriding the styles of the .e-diagram-page-break class. For more details refer to CSS customization
Boundary constraints
The diagram supports restricting or customizing the interactive region where elements cannot be dragged, resized, or rotated. You can achieve this using the boundaryConstraints property in page settings.
There are three types of boundary constraints. They are:
- Infinity
- Diagram
- Page
To explore these constraints further, refer toBoundary Constraints.
Below is an example illustrating how to define boundary constraints within the diagram:
Fit options
The fitOptions in page settings control how diagram content is fitted within the diagram page. The canFit property within fitOptions centers the content within the viewport during diagram rendering. Additionally, the region property specifies whether to fit the page or the content to the center of the viewport. Choosing CustomBounds for the region allows fitting custom bounds within the diagram by defining them in the customBounds property of fitOptions. The canZoomIn property enables zooming in to fit smaller content within the viewport. Additionally, the margin property defines the space around the fitted content within the viewport, while the mode property sets the fitting mode, typically defaulting to Page but also offering options like Width and Height for specific dimension constraints.
The following example demonstrates how fitOptions are utilized in diagram page settings.