Skip to contents

A serializable description of a bar chart. Build one with setup_BarConfig() rather than calling this constructor directly.

Usage

BarConfig(
  dat_path = NULL,
  title = NULL,
  origin = NULL,
  writer = NULL,
  legend_position = "top",
  legend_placement = "outside",
  x = NULL,
  y = NULL,
  order = "input",
  stack = FALSE,
  horizontal = FALSE,
  bar_width = NULL,
  palette = NULL,
  xlab = NULL,
  ylab = NULL,
  margin_top = NULL,
  margin_right = NULL,
  margin_bottom = NULL,
  margin_left = NULL
)

Arguments

dat_path

Optional Character: Path to the data, read at draw time. The serializable alternative to passing data to draw().

title

Optional Character: Chart title. Declared here because it is the one property every chart type has; palette is not (four take a colormap instead), and axis labels and margins are cartesian-only.

origin

Optional Named character {"user", "default", "derived"}: Where each value came from, one entry per settable property. Absent on an authored config; written by the interface that resolved it.

writer

Optional Named character: Which interface wrote the config, as name and version. Absent on an authored config.

legend_position

Character {"top", "bottom", "left", "right", "top-left", "top-right", "bottom-left", "bottom-right"}: Legend anchor. Top/bottom anchors use horizontal rows; left/right anchors use a vertical column. Corner anchors align within the top or bottom row.

legend_placement

Character {"outside", "inside"}: Relation to the plotting area. Outside placement reserves space for the complete legend; inside placement overlays the data. Neither setting adds a missing legend.

x

Optional Character: Column holding the categories.

y

Optional Character: Columns holding the values, one series each.

order

Character {"input", "increasing", "decreasing"}: Order categories by their total across series, retaining ties and placing missing totals last.

stack

Logical: If TRUE, stack the series instead of grouping them.

horizontal

Logical: If TRUE, draw the bars horizontally.

bar_width

Optional Numeric (0, Inf): Bar thickness in pixels. NULL lets ECharts size bars from the category spacing.

palette

Optional Character: Series colors, overriding the theme palette for this chart. NULL uses the theme's.

xlab, ylab

Optional Character: Axis labels. NULL derives them from the data.

margin_top, margin_right, margin_bottom, margin_left

Optional Integer [0, Inf): Plot margins in pixels.

Value

BarConfig object.

Details

x names the column holding the categories. y names one or more columns, one series each – a single column draws one set of bars, several draw a grouped or stacked chart with the column names as the series names. That is the difference from ScatterConfig, whose x and y each name exactly one column.

Fixed thickness maps to barWidth in ECharts' BaseBarSeriesOption (src/chart/bar/BaseBarSeries.ts). It applies to either orientation.

Author

EDG

Examples

setup_BarConfig(x = "cyl", y = "mpg")@type
#> [1] "bar"