Lines are one of the simplest plot objects that are available in Kontrast and render data as a set of line segments.

Data input

Normal lines

Valid data for line plots can be either an array of numbers or a single number. If arrays are used, all arrays must have equal length.

Area fill

To fill the area beneath the line plot up to a certain value, you can assign an object as the data entry. This object must include the property value and the property fillToValue (as in Example: Filled areas below lines).

Alternatively, you can fill the area below/above the lines using lowerError (optional, defaults to 0), upperError (optional, defaults to 0) and error (optional, is internally used as both lowerError and upperError). See Example: Error fills

Values specified as errors are meant to be positive. However, Kontrast does not perform a check to enforce this.

Treatment of Not a number values

If the data contains "NaN" (Not a Number), the corresponding points are skipped. In the following example, the given data for the black line is

and the data for the red line is:

Note that still a point is drawn in the case where NaN values do not allow a line segment.

Dashed lines and custom line segment caps

The default line style in Kontrast is 'solid', which works well for most cases. A line is drawn as a series of line segments. The start and end cap of each line segment is round by default, which means that pixel cover the area where the distance to the line segment is smaller or equal to the line thickness.

Dashed lines can be drawn by setting the lineStyle property to 'dashed'. Note that in this case, it is also useful to use a 'butt' segment cap as shown in the code example below:


Please also refer to the documentation for all plot objects.