Skip to content

Make lago_report() an interactive HTML dashboard - #97

Merged
correspondMerchant merged 1 commit into
mainfrom
feature/interactive-report
Aug 25, 2026
Merged

Make lago_report() an interactive HTML dashboard#97
correspondMerchant merged 1 commit into
mainfrom
feature/interactive-report

Conversation

@correspondMerchant

Copy link
Copy Markdown
Owner

What this changes

lago_report() now renders a self-contained interactive HTML dashboard instead
of a static report. The confidence set is drawn as a hover-enabled D3 plot, a
scatter for a two-component intervention with the recommended intervention
highlighted or a one-dimensional strip for a single component, and each
intervention component gets interactive total-cost and marginal-cost curves with
a hover read-out. For three or more components, or when jsonlite is not
installed, the report falls back to the static plot.lago() figure, and when
there is no confidence set the plot section is omitted.

The report stays a single offline file. The vendored D3 v7 library and a new
inst/js/lago-report.js are inlined into the HTML, so there is no CDN, server,
or extra widget framework, and the public API of lago_report() is unchanged.
Rendering now also uses jsonlite, added under Suggests, to serialize the result
for the client-side code.

The cost curves are labelled by the main components the cost vectors are indexed
by (display_components), so a model with interaction terms is labelled
correctly rather than by the longer intervention_components vector that carries
the backticked interaction entry.

Related issue

No linked issue.

Checklist

  • Tests added or updated under tests/testthat/ (new behaviour has a test
    that fails without this change). Extended test-report.R with render tests
    for the interactive pieces and an interaction-terms regression test for the
    cost labels, which fails if the label fix is reverted. Added
    tests/js/test-report-math.js (24 assertions) and wired it into the
    js-test workflow.
  • devtools::document() run if roxygen comments changed. Man page
    regenerated, no pending diff.
  • devtools::check() passes locally. Not run locally, following the
    "no local builds unless asked" convention. The full testthat suite passes
    via devtools::test(), both D3-math node tests pass, and CI runs
    R CMD check on the PR.
  • NEWS.md updated with a one-line entry if this is a user-facing change.

Upgrade lago_report() from a static HTML report to a self-contained,
interactive dashboard drawn client-side with the vendored D3 v7 library
plus a new inst/js/lago-report.js. The confidence set is now a
hover-enabled D3 plot (a scatter for two components with the recommended
intervention highlighted, a strip for one component), and each
intervention component gains interactive total-cost and marginal-cost
curves with hover read-outs. For 3+ components, or when jsonlite is
unavailable, the report falls back to the static plot.lago() figure; when
there is no confidence set the plot section is omitted.

The output stays a single offline file (D3 and the report JS are inlined,
no CDN or server) and the public API is unchanged. Rendering now also
uses jsonlite (a new Suggests) to serialize the result for the D3 code.

Cost curves are labelled by the main components the cost vectors are
indexed by (display_components), so interaction-terms results are
labelled correctly rather than by the longer, backticked
intervention_components vector.

Tests: extended tests/testthat/test-report.R with render tests for the
interactive pieces (guarded by skip_on_cran + pandoc + Suggests),
including an interaction-terms regression test for the cost labels; added
tests/js/test-report-math.js (24 assertions) and wired it into the
js-test workflow. Updated README, NEWS, the man page, and the example
figure.
@correspondMerchant
correspondMerchant merged commit 0fd4bb4 into main Aug 25, 2026
7 checks passed
@correspondMerchant
correspondMerchant deleted the feature/interactive-report branch August 25, 2026 16:01
@codecov

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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