-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reactable example #107
base: main
Are you sure you want to change the base?
Reactable example #107
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,17 +35,17 @@ | |
"plotly_click-A", "plotly_hover-A", "plotly_afterplot-A", | ||
".clientValue-default-plotlyCrosstalkOpts" | ||
)) | ||
|
||
Check notice Code scanning / lintr Trailing whitespace is superfluous. Note
Trailing whitespace is superfluous.
|
||
observe({ | ||
# Trigger this observer every time an input changes | ||
reactiveValuesToList(input) | ||
session$doBookmark() | ||
}) | ||
|
||
Check notice Code scanning / lintr Trailing whitespace is superfluous. Note
Trailing whitespace is superfluous.
|
||
onBookmarked(function(url) { | ||
updateQueryString(url) | ||
}) | ||
|
||
Check notice Code scanning / lintr Trailing whitespace is superfluous. Note
Trailing whitespace is superfluous.
|
||
observe({ | ||
if (input$navlistPanel == "Example tab 1") { | ||
change_window_title( | ||
|
@@ -66,7 +66,7 @@ | |
) | ||
} | ||
}) | ||
|
||
Check notice Code scanning / lintr Trailing whitespace is superfluous. Note
Trailing whitespace is superfluous.
|
||
# Cookies logic ------------------------------------------------------------- | ||
observeEvent(input$cookies, { | ||
if (!is.null(input$cookies)) { | ||
|
@@ -92,7 +92,7 @@ | |
shinyjs::hide(id = "cookieMain") | ||
} | ||
}) | ||
|
||
Check notice Code scanning / lintr Trailing whitespace is superfluous. Note
Trailing whitespace is superfluous.
|
||
# Need these set of observeEvent to create a path through the cookie banner | ||
observeEvent(input$cookieAccept, { | ||
msg <- list( | ||
|
@@ -104,7 +104,7 @@ | |
shinyjs::show(id = "cookieAcceptDiv") | ||
shinyjs::hide(id = "cookieMain") | ||
}) | ||
|
||
Check notice Code scanning / lintr Trailing whitespace is superfluous. Note
Trailing whitespace is superfluous.
|
||
observeEvent(input$cookieReject, { | ||
msg <- list( | ||
name = "dfe_analytics", | ||
|
@@ -115,27 +115,27 @@ | |
shinyjs::show(id = "cookieRejectDiv") | ||
shinyjs::hide(id = "cookieMain") | ||
}) | ||
|
||
Check notice Code scanning / lintr Trailing whitespace is superfluous. Note
Trailing whitespace is superfluous.
|
||
observeEvent(input$hideAccept, { | ||
shinyjs::toggle(id = "cookieDiv") | ||
}) | ||
|
||
Check notice Code scanning / lintr Trailing whitespace is superfluous. Note
Trailing whitespace is superfluous.
|
||
observeEvent(input$hideReject, { | ||
shinyjs::toggle(id = "cookieDiv") | ||
}) | ||
|
||
Check notice Code scanning / lintr Trailing whitespace is superfluous. Note
Trailing whitespace is superfluous.
|
||
observeEvent(input$remove, { | ||
shinyjs::toggle(id = "cookieMain") | ||
msg <- list(name = "dfe_analytics", value = "denied") | ||
session$sendCustomMessage("cookie-remove", msg) | ||
session$sendCustomMessage("analytics-consent", msg) | ||
print(input$cookies) | ||
}) | ||
|
||
Check notice Code scanning / lintr Trailing whitespace is superfluous. Note
Trailing whitespace is superfluous.
|
||
cookies_data <- reactive({ | ||
input$cookies | ||
}) | ||
|
||
Check notice Code scanning / lintr Trailing whitespace is superfluous. Note
Trailing whitespace is superfluous.
|
||
output$cookie_status <- renderText({ | ||
cookie_text_stem <- "To better understand the reach of our dashboard tools, | ||
this site uses cookies to identify numbers of unique users as part of Google | ||
|
@@ -153,23 +153,23 @@ | |
"Cookies consent has not been confirmed." | ||
} | ||
}) | ||
|
||
Check notice Code scanning / lintr Trailing whitespace is superfluous. Note
Trailing whitespace is superfluous.
|
||
observeEvent(input$cookieLink, { | ||
# Need to link here to where further info is located. You can | ||
# updateTabsetPanel to have a cookie page for instance | ||
updateTabsetPanel(session, "navlistPanel", | ||
selected = "Support and feedback" | ||
selected = "Support and feedback" | ||
Check notice Code scanning / lintr Indentation should be 6 spaces but is 22 spaces. Note
Indentation should be 6 spaces but is 22 spaces.
|
||
) | ||
}) | ||
|
||
Check notice Code scanning / lintr Trailing whitespace is superfluous. Note
Trailing whitespace is superfluous.
|
||
# Dataset with timeseries data ---------------------------------------------- | ||
reactive_rev_bal <- reactive({ | ||
df_revbal %>% filter( | ||
area_name == input$selectArea | area_name == "England", | ||
school_phase == input$selectPhase | ||
) | ||
}) | ||
|
||
Check notice Code scanning / lintr Trailing whitespace is superfluous. Note
Trailing whitespace is superfluous.
|
||
# Dataset with benchmark data ----------------------------------------------- | ||
reactive_benchmark <- reactive({ | ||
df_revbal %>% | ||
|
@@ -179,7 +179,7 @@ | |
year == max(year) | ||
) | ||
}) | ||
|
||
Check notice Code scanning / lintr Trailing whitespace is superfluous. Note
Trailing whitespace is superfluous.
|
||
# Charts -------------------------------------------------------------------- | ||
# Line chart for revenue balance over time | ||
output$lineRevBal <- renderGirafe({ | ||
|
@@ -193,7 +193,7 @@ | |
height_svg = 5.0 | ||
) | ||
}) | ||
|
||
Check notice Code scanning / lintr Trailing whitespace is superfluous. Note
Trailing whitespace is superfluous.
|
||
# Benchmarking bar chart | ||
output$colBenchmark <- renderGirafe({ | ||
girafe( | ||
|
@@ -206,7 +206,7 @@ | |
height_svg = 5.0 | ||
) | ||
}) | ||
|
||
Check notice Code scanning / lintr Trailing whitespace is superfluous. Note
Trailing whitespace is superfluous.
|
||
# Benchmarking table | ||
output$tabBenchmark <- renderDataTable({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, let's just delete this, the idea is just to replace it with reactable There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. on it |
||
datatable( | ||
|
@@ -223,7 +223,36 @@ | |
) | ||
) | ||
}) | ||
|
||
Check notice Code scanning / lintr Trailing whitespace is superfluous. Note
Trailing whitespace is superfluous.
|
||
output$tabBenchmark2 <- renderReactable({ | ||
reactable( | ||
reactive_benchmark() %>% | ||
select( | ||
Area = area_name, | ||
`Average Revenue Balance (£)` = average_revenue_balance, | ||
`Total Revenue Balance (£m)` = total_revenue_balance_million | ||
), | ||
# defaultPageSizr and minRows needed for Pagination: example here | ||
# defaultPageSize = 4, | ||
Check notice Code scanning / lintr Commented code should be removed. Note
Commented code should be removed.
|
||
# minRows = 4, | ||
Check notice Code scanning / lintr Commented code should be removed. Note
Commented code should be removed.
|
||
# searchable = TRUE, # uncomment line if you want a search box | ||
# filterable = TRUE, # uncomment line if you want filters at the top | ||
# filters on individual columns also possible | ||
defaultSorted = list("Total Revenue Balance (£m)" = "desc"), | ||
defaultColDef = colDef( | ||
style = JS("function(rowInfo, column, state) { | ||
// Highlight sorted columns | ||
for (let i = 0; i < state.sorted.length; i++) { | ||
if (state.sorted[i].id === column.id) { | ||
return { background: 'rgba(0, 0, 0, 0.03)' } | ||
} | ||
} | ||
}") | ||
) | ||
) | ||
}) | ||
|
||
|
||
Check notice Code scanning / lintr Trailing whitespace is superfluous. Note
Trailing whitespace is superfluous.
|
||
# Value boxes --------------------------------------------------------------- | ||
# Create a reactive value for average revenue balance | ||
latest_average_balance <- reactive({ | ||
|
@@ -235,7 +264,7 @@ | |
) %>% | ||
pull(average_revenue_balance) | ||
}) | ||
|
||
Check notice Code scanning / lintr Trailing whitespace is superfluous. Note
Trailing whitespace is superfluous.
|
||
# Create a reactive value for previous year average | ||
previous_average_balance <- reactive({ | ||
previous_year <- reactive_rev_bal() %>% | ||
|
@@ -246,13 +275,13 @@ | |
) %>% | ||
pull(average_revenue_balance) | ||
}) | ||
|
||
Check notice Code scanning / lintr Trailing whitespace is superfluous. Note
Trailing whitespace is superfluous.
|
||
# Export values for use in UI tests ----------------------------------------- | ||
exportTestValues( | ||
avg_rev_bal_value = latest_average_balance(), | ||
prev_avg_rev_bal_value = previous_average_balance() | ||
) | ||
|
||
Check notice Code scanning / lintr Trailing whitespace is superfluous. Note
Trailing whitespace is superfluous.
|
||
# Create a value box for average revenue balance | ||
output$box_balance_latest <- renderValueBox({ | ||
value_box( | ||
|
@@ -261,7 +290,7 @@ | |
color = "blue" | ||
) | ||
}) | ||
|
||
Check notice Code scanning / lintr Trailing whitespace is superfluous. Note
Trailing whitespace is superfluous.
|
||
# Create a value box for the change on previous year | ||
output$box_balance_change <- renderValueBox({ | ||
value_box( | ||
|
@@ -274,27 +303,27 @@ | |
color = "blue" | ||
) | ||
}) | ||
|
||
Check notice Code scanning / lintr Trailing whitespace is superfluous. Note
Trailing whitespace is superfluous.
|
||
# Link in the user guide panel back to the main panel ----------------------- | ||
observeEvent(input$link_to_app_content_tab, { | ||
updateTabsetPanel(session, "navlistPanel", selected = "Example tab 1") | ||
}) | ||
|
||
Check notice Code scanning / lintr Trailing whitespace is superfluous. Note
Trailing whitespace is superfluous.
|
||
# Download the underlying data button -------------------------------------- | ||
output$download_data <- downloadHandler( | ||
filename = "shiny_template_underlying_data.csv", | ||
content = function(file) { | ||
write.csv(df_revbal, file) | ||
} | ||
) | ||
|
||
Check notice Code scanning / lintr Trailing whitespace is superfluous. Note
Trailing whitespace is superfluous.
|
||
# Dynamic label showing custom selections ----------------------------------- | ||
output$dropdown_label <- renderText({ | ||
paste0("Current selections: ", input$selectPhase, ", ", input$selectArea) | ||
}) | ||
|
||
Check notice Code scanning / lintr Trailing whitespace is superfluous. Note
Trailing whitespace is superfluous.
|
||
# Stop app ------------------------------------------------------------------ | ||
session$onSessionEnded(function() { | ||
stopApp() | ||
}) | ||
} | ||
} | ||
Check notice Code scanning / lintr Missing terminal newline. Note
Missing terminal newline.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think let's just remove the old reference to data table. We're moving towards reactable as we find it easier for to customise.