| plotly_datahandler {shinyHugePlot} | R Documentation |
R6 class for handling plotly data
Description
A class for handling plotly data,
which defines functions used in the downsampler class
Format
An R6::R6Class object
Public fields
figureplotlyobject.
Active bindings
orig_dataData frame representing
plotlytraces.trace_df_defaultData frame representing default values of
plotlytraces.namecolumn represents the names of the attributes.requiredcolumn represents whether the attributes are necessary to construct a data frame of a trace.datacolumn represents whether the attributes are the data.defaultattributes represents default values of the attributes. When constructing a data frame of a trace, default values are used if no values are assigned.classcolumn represents the acceptable classes of the attributes.
Methods
Public methods
Method new()
Constructing an instance.
The data contained in a plotly object (figure argument)
will be included in the instance (as a reference).
Usage
plotly_datahandler$new(
figure = NULL,
legend_options = list(name_prefix = "<b style=\"color:sandybrown\">[S]</b> ",
name_suffix = "", xdiff_prefix = "<i style=\"color:#fc9944\"> ~", xdiff_suffix =
"</i>"),
tz = Sys.timezone(),
use_light_build = TRUE
)Arguments
figureplotlyobject. The traces of this object will be down-sampled.legend_optionsNamed list, optional. Names of the elements are
name_prefix,name_suffix,xdiff_prefix, andxdiff_suffix.name_prefixandname_suffixwill be added to the name of the trace when the down-sampling is applied. By default, prefix is a bold orange[S]and suffix is none.xdiff_prefixandxdiff_suffixare employed to show the mean aggregation size of the down-sampling.tzCharacter, optional. Time zone used to display time-series data. By default
Sys.timezone().use_light_buildBoolean, optional. Whether
plotly_build_lightis used. It quickly build scatter-typeplotlydata. By default,TRUE.
Method set_trace_data()
In the instance, data is contained as a data frame
(see self$orig_data for detailed information).
Using this method, the data can be added or overwritten.
If a data frame (traces_df argument) is given, it will be
added to self$orig_data or reassigned as self$orig_data.
If attributes to construct a plotly object (... argument)
are given, a data frame is constructed and used.
Usage
plotly_datahandler$set_trace_data(..., traces_df = NULL, append = FALSE)
Arguments
...Arguments to constitute a
plotlyattributes, optional. For instance,x,y,type, andmodeare applicable. Seeplotly::plot_ly.traces_dfData frame, optional. Data frame whose format is agreed with
self$orig_data. Iftraces_dfis given, arguments in...are neglected.appendBoolean, optional. Whether the data is append or overwrite. By default,
FALSE(the traces are overwritten).
Method plotly_data_to_df()
Covert the data contained in plotly object to a data frame.
A unique id (uid) is granted to each data.
The data frame will be returned.
Usage
plotly_datahandler$plotly_data_to_df(plotly_data, use_datatable = TRUE)
Arguments
plotly_dataList. The list whose elements are named list representing
plotlytraces. All elements must have elements namedtype.use_datatableBoolean. If it is
TRUE, data such asxandyare nested in adata.table, of which key column isx. By default,TRUE.
Method clone()
The objects of this class are cloneable with this method.
Usage
plotly_datahandler$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.