execute.handler(analysis.page, params, plot.file, file.params = list(), device = svg, annotate.plot = analysis.page$annotate.plot, max.annotated.regions = 5000, logger = create.logger(stderr(), log4r:::FATAL + 1))
svg
and arguments to the handler function. If there are any extra arguments then an
error is thrown.$name
and $tmp_name
elements).analysis.page$annotate.plot
execute.handler
executes the plot function in the handler based on the
parameter list, checks that the output is valid, adds the SVG attributes to the plot,
and returns an AnnotatedDataFrame.All of the parameters in the parameter list are JSON decoded. Even though this is really just extra work for the scalar parameters, we do it because otherwise it is confusing who needs to be de/encoded and who doesn't.
It is OK if your handler doesn't turn off the device when it's done. This wrapper
will check if the current device hasn't changed. If so, it will call dev.off
.
This is useful because then you can use the same function in an interactive session,
and also saves you one line of code. It's also OK if your handler *does* turn off
the device. Then the current device will have decreased and the wrapper will
known not to call dev.off again.
It is also OK if your handler returns a data.frame instead of an AnnotatedDataFrame.
It just has to have x
, y
. An AnnotatedDataFrame will be built
The interpretation
of the fields in the AnnotatedDataFrame depend on your front end, but the guidelines
are like this:
type
labelDescription
If $no.plot
is true then the plotting device won't be opened or closed, and of course the plot won't be annotated.
If annotate.data.frame is set then your data.frame is converted to an AnnotatedDataFrame and your AnnotatedDataFrame is converted to an AnalysisPageDataNode of "table" type automatically.
new.analysis.page
page <- new.analysis.page(AnalysisPageServer:::sine.handler)
plot.file <- tempfile(fileext = ".svg")
plist <- lapply(list(xmin=-2*pi, xmax=2*pi, n= 50), rjson::toJSON)
sine.data <- AnalysisPageServer:::execute.handler(page, plist, plot.file=plot.file)
# now sine.data is an AnnotatedDataFrame
Run the code above in your browser using DataLab