Repository navigation
Conversation
plot_with_settings_srv classified any non-ggplot/trellis/grob/base plot as
"other", so an htmlwidget (e.g. canvasXpress, plotly) returned by plot_r()
fell through and never rendered. Add a "widget" plot_type and route it
through the htmlwidgets shiny binding (shinyWidgetOutput / shinyRenderWidget)
instead of renderPlot/plotOutput. The widget's class drives the correct JS
output binding, height/width settings apply, and download produces a
self-contained HTML file (htmlwidgets::saveWidget). Static-plot behaviour is
unchanged.
- htmlwidgets added to Imports; canvasXpress added to Suggests (example/tests)
- @examplesIf requireNamespace("canvasXpress") example on plot_with_settings
- tests: plot_type detection for htmlwidget vs ggplot via shiny::testServer
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This branch has not been deployed
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.
Summary
plot_with_settingscurrently renders only static R graphics (ggplot, trellis, grob, base). Anhtmlwidgetreturned byplot_r()falls through to the"other"type and never renders. This adds a render path for interactivehtmlwidgetobjects (e.g. canvasXpress, plotly), as discussed in pharmaverse/teal#1757.What changed
plot_with_settings_srv()gains a"widget"plot_type;htmlwidgetplots render through the htmlwidgets shiny binding (shinyWidgetOutput/shinyRenderWidget) instead ofrenderPlot/plotOutput. The widget's class drives the correct JS output binding.htmlwidgets::saveWidget.htmlwidgetsadded to Imports;canvasXpressadded to Suggests (example + tests only).@examplesIf requireNamespace("canvasXpress")example onplot_with_settings, reusing the existing example structure.plot_typedetection for htmlwidget vs ggplot viashiny::testServer.Design notes
htmlwidgetfromplot_r. Existing callers (includingteal.modules.clinicaloutputs) are unaffected — the interactive render is something a module opts into, e.g. routingtm_g_km/tm_g_forest_*through canvasXpress for the final render only.htmlwidget, so other widget packages benefit too.Verification
shiny::testServerconfirmsplot_type()resolves to"widget"for a canvasXpress object and the UI emits the widget output binding.plot_with_settingscard with the resize/download chrome and interactive behaviour.Happy to adjust anything — naming, the example, or the download behaviour.
🤖 Generated with Claude Code