@@ -71,16 +71,29 @@ orca <- function(p, file = "plot.png", format = tools::file_ext(file),
71
71
72
72
# ' Orca image export server
73
73
# '
74
- # ' @description Compared to [orca], [orca_serve] is more efficient at exporting many plotly
74
+ # ' Compared to [orca], [orca_serve] is more efficient at exporting many plotly
75
75
# ' graphs because the former must startup/shutdown an external process for every image.
76
76
# ' The server (background) process is launched upon initialization of a [orca_serve] class
77
77
# ' (i.e., when the `new()` method is called). The `export()` method accepts any valid plotly
78
78
# ' object as input and spits out an image file to disk. To kill the background server process,
79
79
# ' use `close()`.
80
80
# '
81
- # ' @section Constructor:
81
+ # ' @usage NULL
82
+ # ' @format NULL
82
83
# '
83
- # ' \code{orca_serve$new(port = 5151)}
84
+ # ' @section Initialization:
85
+ # ' A new 'orcaServe'-object is initialized using the new() method on the generator:
86
+ # '
87
+ # ' \strong{Usage}
88
+ # '
89
+ # ' \code{
90
+ # ' orca_serve$new(
91
+ # ' port = 5151, mathjax = FALSE, safe = FALSE, request_limit = NULL, keep_alive = TRUE,
92
+ # ' window_max_number = NULL, quiet = FALSE, debug = FALSE, ...
93
+ # ' )
94
+ # ' }
95
+ # '
96
+ # ' \strong{Arguments}
84
97
# '
85
98
# ' \describe{
86
99
# ' \item{\code{port}}{Sets the server's port number.}
@@ -106,6 +119,22 @@ orca <- function(p, file = "plot.png", format = tools::file_ext(file),
106
119
# ' \item{\code{debug}}{Starts app in debug mode.}
107
120
# ' }
108
121
# '
122
+ # ' @section Methods:
123
+ # '
124
+ # ' \describe{
125
+ # ' \item{\code{export(p, file = "plot.png", format = tools::file_ext(file), scale = NULL, width = NULL, height = NULL)}}{
126
+ # ' Export a static image of a plotly graph. Arguments found here are the same as those found in [orca].
127
+ # ' }
128
+ # ' \item{\code{close()}}{Close down the orca server and kill the underlying node process.}
129
+ # ' }
130
+ # '
131
+ # ' @section Fields:
132
+ # '
133
+ # ' \describe{
134
+ # ' \item{\code{port}}{The port number that the server is listening to.}
135
+ # ' \item{\code{process}}{An R6 class for controlling and querying the underlying node process.}
136
+ # ' }
137
+ # '
109
138
# ' @export
110
139
# ' @author Carson Sievert
111
140
# ' @seealso [orca]
@@ -130,20 +159,19 @@ orca <- function(p, file = "plot.png", format = tools::file_ext(file),
130
159
# ' unlink("test1.pdf")
131
160
# ' unlink("test2.pdf")
132
161
# ' }
133
- # '
162
+
134
163
orca_serve <- R6 :: R6Class(
135
164
" orcaServe" ,
136
165
public = list (
137
166
process = NULL ,
138
167
port = NULL ,
139
-
140
168
initialize = function (port = 5151 , mathjax = FALSE , safe = FALSE , request_limit = NULL ,
141
169
keep_alive = TRUE , window_max_number = NULL , quiet = FALSE ,
142
170
debug = FALSE , ... ) {
143
171
144
172
# make sure we have the required infrastructure
145
173
orca_available()
146
- try_library(" processx" , " orca " )
174
+ try_library(" processx" , " orca_serve " )
147
175
148
176
# use main bundle since any plot can be thrown at the server
149
177
plotlyjs <- plotlyMainBundle()
@@ -175,7 +203,7 @@ orca_serve <- R6::R6Class(
175
203
self $ process <- processx :: process $ new(" orca" , args , ... )
176
204
self $ port <- port
177
205
},
178
- export = function (p , file = " plot.png" , format = tools :: file_ext(file ), width = 1000 , height = 500 ) {
206
+ export = function (p , file = " plot.png" , format = tools :: file_ext(file ), scale = NULL , width = NULL , height = NULL ) {
179
207
180
208
# request/response model works similarly to plotly_IMAGE()
181
209
bod <- list (
0 commit comments