Creating Labels from Fields

Labels that are created from fields are always bound labels in Manifold. Bound labels are automatically created from objects in a drawing, including possibly fields taken from the drawing's table, so they are "bound" to that drawing and its objects.

 

Bound labels may also be synchronized with the drawing as well. If the labels component is synchronized with the drawing, then adding new objects to the drawing will create new labels for those objects and deleting objects from the drawing will delete their associated labels. See the Synchronized Labels topic for more details.

 

Whether or not bound labels are synchronized, if their text is taken from fields then they will automatically be updated with any changes in the drawing's data fields. For example, changing the formatting of the table's columns, such as changing a numeric field to show two digits after a decimal point, will automatically change the format of that numeric field as it appears in a bound label as well.

 

Creating a labels component that prints text based on data fields is the same as creating any bound labels component. We simply use the names of fields within square [ ] brackets in the Text pane of the Create Labels dialog.

 

There are several main ways to create a bound labels component:

 

·      In the project pane or from the File menu choose Create - Labels and then choose a Parent drawing from which labels will be created using fields from that drawing's table.

·      Copy either an entire drawing or some or all objects from a drawing and then Paste As a labels component. This will raise the Paste Labels dialog to create a labels component that is bound to the originating drawing.

·      Right click in the project pane, either on a drawing component or on an empty portion of the project pane and choose Create - Labels in the pop up context menu. Choose a Parent drawing in the resulting dialog. This creates a new labels layer in the project pane.

·      When a map window is open, right click onto the layers tabs and choose Add - New Labels. Choose a Parent drawing in the resulting dialog. This creates a new labels layer in the project pane and after the labels component is created it will be automatically added to the map as a layer.

 

Whichever path is used to raise the Create Labels dialog, we can illustrate the process using the File - Create - Labels command as follows:

 

To create labels using fields in drawings:

 

1. Choose File - Create - Labels

2. In the Create Labels dialog, click on one of the drawings listed in the Parent combo list.

3. This enables a list of fields in that drawing in the Columns pane. Double click on a field and it will appear in the Text pane.

4. Edit the Text pane as desired.

5. Press OK

 

Double-clicking a field name to place it within the editing pane is a useful shortcut but is not necessary. If desired, we can enter field names such as [Place_name] manually. Double clicking is recommended to avoid typographical errors in the names of fields.

 

When a labels component containing bound labels is opened in a labels window the parent drawing will be displayed in gray default color as a background to provide a visual context for the position of the labels.

 

Example

 

We will use the Mexico example drawing to create labels.

 

images\sc_create_labels_01.gif

 

We begin by importing the drawing into the project. We then right click onto the Mexico Drawing component in the project pane and choose Create - Labels to launch the Create Labels dialog.

 

images\dlg_create_labels_01.gif

 

The dialog shows Mexico Drawing loaded into the Parent combo box since we right clicked onto that drawing. If we had right clicked onto an empty portion of the project pane or if we had launched the Create - Labels dialog by choosing from the File main menu then the Parent box would have been loaded with [None] and we would have had to choose Mexico Drawing from the list made available in the Parent combo box.

 

If we had other drawings in our project these would be available in the Parent list as well. When we choose a drawing in the Parent box the columns for that drawing will appear in the Columns pane.

 

images\dlg_create_labels_02.gif

 

In the Columns pane we scroll down to Place_name and double click it. Double clicking a field name in the Columns pane will load it into the text in the Text pane. We could also simply enter the field name in brackets in the Text pane; however, double clicking the name from the Columns pane is often faster and less subject to typographical error.

 

images\dlg_create_labels_03.gif

 

We can now click into the Text pane and add any desired literal text. In this example, we have added "My name is " to the text for the label. When the label is constructed the field names in brackets will be replaced by the value in that column for that label's parent object. All text not in brackets is taken as literal text and will be displayed exactly as entered.

 

images\dlg_create_labels_04.gif

 

