// Single View Specification{ "data": ... , "mark": "rule", "encoding": ... , ...}
Therule
mark represents each data point as a line segment. It can be used in two ways. First, as a line segment that spans the complete width or height of a view. Second, a rule can be used to draw a line segment between two positions.
// Single View Specification{ ... "mark": { "type": "rule", ... }, "encoding": ... , ...}
A rule mark definition can contain anystandard mark properties.
If therule
mark only hasy
encoding, the output view produces horizontal rules that spans the complete width. Similarly, if therule
mark only hasx
encoding, the output view produces vertical rules that spans the height.
We can use rules to show the average price of different stocks akin totick
marks.
The fact that rule marks span the width or the height of a single view make them useful as an annotationlayer. For example, we can use rules to show average values of different stocks alongside the price curve.
We can also use a rule mark to show global mean value over a histogram.
To control the spans of horizontal/vertical rules,x
andx2
/y
andy2
channels can be specified.
For example, we can usey
andy2
show the"min"
and"max"
values of horsepowers for cars from different locations.
We can also use rule to create error bars. In the example below, we use theci0
andci1
aggregation operators to visualize the95% confidence interval as a measure of the spread of the average yields for a variety of barley strains.
Alternatively, we can create error bars showing one standard deviation (stdev
) over and below the mean value.
// Top-level View Specification{ ... "config": { "rule": ..., ... }}
Therule
property of the top-levelconfig
object sets the default properties for all rule marks. Ifmark property encoding channels are specified for marks, these config values will be overridden.
The rule config can contain anyrule mark properties (excepttype
,style
, andclip
).