Lines
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
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:
Interface
Please also refer to the documentation for all plot objects.
Properties
-
abscissa
:KontrastNumber
(default value:0
)The abscissa value used whenever no data is assigned to an abscissa.
-
ordinate
:KontrastNumber
(default value:0
)The ordinate value used whenever no data is assigned to an ordinate.
-
applicate
:KontrastNumber
(default value:0
)The applicate value used whenever no data is assigned to an applicate.
-
color
:KontrastColor
(default value:'black'
)The color used whenever no data is assigned to a color axis.
-
opacity
:KontrastNumber
(default value:1
)The opacity used whenever no data is assigned to an opacity axis.
-
thickness
:KontrastNumber
(default value:2
)The thickness used whenever no data is assigned to a thickness axis.
-
segmentCap
:KontrastSelection
(default value:'round'
, possible values:'round'
,'butt'
,'square'
)The style of the segment caps.
-
lineStyle
:KontrastSelection
(default value:'solid'
, possible values:'solid'
,'dashed'
)The style of the line.
-
dashLength
:KontrastNumber
(default value:4
)The length (pixel) of the dashes. This is only relevant if the line style is 'dashed'
-
dashSkip
:KontrastNumber
(default value:2
)The skip (in pixels) between the dashes. This is only relevant if the line style is 'dashed'