@@ -24,15 +24,10 @@ plot_with_settings_ui <- function(id) {
24
24
shinyjs :: useShinyjs(),
25
25
bslib :: card(
26
26
id = ns(" plot-with-settings" ),
27
+ full_screen = TRUE ,
27
28
tags $ div(
28
29
tags $ div(
29
30
class = " teal-widgets settings-buttons" ,
30
- bslib :: tooltip(
31
- trigger = tags $ div(type_download_ui(ns(" downbutton" ))),
32
- options = list (trigger = " hover" ),
33
- class = " download-button" ,
34
- " Download"
35
- ),
36
31
bslib :: tooltip(
37
32
trigger = tags $ div(
38
33
bslib :: popover(
@@ -47,22 +42,14 @@ plot_with_settings_ui <- function(id) {
47
42
" Resize"
48
43
),
49
44
bslib :: tooltip(
50
- trigger = tags $ div(
51
- actionLink(
52
- ns(" expand" ),
53
- label = character (0 ),
54
- icon = icon(" up-right-and-down-left-from-center" ),
55
- class = " btn-sm" ,
56
- style = " color: #000;"
57
- )
58
- ),
45
+ trigger = tags $ div(type_download_ui(ns(" downbutton" ))),
59
46
options = list (trigger = " hover" ),
60
- class = " expand -button" ,
61
- " Expand "
62
- ),
47
+ class = " download -button" ,
48
+ " Download "
49
+ )
63
50
),
64
- tags $ br(),
65
51
tags $ div(
52
+ id = ns(" plot-out-main" ),
66
53
class = " teal-widgets plot-content" ,
67
54
uiOutput(ns(" plot_out_main" ))
68
55
)
@@ -87,29 +74,27 @@ plot_with_settings_ui <- function(id) {
87
74
# ' Take into account that simple functions are less efficient than reactive, as not catching the result.
88
75
# ' @param height (`numeric`) optional\cr
89
76
# ' vector with three elements c(VAL, MIN, MAX), where VAL is the starting value of the slider in
90
- # ' the main and modal plot display. The value in the modal display is taken from the value of the
91
- # ' slider in the main plot display.
77
+ # ' the main and expanded plot display.
92
78
# ' @param width (`numeric`) optional\cr
93
79
# ' vector with three elements `c(VAL, MIN, MAX)`, where VAL is the starting value of the slider in
94
- # ' the main and modal plot display; `NULL` for default display. The value in the modal
95
- # ' display is taken from the value of the slider in the main plot display.
80
+ # ' the main and expanded plot display; `NULL` for default display.
96
81
# ' @param show_hide_signal optional, (`reactive logical` a mechanism to allow modules which call this
97
82
# ' module to show/hide the plot_with_settings UI)
98
83
# ' @param brushing (`logical`) optional\cr
99
- # ' mechanism to enable / disable brushing on the main plot (in particular: not the one displayed
100
- # ' in modal). All the brushing data is stored as a reactive object in the `"brush"` element of
84
+ # ' mechanism to enable / disable brushing on the main plot.
85
+ # ' All the brushing data is stored as a reactive object in the `"brush"` element of
101
86
# ' returned list. See the example for details.
102
87
# ' @param clicking (`logical`)\cr
103
- # ' a mechanism to enable / disable clicking on data points on the main plot (in particular: not the
104
- # ' one displayed in modal). All the clicking data is stored as a reactive object in the `"click"`
88
+ # ' a mechanism to enable / disable clicking on data points on the main plot.
89
+ # ' All the clicking data is stored as a reactive object in the `"click"`
105
90
# ' element of returned list. See the example for details.
106
91
# ' @param dblclicking (`logical`) optional\cr
107
- # ' mechanism to enable / disable double-clicking on data points on the main plot (in particular:
108
- # ' not the one displayed in modal). All the double clicking data is stored as a reactive object in
92
+ # ' mechanism to enable / disable double-clicking on data points on the main plot.
93
+ # ' All the double clicking data is stored as a reactive object in the
109
94
# ' the `"dblclick"` element of returned list. See the example for details.
110
95
# ' @param hovering (`logical(1)`) optional\cr
111
- # ' mechanism to enable / disable hovering over data points on the main plot (in particular: not
112
- # ' the one displayed in modal). All the hovering data is stored as a reactive object in the
96
+ # ' mechanism to enable / disable hovering over data points on the main plot.
97
+ # ' All the hovering data is stored as a reactive object in the
113
98
# ' `"hover"` element of returned list. See the example for details.
114
99
# ' @param graph_align (`character(1)`) optional,\cr
115
100
# ' one of `"left"` (default), `"center"`, `"right"` or `"justify"`. The alignment of the graph on
@@ -298,10 +283,9 @@ plot_with_settings_srv <- function(id,
298
283
ns <- session $ ns
299
284
shinyjs :: runjs(
300
285
sprintf(
301
- ' establishPlotResizing("%s", "%s", "%s");' ,
302
- ns(" plot_main" ), # graph parent id
303
- ns(" flex_width" ), # session input$ variable name
304
- ns(" plot_modal_width" ) # session input$ variable name
286
+ ' establishPlotResizing("%s", "%s");' ,
287
+ ns(" plot-out-main" ), # graph parent id
288
+ ns(" flex_width" ) # session input$ variable name
305
289
)
306
290
)
307
291
default_w <- function () session $ clientData [[paste0(" output_" , ns(" plot_main_width" ))]]
@@ -430,25 +414,14 @@ plot_with_settings_srv <- function(id,
430
414
width = p_width
431
415
)
432
416
433
- output $ plot_modal <- renderPlot(
434
- apply_plot_modifications(
435
- plot_obj = plot_suppress(plot_r()),
436
- plot_type = plot_suppress(plot_type()),
437
- dblclicking = dblclicking ,
438
- ranges = ranges
439
- ),
440
- res = get_plot_dpi(),
441
- height = reactive(input $ height_in_modal ),
442
- width = reactive(input $ width_in_modal )
443
- )
444
-
445
417
output $ plot_out_main <- renderUI({
446
418
req(plot_suppress(plot_r()))
447
419
tags $ div(
448
420
align = graph_align ,
449
421
plotOutput(
450
422
ns(" plot_main" ),
451
423
height = " 100%" ,
424
+ width = p_width(),
452
425
brush = `if`(brushing , brushOpts(ns(" plot_brush" ), resetOnNew = FALSE ), NULL ),
453
426
click = `if`(clicking , clickOpts(ns(" plot_click" )), NULL ),
454
427
dblclick = `if`(dblclicking , dblclickOpts(ns(" plot_dblclick" )), NULL ),
@@ -479,72 +452,6 @@ plot_with_settings_srv <- function(id,
479
452
default_h = default_h
480
453
)
481
454
482
- output $ plot_out_modal <- renderUI({
483
- plotOutput(ns(" plot_modal" ), height = input $ height_in_modal , width = input $ width_in_modal )
484
- })
485
-
486
- observeEvent(input $ expand , {
487
- showModal(
488
- tags $ div(
489
- class = " teal-widgets plot-modal" ,
490
- modalDialog(
491
- easyClose = TRUE ,
492
- tags $ div(
493
- class = " plot-modal-sliders" ,
494
- optionalSliderInputValMinMax(
495
- inputId = ns(" height_in_modal" ),
496
- label = " Plot height" ,
497
- value_min_max = round(c(p_height(), height [2 : 3 ])),
498
- ticks = FALSE ,
499
- step = 1L ,
500
- round = TRUE ,
501
- width = " 30vw"
502
- ),
503
- optionalSliderInputValMinMax(
504
- inputId = ns(" width_in_modal" ),
505
- label = " Plot width" ,
506
- value_min_max = round(c(
507
- ifelse(
508
- is.null(input $ width ) || ! isFALSE(input $ width_resize_switch ),
509
- ifelse(
510
- is.null(input $ plot_modal_width ) || input $ plot_modal_width > default_slider_width()[3 ],
511
- default_slider_width()[1 ],
512
- input $ plot_modal_width
513
- ),
514
- input $ width
515
- ),
516
- default_slider_width()[2 : 3 ]
517
- )),
518
- ticks = FALSE ,
519
- step = 1L ,
520
- round = TRUE ,
521
- width = " 30vw"
522
- ),
523
- bslib :: tooltip(
524
- trigger = tags $ div(type_download_ui(ns(" modal_downbutton" ))),
525
- options = list (trigger = " hover" ),
526
- " Download"
527
- )
528
- ),
529
- tags $ div(
530
- class = " teal-widgets plot-modal-content" ,
531
- uiOutput(ns(" plot_out_modal" ))
532
- )
533
- )
534
- )
535
- )
536
- })
537
-
538
- type_download_srv(
539
- id = " modal_downbutton" ,
540
- plot_reactive = plot_r ,
541
- plot_type = plot_type ,
542
- plot_w = reactive(input $ width_in_modal ),
543
- default_w = default_w ,
544
- plot_h = reactive(input $ height_in_modal ),
545
- default_h = default_h
546
- )
547
-
548
455
list (
549
456
brush = reactive({
550
457
# refresh brush data on the main plot size change
0 commit comments