# Configuring Lines

Most of the functionality in QlikMaps is accessible through simple selections from drop-down menus. See Feature Layers - Line 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 'Line' maps.

## Line Color

By default, line colors are randomized. The colors can be changed using an expression.

To configure different colors for lines, 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 Lines

- Open the Line
*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 Lines

- Open the lines
*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 line 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 lines is s 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))'
```

## Line Size

By default, line width is set to 3 pixels wide.

To configure different sizes for lines, select `<Use Expression>`

from the `<Select a Value>`

drop down under *size*

- If
`value`

is selected, the expression will take the return of any Sense expression and scale the points accordingly. - If
`pixels`

is selected, the expression must return the pixel size for each point. The examples below provide examples.

### Single Line Size

- Open the
*size*expression box by clicking on the*Fx*. - Type an integer that represents the pixel width of the line.
- Enclose the color value in single quotes.

`'10'`

or

`'20'`

### Multi Line Size

- Open the
*size*expression box by clicking on the*Fx*. - Type an an integer that represents the pixel width of the line 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)'`

Or

`'if([Dimension]=''A'',5,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.

## Line Opacity

By default, line *opacity* is set to 85%. This can be changed using the line *opacity* expression.

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

### Single Line Opacity

- Open the
*line opacity*expression box by clicking on the*Fx*. - Type a number between 0 and 1 in the expression editor that corresponds to the desired opacity percentage.
- Enclose the color value in single quotes.

`'.5'`

### Multi Line Opacity

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

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

Or

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

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

## Line Pattern

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

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

.

### Single Line 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 Line 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