Maps Visualization Configuration

Overview

AnyChart allows you to configure visual style of any map region, to be able to configure how map regions will looks like you have to know what are defined and undefined regions, what is map region style and what it consists of.

Other useful features used to configure map coloring are palettes and thresholds.

to top

Defined and Undefined Regions

Difference between defined and undefined regions is very easy to learn - if there is any point in series of "MapRegions" - then this region is defined, otherwise (no such point) - the region is undefined.

This distinction is made to make easier the creation of simple color maps (with no additional data attached in XML), and to ease coloring of those regions that have no data attached (to make them all gray and non-interactive, for example)

So, there are two almost identical nodes in <map_series>: <defined_map_region> and <undefined_map_region>.

Both of them contain <map_region_style> node that is used configuration, but undefined<undefined_map_region> also has palette attribute (used to color all undefined regions) and threshold attribute (used to apply threshold to color undefined regions - in case when some data is built-in into .amap file).

Also, <undefined_map_region> can contain <actions> subnode to attach actions to regions without data attached, if you want to attach actions to regions with data - use <actions> in <data>, <series> or <point> nodes.

In the next chapter you can learn what can be configured in <map_region_style> node.

to top

Map Styles

In this section we will describe main parts of map regions style and demonstrate how style can be created and applied.

The main idea of styles is to segregate visualization and data definition. Visual appearance of regions is defined using certain styles and then you just apply the style to the certain regions. Style can be applied to all defined regions, to all undefined regions, to a series or a single region.

Style can be configured in <map_region_style>, <defined_map_region> and <undefined_map_region> nodes. On the sample image below you can see what map_region_style consists of: fill (including solid color fill, hatch fill, image fill and gradient fill), border and effects applied to whole region.

Now we will take a closer look at XML settings that allowed us to create a map displayed on image above.

Undefined regions

There are two "Undefined" regions - Wales and Northern Ireland, their appearance is configured in <map_region_style> sub-node of <undefined_map_region>:

XML Syntax
Plain code
01 <undefined_map_region>
02   <map_region_style>
03     <fill type="Solid" opacity="0.3" />
04     <hatch_fill enabled="false" />
05   </map_region_style>
06 </undefined_map_region>

As you can see, you can change style for all undefined regions in this node (in this sample change the opacity of background and disable hatch fill).

Defined regions

We have two defined regions - England and Scotland, we could color them just the same way - setting <map_region_style> sub-node of <defined_map_region>, but we will demonstrate creation and applying styles on this two regions.

For England we will create a "SimpleStyle", which XML settings are:

XML Syntax
Plain code
01 <styles>
02   <map_region_style name="SimpleStyle">
03     <fill type="Solid" color="Red" />
04     <border color="Green" />
05     <hatch_fill enabled="true" />
06     <effects enabled="true">
07       <drop_shadow enabled="true" />
08     </effects>
09   </map_region_style>
10 </styles>

In this ("SimpleStyle") style we changed fill and border colors, enabled hatch fill, and added drop shadow effect.

For Scotland we will create a "Scotland" style, which XML settings are:

XML Syntax
Plain code
01 <styles>
02   <map_region_style name="Scotland">
03     <fill type="Image" image_url="Scotland.png" image_mode="FitByProportions" />
04     <border color="Black" />
05     <hatch_fill enabled="false" />
06     <effects enabled="false" />
07   </map_region_style>
08 </styles>

In "Scotland" style we changed fill to image (using image old Royal coat of arms of Scotland), set border color, disabled hatch fill and effects.

As soon as this two styles are created - we can apply them to regions:

England gets its simple style from style attribute of <defined_map_region> node - this attribute sets default style for all defined regions (<undefined_map_region> also has such attribute).

XML Syntax
Plain code
01 <defined_map_region style="SimpleStyle" />

Scotland region style is set explicitly in <point> node:

XML Syntax
Plain code
01 <series type="MapRegions">
02   <point name="Scotland" style="Scotland" />
03   <point name="England" />
04 </series>

And here is a live sample of the map with styles defined, you can take a closer look at XML settings:

Live Sample:  Map Styles Sample

to top

Styles Inheritance

Important thing about styles defined in <styles> node is that they can be inherited, and you can define one "Basic" style and inherit several styles from it - just changing a few setting instead of duplicating all style.

Lets look at the sample of styles inheritance. We will display map of the USA, all states will be styled using one basic style, and some states will be styled using styles inherited from the basic one.

Basic style settings will look like that:

