iNZightPlots (version 2.15.3)

can.interact: Identify if a plot can be interactive

Description

Several iNZightPlots graphs have been enabled with custom interaction, while others make use of the automatic output of `plotly`. This function returns `TRUE` if the provided plot has interaction (as determined by iNZight), and `FALSE` otherwise.

Usage

can.interact(x)

# S3 method for default can.interact(x)

# S3 method for inzplotoutput can.interact(x)

# S3 method for ggplot can.interact(x)

Value

Logical to identify if there is an interactive version

Arguments

x

a plot object returned from a plotting function

Methods (by class)

  • can.interact(default): Default interaction helper (always returns `FALSE`)

  • can.interact(inzplotoutput): Graphs from `iNZightPlot()`, many of which have interaction enabled, but some do not (for example, hex plots)

  • can.interact(ggplot): Those `iNZight*` plotting functions which return a `ggplot2` object and have been tested to work with plotly will be tagged as such; this is just a helper to check for the necessary attribute.

Author

Tom Elliott, Yu Han Soh

Details

Not that, while most `ggplot2` graphs can be passed to `plotly`, and even though we are using plot.ly directly for some of our ggplot2 graphs, we still only return `TRUE` if the graph was created by one of the packages in the iNZight collection.

Examples

Run this code
can.interact(iNZightPlot(Sepal.Length, data = iris))

Run the code above in your browser using DataLab