Style properties for drawings such as colors for areas are stored in human readable JSON values as properties in the mfd_meta system table. This example shows how we can copy formatting from one drawing to another by simply copying values between records in the mfd_meta table.
We have a project that contains a Regions drawing and a Regions Table with the names of regions in France (using the pre-2017 arrangement) and a Regions drawing created from that table:
The Regions drawing has been formatted using the Style dialog similar to the procedures shown in the Example: Format a Drawing using the Style Pane topic. The drawing's formatting is simply human-readable text that is stored in the drawing's properties.
If we right-click on the Regions drawing in the Project pane and choose Properties we can see that the drawing has a Style property for area color that specifies the formatting to use for the Fill color of objects in the drawing:
All Style information is in JSON, human-readable form, and can be copied, pasted or edited using the context menu which appears with a right-click on the string. The full text of the string is:
{ "Field": "mfd_id", "Fill": "boundmin", "Value": 12211667, "Values": { "40": 12211667, "46": 4286945, "52": 3978097, "58": 49151 } }
In addition to appearing in the Properties dialog for the drawing, any Style properties for a drawing also exist in the mfd_meta system table. In fact, the Properties dialog simply reports the values it finds in the mfd_meta system table.
We will demonstrate how to copy and paste style property values between drawings. We first will create a second drawing from the same table. We will use that second drawing as an example.
To do that, we click the Regions drawing in the Project pane, press Ctrl-C to Copy it, and then press Ctrl-V to Paste it to create a copy in the Project pane. The copy is automatically named Regions 2.
Manifold allows us to create more than one drawing from the same table, so we can apply different formatting to the different drawings if we want.
If we open the Regions 2 drawing we see that it is indeed a copy of the Regions drawing. Copying and pasting the Regions drawing also copied and pasted the properties for that drawing, including the Style property for Fill color. We now have two, separate drawings that both take their objects from the same table but which have completely independent Style properties.
With the focus on the Regions 2 drawing, in the Style pane, we change the formatting of Fill color for areas from a thematic format to green color. This is simple: we click twice on the Fill color button for areas (the first click calls up the thematic format, and the second click switches to a grid of colors) and we choose a green color from the drop down menu of colors. See the Example: Format a Drawing using the Style Pane topic.
As seen above, all areas in Regions 2 are now shown using the same shade of green. We now have two drawings that use different formatting.
If we open the Properties dialog for the Regions 2 drawing, we see that it has a simpler JSON string specifying the area color style property.
We will open the mfd_meta table to take a look at how we can copy and paste field values between records within that table to copy formatting from one drawing to another.
In the Project pane we double-click on the mfd_meta table to open it. This is just a table like any other and is fully editable. We want to be careful editing it, of course, but we can easily edit it either manually, using SQL or using programmatic processes to take advantage of and to manipulate the information it exposes.
Looking at the mfd_meta table we can see how it contains records for the Style properties of both the Regions and the Regions 2 drawings. The Style property of interest for this example is the StyleAreaColorBack property, which specifies the background color for objects in a given drawing.
The value of the StyleAreaColorBack property for the Regions 2 drawing is a single color, simply written as:
{ "Value": 3978097 }
The value of the StyleAreaColorBack property for the Regions drawing is a more complex JSON expression because describes how colors are assigned based upon breaks using the values of the mfd_id field, a convenient way of coloring areas in a drawing with different colors:
{ "Field": "mfd_id", "Fill": "boundmin", "Value": 12211667, "Values": { "40": 12211667, "46": 4286945, "52": 3978097, "58": 49151 } }
We intend to copy the JSON style value from the Regions drawing and then paste it as the JSON style value for the Regions 2 drawing. This is not rocket science but simple editing of tables as discussed in the Editing Tables and Example: Editing Records in a Table topics.
We Right-click onto the Value cell for the StyleAreaColorBack property record for the Regions drawing, and then we choose Copy in the context menu that pops open.
Next, we Right-click onto the Value cell for the StyleAreaColorBack property record for the Regions 2 drawing, and we choose Paste. The Paste operation is immediate.
We have now copied the Style value for area background color from the Regions drawing property record into the Regions 2 drawing property record. The moment we pressed Paste, the Regions 2 drawing updated to the new formatting.
It now looks just like the Regions drawing again, since we have copied into its properties in the mfd_meta table the Style setting from the Regions drawing.
If we Right-click onto the Regions 2 drawing in the Project pane and choose Properties, we see that the properties have been updated. This is as expected, since the mfd_meta table is simply a consolidated listing of properties.
So far we have copied and pasted the entire Style property's JSON string. But if we want we can edit that JSON string in place if we would like to change the formatting used.
Recall that we set up this example by first using a single color, a shade of green, to format area backgrounds in the Regions 2 drawing. That resulted in a StyleAreaColorBack property for the Regions 2 drawing of:
{ "Value": 3978097 }
The number 3978097 encodes the shade of green color that we used. We will edit the JSON string for the Regions drawing to replace one of the colors used with that color, as follows:
We Right-click onto the Value cell for the StyleAreaColorBack property record for the Regions drawing, and we choose Edit to start editing. We could double-click into the cell to start editing it, but when editing longer strings it is more convenient to use the Edit dialog.
The Edit dialog conveniently displays the entire JSON string at once.
We change the number 12211667 (a code for the purple color) which follows the "40" to 3978097 so that the string after editing reads:
{ "Field": "mfd_id", "Fill": "boundmin", "Value": 3978097, "Values": { "40": 12211667, "46": 4286945, "52": 3978097, "58": 49151 } }
We press OK to close the Edit dialog and to commit the edit. As soon as we commit the edit the Regions drawing updates to incorporate the new StyleAreaColorBack property. That property now says to use green color as a new part of the thematic formatting.
From the above we can see there is nothing magical about how Style information is stored and exposed in Manifold: all Style properties are just values in a table, in human-readable JSON form, that can be manipulated just like any values in any table.
Historical regions - The illustrations in this topic use data from the US government, which show the regions of France as they were before 1 January 2016, when regions in France were reduced from 22 to 13.
Historical property names - Why is the style property for Fill color for areas called StyleAreaColorBack and not StyleAreaColorFill? Prior Manifold versions referred to Fill color as "background" color, so the historic names of properties have been retained, to simplify porting of scripts and other programming between versions.
Example: Format a Drawing using the Style Pane - In this example we provide a first, step by step look at how to format areas in a drawing using the Style pane. We can specify the same formatting for all areas or use a field to automatically set formatting, a process usually known as thematic formatting.
Example: Format the Size of City Points by Population - A common GIS task is to format the size of points in a drawing based on some value. For example, the size of points that represent cities might be formatted based on the value of the city's population, with cities that have larger populations being marked by larger point icons. This is an example of thematic formatting and is easy to do using the Style pane.
Example: Add, Delete and Edit Thematic Formatting Intervals - This topic provides a step by step example of adding, deleting and editing intervals in the Style pane that are used for thematic formatting.
Example: Formatting Tricks - The visualization capabilities of Manifold using Style can be exploited to provide many visual effects. This topic provides some examples of how to use Style in unexpected ways to create a range of more elaborate effects.
Example: How Not to Format a Drawing - When using Style to format a drawing it is a really bad idea to use the same color for objects that is used for the background color. It can also be a bad idea to use transparent color. This topic illustrates why.
Example: Multiple Drawings from the Same Table - Illustrates how easy it is to create multiple drawings that use the same table and same geometry by copying and pasting an existing drawing. Each new drawing takes no additional storage space in the project, but can be formatted differently.
Example: Layout Properties - Editing properties which appear in the mfd_meta table for a layout changes the content of that layout. We can exploit that effect to create standardized layouts which are then re-cycled for different content.