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.

 

eg_style_mfd_meta01_01.png

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.

 

eg_style_mfd_meta01_13.png

 

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.

 

eg_style_mfd_meta01_02.png

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.

eg_style_mfd_meta01_03.png

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.

 

eg_style_mfd_meta01_04.png

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.

eg_style_mfd_meta01_05.png

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 StyleColorBack property, which specifies the background color for objects in a given drawing.

 

The value of the StyleColorBack property for the Regions 2 drawing is a single color, simply written as:

 

{ "Value": 3978097 }

 

The value of the StyleColorBack 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.

 

eg_style_mfd_meta01_06.png

 

We double-click into the Value cell for the StyleColorBack property record for the Regions drawing to start editing and then we press Ctrl-A to select all.  Press Ctrl-C to copy.

 

eg_style_mfd_meta01_07.png

 

Next, we double-click into the Value cell for the StyleColorBack property record for the Regions 2 drawing to start editing and then we press Ctrl-A to select all.  Press Ctrl-V to paste.

 

eg_style_mfd_meta01_08.png

Click the row handle to commit the edit.

eg_style_mfd_meta01_09.png

 

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 clicked the row handle to commit the edit, the Regions 2 drawing updated to the new formatting.

eg_style_mfd_meta01_10.png

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.

 

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 StyleColorBack 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:

eg_style_mfd_meta01_11.png

We double-click into the Value cell for the StyleColorBack property record for the Regions drawing to start editing.    We scroll into the JSON string and change the number 6591981 which follows the "51" to 3978097 so that the string after editing reads:

 

{ "Field": "mfd_id", "Fill": "boundmin", "Value": 12211667, "Values": { "41": 12211667, "46": 4286945, "51": 3978097, "57": 49151, "64": 52945 } }

 

We press Enter to stop editing and then Ctrl-Enter to commit the edit, which has the same effect as clicking on the row handle to commit the edit.

 

As soon as we commit the edit the Regions drawing updates to incorporate the new StyleColorBack property that now says to use a new, green color as part of the thematic formatting.

 

eg_style_mfd_meta01_12.png

 

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.

 

Notes

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

 

Maps

 

Editing Tables

 

Drawings

 

Style

 

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.