Interactive Data Visualizations Using 'd3.js'

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


R-CMD-check WebR compatibility R coverage JS coverage Lifecycle: stable License: MIT version

myIO

An R package for creating interactive d3.js visualizations using htmlwidgets. Supports 36 chart types including scatter plots, line charts, uncertainty views, statistical composites, and more — all composable through a piped API.

Live Demo

Installation

# install.packages("devtools")
devtools::install_github("mortonanalytics/myIO")

Usage

Build plots by piping layers together with myIO() and addIoLayer():

library(myIO)

myIO() |>
  addIoLayer(
    type = "point",
    color = "#E69F00",
    label = "points",
    data = mtcars,
    mapping = list(x_var = "wt", y_var = "mpg")
  ) |>
  addIoLayer(
    type = "line",
    transform = "lm",
    color = "red",
    label = "trend",
    data = mtcars,
    mapping = list(x_var = "wt", y_var = "mpg")
  )

Chart Type Examples

The table below covers common chart types. See the Chart Types article for more examples, or run myio_list_chart_types() for the complete list.

Type type value
Scatter plot "point"
Line chart "line"
Bar chart "bar"
Grouped bar chart "groupedBar"
Area chart "area"
Histogram "histogram"
Heatmap "heatmap"
Candlestick "candlestick"
Waterfall "waterfall"
Sankey "sankey"
Boxplot "boxplot"
Violin "violin"
Ridgeline "ridgeline"
Donut chart "donut"
Gauge chart "gauge"
Hexbin plot "hexbin"
Treemap "treemap"

addIoLayer()

Argument Description
type Chart type (see table above)
color Any CSS color string
label Unique identifier for the layer
data A data frame
mapping List mapping variables, e.g. list(x_var = "wt", y_var = "mpg")
transform Optional derived-data transform, e.g. "identity" or "lm"

Interactions

myIO charts are bidirectional — user actions flow back as structured data:

  • setBrush() — Rectangle select returns selected rows as data
  • setAnnotation() — Click to label data points; export annotations as CSV
  • setLinked() — Crosstalk linked brushing across multiple charts
  • setSlider() — Parameter sliders that trigger Shiny recomputation
  • addKeyframe() — Register complete data snapshots for sequential storytelling
  • setKeyframe() / stepKeyframe() — Select or step keyframes through a Shiny proxy

Runtime Compatibility

Runtime Supported path
RStudio, R Markdown, and Quarto Standard htmlwidgets rendering
Shiny Widget rendering, reactive inputs, proxy data updates, and keyframe control
WebR 0.6.0 Precompiled Wasm package, R payload creation, and production-bundle rendering in Chromium

The WebR claim is intentionally bounded to the pinned end-to-end CI path; it does not imply that DuckDB-WASM or every browser host has been validated.

Customization

Customize plots by chaining additional functions:

  • setAxisFormat() — Set d3.js axis formats and labels
  • setAxisLimits() — Set axis ranges
  • defineCategoricalAxis() — Define a categorical axis
  • setMargin() — Adjust chart margins
  • setColorScheme() — Apply a custom color palette
  • setTheme() — Set theme tokens (colors, font, background)
  • setTransitionSpeed() — Control animation duration
  • setTransition() — Configure duration, easing, and stagger
  • setToolTipOptions() — Configure tooltip behavior
  • setToggle() — Enable layer toggle controls
  • flipAxis() — Swap x and y axes
  • suppressAxis() — Hide axes
  • suppressLegend() — Hide the legend
  • setLegendTitle() — Title the legend with the grouping variable
  • dragPoints() — Enable draggable points
  • setReferenceLines() — Add reference lines

See the Getting Started, Chart Types, Sequential Storytelling, Shiny Integration, and Transforms & Theming articles for full examples.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("myIO")

1.4.0 by Ryan Morton, 11 days ago


https://mortonanalytics.github.io/myIO/, https://github.com/mortonanalytics/myIO


Report a bug at https://github.com/mortonanalytics/myIO/issues


Browse source code at https://github.com/cran/myIO


Authors: Ryan Morton [aut, cre, cph] , Mike Bostock [cph] (D3.js , d3-hexbin , and d3-sankey libraries) , James Hall [cph] (jsPDF library) , yWorks GmbH [cph] (jsPDF library)


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports htmlwidgets, jsonlite, stats

Suggests testthat, knitr, rmarkdown, pkgdown, shiny, crosstalk, dplyr, DT, reactable, htmltools, arrow, base64enc, cli, curl, DBI, duckdb, openssl, later, mockery, withr


See at CRAN