chartjs: Create a 'Chart.js' Plot Object

Description Usage Arguments Details Value Examples

View source: R/chartjs.R

Description

This is the starting function for creating a charts object in R. It operates similarly to plotly::plot_ly.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
chartjs(
  data,
  x,
  type = "bar",
  options = baseOptions,
  forceBig = FALSE,
  width = "100%",
  height = "100%",
  elementId = NULL
)

Arguments

data

The data that the plot is based on (a data.frame-like object).

x

An expression that evaluates to a vector that will be used as the x-axis values (see x in eval_data).

type

The type of trace (character scalar, one of c("bar", "line", "scatter", "horizontalBar")).

options

A list containing the options to start with.

elementId

An ID string for the widget (will be randomly assigned) (character scalar).

width/height

The width/height of the htmlwidget container.

Details

See here for Chart.js examples: https://www.chartjs.org/.

And see here for the official Chart.js library documentation: https://www.chartjs.org/docs/latest/.

Value

A chartjs htmlwidget object.

Examples

1
chartjs(mtcars, x = 1:32) %>% new_bars(y = ~ disp)

KO112/chartjs documentation built on Aug. 6, 2020, 2:35 p.m.