mjs_plot: Create a new metricsgraphics.js plot

Description Usage Arguments Details Value Note Examples

Description

mjs_plot() initializes the metricsgraphics.js html widget and takes a data frame & (bare or quoted) x & y column names as minimum input. This must be piped to a "geom" (metricsgraphics.js only supports single "geom" layers) and can also be piped to other mjs_ functions that manipulate aesthetics.

Usage

1
2
3
4
mjs_plot(data, x, y, show_rollover_text = TRUE, linked = FALSE,
  decimals = 2, format = "count", missing_is_hidden = FALSE, left = 80,
  right = 10, top = 40, bottom = 60, buffer = 8, width = NULL,
  height = NULL, title = NULL, description = NULL)

Arguments

data

data frame

x

bare or quoted name of column to use for x values

y

bare or quoted name of column to use for y values

show_rollover_text

determines whether or not to show any text when a data point is rolled over.

linked

inks together all other graphs whose linked option is set to true. When one graphic in that set is rolled over, the corresponding values in the other graphics are also rolled over (default: FALSE - not linked)

decimals

the number of decimals to show in a rollover (default: 2)

format

sets the format of the data object, which is to say, counts or percentages

missing_is_hidden

if true and if the data object is a time series, missing data points will be treated as zeros

left

the size of the left margin in pixels.

right

the size of the right margin in pixels.

top

the size of the top margin in pixels.

bottom

the size of the bottom margin in pixels.

buffer

the buffer size in pixels between the actual chart area and the margins.

width

Width in pixels (optional, defaults to automatic sizing)

height

Height in pixels (optional, defaults to automatic sizing)

title

plot title

description

plot description

Details

See MetricsGraphics.js for more information.

Value

metricsgraphics object

Note

Plot title and description work best when the widget is in a Bootstrap template. They also increase the overall plot area (height, mostly) since they add <div>s. The description will be visible in the upper left area (on ? hover) if not displayed in a Boostrap template.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
data.frame(year=seq(1790, 1970, 10),
           uspop=as.numeric(uspop)) %>%
  mjs_plot(x=year, y=uspop) %>%
  mjs_line()

# accessor params can also be quoted

data.frame(year=seq(1790, 1970, 10),
           uspop=as.numeric(uspop)) %>%
  mjs_plot(x="year", y="uspop") %>%
  mjs_line()

metricsgraphics documentation built on May 1, 2019, 8:07 p.m.