Note that intrinsic fields will also be listed in the Columns pane. If desired, we could scroll down to and double click on the Latitude (I) and Longitude (I) fields to add these in brackets to the Text pane. Intrinsic fields are computed by the system for each object. The Latitude (I) and Longitude (I) intrinsic fields report the centroid position of an object in the map. See the Intrinsic Fields in Tables topic for more information on intrinsic fields. When we are done adding text in the Text pane we press OK.

 

images\sc_create_labels_02.gif

 

A new labels component appears in the project. Since it is created using fields from Mexico Drawing it appears in the project hierarchy under its parent component.

 

images\sc_create_labels_03.gif

 

We can create a map that shows Mexico Drawing and the Labels label component together as layers with the labels layer above the drawing layer. Note how values have been substituted for [Place_name], [Latitude (I)] and [Longitude (I)]. The label is positioned at the centroid of the area. Each area in the drawing has a label.

 

Changing Formatting of Numbers in Labels

 

Suppose we would like to create labels with fewer digits after the decimal point in the latitude and longitude values? The formats of numbers in labels are taken from the format used for the columns in the table that provide those numbers. To change the appearance of numbers in labels that are taken from columns, change the formatting of those columns in the table. See the Formatting Columns topic.


For example, to change the appearance of the latitude and longitude intrinsic values, open the table and display the intrinsic columns. Next, change their formatting by right clicking on their column heads and choosing Format. Changing the format of the column will also change the format of any label that uses numbers from that column.

 

Changing Text used in Bound labels

 

If we would like to change the text or fields used in bound labels like the example above, open the labels component in its own window and choose Labels - Text to launch the Text dialog.

 

Creating Labels for Some, but not All, Objects

 

At times we may wish to create labels for some, but not all, objects in a drawing. We have several methods available:

 

·      Select those objects (such as areas in a drawing) for which labels are to be created. Copy the objects and paste them as a drawing, and then create labels for that drawing.

·      Un-check the Automatically label new drawing objects option in the Create Labels dialog, so that the resultant labels component is not synchronized. Alternately, after the component is created un-check Labels - Synchronized from the main menu so that it is not synchronized. We can then select and delete all labels we don't want. If only a few out of many labels are desired, it will be faster to select those labels we do want, choose Edit - Select Inverse to invert the selection and then delete. See the Synchronized Labels topic for more info.

·      Create a field that can be used for thematic formatting so labels that are not to be displayed can be thematically formatted using invisible color and desired labels can be formatted using a visible color. This technique allows only some of the labels to be made visible.

·      Create unbound labels manually. The disadvantage of this method is that label text cannot be taken automatically from fields as is the case with bound labels. See the Adding Text Labels topic.

·      Create bound labels and then use the Unlink command to convert the bound labels component into a standalone, unbound labels component. The labels may then be repositioned or individually deleted or altered.

·      Use linked drawings to create a drawing from a query where the results of the query are the drawing objects we want to have labeled. Create a synchronized, bound labels components using that dynamic drawing as the parent and then use that labels component. This can be faster than the thematic formatting approach because the labels component only contains those labels desired.

 

Example

 

In this example we create labels for some provinces in Mexico, using thematic formatting to show only some labels but not others.

 

images\eg_create_labels_01.gif

 

Consider a map with one layer, the example drawing of Mexican provinces. We add a labels layer by right clicking on the Mexico Drawing layer tab and choosing Add - New Labels.

 

images\eg_create_labels_02.gif

 

In the Create Labels dialog we choose the Mexico Drawing component as the parent and double click the Place_name column to add it to the label text. Press OK.

 

images\eg_create_labels_03.gif

 

This creates a new labels component, called Labels, and also adds it as a layer to the map. Note that labels are created for all provinces. The default auto-clipping will hide some labels that would otherwise overlap other labels. Overlap resolution may be adjusted using the View - Display Options dialog for the labels component.

 

At this point, the smart thing would be to simply un-check Labels - Synchronized to make this an unsynchronized labels component. We could then simply select and delete unwanted labels.

 

