# Configuring Polygons

Most of the functionality in QlikMaps is accessible through simple selections from drop-down menus. See Feature Layers - Polygon for more information.

If an older versions of QlikMaps is used or there is a need for more granular control over the map, more advanced techniques can be used.

Below are a number of examples of advanced expressions that can be used to customize 'Polygon' maps.

## Polygon Fill Color

By default, Qlikmaps uses a preselected color gradient for each polygon layer. That color can be changed using an expression.

To configure different colors for polygons, select `<Use Expression>`

from the `<Select a Value>`

drop down under *color*.

- If
`value`

is selected, the returned expression will be evaluated by QlikMaps and colored based on the selected palette. - If
`color`

is selected, the returned expression will be evaluated as an RGB() color or HEX#.

The following examples assume you have selected *color*.

### Single Color Polygons

- Open the
*Polygon Fill Color*expression box by clicking on the*Fx.* - Type an RGB code or native Sense color code in the expression editor.
- Enclose the color value in single quotes.

`'RGB(255,0,0)'`

or

`'red()'`

### Multi Color Polygons

- Open the
*Polygon Fill Color*expression box by clicking on the Fx. - Type an an expression that returns an RGB() code or native Sense color code for each polygon type in the expression editor.
- Enclose the expression in single quotes.

`'if(Sum([x]) > sum(TOTAL [x])/Count(DISTINCT Total [Dimension]), Green(),LightRed())'`

Or

`'if([Dimension]=''A'',Green(),LightRed())'`

Note that in the example below two single quotes are used around the value `A`

. This is because two single quotes are necessary when returning a Text value. For more information, see Qlik Sense Editor.

Another popular method of coloring polygons is using color gradients.

This first example uses fractals. This allows for a graduated color based on an expression and is fairly forgiving with poorer data quality.

```
'if(count(DISTINCT TOTAL [Dimension]) = 1, RGB(127,39,4),
if(Sum(TOTAL <[Dimension]> [x]) <= fractile(TOTAL aggr(Sum([x]),[Dimension]), 0.1), RGB(255,245,235),
if(Sum(TOTAL <[Dimension]> [x]) <= fractile(TOTAL aggr(Sum([x]),[Dimension]), 0.2), RGB(254,230,206),
if(Sum(TOTAL <[Dimension]> [x]) <= fractile(TOTAL aggr(Sum([x]),[Dimension]), 0.3), RGB(253,208,162),
if(Sum(TOTAL <[Dimension]> [x]) <= fractile(TOTAL aggr(Sum([x]),[Dimension]), 0.4), RGB(253,174,107),
if(Sum(TOTAL <[Dimension]> [x]) <= fractile(TOTAL aggr(Sum([x]),[Dimension]), 0.5), RGB(253,141,60),
if(Sum(TOTAL <[Dimension]> [x]) <= fractile(TOTAL aggr(Sum([x]),[Dimension]), 0.6), RGB(241,105,30),
if(Sum(TOTAL <[Dimension]> [x]) <= fractile(TOTAL aggr(Sum([x]),[Dimension]), 0.7), RGB(216,88,15),
if(Sum(TOTAL <[Dimension]> [x]) <= fractile(TOTAL aggr(Sum([x]),[Dimension]), 0.8), RGB(187,70,1),
if(Sum(TOTAL <[Dimension]> [x]) <= fractile(TOTAL aggr(Sum([x]),[Dimension]), 0.9), RGB(166,54,3),
RGB(127,39,4)))))))))))'
```

The next example also creates a color graduated map. It performs better but is less forgiving and less flexible with poorer data quality, or, very homogeneous data.

```
'pick(Ceil(rank(total sum([x]))/Count(distinct TOTAL [Dimension])*10),
RGB(127,39,4),
RGB(166,54,3),
RGB(187,70,1),
RGB(216,88,15),
RGB(241,105,30),
RGB(253,141,60),
RGB(253,174,107),
RGB(253,208,162),
RGB(254,230,206),
RGB(255,245,235))'
```

## Polygon Outline Color

By default, polygon border colors are white.

To configure different colors for polygon borders, select `<Use Expression>`

from the `<Select a Value>`

drop down under *Border -> Color*.

### Single Polygon Outline Color

- Open the
*Polygon Outline Color*expression box by clicking on the*Fx*. - Type an RGB code or native Sense color code in the expression editor.
- Enclose the color value in single quotes.

`'RGB(255,0,0)'`

or

`'red()'`

### Multi Polygon Outline Color

