Example: Style Properties in the mfd_meta Table

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 begin with a drawing called Regions that shows regions in France that has been formatted using the Style dialog similar to the procedures shown in the Example: Format a Drawing using the Style Panel topic.



If we right-click on the Regions drawing in the Project pane and choose Properties we can see that the drawing has Style properties that specify the formatting to use for the objects in the drawing.    All Style information is in JSON, human-readable form.  In addition to be present in the Properties dialog for the drawing, the Style properties 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.




For this example we will 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, which is automatically named Regions 2.




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 all of the Style properties that specify how objects in the drawing should be formatted.  We now have two, separate drawings that both take their objects from the same table but which have completely independent Style properties.


Using the procedures given in the Example: Format a Drawing using the Style Panel topic, we use the Style dialog to change the formatting of the Regions 2 drawing.




As seen above we have used Style to change the area background color for all areas to a shade of green.


We now have two drawings that use different formatting.   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": { "41": 12211667, "46": 4286945, "51": 6591981, "57": 49151, "64": 52945 } }


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.  

Edit Values in the mfd_meta Table

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 6591981 which follows the "52" to 3978097 so that the string after editing reads:


{ "Field": "mfd_id", "Fill": "boundmin", "Value": 12211667, "Values": { "40": 12211667, "46": 4286945, "52": 3978097, "58": 49151, "64": 52945 } }


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 a new, green color as 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.


See also

Getting Started


User Interface Basics




Editing Tables






Style: Drawings


Example: Format a Drawing using the Style Panel - In this example we provide a first, step by step look at how to format areas in a drawing using the Style panel.  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 panel.


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 panel 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.