However, since this is an example for Help that is intended to illustrate various was of working with fields in tables in connection with labels, we will use a trickier approach, that of thematic formatting. This technique does not make much sense in ordinary interactive usage, but it is often used in IMS applications where we may want labels to appear or disappear based upon the contents of data fields.

 

We will create a new data column and the use that to guide whether or not a label is visible.

 

images\eg_create_labels_04a.gif

 

In the project pane we double click on the table for the drawing to open the table.

 

images\eg_create_labels_04.gif

 

We right click on any of the table's column headings and choose Add - Column to add a column to the table.

 

images\eg_create_labels_05.gif

 

In the Add Column dialog we create a new Boolean field called Label. A Boolean field can have only two values, which depending on the formatting for the column in use, can be represented as 1 or 0 (default formatting), True or False, Yes or No, On or Off and so on. Boolean fields are handy when a value may be either on or off.

 

There is no special meaning to our choice of the name Label for the new column. It is only a mnemonic to remind us that this field's values will be used to turn labels on or off for display.

 

images\eg_create_labels_06.gif

 

The new field is created with default 0 values. Our task now is to fill the Label cell with a 1 for those provinces for which we wish to have labels displayed.

 

images\eg_create_labels_07a.gif

 

This is easily done by clicking on the drawing layer in the map to make it the active layer and then selecting those provinces for which we want labels. We use touch selection in Add to Selection mode to click each province to be selected.

 

images\eg_create_labels_07.gif

 

If we switch back to the drawing's table, we see that those records corresponding to selected provinces are also selected. We double click into the Label cell for any of the selected records…

 

images\eg_create_labels_08.gif

 

…enter a 1 and then…

 

images\eg_create_labels_09.gif

 

…when we press Enter the new value of 1 will be propagated into the Label value for all of the selected records. Manifold uses auto-scoping for selection editing in tables, so that a change made to any selected record is a change made to all selected records. This is a very convenient way of modifying many records at once.

 

We have now marked all selected provinces with a value of 1 in their Label column. We can use this column to thematically format the labels component so that labels with a 1 in their object's Label column are visible and those with a 0 in their Label column are invisible.

 

images\eg_create_labels_10.gif

 

Click on the labels layer in the map to make it the active layer and then in the pull-down menu for the Foreground Color well in the formatting toolbar choose Theme.

 

images\eg_create_labels_11.gif

 

This launches the thematic formatting dialog. We choose Label as the field to control the formatting. We double click into the Values color well for the 0 value and choose invisible color. We will continue to use the default black color for the 1 value. Press OK.

 

Note: the thematic formatting dialog shows both 0 and 1 values in the Values pane for our editing pleasure because there are already some 0 values and also some 1 values in the table. If we did not previously change some of the values to 1 in the table the formatting dialog would only show 0 value in the Values pane.

 

images\eg_create_labels_12.gif

 

In the map window we can see that now only labels for selected states will be visible, because other labels are rendered in invisible color and cannot be seen. Not all labels are seen because some (such as the label for Durango province to the East of Sinaloa) will be suppressed by the auto-clipping algorithms designed to prevent overlapping label text.

 

images\eg_create_labels_13.gif

 

We can clean up the display by deselecting the selected provinces in the drawing. We can also change the formatting of labels in the labels layer to turn on Bold face so the labels stand out better.

 

The example above works well to display labels for only a subset of objects in a drawing. However, it has the performance impact of computing labels for all of the objects in a drawing and then reckoning which of those labels should be displayed with invisible color (so they cannot be seen) and which should be displayed for visible color. If we have 100,000 objects and only wish to show labels for five of those objects the above technique is somewhat wasteful because it requires the computation of 100,000 labels even though only five of the labels will be seen.

 

A more efficient technique would be to create a drawing consisting only of the five objects for which labels should be displayed and then create a labels component bound to that drawing. In that case, only five labels would be in play in the labels component. We could create such a drawing dynamically by using a query to create a linked drawing based upon the other drawing and then create a labels component that is bound to the linked drawing.

 