- Open the
*Polygon Outline Color*expression box by clicking on the*Fx*. - Type an an expression that returns an RGB() code or native Sense color code for each polygon type in the expression editor.
- Enclose the expression in single quotes.

`'if(Sum([x]) > sum(TOTAL [x])/Count(DISTINCT Total [Dimension]), Green(),LightRed())'`

Or

`'if([Dimension]=''A'',Green(),LightRed())'`

Note that in the example above two single quotes are used around the value `A`

. This is because two single quotes are necessary when returning a text value. For more information, see Qlik Sense Editor.

Another popular method of coloring polygons is by using fractals. This allows for a graduated color based on an expression.

```
'if(count(DISTINCT TOTAL [Dimension]) = 1, RGB(127,39,4),
if(Sum(TOTAL <[Dimension]> [x]) <= fractile(TOTAL aggr(Sum([x]),[Dimension]), 0.1), RGB(255,245,235),
if(Sum(TOTAL <[Dimension]> [x]) <= fractile(TOTAL aggr(Sum([x]),[Dimension]), 0.2), RGB(254,230,206),
if(Sum(TOTAL <[Dimension]> [x]) <= fractile(TOTAL aggr(Sum([x]),[Dimension]), 0.3), RGB(253,208,162),
if(Sum(TOTAL <[Dimension]> [x]) <= fractile(TOTAL aggr(Sum([x]),[Dimension]), 0.4), RGB(253,174,107),
if(Sum(TOTAL <[Dimension]> [x]) <= fractile(TOTAL aggr(Sum([x]),[Dimension]), 0.5), RGB(253,141,60),
if(Sum(TOTAL <[Dimension]> [x]) <= fractile(TOTAL aggr(Sum([x]),[Dimension]), 0.6), RGB(241,105,30),
if(Sum(TOTAL <[Dimension]> [x]) <= fractile(TOTAL aggr(Sum([x]),[Dimension]), 0.7), RGB(216,88,15),
if(Sum(TOTAL <[Dimension]> [x]) <= fractile(TOTAL aggr(Sum([x]),[Dimension]), 0.8), RGB(187,70,1),
if(Sum(TOTAL <[Dimension]> [x]) <= fractile(TOTAL aggr(Sum([x]),[Dimension]), 0.9), RGB(166,54,3),
RGB(127,39,4)))))))))))'
```

## Polygon Opacity

By default, polygon *opacity* is set to 85%. This can be changed using an expression for polygon opacity.

To configure different opacity levels for polygons, click on the *color* caption and select the gear icons.

### Single Polygon Opacity Level

- Open the
*Polygon Opacity*expression box by clicking on the*Fx.* - Type a number between 0 and 100 in the Expression Editor that corresponds to the desired opacity percentage.
- Enclose the color value in single quotes.

`'50'`

### Multi Polygon Opacity Levels

- Open the
*Polygon Opacity*expression box by clicking on the*Fx*. - Type an an expression that returns a number between 0 and 100 that corresponds to the desired opacity percentage for each polygon type in the expression editor.
- Enclose the expression in single quotes.

`'if(Sum([x]) > sum(TOTAL [x])/Count(DISTINCT Total [Dimension]), 100,50)'`

Or

`'if([Dimension]=''A'',100,50)'`

Note that in the example above two single quotes are used around the value `A`

. This is because two single quotes are necessary when returning a text value. For more information, see Qlik Sense Editor

## Border Pattern

By default, *border pattern* is set to solid. This can be changed using the *border pattern* expression.

To configure different patterns for borders, click on the *pattern* drop down and select `<Use Expression>`

.

### Single Border Pattern

- Open the
*pattern*expression box by clicking on the Fx. - Type two numbers separated by a comma in the expression editor where the first number represents the pixel length or the line segment and the second corresponds to the pixel space between the line segments. (Additional comma separated values can be added to vary subsequent line segments and spaces.)
- Enclose the color value in single quotes.
- Close the expression editor
- Remove the equal sign in front of the
*pattern*

`'5,10'`

### Multi Border Pattern

- Open the
*pattern*expression box by clicking on the Fx. - Type two numbers seperated by a comma in the expression editor where the first number represents the pixel length or the line segment and the second corresponds to the pixel space between the line segments for each line type in the expression editor.
- Enclose the expression in single quotes.

`'if(Sum([x]) > sum(TOTAL [x])/Count(DISTINCT Total [Dimension]), ''5,10'',''10,10'')'`

Or

`'if([Dimension]=''A'',''5,10'',''10,10'')'`

Note that in the example above two single quotes are used around the value `A`

. This is because two single quotes are necessary when returning a text value. For more information, see Qlik Sense Editor.