-
Notifications
You must be signed in to change notification settings - Fork 633
/
Copy pathdebug.R
43 lines (38 loc) · 1.03 KB
/
debug.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#' Obtain JSON sent to plotly.js
#'
#' This function returns the JSON sent to plotly.js which can be useful for
#' debugging.
#'
#' @param p a plotly or ggplot object.
#' @param ... other options passed onto \code{listviewer::jsonedit}
#' @export
#' @examples
#'
#' plotly_spec(plot_ly())
plotly_spec <- function(p = plot_ly(), ...) {
if (system.file(package = "listviewer") == "") {
stop("This function requires the listviewer package:\n",
"install.packages('listviewer')", call. = FALSE)
}
listviewer::jsonedit(to_JSON(plotly_build(p)$x), mode = "form", ...)
}
#' Display plot schema
#'
#' @export
#' @examples
#'
#' schema()
schema <- function() {
listviewer::jsonedit(Schema, mode = "form")
}
#' Show information about attribute(s) of a given trace type
#'
#' @export
#' @param type a trace type
#' @param attrs attributes for the race type
#' @examples
#'
#' explain_attrs()
explain_attrs <- function(type = "scatter", attrs = c("x", "y")) {
jsonlite::toJSON(verify_attrs(type, attrs), pretty = TRUE)
}