Initialise a chart.

g2(
  data = NULL,
  ...,
  width = NULL,
  height = NULL,
  elementId = NULL,
  digits = NULL,
  reorder = TRUE
)

Arguments

data

A data.frame or tibble containing data to chart, an object of class igraph, an object of class ts, or as crosstalk::sharedDataset.

...

Aspects of the chart, see asp().

width, height

Dimensions of the chart, accepts any valid CSS unit e.g.: 100%, numerics are treated as pixels, e.g.: 400 = 400px.

elementId

Valid CSS id attribute.

digits

Maximum number of digits after the comma to show on the chart.

reorder

Whether to internally reorder the data, namely the x and color. The x axis must be reordered in a descending order for most data type since G2.js plots data as-is. Moreover, color order of all data.frames passed either to this function or subsequent fig_* layers must be identical or the colors will might match the legends on the plot. However, one may sometimes not want the data to be reordered.

Examples

g2(cars) %>%
  fig_point(asp(speed, dist))