| Title: | Interactive Data Visualizations Using 'd3.js' |
|---|---|
| Description: | Create interactive 'd3.js' visualizations from R with built-in statistical transforms. Computes confidence intervals, regression fits, LOESS smoothing, moving averages, error bars, and uncertainty visualizations (quantile dot plots and fan charts) in R and renders them as composable chart layers via 'htmlwidgets'. Supports 36 chart types including boxplots, violin plots, Q-Q diagnostic plots, calendar heatmaps, survival curves, and group comparisons with pairwise significance testing. Also provides a machine-readable chart specification schema with validators so that large language model agents can author and verify charts. Works in 'RStudio', 'Shiny', and 'R Markdown'. |
| Authors: | Ryan Morton [aut, cre], Morton Analytics LLC [cph, fnd], Mike Bostock [cph] (D3.js, d3-hexbin, and d3-sankey libraries), James Hall [cph] (jsPDF library), yWorks GmbH [cph] (jsPDF library) |
| Maintainer: | Ryan Morton <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.4.0 |
| Built: | 2026-10-29 22:18:31 UTC |
| Source: | https://github.com/mortonanalytics/myio |
Adds individual layer to a myIO widget
addIoLayer( myIO, type, color = NULL, label, data = NULL, mapping, transform = "identity", options = list(barSize = "large", toolTipOptions = list(suppressY = FALSE)) )addIoLayer( myIO, type, color = NULL, label, data = NULL, mapping, transform = "identity", options = list(barSize = "large", toolTipOptions = list(suppressY = FALSE)) )
myIO |
an htmlwidget object created by the |
type |
chart type |
color |
optional CSS color string or vector for grouped layers. For
|
label |
unique layer label |
data |
data frame backing the layer |
mapping |
named aesthetic mapping list |
transform |
transform name applied before serialization |
options |
layer options passed through to the widget config |
A modified myIO htmlwidget object with the new layer appended
to the configuration.
myIO(data = mtcars) |> addIoLayer( type = "point", label = "points", mapping = list(x_var = "wt", y_var = "mpg") )myIO(data = mtcars) |> addIoLayer( type = "point", label = "points", mapping = list(x_var = "wt", y_var = "mpg") )
Registers a named data state for sequential chart storytelling. A chart with one serialized layer accepts a data frame directly. Multi-layer charts use a named list of data frames keyed by existing layer labels; omitted layers retain their data from the previous keyframe.
addKeyframe(myIO, data, label)addKeyframe(myIO, data, label)
myIO |
A widget created by |
data |
A data frame for a single-layer chart, or a named list of data frames keyed by layer label for a multi-layer chart. |
label |
A unique, non-empty keyframe label. |
A modified myIO widget with the keyframe appended.
start <- data.frame(x = 1:3, y = c(2, 4, 3)) finish <- data.frame(x = 1:3, y = c(5, 3, 7)) myIO(start) |> addIoLayer("line", label = "series", mapping = list(x_var = "x", y_var = "y")) |> addKeyframe(start, "Start") |> addKeyframe(finish, "Finish")start <- data.frame(x = 1:3, y = c(2, 4, 3)) finish <- data.frame(x = 1:3, y = c(5, 3, 7)) myIO(start) |> addIoLayer("line", label = "series", mapping = list(x_var = "x", y_var = "y")) |> addKeyframe(start, "Start") |> addKeyframe(finish, "Finish")
Remove DuckDB-WASM cache entries
clear_duckdb_wasm_cache(version = NULL)clear_duckdb_wasm_cache(version = NULL)
version |
Character scalar naming a specific version to remove. If NULL, removes all cached versions. |
Number of removed entries, invisibly.
## Not run: # Removes cached DuckDB-WASM binaries from the user cache. clear_duckdb_wasm_cache() ## End(Not run)## Not run: # Removes cached DuckDB-WASM binaries from the user cache. clear_duckdb_wasm_cache() ## End(Not run)
Function to define the x variable as categorical
defineCategoricalAxis(myIO, xAxis = TRUE, yAxis = FALSE)defineCategoricalAxis(myIO, xAxis = TRUE, yAxis = FALSE)
myIO |
an htmlwidget object created by the myIO() function |
xAxis |
a logical argument (TRUE) for defining the x axis as categorical |
yAxis |
a logical argument (TRUE) for defining the y axis as categorical |
A modified myIO htmlwidget object with categorical axis
configured.
# Define x axis as categorical myIO() |> defineCategoricalAxis(xAxis = TRUE) # Define both axes as categorical myIO() |> defineCategoricalAxis(xAxis = TRUE, yAxis = TRUE)# Define x axis as categorical myIO() |> defineCategoricalAxis(xAxis = TRUE) # Define both axes as categorical myIO() |> defineCategoricalAxis(xAxis = TRUE, yAxis = TRUE)
Function to make points draggable
dragPoints(myIO, dragPoints = TRUE)dragPoints(myIO, dragPoints = TRUE)
myIO |
an htmlwidget object created by the myIO() function |
dragPoints |
a logical argument (TRUE) for creating draggable points |
A modified myIO htmlwidget object with drag interaction
enabled.
# Enable draggable points myIO() |> addIoLayer( type = "point", color = "red", label = "pts", data = mtcars, mapping = list(x_var = "wt", y_var = "mpg") ) |> dragPoints()# Enable draggable points myIO() |> addIoLayer( type = "point", color = "red", label = "pts", data = mtcars, mapping = list(x_var = "wt", y_var = "mpg") ) |> dragPoints()
DuckDB-WASM cache status
duckdb_wasm_status()duckdb_wasm_status()
A list with class 'myIO_duckdb_wasm_status' and fields 'installed' (logical), 'version' (chr or NA), 'cache_dir' (chr), 'size_bytes' (numeric).
duckdb_wasm_status()duckdb_wasm_status()
Function to flip the x and y axes
flipAxis(myIO, flipAxis = TRUE)flipAxis(myIO, flipAxis = TRUE)
myIO |
an htmlwidget object created by the myIO() function |
flipAxis |
a logical argument (TRUE) for flipping the x and y axes |
A modified myIO htmlwidget object with axes flipped.
# Flip the axes for a horizontal bar chart myIO() |> addIoLayer( type = "bar", color = "steelblue", label = "bars", data = mtcars, mapping = list(x_var = "wt", y_var = "mpg") ) |> flipAxis()# Flip the axes for a horizontal bar chart myIO() |> addIoLayer( type = "bar", color = "steelblue", label = "bars", data = mtcars, mapping = list(x_var = "wt", y_var = "mpg") ) |> flipAxis()
Downloads and verifies the DuckDB-WASM runtime into a user-local cache so the in-browser big-data engine is available for subsequent widgets. This follows the keras3 / torch / reticulate pattern: the binary is NOT bundled with the R package and is not required for small-data use.
install_duckdb_wasm( version = NULL, from = NULL, force = FALSE, quiet = !interactive() )install_duckdb_wasm( version = NULL, from = NULL, force = FALSE, quiet = !interactive() )
version |
Character scalar naming the version to install. Defaults to the latest row in 'inst/duckdb-wasm-manifest.csv'. |
from |
Optional local directory containing pre-downloaded binaries ('duckdb-mvp.wasm' and 'duckdb-browser-mvp.worker.js'). Airgap path. |
force |
Logical. If TRUE, overwrite existing cached binaries. |
quiet |
Logical. Suppress progress output. Defaults to '!interactive()'. |
Invisibly returns the cache path where the binary was installed.
## Not run: # Downloads ~22 MB from the upstream mirror into the user cache. install_duckdb_wasm() ## End(Not run)## Not run: # Downloads ~22 MB from the upstream mirror into the user cache. install_duckdb_wasm() ## End(Not run)
A convenience wrapper that sets matching link config on multiple widgets
so that brush selections propagate between them. Unlike setLinked,
this does not require Crosstalk — it uses a shared group identifier and key
column to coordinate selections across charts rendered in the same page.
linkCharts(..., on, group = NULL, cursor = FALSE, cursorAxis = "x")linkCharts(..., on, group = NULL, cursor = FALSE, cursorAxis = "x")
... |
myIO widget objects to link. |
on |
Character. Column name to match rows across charts. |
group |
Character. Group identifier. Default auto-generated. |
cursor |
Logical. When |
cursorAxis |
Character. Which axis to sync: |
Cross-selection is driven by the brush, so at least one linked
chart must also call setBrush; brushing that chart
propagates the selected on values to every other chart in the
group, which dim their non-matching marks.
A list of modified myIO widgets with matching link config.
setLinked for Crosstalk SharedData-based
linking (use that path inside Shiny or with reactive filters).
w1 <- myIO() |> addIoLayer(type = "point", label = "scatter", data = mtcars, mapping = list(x_var = "wt", y_var = "mpg")) w2 <- myIO() |> addIoLayer(type = "bar", label = "bars", data = mtcars, mapping = list(x_var = "cyl", y_var = "mpg")) linked <- linkCharts(w1, w2, on = "cyl")w1 <- myIO() |> addIoLayer(type = "point", label = "scatter", data = mtcars, mapping = list(x_var = "wt", y_var = "mpg")) w2 <- myIO() |> addIoLayer(type = "bar", label = "bars", data = mtcars, mapping = list(x_var = "cyl", y_var = "mpg")) linked <- linkCharts(w1, w2, on = "cyl")
Create an interactive D3.js chart widget
myIO( data = NULL, width = "100%", height = "400px", elementId = NULL, title = NULL, sparkline = FALSE, engine = "auto", webgl_threshold = 50000L, unify_data_path = FALSE )myIO( data = NULL, width = "100%", height = "400px", elementId = NULL, title = NULL, sparkline = FALSE, engine = "auto", webgl_threshold = 50000L, unify_data_path = FALSE )
data |
an optional point of entry for the data frame or vector |
width |
a string of either pixel width or a percentage width |
height |
a string of pixel height |
elementId |
a unique id for the htmlwidget object |
title |
Optional chart title rendered inside the widget SVG. |
sparkline |
Logical. If TRUE, renders a compact sparkline suitable for embedding in table cells. Strips axes, legend, interactions, and the floating action button. Only "line", "bar", and "area" layer types are supported. Default FALSE. |
engine |
one of |
webgl_threshold |
Positive integer row-count threshold for the big-data
WebGL render path. Use |
unify_data_path |
Logical. If TRUE, coordinator results also replace SVG
layer data below |
An htmlwidget object of class myIO.
myIO(data = mtcars) |> setMargin(top = 40, bottom = 80, left = 60, right = 10)myIO(data = mtcars) |> setMargin(top = 40, bottom = 80, left = 60, right = 10)
Get myIO Chart Schema for LLM Tool Calling
myio_chart_schema(type = NULL)myio_chart_schema(type = NULL)
type |
Optional chart type. When |
A list containing one chart schema or all chart schemas.
myio_chart_schema("boxplot")myio_chart_schema("boxplot")
Get a myIO Function Signature for LLM Tool Calling
myio_function_signature(fn = NULL)myio_function_signature(fn = NULL)
fn |
Optional exported function name. When |
A character vector of argument names or a named list of signatures.
myio_function_signature("setAxisFormat")myio_function_signature("setAxisFormat")
Prints guidance on how to find the most recent JavaScript error from a myIO widget. In Shiny, errors are available as reactive inputs. Outside Shiny, errors appear in the browser's developer console.
myIO_last_error(outputId = NULL)myIO_last_error(outputId = NULL)
outputId |
optional Shiny output ID (character string). If provided, prints the exact Shiny input key to read. |
Invisibly returns NULL. Called for its side effect
(printing diagnostic guidance).
myIO_last_error() myIO_last_error("chart1")myIO_last_error() myIO_last_error("chart1")
Returns chart type names from the generated myIO schema.
myio_list_chart_types()myio_list_chart_types()
A character vector of chart type names.
head(myio_list_chart_types())head(myio_list_chart_types())
List myIO Functions for LLM Tool Calling
myio_list_functions()myio_list_functions()
A character vector of exported myIO function names.
head(myio_list_functions())head(myio_list_functions())
Validate a myIO Function Call
myio_validate_call(fn, args = list())myio_validate_call(fn, args = list())
fn |
Exported myIO function name. |
args |
Named list of proposed arguments. |
A list with valid and errors. Errors use stable
machine-readable code values.
myio_validate_call("setAxisFormat", list(axis_x = ".0f"))myio_validate_call("setAxisFormat", list(axis_x = ".0f"))
Validates a proposed chart specification against the generated myIO schema.
myio_validate_spec(spec, columns = NULL)myio_validate_spec(spec, columns = NULL)
spec |
A list with |
columns |
Optional named column type map. When supplied, overrides
|
A list with valid and errors. Errors use stable
machine-readable code values.
myio_validate_spec(list( type = "boxplot", mapping = list(column_var = "Species", value_var = "Sepal.Width") ))myio_validate_spec(list( type = "boxplot", mapping = list(column_var = "Species", value_var = "Sepal.Width") ))
Shiny Bindings for myIO
myIOOutput(outputId, width = "100%", height = "400px") renderMyIO(expr, env = parent.frame(), quoted = FALSE)myIOOutput(outputId, width = "100%", height = "400px") renderMyIO(expr, env = parent.frame(), quoted = FALSE)
outputId |
output variable to read from |
width, height
|
Must be a valid CSS unit or a number. |
expr |
An expression that generates a myIO |
env |
The environment in which to evaluate |
quoted |
Is |
myIOOutput returns a Shiny UI element for placement in a UI
definition. renderMyIO returns a Shiny render function for use in a
server definition.
if (interactive()) { library(shiny) ui <- fluidPage(myIOOutput("chart")) server <- function(input, output) { output$chart <- renderMyIO({ myIO(data = mtcars) |> addIoLayer(type = "point", label = "scatter", mapping = list(x_var = "wt", y_var = "mpg")) }) } shinyApp(ui, server) }if (interactive()) { library(shiny) ui <- fluidPage(myIOOutput("chart")) server <- function(input, output) { output$chart <- renderMyIO({ myIO(data = mtcars) |> addIoLayer(type = "point", label = "scatter", mapping = list(x_var = "wt", y_var = "mpg")) }) } shinyApp(ui, server) }
'myIOProxy()' creates a lightweight handle to an already-rendered myIO widget, and 'updateMyIOData()' swaps the data of one or more existing layers without re-rendering the whole widget. Unlike re-executing 'renderMyIO()' (which destroys and recreates the chart on every reactive invalidation, dropping brush/zoom/toggle state and flickering), a proxy update reuses the existing data-join path: only the changed marks transition, and interaction state is preserved.
myIOProxy(outputId, session = NULL) updateMyIOData(proxy, ...)myIOProxy(outputId, session = NULL) updateMyIOData(proxy, ...)
outputId |
The output id of the 'myIOOutput()' whose chart to update. |
session |
The Shiny session object. Defaults to the current reactive domain. |
proxy |
A 'myIO_proxy' object from 'myIOProxy()'. |
... |
One or more 'label = data.frame' updates, where 'label' is an existing layer label and the data frame carries that layer's mapped columns. |
Layers are matched by their 'label'. Unknown labels are ignored client-side. The supplied data frame replaces the layer's data as-is (the identity data path); statistical transforms attached at 'addIoLayer()' time are not re-applied, so pass already-transformed data for transformed layers.
'myIOProxy()' returns a 'myIO_proxy' object; 'updateMyIOData()' returns the proxy invisibly.
## Not run: library(shiny) ui <- fluidPage(myIOOutput("chart"), actionButton("go", "Resample")) server <- function(input, output, session) { output$chart <- renderMyIO({ myIO(data = data.frame(x = 1:50, y = rnorm(50))) |> addIoLayer("line", label = "series", mapping = list(x_var = "x", y_var = "y")) }) observeEvent(input$go, { myIOProxy("chart") |> updateMyIOData(series = data.frame(x = 1:50, y = rnorm(50))) }) } shinyApp(ui, server) ## End(Not run)## Not run: library(shiny) ui <- fluidPage(myIOOutput("chart"), actionButton("go", "Resample")) server <- function(input, output, session) { output$chart <- renderMyIO({ myIO(data = data.frame(x = 1:50, y = rnorm(50))) |> addIoLayer("line", label = "series", mapping = list(x_var = "x", y_var = "y")) }) observeEvent(input$go, { myIOProxy("chart") |> updateMyIOData(series = data.frame(x = 1:50, y = rnorm(50))) }) } shinyApp(ui, server) ## End(Not run)
Enables annotation mode where clicking a data point opens a label input. Annotations are stored as data and can be exported or accessed as a Shiny reactive input.
setAnnotation(myIO, labels = NULL, colors = NULL, mode = "click")setAnnotation(myIO, labels = NULL, colors = NULL, mode = "click")
myIO |
an htmlwidget object created by the |
labels |
character vector of preset label options (optional). If provided, shows a dropdown instead of free-text input. |
colors |
named character vector of category colors (optional). Names are category labels, values are CSS colors. |
mode |
|
A modified myIO htmlwidget object with annotation enabled.
myIO(data = mtcars) |> addIoLayer( type = "point", label = "pts", mapping = list(x_var = "wt", y_var = "mpg") ) |> setAnnotation(labels = c("outlier", "normal"))myIO(data = mtcars) |> addIoLayer( type = "point", label = "pts", mapping = list(x_var = "wt", y_var = "mpg") ) |> setAnnotation(labels = c("outlier", "normal"))
Sets axis for x axis, y axis, and/or tool tip
setAxisFormat( myIO, xAxis = NULL, yAxis = NULL, toolTip = NULL, xLabel = NULL, yLabel = NULL )setAxisFormat( myIO, xAxis = NULL, yAxis = NULL, toolTip = NULL, xLabel = NULL, yLabel = NULL )
myIO |
an htmlwidget object created by the myIO() function |
xAxis |
Optional string indicating a d3.js format for the x axis.
When |
yAxis |
Optional string indicating a d3.js format for the y axis.
When |
toolTip |
Optional string indicating a d3.js format for tooltips.
When |
xLabel |
Optional string label for the x axis. When |
yLabel |
Optional string label for the y axis. When |
A modified myIO htmlwidget object with updated axis format
configuration. with options set for the tooltip formats
# Set axis formats using d3.js format strings myIO() |> setAxisFormat(xAxis = ".0f", yAxis = ".1f") # Set axis labels myIO() |> setAxisFormat(xLabel = "Weight (lbs)", yLabel = "MPG") # Label-only calls preserve previously configured formats myIO() |> setAxisFormat(yAxis = ".2f") |> setAxisFormat(yLabel = "Rate")# Set axis formats using d3.js format strings myIO() |> setAxisFormat(xAxis = ".0f", yAxis = ".1f") # Set axis labels myIO() |> setAxisFormat(xLabel = "Weight (lbs)", yLabel = "MPG") # Label-only calls preserve previously configured formats myIO() |> setAxisFormat(yAxis = ".2f") |> setAxisFormat(yLabel = "Rate")
Sets the minimum and maximum values for chart axes
setAxisLimits( myIO, xlim = list(min = NULL, max = NULL), ylim = list(min = NULL, max = NULL) )setAxisLimits( myIO, xlim = list(min = NULL, max = NULL), ylim = list(min = NULL, max = NULL) )
myIO |
an htmlwidget object created by the myIO() function |
xlim |
a list of min and max values |
ylim |
a list of min and max values |
A modified myIO htmlwidget object with updated axis limits.
# Set x axis limits myIO() |> setAxisLimits(xlim = list(min = 0, max = 100)) # Set both axis limits myIO() |> setAxisLimits( xlim = list(min = 0, max = 50), ylim = list(min = -10, max = 200) )# Set x axis limits myIO() |> setAxisLimits(xlim = list(min = 0, max = 100)) # Set both axis limits myIO() |> setAxisLimits( xlim = list(min = 0, max = 50), ylim = list(min = -10, max = 200) )
'setBigData()' declares the data source that a myIO widget should use for large-dataset rendering and linked-selection coordination.
setBigData(widget, source, rowkeyCol = NULL, ...)setBigData(widget, source, rowkeyCol = NULL, ...)
widget |
A myIO htmlwidget object. |
source |
A supported big-data source: a 'data.frame', an Arrow table or record-batch reader, a single file path or URL ending in '.parquet', '.arrow', '.feather', or '.csv', or a 'DBIConnection'. |
rowkeyCol |
Optional name of the column that uniquely identifies rows for Crosstalk-compatible linked selections. |
... |
Additional source-specific options. Also accepts the deprecated
|
This function writes the 'x.bigdata.*' payload fields consumed by the widget's large-dataset virtualization path and follows its row-key contract. DBI sources are stored as an internal session-scoped marker in 'x.bigdata$dbi_handle_internal'; render-time source registration is handled by the source registry phase.
A modified myIO htmlwidget object.
myIO(data = mtcars) |> setBigData(mtcars) myIO() |> setBigData("data/large.parquet", schema = c("id", "x", "y"), rowkeyCol = "id") if (requireNamespace("duckdb", quietly = TRUE)) { con <- DBI::dbConnect(duckdb::duckdb()) obs <- data.frame(id = seq_len(nrow(mtcars)), mpg = mtcars$mpg) DBI::dbWriteTable(con, "observations", obs) myIO() |> setBigData(con, table = "observations", rowkeyCol = "id") DBI::dbDisconnect(con, shutdown = TRUE) }myIO(data = mtcars) |> setBigData(mtcars) myIO() |> setBigData("data/large.parquet", schema = c("id", "x", "y"), rowkeyCol = "id") if (requireNamespace("duckdb", quietly = TRUE)) { con <- DBI::dbConnect(duckdb::duckdb()) obs <- data.frame(id = seq_len(nrow(mtcars)), mpg = mtcars$mpg) DBI::dbWriteTable(con, "observations", obs) myIO() |> setBigData(con, table = "observations", rowkeyCol = "id") DBI::dbDisconnect(con, shutdown = TRUE) }
Enables rectangle brush selection on the chart. When a user drags to select a region, the selected data points are available as a reactive input in Shiny or exportable in static HTML.
setBrush(myIO, direction = "xy", onSelect = NULL, ...)setBrush(myIO, direction = "xy", onSelect = NULL, ...)
myIO |
an htmlwidget object created by the |
direction |
brush direction: |
onSelect |
behavior in static mode: |
... |
reserved; accepts the deprecated |
A modified myIO htmlwidget object with brush interaction
enabled.
myIO(data = mtcars) |> addIoLayer( type = "point", label = "pts", mapping = list(x_var = "wt", y_var = "mpg") ) |> setBrush()myIO(data = mtcars) |> addIoLayer( type = "point", label = "pts", mapping = list(x_var = "wt", y_var = "mpg") ) |> setBrush()
Sets color scheme for a chart and the category names (optional)
setColorScheme(myIO, colorScheme = NULL, setCategories = NULL)setColorScheme(myIO, colorScheme = NULL, setCategories = NULL)
myIO |
an htmlwidget object created by the myIO() function |
colorScheme |
a vector of colors in the order you want them used |
setCategories |
an optional vector of names that will be mapped to the corresponding color in the colorScheme |
A modified myIO htmlwidget object with updated color scheme.
# Set a custom color scheme myIO() |> setColorScheme(colorScheme = list("red", "blue", "green")) # Set colors with category labels myIO() |> setColorScheme( colorScheme = list("steelblue", "orange"), setCategories = c("Group A", "Group B") )# Set a custom color scheme myIO() |> setColorScheme(colorScheme = list("red", "blue", "green")) # Set colors with category labels myIO() |> setColorScheme( colorScheme = list("steelblue", "orange"), setCategories = c("Group A", "Group B") )
Controls which export buttons appear in the chart toolbar.
setExportOptions( myIO, png = TRUE, svg = TRUE, pdf = TRUE, clipboard = TRUE, csv = TRUE, title = NULL )setExportOptions( myIO, png = TRUE, svg = TRUE, pdf = TRUE, clipboard = TRUE, csv = TRUE, title = NULL )
myIO |
A myIO widget object. |
png |
Logical. Show PNG download button. Default TRUE. |
svg |
Logical. Show SVG download button. Default TRUE. |
pdf |
Logical. Show PDF download button. Default TRUE. |
clipboard |
Logical. Show clipboard copy button. Default TRUE. |
csv |
Logical. Show CSV export button. Default TRUE. |
title |
Character or NULL. Chart title for PDF metadata. |
Modified myIO widget.
myIO(iris) |> addIoLayer("point", label = "pts", mapping = list(x_var = "Sepal.Length", y_var = "Sepal.Width")) |> setExportOptions(svg = TRUE, clipboard = TRUE, pdf = FALSE)myIO(iris) |> addIoLayer("point", label = "pts", mapping = list(x_var = "Sepal.Length", y_var = "Sepal.Width")) |> setExportOptions(svg = TRUE, clipboard = TRUE, pdf = FALSE)
Splits the chart into a grid of panels, one per unique value of the faceting variable. Each panel shows the same layers filtered to that subset of the data.
setFacet( myIO, var, ncol = NULL, minWidth = NULL, scales = "fixed", labelPosition = NULL, ... )setFacet( myIO, var, ncol = NULL, minWidth = NULL, scales = "fixed", labelPosition = NULL, ... )
myIO |
A myIO widget object. |
var |
Character. Column name to facet by. Must exist in at least one layer's data. |
ncol |
Integer or NULL. Number of columns in the grid. If NULL,
auto-computes from |
minWidth |
Numeric. Minimum panel width in pixels when |
scales |
Character. Scale sharing mode:
|
labelPosition |
Character. Where to show panel labels:
|
... |
reserved; accepts the deprecated |
Modified myIO widget.
myIO(iris) |> addIoLayer("point", label = "pts", mapping = list(x_var = "Sepal.Length", y_var = "Sepal.Width")) |> setFacet("Species", ncol = 3)myIO(iris) |> addIoLayer("point", label = "pts", mapping = list(x_var = "Sepal.Length", y_var = "Sepal.Width")) |> setFacet("Species", ncol = 3)
Select a named or numbered keyframe, or step an existing myIO widget without re-rendering the widget.
setKeyframe(proxy, frame) stepKeyframe(proxy, direction = c("next", "previous"))setKeyframe(proxy, frame) stepKeyframe(proxy, direction = c("next", "previous"))
proxy |
A |
frame |
A unique keyframe label or positive one-based keyframe index. |
direction |
Either |
The proxy, invisibly.
## Not run: myIOProxy("chart") |> setKeyframe("Forecast") myIOProxy("chart") |> stepKeyframe("next") ## End(Not run)## Not run: myIOProxy("chart") |> setKeyframe("Forecast") myIOProxy("chart") |> stepKeyframe("next") ## End(Not run)
Set Layer Opacity
setLayerOpacity(myIO, label, opacity)setLayerOpacity(myIO, label, opacity)
myIO |
an htmlwidget object created by the myIO() function |
label |
character. The layer label to target. |
opacity |
numeric. Opacity value between 0 (transparent) and 1 (opaque). |
A modified myIO htmlwidget object.
myIO(iris) |> addIoLayer("point", label = "pts", mapping = list(x_var = "Sepal.Length", y_var = "Sepal.Width")) |> setLayerOpacity("pts", 0.5)myIO(iris) |> addIoLayer("point", label = "pts", mapping = list(x_var = "Sepal.Length", y_var = "Sepal.Width")) |> setLayerOpacity("pts", 0.5)
Adds a title to the chart legend naming the variable its entries come from. The title renders on whichever legend surface is active – the compact in-plot legend or the panel opened from the chart's legend button – and on exported SVG, PNG and PDF output.
setLegendTitle(myIO, title = NULL)setLegendTitle(myIO, title = NULL)
myIO |
an htmlwidget object created by the |
title |
a single character string used as the legend title, or
|
The title is omitted when suppressLegend() is set. The
derived form (title = TRUE) is omitted unless the legend has at
least two entries and every entry comes from the same grouping column, so
a chart that mixes grouped series with a standalone fitted line stays
untitled unless a literal string is supplied.
A modified myIO htmlwidget object carrying the legend title.
df <- data.frame(x = rep(1:5, 2), y = runif(10), Month = rep(c("May", "June"), each = 5)) myIO() |> addIoLayer(type = "line", label = "Temp", data = df, mapping = list(x_var = "x", y_var = "y", group = "Month")) |> setLegendTitle("Month") # Derive the title from the grouping column name myIO() |> addIoLayer(type = "line", label = "Temp", data = df, mapping = list(x_var = "x", y_var = "y", group = "Month")) |> setLegendTitle(TRUE)df <- data.frame(x = rep(1:5, 2), y = runif(10), Month = rep(c("May", "June"), each = 5)) myIO() |> addIoLayer(type = "line", label = "Temp", data = df, mapping = list(x_var = "x", y_var = "y", group = "Month")) |> setLegendTitle("Month") # Derive the title from the grouping column name myIO() |> addIoLayer(type = "line", label = "Temp", data = df, mapping = list(x_var = "x", y_var = "y", group = "Month")) |> setLegendTitle(TRUE)
Connects the chart to a Crosstalk SharedData object so that brush selections propagate to other linked widgets.
setLinked( myIO, shared_data, mode = "both", filter = FALSE, key = NULL, group = NULL, cursor = FALSE, cursorAxis = "x" )setLinked( myIO, shared_data, mode = "both", filter = FALSE, key = NULL, group = NULL, cursor = FALSE, cursorAxis = "x" )
myIO |
an htmlwidget object created by the |
shared_data |
a |
mode |
|
filter |
if |
key |
Optional character vector of row keys. When supplied, overrides
the keys extracted from |
group |
Optional character string. When supplied, overrides the
Crosstalk group name from |
cursor |
Logical. When |
cursorAxis |
Character. Which axis to sync: |
Selections travel on the Crosstalk key space, so a myIO chart matches
rows against sibling widgets (DT, plotly, leaflet) by
the same keys they use. The keys are matched to the chart's rows by
position, which requires the data passed to addIoLayer() to be
shared_data$data() in its original row order. If a layer's row
count does not match the number of keys – for example after re-filtering
the frame, or after updateMyIOData() replaced the rows – the
chart falls back to matching within its own widget only, rather than
pairing keys with the wrong rows.
A modified myIO htmlwidget with Crosstalk linking.
linkCharts for group-identifier linking that does
not require Crosstalk (e.g. static R Markdown / Quarto HTML).
if (interactive() && requireNamespace("crosstalk", quietly = TRUE)) { shared <- crosstalk::SharedData$new(mtcars, key = ~rownames(mtcars)) myIO() |> addIoLayer( type = "point", label = "scatter", data = shared$data(), mapping = list(x_var = "wt", y_var = "mpg") ) |> setLinked(shared) }if (interactive() && requireNamespace("crosstalk", quietly = TRUE)) { shared <- crosstalk::SharedData$new(mtcars, key = ~rownames(mtcars)) myIO() |> addIoLayer( type = "point", label = "scatter", data = shared$data(), mapping = list(x_var = "wt", y_var = "mpg") ) |> setLinked(shared) }
Enables or disables synchronized hover crosshair across linked charts.
Composable with linkCharts and setLinked via
the pipe: call after linking to opt into cursor sync without re-linking.
Preserves any existing interactions$linked configuration.
setLinkedCursor(myIO, enabled = TRUE, axis = "x")setLinkedCursor(myIO, enabled = TRUE, axis = "x")
myIO |
A myIO htmlwidget. |
enabled |
Logical. |
axis |
Character. Which axis to sync: |
A modified myIO htmlwidget.
w1 <- myIO() |> addIoLayer(type = "point", label = "a", data = mtcars, mapping = list(x_var = "wt", y_var = "mpg")) w2 <- myIO() |> addIoLayer(type = "point", label = "b", data = mtcars, mapping = list(x_var = "hp", y_var = "mpg")) linked <- linkCharts(w1, w2, on = "cyl") linked[[1]] <- setLinkedCursor(linked[[1]]) linked[[2]] <- setLinkedCursor(linked[[2]])w1 <- myIO() |> addIoLayer(type = "point", label = "a", data = mtcars, mapping = list(x_var = "wt", y_var = "mpg")) w2 <- myIO() |> addIoLayer(type = "point", label = "b", data = mtcars, mapping = list(x_var = "hp", y_var = "mpg")) linked <- linkCharts(w1, w2, on = "cyl") linked[[1]] <- setLinkedCursor(linked[[1]]) linked[[2]] <- setLinkedCursor(linked[[2]])
Sets margins for the top, bottom, left, and right sides of the chart
setMargin(myIO, top = 20, bottom = 40, left = 50, right = 50)setMargin(myIO, top = 20, bottom = 40, left = 50, right = 50)
myIO |
an htmlwidget object created by the myIO() function |
top |
a numeric value representing in pixels the top margin |
bottom |
a numeric value representing in pixels the bottom margin |
left |
a numeric value representing in pixels the left margin |
right |
a numeric value representing in pixels the right margin |
A modified myIO htmlwidget object with updated margin
configuration.
# Set custom margins myIO() |> setMargin(top = 50, bottom = 80, left = 60, right = 20)# Set custom margins myIO() |> setMargin(top = 50, bottom = 80, left = 60, right = 20)
Sets x and y reference lines
setReferenceLines(myIO, xRef = 0, yRef = 0)setReferenceLines(myIO, xRef = 0, yRef = 0)
myIO |
an htmlwidget object created by the myIO() function |
xRef |
a list of the reference line value of x |
yRef |
a list of the reference line value of y |
A modified myIO htmlwidget object with reference lines added.
# Add reference lines at x=5 and y=20 myIO() |> setReferenceLines(xRef = 5, yRef = 20)# Add reference lines at x=5 and y=20 myIO() |> setReferenceLines(xRef = 5, yRef = 20)
Adds a slider control below the chart. Read its Shiny input in the render expression and pass the value to the transform option to recompute the chart.
setSlider(myIO, param, label, min, max, value, step = NULL, debounce = 200)setSlider(myIO, param, label, min, max, value, step = NULL, debounce = 200)
myIO |
an htmlwidget object created by the |
param |
Slider input name (e.g., |
label |
display label for the slider |
min |
minimum value |
max |
maximum value |
value |
default value |
step |
step size (default: |
debounce |
debounce delay in milliseconds (default: 200) |
A modified myIO htmlwidget with slider config attached.
## Not run: # In a Shiny server function: output$chart <- renderMyIO({ level <- input$`myIO-chart-slider-ci_level` if (is.null(level)) level <- 0.95 myIO(data = mtcars) |> addIoLayer( type = "regression", label = "fit", mapping = list(x_var = "wt", y_var = "mpg"), options = list(level = level) ) |> setSlider("ci_level", "Confidence level", 0.80, 0.99, level, 0.01) }) ## End(Not run)## Not run: # In a Shiny server function: output$chart <- renderMyIO({ level <- input$`myIO-chart-slider-ci_level` if (is.null(level)) level <- 0.95 myIO(data = mtcars) |> addIoLayer( type = "regression", label = "fit", mapping = list(x_var = "wt", y_var = "mpg"), options = list(level = level) ) |> setSlider("ci_level", "Confidence level", 0.80, 0.99, level, 0.01) }) ## End(Not run)
Sets chart theme tokens using CSS custom properties
setTheme( myIO, textColor = NULL, gridColor = NULL, bg = NULL, font = NULL, mode = NULL, preset = NULL, overrides = list(), ... )setTheme( myIO, textColor = NULL, gridColor = NULL, bg = NULL, font = NULL, mode = NULL, preset = NULL, overrides = list(), ... )
myIO |
an htmlwidget object created by the myIO() function |
textColor |
text and label color |
gridColor |
grid line color |
bg |
background color |
font |
font family |
mode |
Character or NULL. Theme mode: "light", "dark", or "auto". Default NULL (no mode, manual CSS vars only). |
preset |
Character or NULL. Named theme preset applied as a complete
palette. One of |
overrides |
Named list of CSS custom property overrides
(e.g., |
... |
additional CSS custom property overrides; only names with a
|
A modified myIO htmlwidget object with updated theme
configuration.
myIO() |> setTheme(textColor = "#222222", gridColor = "#d9d9d9") myIO() |> setTheme(mode = "dark", bg = "#1a1a2e")myIO() |> setTheme(textColor = "#222222", gridColor = "#d9d9d9") myIO() |> setTheme(mode = "dark", bg = "#1a1a2e")
Sets the title rendered inside the myIO widget SVG.
setTitle(myIO, title = NULL)setTitle(myIO, title = NULL)
myIO |
A myIO widget object. |
title |
Character title or NULL to remove the title. |
A modified myIO htmlwidget object.
myIO() |> setTitle("Miles per gallon") |> addIoLayer("point", label = "cars", data = mtcars, mapping = list(x_var = "wt", y_var = "mpg"))myIO() |> setTitle("Miles per gallon") |> addIoLayer("point", label = "cars", data = mtcars, mapping = list(x_var = "wt", y_var = "mpg"))
Sets toggle options for y_var and adds a toggle button for chart
setToggle(myIO, variable, format = NULL)setToggle(myIO, variable, format = NULL)
myIO |
an htmlwidget object created by the myIO() function |
variable |
a string indicating the variable name in data for toggle |
format |
a string indicating the format for the toggled variable |
A modified myIO htmlwidget object with toggle interaction
configured.
# Add a toggle button to switch y variable myIO() |> setToggle(variable = "Percent", format = ".0%")# Add a toggle button to switch y variable myIO() |> setToggle(variable = "Percent", format = ".0%")
Generic function for setting tool tip options for a chart
setToolTipOptions(myIO, suppressY = NULL)setToolTipOptions(myIO, suppressY = NULL)
myIO |
an htmlwidget object created by the myIO() function |
suppressY |
a boolean |
A modified myIO htmlwidget object with updated tooltip
options.
# Suppress the y value in tooltips myIO() |> setToolTipOptions(suppressY = TRUE)# Suppress the y value in tooltips myIO() |> setToolTipOptions(suppressY = TRUE)
Sets the duration, easing, and per-element stagger for the enter/update/exit
animations used across chart layers. All arguments are optional; any left
NULL keeps the chart's current behavior, so this setter is fully
additive and backward compatible.
setTransition(myIO, duration = NULL, easing = NULL, stagger = NULL)setTransition(myIO, duration = NULL, easing = NULL, stagger = NULL)
myIO |
an htmlwidget object created by the |
duration |
transition duration in milliseconds ( |
easing |
easing function name, one of |
stagger |
per-element delay in milliseconds ( |
Animation remains fully opt-out-able: duration = 0 (or
setTransitionSpeed(0)) disables animation, and easing and
stagger automatically no-op whenever the effective duration is 0 — including
when the viewer's system requests prefers-reduced-motion: reduce.
A modified myIO htmlwidget object with updated transition
settings.
setTransitionSpeed for the duration-only shorthand.
# Slower transitions with a bouncing ease and a 25ms cascade myIO() |> setTransition(duration = 1200, easing = "bounce", stagger = 25) # Change only the easing myIO() |> setTransition(easing = "cubic") # Disable animation entirely myIO() |> setTransition(duration = 0)# Slower transitions with a bouncing ease and a 25ms cascade myIO() |> setTransition(duration = 1200, easing = "bounce", stagger = 25) # Change only the easing myIO() |> setTransition(easing = "cubic") # Disable animation entirely myIO() |> setTransition(duration = 0)
Sets transition speeds across the chart (set to 0 to suppress)
setTransitionSpeed(myIO, speed)setTransitionSpeed(myIO, speed)
myIO |
an htmlwidget object created by the myIO() function |
speed |
a number indicating the speed of transition in milliseconds |
A modified myIO htmlwidget object with updated transition
speed.
setTransition to also configure easing and stagger.
# Set transition speed to 500ms myIO() |> setTransitionSpeed(speed = 500) # Disable transitions myIO() |> setTransitionSpeed(speed = 0)# Set transition speed to 500ms myIO() |> setTransitionSpeed(speed = 500) # Disable transitions myIO() |> setTransitionSpeed(speed = 0)
Suppresses axes from printing
suppressAxis(myIO, xAxis = NULL, yAxis = NULL)suppressAxis(myIO, xAxis = NULL, yAxis = NULL)
myIO |
an htmlwidget object created by the myIO() function |
xAxis |
a logical operator defining whether the x axis should be printed or not |
yAxis |
a logical operator defining whether the y axis should be printed or not |
A modified myIO htmlwidget object with axis display
suppressed.
# Suppress both axes myIO() |> suppressAxis(xAxis = TRUE, yAxis = TRUE) # Suppress only the x axis myIO() |> suppressAxis(xAxis = TRUE)# Suppress both axes myIO() |> suppressAxis(xAxis = TRUE, yAxis = TRUE) # Suppress only the x axis myIO() |> suppressAxis(xAxis = TRUE)
Suppresses legend from printing
suppressLegend(myIO, suppressLegend = TRUE)suppressLegend(myIO, suppressLegend = TRUE)
myIO |
an htmlwidget object created by the myIO() function |
suppressLegend |
a logical operator defining whether the legend should be printed or not |
A modified myIO htmlwidget object with legend display
suppressed.
# Hide the legend myIO() |> suppressLegend()# Hide the legend myIO() |> suppressLegend()