mark_bar: Bar mark

Description Usage Arguments References Examples

View source: R/mark.r

Description

A bar mark represents each data point as a rectangle, where the length is mapped to a quantitative scale.

Usage

1
2
mark_bar(vl, orient = NULL, stack = NULL, size = NULL, opacity = NULL,
  filled = NULL, color = NULL, fill = NULL, stroke = NULL)

Arguments

vl

Vega-Lite object

orient

the orientation of a non-stacked bar, area, and line charts. The value is either "horizontal", or "vertical" (default). For bar and tick, this determines whether the size of the bar and tick should be applied to x or y dimension. For area, this property determines the orient property of the Vega output. For line, this property determines the path order of the points in the line if path channel is not specified. For stacked charts, this is always determined by the orientation of the stack; therefore explicitly specified value will be ignored.

stack

stacking modes for bar and area marks. zero - stacking with baseline offset at zero value of the scale (for creating typical stacked bar and area chart). normalize - stacking with normalized domain (for creating normalized stacked bar and area chart). center - stacking with center baseline (for streamgraph). none - No-stacking. This will produces layered bar and area chart.

size

The pixel area each the point. For example: in the case of circles, the radius is determined in part by the square root of the size value.

opacity

0.0-1.0

filled

whether the shape's color should be used as fill color instead of stroke color.

color

color of the mark – either fill or stroke color based on the filled mark config.

fill

fill color. This config will be overridden by color channel’s specified or mapped values if filled is true.

stroke

stroke color. This config will be overridden by color channel’s specified or mapped values if filled is false.

References

Vega-Lite Mark spec

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
dat <- jsonlite::fromJSON('[
    {"a": "A","b": 28}, {"a": "B","b": 55}, {"a": "C","b": 43},
    {"a": "D","b": 91}, {"a": "E","b": 81}, {"a": "F","b": 53},
    {"a": "G","b": 19}, {"a": "H","b": 87}, {"a": "I","b": 52}
  ]')

vegalite() %>%
  add_data(dat) %>%
  encode_x("a", "ordinal") %>%
  encode_y("b", "quantitative") %>%
  mark_bar()

Example output



vegalite documentation built on May 2, 2019, 10:46 a.m.