Bar 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... ]
	{ Bar [ Normalized ] | Stacked Bar [ Fixed ] }
	[ Max Size chart_size [ Units unitname ] 
		[ At Value max_value [ Vary Size By {"LOG" | "SQRT" | "CONST" } ]] 
	[ Border Pen... ]
	[ Frame Brush... ]
	[ Width value [ Units unitname ] ] 
	[ 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.

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

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.

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

value

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 Bar 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 Bar map, see Syntax Bar Charts.

In a Bar map, MapInfo Pro creates a small bar chart for each map object. The With clause specifies a comma-separated list of expressions to comprise each thematic chart.

If you place the optional keyword Stacked before the keyword Bar, MapInfo Pro draws a stacked bar chart; otherwise, MapInfo Pro draws bars side-by-side. If you omit the keyword Stacked, you can include the keyword Normalized to specify that the bars have independent scales.

When you create a Stacked bar chart map, you can include the optional Fixed keyword to specify that all bar charts in the thematic layer should appear in the same size (for example, half an inch tall) regardless of the numeric values for that map object. If you omit the Fixed keyword, MapInfo Pro sizes each object's bar chart according to the net sum of the values in the chart.

The Frame Brush clause specifies a fill style used for the background behind the bars.

The Position clause controls both the orientation of the bar charts (horizontal or vertical bars) and the position of the charts relative to object centroids. If the Position clause specifies Left or Right, the bars are horizontal, otherwise the bars are vertical.

The Style clause specifies a comma-separated list of Brush styles. Specify one Brush style for each expression specified in the With clause.

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

Shade sales_93 
	With phone_sales, retail_sales 
	Bar 
	Max Size 0.4 Units "in" At Value 1245000 
	Vary Size By "CONST" 
	Border Pen (1, 2, 0) 
	Position Center Above 
	Style Brush(2, RED, 0), Brush(2, BLUE, 0) 

See Also:

Create Ranges statement, Create Styles statement, Map statement, Set Legend statement, Set Map statement, Set Shade statement