Style: Overrides

Style properties shown in the Style
panel normally apply to all items in the active layer. Style
overrides allow individual objects or labels to ignore the overall
Style properties for the layer and instead to use their own, individual
styles. This topic is intended to be read together with the
Example:
Style Overrides topic.

A style override is
a plain text field in a record that specifies what style should be
used for that record's object or label instead of the style set by
the Style
panel for the layer. By default, the text field used for style
overrides is named Style.

By default, style overrides are not
allowed and the system ignores any style specifications found in a record.
When we check the option box to use
style overrides, if a record contains a style specification the system
will use that specification, overriding whatever has been set by the Style
panel for the layer. Only those style properties changed by the
override will be changed. All other style properties will
continue to be applied as specified by the Style panel.

When style overrides are in use they allow us to individually specify
style properties for specific objects or labels.

To use style overrides:

Open the drawing or labels component or click on its tab in
an open map window.

Open the Style panel
in the Contents pane.

Click on the Options
tab and check the Use style overrides
box.

Choose the text field to be used or allow the system to create
a new field, named 'Style' by default.

Press the Create button
when creating a new field, or Apply
when using an existing text field.

To specify a style override for an object or label:

Open the drawing or labels component or click on its tab in
an open map window.

Alt-click onto the object
or label desired.

In the Record panel's
Style tab, choose the desired
style properties.

Press Update Record.

To remove a style override from an object or label:

Open the drawing or labels component or click on its tab in
an open map window.

Alt-click onto the object
or label desired.

In the Record panel's
Style tab, click the desired
style property and choose Default.

Press Update Record.

To find all records/objects/labels with style overrides:

Open the drawing's table for the drawing or labels component
desired.

In the Select
panel choose the Style field
and the Is not NULL template.

Press Replace Selection.

All records for which the Style
field is not <NULL> will be selected, and their corresponding drawing
objects or labels will also be selected.

Style Overrides are just Fields in Tables

A style override is nothing more than a string of human-readable text
in a record. The text specifies style properties using
JSON style. If the Use style
override box is checked
in the main Style panel, Option tab for the layer, Manifold will look
at the specified text field for each record to see if is empty or if it
contains a style override. If it is not empty, Manifold uses whatever
style properties it finds in the string for that record.

The table above has a text field called Style
that contains NULLs for all records except one record, which has a style
override in that field. The Style
field for the Centre-Val de Loire record
specifies use of a green color for the fill color for areas. That
one record has a style override while all the other records have NULLs.

Manifold draws objects for that layer using whatever style properties
are specified by the Style panel. If we turn on style overrides,
the override for the Centre-Val
de Loire record will be used for that object in preference
to what the Style panel says. No matter what the Style panel
specifies, the Centre-Val de Loire object
will have green fill color within the area. The override for Centre-Val de Loire does
not mention any other style properties, so all other style properties
like the color of the area border will continue as specified by the Style
panel.

When we specify a style override for an object or label by clicking
style buttons and choosing a color or other property, Manifold writes
the appropriate JSON test for us into the table for that object. We
do not need to learn how to write style overrides in JSON. However,
if we do understand JSON we can use queries and scripts to automate the
creation of style overrides. Even if we do not understand
how to write a style override in JSON from scratch, we can create an override
and then copy and paste that style override from the record in which it
was created to other records. Using the Select and Transform panels we can
copy it into thousands of records at once with a few mouse clicks.

Notes

Is the field named 'Style' special?
- Yes and no. The Use
style overrides facility will look for a text field called Style
in the drawing's table and, if a field named Style
exists, that field will be used by default to store any style overrides.
We can choose a different text field if we like. If
a field named Style does not exist,
the (new field) choice will create
an nvarchar text field called
Style. If we already
have a field called Style and
we choose (new field), that will
create a field called Style 2
and so on. But there is nothing special about the name 'Style'
other than it is short, easy to remember, and more self-documenting than
using the name 'Ringo' or 'Beatrice' for a field that will store style
override text.

Why nvarchar? Can it be a varchar?
- Yes, if you prefer. Manifold uses nvarchar
text type by default because supporting Unicode is good karma in an application
that is used in many different countries.

More than one style overrides field.
- We can have more than one text field in the table that is used for style
overrides. Whichever field has been chosen in the field box by the
Use style overrides check box
is the field that will be used.

Are style overrides a replacement for
thematic formatting? - No. Style overrides generally
are intended for special case needs, to be applied in an ad hoc manner.
For example, suppose we have thematically formatted a map
for cartographic reasons but when it comes time to print there is one
area that just does not look right, for which a slightly lighter color
would look better. If we are in a hurry, instead of spending
more time tinkering with thematic formats we could simply take a brute
force approach and use a style override to color that one area exactly
the color which looks good in the layout.

Another good use for style overrides is when creating labels manually
to annotate a map. Style overrides allow us to manually specify
the style of each label, such as size, font and color that we create.
When the numbers of labels are limited it is often easier
to simply use style overrides than to organize a limited number of labels
into several different layers that can all be formatted in the usual way.