Skip to content

Commit 0a15929

Browse files
llrs-rochem7pr
andauthored
Fix examples on decorator vignette (#1423)
Co-authored-by: Marcin <[email protected]> Fixes comments on vignette example on #1357
1 parent 347b82a commit 0a15929

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

vignettes/decorate-module-output.Rmd

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,9 @@ if (interactive()) {
311311

312312
### Example Module
313313

314-
It is possible to pass any number of decorators (n) to a module. The example below demonstrates how to handle a dynamic number of decorators, allowing the user to choose which decorator to apply from a list. This makes the module more flexible and capable of accommodating various customization requirements.
314+
It is possible to pass any number of decorators (n) to a module.
315+
The example below demonstrates how to handle a dynamic number of decorators, allowing the user to choose which decorator to apply from a list.
316+
This makes the module more flexible and capable of accommodating various customization requirements.
315317

316318
```{r}
317319
library(ggplot2)
@@ -418,6 +420,11 @@ tm_decorated_plot <- function(label = "module", decorators = NULL) {
418420
}
419421
```
420422

423+
By order of the decorator we will:
424+
425+
1. Change the x axis title
426+
2. Change the y axis title
427+
3. Replace the x axis title
421428

422429
```{r}
423430
interactive_decorator_1 <- teal_transform_module(
@@ -447,7 +454,7 @@ interactive_decorator_2 <- teal_transform_module(
447454
ui = function(id) {
448455
ns <- NS(id)
449456
div(
450-
textInput(ns("x_axis_title"), "X axis title", value = "x axis 2")
457+
textInput(ns("y_axis_title"), "Y axis title", value = "y axis 1")
451458
)
452459
},
453460
server = function(id, data) {
@@ -457,9 +464,9 @@ interactive_decorator_2 <- teal_transform_module(
457464
within(data(),
458465
{
459466
plot <- plot +
460-
xlab(title)
467+
ylab(title)
461468
},
462-
title = input$x_axis_title
469+
title = input$y_axis_title
463470
)
464471
})
465472
})
@@ -492,6 +499,8 @@ interactive_decorator_3 <- teal_transform_module(
492499

493500
### Application
494501

502+
As you might have noted, the x axis title from the first decorator will be used but won't show up on the resulting plot:
503+
495504
```{r}
496505
app <- init(
497506
data = teal_data(iris = iris, mtcars = mtcars),

0 commit comments

Comments
 (0)