Skip to content

Commit

Permalink
struttura con script pre-render
Browse files Browse the repository at this point in the history
  • Loading branch information
Umberto Vesco committed Apr 16, 2024
1 parent b5538d1 commit 5283fb9
Show file tree
Hide file tree
Showing 9 changed files with 720 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ on:
push:
branches: [master]
schedule:
- cron: '0 0-12/8 * * *' # every 8 hours
- cron: '0 6-23/8 * * *' # every 8 hours UTC time zone (?)
release:
types: [published]
workflow_dispatch:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
.Rhistory
.RData
.Ruserdata

/.quarto/
_site
5 changes: 5 additions & 0 deletions _quarto.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
project:
type: website
pre-render:
- scripts/qfieldCloud.R
- scripts/calcoliTrappole.R

website:
title: "vespaPiemonte"
navbar:
left:
- href: index.qmd
text: Home
- href: trapSettori.qmd
text: Scadenze settori
- about.qmd

format:
Expand Down
93 changes: 30 additions & 63 deletions index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -18,75 +18,42 @@ Questo è un sito web Quarto.

To learn more about Quarto websites visit <https://quarto.org/docs/websites>.

```{r}
1 + 1
```


:::callout-important
Please switch `{{shinylive-r}}` to `{shinylive-r}`. We've suppressed this example from running by using `{{}}`.
:::

```{shinylive-r}
#| standalone: true
<!-- ```{r, include=FALSE} -->
<!-- # Importazione dal cloud -->
<!-- source("scripts/qfieldCloud.R", local = knitr::knit_global()) -->
<!-- # Manipolazione dei dati -->
<!-- source("scripts/calcoliTrappole.R") -->
<!-- ``` -->

# Packages ----
library(shiny) # Required to run any Shiny app


# ui.R ----
ui <-
fluidPage(
# Paragraph "Hello world"
p("Hello world"),
# Create button to print "Hello world" from server
actionButton(inputId = "Print_Hello", label = "Print_Hello World"),
# Create position for server side text
textOutput("Server_Hello")
)
server <- function(input, output) {
# Create action when actionButton is clicked
observeEvent(input$Print_Hello,{
# Change text of Server_Hello
output$Server_Hello = renderText("Hello world from server side")
})
}
shinyApp(ui, server)
```

Full Skeletal Document Source:

````md
---
title: "Template for r-shinylive Quarto document"
format:
html:
resources:
- shinylive-sw.js
filters:
- shinylive
---

```{shinylive-r}
#| standalone: true
:::callout-important
Please switch `{{shinylive-r}}` to `{shinylive-r}`. We've suppressed this example from running by using `{{}}`.
:::

ui <- ...

server <- function(input, output, session) {
...
}

shinyApp(ui, server)
```{r, include=FALSE}
library(ggplot2)
ggplot(modaEtaBirra, x = etaBirra, y = zone, fill = zone) +
geom_linerange(aes(y=zone, xmin = minControllo, xmax = maxControllo), color = "orange",size = 3*modaEtaBirra$nTrappole/max(modaEtaBirra$nTrappole)) +
scale_y_discrete(labels= paste0(modaEtaBirra$zone, " (", modaEtaBirra$nTrappoleMin, "/", modaEtaBirra$nTrappole, ")")) +
geom_point(aes(x = modaEtaBirra$minimControllo, y = modaEtaBirra$zone, size = 1, color = "orange")) +
geom_vline(xintercept=Sys.Date(), linetype = "dashed", color = "red") +
geom_text(x = Sys.Date(), y = Inf, label = "Oggi", vjust = 1, hjust = 1, color = "black") +
{if(!is.na(data_prevista))geom_vline(xintercept=c(data_prevista), linetype = "dashed", color = c("blue"))} +
{if(!is.na(data_prevista))geom_text(x = data_prevista, y = Inf, label = format(data_prevista, "%d/%m"), vjust = 1, hjust = 0, color = "blue")} +
# geom_text(x = data_prevista, y = Inf, label = format(data_prevista, "%d/%m"), vjust = 1, hjust = 1, color = "blue")
# } +
theme_minimal() +
theme(axis.text.y = element_text(angle = 0, hjust = 1)) +
coord_cartesian(xlim = c(min(modaEtaBirra$minControllo), Sys.Date() + 30)) +
labs(title = "Finestra di sostituzione della birra per zona",
x = "Tempo",
y = "Zone",
fill = "Zona") +
scale_fill_brewer(palette = "Set1") +
theme(legend.position = "none")
```
````
Binary file added latestData/Vespa_velutina.gpkg
Binary file not shown.
Loading

0 comments on commit 5283fb9

Please sign in to comment.