plotly_datahandler | R Documentation |
A class for handling plotly
data,
which defines functions used in the downsampler
class
An R6::R6Class
object
figure
plotly
object.
orig_data
Data frame representing plotly
traces.
trace_df_default
Data frame representing default values
of plotly
traces.
name
column represents the names of the attributes.
required
column represents whether the attributes are necessary
to construct a data frame of a trace.
data
column represents whether the attributes are the data.
default
attributes represents default values of the attributes.
When constructing a data frame of a trace, default values are used
if no values are assigned.
class
column represents the acceptable classes of the attributes.
new()
Constructing an instance.
The data contained in a plotly
object (figure
argument)
will be included in the instance (as a reference).
plotly_datahandler$new( figure = NULL, srcs = NULL, formula = NULL, srcs_ext = 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 )
figure
plotly
object.
The traces of this object will be down-sampled.
srcs, srcs_ext, formula
Character and formula, optional.
srcs
is the path of the source data (or directory).
When a directory is specified, srcs_ext
is the extension of the source file.
formula
is the formula to extract the data from the source data.
legend_options
Named list, optional.
Names of the elements are name_prefix
,
name_suffix
, xdiff_prefix
,
and xdiff_suffix
.
name_prefix
and name_suffix
will 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_prefix
and xdiff_suffix
are employed to show
the mean aggregation size of the down-sampling.
tz
Character, optional.
Time zone used to display time-series data.
By default Sys.timezone()
.
use_light_build
Boolean, optional.
Whether plotly_build_light
is used.
It quickly build scatter-type plotly
data.
By default, TRUE
.
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.
plotly_datahandler$set_trace_data(..., traces_df = NULL, append = FALSE)
...
Arguments to constitute a plotly
attributes, optional.
For instance, x
, y
, type
, and mode
are applicable. See plotly::plot_ly
.
traces_df
Data frame, optional.
Data frame whose format is agreed with self$orig_data
.
If traces_df
is given, arguments in ...
are neglected.
append
Boolean, optional.
Whether the data is append or overwrite. By default, FALSE
(the traces are overwritten).
srcs_to_df()
Covert the data contained in srcs
file(s) to a duck-db.
A minimum data and the path of the database will be returned.
plotly_datahandler$srcs_to_df(fml, srcs, srcs_ext = NULL)
fml
Formula. The formula to extract the data from the source data.
srcs
Character. The name of the source file (e.g. data.parquet) or the directory can be specified.
srcs_ext
Character, optional.
The extension of the source file, if srcs
is a directory.
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.
plotly_datahandler$plotly_data_to_df(plotly_data, use_datatable = TRUE)
plotly_data
List.
The list whose elements are named list representing plotly
traces.
All elements must have elements named type
.
use_datatable
Boolean.
If it is TRUE
, data such as x
and y
are nested
in a data.table
, of which key column is x
.
By default, TRUE
.
clone()
The objects of this class are cloneable with this method.
plotly_datahandler$clone(deep = FALSE)
deep
Whether to make a deep clone.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.