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

figure

plotly object.

Active bindings

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.

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
figure

plotly object. The traces of this object will be down-sampled.

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.


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 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).


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_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.


Method clone()

The objects of this class are cloneable with this method.

Usage
plotly_datahandler$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


[Package shinyHugePlot version 0.2.6 Index]