Shading by Individual Values - MapBasic - 2023

MapInfo MapBasic Reference

Product type
Software
Portfolio
Locate
Product family
MapInfo
Product
MapInfo > MapBasic
Version
2023
Language
English
Product name
MapBasic
Title
MapInfo MapBasic Reference
First publish date
1985
Last updated
2023-09-12
Published on
2023-09-12T16:32:32.686312

Syntax

Shade [ Window window_id ] 
	{ layer_id | layer_name } 
	With Metadata
	With expr 
		[ Ignore value_to_ignore ] 
	Values const [ Pen... ] [ Line...] [ Brush... ] [ Symbol... ] 
		[ , const [ Pen... ] [ Line...] [ Brush... ] [ Symbol... ] ... ] 
		[ Vary { Color | All } ]
	[ Style Replace { On | Off } ]
	[ Default [ Pen... ] [ Brush... ] [ Symbol... ] ] 

window_id is the integer window identifier of a Map window.

layer_id is the layer identifier of a layer in the Map (one or larger).

layer_name is the name of a layer in the Map.

expr is the expression by which the table will be shaded, such as a column name.

value_to_ignore is a value to be ignored; this is usually zero (when using numerical expressions) or a blank string (when using string expressions); no thematic object will be created for a row if the row's value matches the value to be ignored.

const is a constant numeric expression or a constant string expression.

Description

The optional window_id clause identifies which Map is to be shaded; if no window_id is provided, MapBasic shades the topmost Map window.

The Shade statement must specify which layer to shade thematically, even if the Map window has only one layer. The layer may be identified by number (layer_id), where the topmost map layer has a layer_id value of one, the next layer has a layer_id value of two, etc. Alternately, the Shade statement can identify the map layer by name (for example, "world").

Each Shade statement must specify an expr expression clause. MapInfo Pro evaluates this expression for each object in the table being shaded; following the Shade statement, MapInfo Pro chooses each object's display style based on that record's expr value. The expression typically includes the names of one or more columns from the table being shaded.

If you specify With Metadata, any theme metadata contained in the open table is used to create the Individual or Ranged Value theme.

The keywords following the expr clause dictate which type of shading MapInfo Pro will perform. The Values keyword creates a map where each unique value has its own display style.

The Pen clause specifies a line style (for example, MakePen(width, pattern, color)) to use for the borders of filled objects (for example, regions).

The Line clause specifies a line style to use for lines, polylines, and arcs. The syntax of the Line clause is identical to the Pen clause, except for the keyword Line appearing in place of Pen.

The Brush clause specifies a fill style (for example, MakeBrush(pattern, forecolor, backcolor)).

The Symbol clause specifies a symbol style (for example, MakeSymbol(shape, color, size)).

For the specific syntax of an Individual Values map, see Syntax Shading by Individual Values.

In a Values map, the keyword Values is followed by from one to 255 value descriptions. Each value description consists of a unique value (string or numeric), followed by the graphic styles that MapInfo Pro should use to display objects having that exact value. If a record's expr value is exactly equal to one of the Shade statement's value descriptions, then that record's object will be displayed with the appropriate graphic style. The value descriptions are separated by commas.

If the Shade statement specifies either the Ranges or Values keyword, the statement can include the optional Default clause. This clause lets you specify the graphic styles used by the "all others" range. If a row does not fall into any of the specified ranges, MapInfo Pro assigns the row to the all-others range. The Vary clause sets how the objects will vary in appearance. The default is Vary All. If Vary All is specified, all of the display tools for each range are applied in the theme. If Vary Color is specified, only the color for the specified range is applied.

Style Replace On (default) specifies the layers under the theme are not drawn.

Style Replace Off specifies the layers under the theme are drawn, allowing for multi-variate transparent themes. This enables transparent patterns to be displayed on the same layer.

Style Replace On is the default and provides backwards compatibility with the existing behavior so that the underlying layers are not drawn.

The following example assumes that the UK_Sales table has a column called Sales_Rep; this column contains the name of the sales representative who handles the accounts for a sales territory in the United Kingdom. The Shade statement will display each region in a shade which depends upon that region's salesperson. Thus, all regions assigned to Bob will appear in one color, while all regions assigned to Jan will appear in another color, etc.

Open Table "uk_sales"
Map From uk_sales 

Shade 1 With Proper$(Sales_Rep) 
	Ignore "" 
	Values
		"Alan" , 
		"Amanda" ,
		"Bob" , 
		"Jan"