Skip to content

Add a dashboard app for the figure - #5

Merged
macromeer merged 1 commit into
mainfrom
dashboard-app
Oct 6, 2026
Merged

macromeer merged 1 commit into
mainfrom
dashboard-app

Conversation

@macromeer

Copy link
Copy Markdown
Owner

Adds app/, a Shiny app where you can change the figure's settings and download the result. It uses the plotting functions from R/figure.R (#4), so the script and the app draw the same plots. Uploading your own data and deploying to GitHub Pages come in later PRs.

The app

  • Sidebar: every setting from figure_defaults(), grouped by panel: font size, which panels to show, the two group colours, lognormal sigma and the inset/polygon switches (B), jitter seed and point opacity (C), the shear-stress constant and dashed lines (D), the decay constants and band width (E), and the viridis palette (F). A reset button restores the defaults. Invalid values (empty fields, a negative constant, no panel selected) show a message in place of the figure.
  • Figure tab: preview at the script's fixed size (1148 × 686 px). Downloads: PNG at 96, 150 or 300 dpi (same layout, more pixels) and SVG.
  • Panel tab: one panel at a larger size. It is drawn in its cell of the 3 × 2 layout and then trimmed, so it looks as it does in the figure (drawn alone, the insets in B and D would shift).
  • About tab.

Each panel is cached and rebuilt only when one of its own settings changes. The colour pickers are native <input type="color"> elements with a small input binding, so no extra package is needed.

Shinylive (webR)

The plan is to host it on GitHub Pages with Shinylive, so R runs in the visitor's browser. I exported this branch with shinylive::export() and drove it in headless Chromium. It works:

  • about 16 s from opening the page to the first figure (served from localhost), and 3–4 s per settings change;
  • text uses webR's Noto Sans, so fonts differ slightly from the script's exports;
  • the app avoids cairo devices, which crash in webR once magick is loaded, and passes an explicit cache to bindCache(), because Shinylive sets up no default one.

Tests and dependencies

  • tests/testthat/test-app.R checks the server logic with shiny::testServer(): defaults, settings reaching the panels, panel selection, the validation messages, the panel tab, and both downloads (PNG pixel size per dpi). 91 tests pass locally.
  • shiny, bslib and ragg are added to Suggests, so CI installs them. The script itself doesn't need them.
  • README: new "Dashboard" section with how to run the app locally.

Run it locally with shiny::runApp("app").

🤖 Generated with Claude Code

app/app.R is a Shiny (bslib) app that builds the figure with the
functions in R/figure.R. The sidebar exposes the settings from
figure_defaults(): font size, panels, the two group colours, the panel B
model and inset switches, the panel C jitter, the panel D constant and
dashed lines, the panel E decay constants and band, and the panel F
palette, plus a reset button. Tabs show the full figure, one panel at a
larger size, and an about page. The figure downloads as PNG (96, 150 or
300 dpi) or SVG.

The figure is always drawn at the script's fixed size, since the insets
in panels B and D are placed for it. The panel tab draws the panel in
its cell of the 3 x 2 layout and trims the empty space, so it matches
the figure. Each panel is rebuilt only when one of its own settings
changes. The app runs as is under Shinylive (webR): no cairo devices
(they crash in webR once magick is loaded) and an explicit bindCache()
cache (Shinylive sets up no default one).

tests/testthat/test-app.R checks the server logic with testServer():
defaults, settings reaching the panels, panel selection, messages for
invalid settings, the panel tab and both downloads. shiny, bslib and
ragg are added to Suggests so CI installs them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@macromeer
macromeer merged commit 070b0ad into main Oct 6, 2026
1 check passed
@macromeer
macromeer deleted the dashboard-app branch October 6, 2026 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant