Style overrides allow us to specify exceptions to the default, layer-wide style properties specified by the Style pane for drawings and labels. Before proceeding, please read the Style: Overrides topic.
We begin with a map that has one layer, called Regions, a drawing that shows the regions of France as areas. This drawing shows French regions after the recent consolidation of regions into a smaller number of larger regions. The areas in the drawing use default, black and gray style. We have used the Layers pane to specify a nice shade of blue for the background, to liven up the display despite the default gray formatting.
Opening the drawing's table we see it has three fields, an mfd_id field as usual for drawings, a Name text field and a Geom field that contains geom data defining each area.
With the focus on the map, in the Style pane we can see default black and gray formatting is used for style properties. We click the Options tab.
The Options tab provides a box to choose what text field should be used to store style override information. The chosen text field will contain the style JSON string for each record that is used to specify an individual style for that record.
If there already is a text field in the table called Style, by default that will be loaded. If not, as in the example above, whatever is the first text field in the table will appear. In our example there is no text field called Style in the table, so the Options tab provides the first text field it finds, called Name.
It would not be a good idea to use the text field called Name, since that already is filled with the names of Mexican provinces. Using the same field to save JSON text for style overrides would overwrite the names of the Mexican provinces. If there was some other existing, but unused, text field in the table we could use that.
However, it is a much better idea to create a new field and to name that field Style so we know what it is intended to be. Most Manifold users get into the habit of using a text field named Style to store style override data.
We click Schema to use the Schema dialog to create a new text field.
Press the Add command button and then choose Field in the drop down menu.
Enter the name Style and choose the type nvarchar. We could name the field whatever we want, but most Manifold users get into the habit of using the default name, Style, so the purpose of the field is obvious when viewing a table or a table's schema. We could choose varchar as the data type for the text field, but most Manifold users will always choose nvarchar for text fields for the greater generality of using Unicode, just in case some day a text value in a different language might be used.
We check our work and press Save Changes to add the new Style text field to the table.
Back in the Style pane, the new Style text field we added appears as the choice of field for storing style override text. We check the Use style overrides box.
Press the Update Style button.
A new text field called Style appears in the table. It is filled with NULLs since so far we have not specified any style overrides for any areas in the drawing.
To specify a style override, we Alt-click an area to pick it as the context object for the Info pane. The area is marked with small blue boxes at the vertices of the area.
The Info pane immediately pops into action, showing field values for that object. We see we have clicked the area for Centre-Val de Loire, a truly fine region of France, the historical heart of the country. We click on the Style tab.
The Style tab shows the style properties applied to the area. By default, these are the same style properties set in the Style pane for the entire layer, with the area symbol being a total style button. We click the Fill Color button to change fill color from the default gray to green.
Important: If the Use style overrides box has not been checked in the Options tab of the Style pane, we will not be able to change the style used by this object. We can only change these style properties if we have checked the Use style overrides box.
When we change the fill color to green a square icon appears on the button to indicate we have specified a style override. We press Update Record to apply the change.
Immediately, our area is rendered using the green fill color we specified. We can clean up the display by Alt-clicking an empty spot on the map to clear the context status of the area, so it is not highlighted with a necklace of blue dots.
If we look in the drawing's table we see that the Style field for the Centre-Val de Loire record has acquired a JSON text string for the style override we specified. All the other areas have NULLs in their Style field because we only specified a style override for one area.
One of the great things about saving style overrides in text fields is that we can uncheck and then re-check the Use style overrides box without losing the style overrides we have specified.
Suppose in the Style pane Option tab we uncheck the Use style overrides box:
If we uncheck the Use style overrides box and press the Update Style button the system stops using style overrides. Instead of using style overrides, it applies to all objects whatever style has been specified in the Style pane.
Suppose we check the Use style overrides box:
If we check the Use style overrides box and press the Update Style button again, the system once more starts using style overrides. Any style overrides in the Style field are applied.
Uncheck the Use style overrides box:
We uncheck Use style overrides and press the Update Style button. Style overrides no longer appear.
Next, we will demonstrate that changing the overall style properties for the drawing have no effect on style overrides we have specified.
Click the Style pane to change style properties for the layer.
In the Style pane we set a thematic format that colors regions of France using their names as unique values.
In the map we see the effect as each region is colored by the thematic format based on region name.
Again, we check the Use style overrides box:
In the Options tab we check the Use style overrides box and press the Update Style button. Once again, the style override we specified earlier takes effect. The style override for the Centre Val de Loire region is still there, saved as a JSON text string in the Style text field of the table.
If we look at a map where objects are styled in a variety of ways we may want to know which are styled using the layer style properties specified by Style Pane and which are styled using a style override.
That is easy to do using the Select pane.
With the focus on the map window, in the Select pane the Regions layer will be chosen, since it is the only layer in the map. We choose the Style field and then we double-click the Null template to launch it.
In the Null template we choose not null as the Condition option. For Action, we use the default replace selection.
That immediately selects all records where the Style field value is not NULL. In this case, only one record is selected, shown above using red selection color.
The corresponding area automatically also is selected in the map and also shown in red selection color.
Suppose we have some style overrides set for various objects in our drawing, and we would like to clear those, that is not have them any more. That is easy to do, by simply setting the values of the Style field for those objects to NULL.
We start with a drawing where three objects, shown in green, use style overrides. Clearing style overrides for all objects is simple: we copy a NULL into the Style field for each record.
Open the drawing's table and press Ctrl-A to select all records, or in the main menu press Edit - Select All. Next, right-click any of the Style field cells that contains a NULL and in the context menu choose Copy to Selection.
That copies NULL into all Style cells.
We choose Edit - Select None to clear the selection and thus to clean up the display.
If we like, we can choose only some objects for which the style override will be cleared. To do that we select all the desired objects, either in the drawing or in the table.
In the table, Ctrl-click any record that has a NULL in the Style field to select that record. Next, right-click onto the Style field cell that contains a NULL and in the context menu choose Copy to Selection.
That copies NULL into the Style cells for all selected records. We choose Edit - Select None to clear the selection and thus to clean up the display.
In the map we see that there is only one record left with a style override. In the examples above there were only a few selected records, but if we had thousands of objects using a style override and we had selected them all, we could have instantly cleared the style override for all of those thousands of objects at once in a single step using the same procedure.
Another way to clear a style override is to manually Alt-click each object for which we would like to clear the style override and then use the Info pane.
Suppose the Centre-Val de Loire area is colored in green, using a style override:
We Alt-click the Centre-Val de Loire area to pick it for use in the Info pane.
In the Info pane's Style tab we click on the Fill Color property.
In the drop down menu we choose Default.
That clears the style override. The square icon indicating a style override disappears from that style property's button, and the style property button shows the light brown color assigned to that area by the thematic format which is specified for the entire layer. We press the Update Record button to apply the changes.
Back in the map, we see that there is no longer any style override applied for the Centre-Val de Loire area.
Because style overrides are simply non-NULL strings in the Style field we can copy and paste them between records if we want to apply the same style overrides to other objects.
Consider our example with a style override in use for the Centre-Val de Loire area, as seen above.
The style override is simply a string value in the Style field for the Centre-Val de Loire record. We can copy and paste it just like any other string.
For example, we can right-click onto the Style cell for the Centre-Val de Loire record and choose Copy.
We can then right-click onto the Style cell for the Hauts-de-France record and choose Paste.
That copies the style override string from the Centre-Val de Loire record and pastes it into the Hauts-de-France record.
Like magic, when we refresh the map view (choose View - Refresh or pan or zoom the view) the Hauts-de-France area is also colored with the same style override as used by the Centre-Val de Loire area.
We can right-click onto the Style cell for the Normandie record and Paste again.
That pastes the style override into the Normandie record.
Refreshing the map shows that the Normandie area now also uses the same style override.
We can have style override strings in more than one field in a table. Whatever style override field we tell the system to use in the Style Pane - Options tab will be used.
For example, suppose we use Edit - Schema to add an nvarchar field called Style 2 to the Regions Table.
In the Style Pane - Options tab we check the Use style overrides box and in the pull-down list of available text fields we choose Style 2.
That will now be the field the system will use as a source of style overrides for each object. We press the Update Style button.
The map shows default formatting for all areas, because all of the areas have NULLs, that is no style overrides, in their Style 2 field.
We add some style overrides:
We Alt-click on the Pays de la Loire area.
In the Info pane Style tab we change the fill color to yellow and we press Update Record. That creates a style override for that object.
The Pays de la Loire area appears in yellow. We Alt-click the Centre-Val de Loire area.
We specify a magenta fill color and press Update Record.
We Alt-click into an empty part of the map to clear up the display. We now have two areas that use style overrides.
If we open the Regions Table we see that style override strings have been added to the Style 2 field for two records.
If we like, we can switch back and forth between using the two different style override fields.
In the Style pane Options tab we choose Style as the field to use with style overrides. We press the Update Style button. Right away, the map uses the style overrides from that field.
In the Style Pane - Options tab we choose Style 2 as the field to use with style overrides. We press the Update Style button. Right away, the map uses the style overrides from that field.
We may want to use SQL or scripts to manipulate the use of style overrides. How can we see if style overrides are in use, and, if they are, which field do they use?
Right-clicking a drawing in the Project pane and choosing Properties will show the properties for that drawing. If Use style overrides has been checked for that drawing, it will contain a StyleOverrides property, the value of which will be the name of the field from which style overrides are used. In the illustration above we see that style overrides are in use and that the Style field provides those overrides.
In the illustration above we see that style overrides are in use and that the Style 2 field provides those overrides.
In the illustration above there is no StyleOverrides property for the drawing, so we know that style overrides are not in use.
If we would like to access or to manipulate style overrides with SQL or programmatically, we can see in the mfd_meta System Data table if a layer has style overrides in use. From the illustration above we can see that the Regions drawing uses style overrides, using the Style 2 field.
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, it makes sense to create a new text field called Style in the schema dialog, just so in the future we are reminded what that field is for. But there is nothing special about the name 'Style' other than it is short and easy to remember. It also is 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 we prefer. Manifold uses nvarchar text type by default because using Unicode by default is good karma in an application that is used in many different countries.
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. A related use of style overrides would be to change the Stroke color for a single object to transparent color, which would make that one object disappear.
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.
Example: Style Pane Quickstart - A tutorial introduction to using the Style pane to apply color, symbology, size and rotation to areas, lines and points in drawings.