Skip to content

Commit a35a817

Browse files
committed
add pretty argument to plotly_json()
1 parent d8ce78b commit a35a817

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

DESCRIPTION

+2-1
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,6 @@ Suggests:
7171
Remotes:
7272
tidyverse/ggplot2
7373
LazyData: true
74-
RoxygenNote: 6.0.1
74+
RoxygenNote: 6.0.1.9000
75+
Encoding: UTF-8
7576
Roxygen: list(markdown = TRUE)

R/dev.R

+6-4
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@
44
#' sent to plotly.js.
55
#'
66
#' @param p a plotly or ggplot object.
7-
#' @param jsonedit use `listviewer::jsonedit` to view the JSON?
8-
#' @param ... other options passed onto `listviewer::jsonedit`
7+
#' @param jsonedit use [listviewer::jsonedit] to view the JSON?
8+
#' @param pretty adds indentation whitespace to JSON output. Can be TRUE/FALSE
9+
#' or a number specifying the number of spaces to indent. See [jsonlite::prettify].
10+
#' @param ... other options passed onto [listviewer::jsonedit]
911
#' @export
1012
#' @examples
1113
#'
1214
#' plotly_json(plot_ly())
1315
#' plotly_json(plot_ly(), FALSE)
1416

15-
plotly_json <- function(p = last_plot(), jsonedit = interactive(), ...) {
16-
plotlyJSON <- to_JSON(plotly_build(p)$x, pretty = TRUE)
17+
plotly_json <- function(p = last_plot(), jsonedit = interactive(), pretty = TRUE, ...) {
18+
plotlyJSON <- to_JSON(plotly_build(p)$x, pretty = pretty)
1719
if (jsonedit) {
1820
try_library("listviewer", "plotly_json")
1921
listviewer::jsonedit(plotlyJSON, mode = "form", ...)

man/plotly_json.Rd

+6-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)