From 9b551565ae3c3f54b9bf908a4d76f8a71f63ba44 Mon Sep 17 00:00:00 2001 From: Hans Sponberg Date: Sun, 9 Feb 2020 14:51:32 -0800 Subject: [PATCH] update readme for overriding default settings --- README.md | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9643df1..c9b4bc9 100644 --- a/README.md +++ b/README.md @@ -1409,14 +1409,42 @@ renderDiagram('diagram2') ... ``` +### Overriding Default Settings + +Default settings can be overridden, which will then apply to all diagrams that a Diagram Factory renders (unless the input file specifies the setting). The following default settings can be overridden: + + - margin + - left + - top + - right + - bottom + - defaultSettings + - horizontal-spacer + - vertical-spacer + - text-width + - text-height + - grid-align + - grid-valign + +Example: + +```javascript +const diagramFactory = new SvgDiagramFactory(basePath, pluginPaths) + +diagramFactory.margin.left = 5 + +diagramFactory.defaultSettings['grid-align'] = 'left' +``` + ### Relative and Absolute Paths By default, paths to images and fonts in the generated svg are relative from the diagram file. -There could be times when the author wants to use an absolute path. This can be done by setting the parameter in the example below. +There could be times when the author wants to use an absolute path. This can be done by setting the property in the example below. ```javascript const diagramFactory = new SvgDiagramFactory(basePath, pluginPaths) + diagramFactory.convertRelativePathsToAbsolute = true ```