Render persistent manual plot layout edits across re-renders
Source:R/plot_helpers.R
finalize_manual_edits.RdRender-step companion to setup_manual_edits(). Call this inside
your module's plotly::renderPlotly() on the freshly rebuilt
figure, immediately before returning it.
Arguments
- fig
A plotly figure object, typically the result of your plotting pipeline. If
NULL, it is returned unchanged.- plot_source
Character scalar. The same plotly event source id passed to
setup_manual_edits(); assigned tofig$x$source.- store
The list returned by
setup_manual_edits().- session
The module's
sessionobject, used to namespace the colorbar drag input.
Value
The finalized plotly figure, ready to be returned from
plotly::renderPlotly().
Details
It performs four jobs:
tags the figure with the module's plotly event
sourceso itsplotly_relayoutevents are captured bysetup_manual_edits();restores any manually repositioned legend, annotations, axis titles, and colorbar captured so far;
records the figure so future relayout events can be matched to stable annotation keys (surviving re-ordering on rebuild); and
attaches the JavaScript listener that forwards colorbar drags.
Restored edits are applied under shiny::isolate() so re-applying
them never triggers an additional re-render.
See also
setup_manual_edits() for the setup-step companion.