XML Syntax
Plain code
01 <map_region_style name="Basic">
02   <fill type="Gradient" color="%Color" opacity="0.8">
03     <gradient angle="45">
04       <key position="0" color="%Color" opacity="1" />
05       <key position="1" color="Blend(DarkColor(%Color),%Color,0.4)" opacity="1" />
06     </gradient>
07   </fill>
08   <states>
09     <pushed>
10       <fill type="Gradient" opacity="0.8">
11         <gradient angle="45">
12           <key position="0" color="DarkColor(%Color)" opacity="1" />
13           <key position="1" color="Blend(DarkColor(%Color),%Color,0.4)" opacity="1" />
14         </gradient>
15       </fill>
16     </pushed>
17     <selected_normal>
18       <hatch_fill enabled="true" />
19     </selected_normal>
20   </states>
21 </map_region_style>

You can see that is is pretty complex style - in configures gradient background and defines how region looks like in selected and pushed states (Read more about region states).

We want to create a style ("Child1") that will be almost similar and don't want to duplicate this complex settings, so we just create new style and set "Basic" as a parent:

XML Syntax
Plain code
01 <map_region_style name="Child1" parent="Basic" color="Khaki">
02   <hatch_fill enabled="false" />
03 </map_region_style>

And one more ("Child2") style - another color, and hatch fill enabled in normal state:

XML Syntax
Plain code
01 <map_region_style name="Child2" parent="Basic" color="CornflowerBlue">
02   <states>
03     <normal>
04       <hatch_fill enabled="true" />
05     </normal>
06   </states>
07 </map_region_style>

So, in "Child1" style we just disabled hatch fill (hatch fill on select is enabled in Basic), and set the Khaki color.

Now we will apply these two styles, "Basic" style will be applied to all undefined regions:

XML Syntax
Plain code
01 <undefined_map_region style="Basic">
02   <map_region_style color="DarkSeaGreen" />
03   <label_settings enabled="false" />
04 </undefined_map_region>

"Child1" and "Child2" style will be applied to the certain states in <point> and <series> nodes:

XML Syntax
Plain code
01 <data>
02   <series>
03     <point name="WA" style="Child1" />
04     <point name="OR" style="Child1" />
05   </series>
06   <series style="Child2">
07     <point name="CA" />
08     <point name="NV" />
09   </series>
10 </data>

Sample USA map with style inheritance use:

Live Sample:  Sample USA Flash Map with Styles Inheritance

to top

Palettes

AnyChart palettes allow you to color your map without setting certain color to each regions personally, there are built-in palettes, custom color range palettes and custom distinct colors palettes. You also can use Hatch Palettes and Marker Palettes as well.

General information about palettes can be found in Palettes tutorial.

You have the following options when applying palettes to a map:

Color all map regions series in a map

When you have several series of Map Regions, and want all of them to be colored with a different color you may either explicitly set the color in each <series> node, or apply palette ("Default" or Custom) to <data> node:

XML Syntax
Plain code
01 <data palette="Default" />

In the sample below we will add five series in <data> and apply default palette to <data>:

Live Sample:  Map Palette to Data Sample

to top

Color given regions series

If you want to color all regions in one series on different colors - you can use palette attribute of <series> node:

XML Syntax
Plain code
01 <series palette="Default" />

In the sample below we will put all regions from the sample above in one series and apply default color and hatch palettes to <series>:

Live Sample:  Map Color and Hatch Palette to Series Sample

to top

Color all undefined regions

Applying palette to all undefined regions is useful when you are not attaching any data to your map, but want it to be colorful. Just set palette attribute to <undefined_map_region> node and all regions on a map will be colored. If there are more regions on a map, than the number of the colors in a palette - palette will be cycled.

XML Syntax
Plain code
01 <map_series>
02   <undefined_map_region palette="PaletteName" />
03 </map_series>

In the sample below we will display a map of the world and color all countries using palette.

Also we will attach an actions to all countries - to show message box with country name and open a Wikipedia Page about this country after that.

XML Syntax
Plain code
01 <map_series>
02   <undefined_map_region palette="PaletteName">
03     <actions>
04       <action type="call" function="alert">
05         <arg><![CDATA[A page about "{%REGION_NAME}" will be opened in a new window.]]></arg>
06       </action>
07       <action type="navigateToURL" url="http://en.wikipedia.org/wiki/{%REGION_NAME}" target="_blank" />
08     </actions>
09   </undefined_map_region>
10 </map_series>

 

Live Sample:  Palette Colored Map of the world

to top

Use palette via Automatic Thresholds

Automatic Thresholds color regions only using some palette - color range or distinct colors, this allows you to switch palette when needed, and, for example use grayscale palette instead of colorful palette.

Read more about automatic thresholds in: Automatic Thresholds

to top

Threshold coloring

Thresholds is a great feature for map coloring, they allow to create the thematic maps (choropleth maps) in which areas are shaded in proportion to the measurement of the statistical variable being displayed on the map, such as population density or per-capita income. It provides an easy way to visualize how a measurement varies across a geographic area.

AnyChart features custom and automatic thresholds, that give you a very flexible options for map coloring. Please refer to the following documents to learn how to color maps using thresholds:

to top