Make lago_report() an interactive HTML dashboard - #97
Merged
Conversation
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.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
lago_report()now renders a self-contained interactive HTML dashboard insteadof 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 whenthere 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.jsare 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 labelledcorrectly rather than by the longer
intervention_componentsvector that carriesthe backticked interaction entry.
Related issue
No linked issue.
Checklist
tests/testthat/(new behaviour has a testthat fails without this change). Extended
test-report.Rwith render testsfor 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 thejs-testworkflow.devtools::document()run if roxygen comments changed. Man pageregenerated, no pending diff.
devtools::check()passes locally. Not run locally, following the"no local builds unless asked" convention. The full
testthatsuite passesvia
devtools::test(), both D3-math node tests pass, and CI runsR CMD checkon the PR.NEWS.mdupdated with a one-line entry if this is a user-facing change.