Showing Multiple Labels per Object

 

Sometimes we would like to show more than one label for objects. For example, we might have a drawing showing cities as points with population and name fields. We would like to show a label for population and a label for the name for each point.

 

images\sc_create_labels_10.gif

 

One way to accomplish this is to create a single label that uses the contents from both the name and population field as seen above.

 

Another way to show two labels for each point we create two labels components. We copy the cities drawing and paste it once as a labels component using the name field. We then paste it a second time as a labels component using the population field. Use a different alignment for the two labels components so that the two labels do not appear on top of each other. We then use both labels components in a map with the drawing. When using this method it may be important to turn off the Resolve overlaps between labels option in the View - Display Options dialog for labels so the different label layers do not clip each other.

 

Labels without Fields

 

At times we may want to create labels for a bound component that do not use fields.

 

images\eg_labels_thematic_01.gif

 

Consider a drawing that shows oil well locations as points.

 

images\eg_labels_thematic_02.gif

 

We create a labels component using this drawing as the parent and use the text "Oil Well" without using the names of any fields in brackets.

 

images\eg_labels_thematic_03.gif

 

We can drag and drop this labels component into the same map as the Oil Wells drawing to see that it creates the same text for every object. We have used the alignment toolbar to move the text labels slightly above and to the right of each parent point and we have used the Display Options dialog to add three pixels of space via the X and Y offsets between the labels and the points as well.

 

images\eg_labels_thematic_04.gif

 

Let's now create another labels component for this drawing but this time we will use a field to customize each label with the contents of the Production data field.

 

images\eg_labels_thematic_05.gif

 

We can drag and drop the new labels field into the map to create another labels layer. This labels component also has the labels moved slightly and uses the format toolbar to boldface each label.

 

Tech Tip: Using Bracket [ ] Characters in Labels

 

Given that bracket characters [ ] are used in the Create Labels text pane to indicate a field name from which data should be taken, how can we create text that includes a bracket character? Manifold at the present time does not allow an escape sequence, such as \[ to be used to denote the next character should be taken as a literal. Instead, we must use a hack.

 

Create two new text columns in the drawing's table. Call one LeftBracket or similar name and call the other RightBracket or similar name. The text columns may be created as fixed-length text with a length of 1 character. Select all records in the table and double-click into the LeftBracket column and enter a [ character. Because Manifold offers the convenient shortcut of filling all selected records with the edited value this will populate the LeftBracket column with a [ character for all records. Do the same for the RightBracket column except populate it with a ] character.

 

Now, whenever we want to use a left bracket in labels text we simply use the expression [LeftBracket] and whenever we want to use a right bracket we use the expression [RightBracket]. For example, if we want to create a text label like Verified [1995] we would enter the following into the text pane:

 

 Verified [LeftBracket]1995[RightBracket]

 

The contents of the "bracket" field names will be taken from the field which in all cases will be either a left bracket character or a right bracket character as desired.

 

Note that we can combine this technique with other field names as well. Suppose we have a Date Verified column in the table that has the particular year each record was verified, so that instead of hard-coding 1995 as the year we want to take the value from the field. We could do that by writing:

 

Verified [LeftBracket][Date Verified][RightBracket]

 

Note: It's quite likely at some future point Manifold will add an escape sequence allowing direct entry of bracket characters without the need for the above technique. However, the above technique should still be kept in mind as there may always be special characters in various fonts that can only be accessed through programmatic or other special means. In that case, an active column can be created that generates them and then the name of the active column can be used within brackets in the label text.

 

A Note for Enterprise Edition Users

 

It is possible to create a local labels component that is bound to a shared drawing component. This allows creation of a labels component within our project that is created based upon a drawing linked in from an Enterprise server.

 

See Also

 

Labels

Formatting Labels

Formatting Individual Labels

Thematic Formatting and Labels

Label Display Options