Pie Charts - 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 | Selection }
	With expr [ , expr... ]
	[ Half ] Pie [ Angle angle ] [ Counter ] 
	[ Fixed ] [ Max Size chart_size [ Units unitname ] 
		[ At Value max_value [ Vary Size By {"LOG" | "SQRT" | "CONST" } ] ] ]
	[ Border Pen... ]
	[ Position [ { Left | Right | Center } ] [ { Above | Below | Center }]]
	[ Style Brush... [ , Brush... ] ] 

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.

angle is the starting angle, in degrees, of the first wedge in a pie chart.

chart_size is a float size, representing the maximum height of each pie or bar chart.

unitname is a paper unit name (for example, "in" for inches, "cm" for centimeters).

max_value is a number, used in the At Value clause to control the heights of Pie and Bar charts. For each record, if the sum of the column expressions equals the max_value, that record's Pie or Bar chart will be drawn at the chart_size height; the charts are smaller for rows with smaller sums.

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.

The keywords following the expr clause dictate which type of shading MapInfo Pro will perform. The Pie keyword specify thematically constructed charts.

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 Brush clause specifies a fill style (for example, MakeBrush(pattern, forecolor, backcolor)).

For the specific syntax of a Pie map, see Syntax Pie Charts.

In a Pie map, MapInfo Pro creates a small pie chart for each map object to be shaded. The With clause specifies a comma-separated list of two or more expressions to comprise each thematic pie.

If you place the optional keyword Half before the keyword Pie, MapInfo Pro draws half-pies; otherwise, MapInfo Pro draws whole pies.

The optional Angle clause specifies the starting angle of the first pie wedge, specified in degrees. The default start angle is 180.

The optional Counter keyword specifies that wedges are drawn in counter-clockwise order, starting at the start angle.

The Max Size clause controls the sizes of the pie charts, in terms of paper units (for example, "in" for inches). For details about paper units, see Set Paper Units statement. If you include the Fixed keyword, all charts are the same size.

For example, the following statement produces pie charts, all of the same size:

Shade sales_95 With phone_sales, retail_sales 
	Pie Fixed 
	Max Size 0.25 Units "in" 

To vary the sizes of Pie charts, omit the Fixed keyword and include the At Value clause. For example, the following statement produces a theme where the size of the Pie charts varies. If a record has a sum of 85,000 its Pie chart will be 0.25 inches tall; records having smaller values are shown as smaller Pie charts.

Shade sales_95 With phone_sales, retail_sales 
	Pie 
	Max Size 0.25 Units "in" At Value 85000

The optional Vary Size By clause controls how MapInfo Pro varies the Pie chart size. This clause is discussed above (see Graduated Symbols).

Each chart is placed on the original map object's centroid, unless a Position clause is used.

The Style clause specifies a comma-separated list of Brush styles; specify one Brush style for each expression specified in the With clause. Brush style settings are optional; if you omit these settings, MapInfo Pro uses any Brush preferences saved by the user.

The following example creates a thematic map layer which positions each pie chart directly above each map object's centroid.

Shade sales_95 With phone_sales, retail_sales 
	Pie Angle 180 
	Max Size 0.5 Units "in" At Value 85000 
		Vary Size By "SQRT" 
	Border Pen (1, 2, 0) 
	Position Center Above 
	Style Brush(2, RED, 0), Brush(2, BLUE, 0)