Create a new metricsgraphics.js plot
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
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)
- data frame
- bare or quoted name of column to use for x values
- bare or quoted name of column to use for y values
- determines whether or not to show any text when a data point is rolled over.
- 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)
- the number of decimals to show in a rollover (default:
- sets the format of the data object, which is to say,
- if true and if the data object is a time series, missing data points will be treated as zeros
- the size of the left margin in pixels.
- the size of the right margin in pixels.
- the size of the top margin in pixels.
- the size of the bottom margin in pixels.
- the buffer size in pixels between the actual chart area and the margins.
- Width in pixels (optional, defaults to automatic sizing)
- Height in pixels (optional, defaults to automatic sizing)
- plot title
- plot description
See MetricsGraphics.js for more information.
description work best when the widget is in
a Bootstrap template. They also increase the overall plot area (height,
mostly) since they add
description will be
visible in the upper left area (on
? hover) if not displayed
in a Boostrap template.
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()