Defining Styles

It is possible to define a group of attributes as a style and later apply them collectively. Styles are useful if you have e.g., two types of signals on a diagrams and want to visually distinguish between them. Then, instead of re-typing all the required attributes for each arrow, simply define two styles for them. Also, if you later want to change the appearance of these arrows, you just need to change the style and not every arrow individually.

Styles can be defined using the defstyle command, as below.

defstyle stylename, ... [ attribute=value | style, ... ], ... ;

First you list the name of the style(s) to define then the attributes and their intended values. Similar to color names, style names are case-sensitive and can only contain letters, numbers, underscores and dots, but can not start with a number or a dot and can not end with a dot. You do not have to specify all possible attributes, just those you want to modify with the style. The rest of the attributes will remain unspecified. When you apply the style to an element, attributes of the element that are unspecified in the syle are left unchanged.

Any of the attributes listed in Common Attributes can be added to a style. You can also enlist styles among the attributes. In this case the newly defined style inherits all the attributes specified in that style. If you apply a style to an element, those attributes of the style, which not applicable to that particular element type are simply ignored. For example, applying a style including fill.color to an arrow will silently ignore the value of the fill.color attribute.

The same syntax above can be used to extend and modify styles. You can add new attributes to an existing style or modify existing attributes. This is when listing multiple styles comes in handy. You can set attributes to the same value in multiple styles in a signle command.

It is also possible to unset an attribute by specifying the attribute name, followed by the equal sign, but no value.

Default Styles

There are a number of default, built-in styles that govern the default appearance of elements. By modifying these you can impact, e.g., all the arrows in a chart. This is how chart designs operate: by modifying the built-in styles.

First there is a built-in style for each element: arrow, box, emptybox, divider, blockarrow, pipe entity, entitygroup, symbol, indicator[42], title, subtitle, note, comment, endnote, vertical[43], vertical_brace, vertical_bracket, vertical_range, vertical_pointer, symbol[44] and text[45].

There are also predefined styles for grouped entities and boxes for when they are collapsed: entitygroup_collapsed, box_collapsed and box_collapsed_arrow, the latter is used when a box is collapsed to a bidirectional arrow.

If you want to change a set of attributes for multiple elements (such as both for arrows and dividers) simply list these separated by commas before the attributes.

It will apply to both.

Then there are further styles defined for each arrow, box and divider element, called refinement styles. These are partial (by default specify only line type) and will be applied to the element after the main style for the element (listed above).

  • for arrows: ‘->’, ‘=>’, ‘>’ and ‘>>[46].

  • for block arrows: ‘block->’, ‘block=>’, ‘block>’ and ‘block>>’.

  • for boxes: ‘--’, ‘==’, ‘++’ and ‘..

  • for pipes: ‘pipe--’, ‘pipe==’, ‘pipe++’ and ‘pipe..

  • for dividers: ‘---’ and ‘...

  • for verticals: vertical->, vertical>, vertical>>, vertical=>, vertical--, vertical++, vertical.. and vertical==.

Redefining enables you to quickly define, e.g., various arrow styles and use the various symbols as shorthand for these. Usually style names containing non-letter characters have to be quoted, but for the above styles the parser is expected to recognize them without quotation. So both below are valid.

Note that re-defining an existing style do not erase the attributes previously set in the style. Only the new attribute definition is added - changing the value of the attribute if already set in the style. This the example above keeps the line.type=solid setting in ‘->’ style.

Finally there are two more pre-defined styles: strong and weak. By adding these to any element you will get a more and less emphasized look, respectively. The benefit of these compared to making elements stronger or weaker by yourself is that they are defined in all chart designs in a visually appropriate manner. Thus you do not need to change anything when changing chart design just keep using them unaltered.

As a related comment we note that chart designs modify all the above styles and the default value for the hscale, compress, vspacing, numbering, indicator, angle and text chart options, too.

Thus, in summary the actual attributes of an element are set using the following logic.

  1. If you specify an attribute directly at the element (perhaps via applying a style), the specified value is used[47].

  2. Otherwise, if the attribute is set in the refinement style (at the point and in the scope of where the element is defined), the value there is used. (Usually only line styles are set, so this is why you can use e.g., => to make an arrow double-lined.)

  3. Otherwise, if the attribute is set in the default style of the element, the value there is used.

  4. Otherwise, the value of the applicable chart option is used, such as text.*, compress, vspace, indicator, numbering, auto_heading and angle. In order for these chart options to be effective default styles usually have no value specified for these attributes. You can set these attributes in styles, e.g., to set font type for empty boxes, which will take precedence over chart options.



[42] The style indicator determines the appearance of the small symbols that indicate elements hidden due to a collapsed box or entity group.

[43] referring to vertical boxes

[44] referring to all symbols

[45] referring to text at commands

[46] These are also applied to bi-directional arrows and arrows pointing from an entity back to itself. Thus there is no separate ‘<->’ style, for example.

[47] If you specify the attribute several times, the last one is used.