OliverKeyes has submitted this change and it was merged. Change subject: Move code out to polloi ......................................................................
Move code out to polloi Bug: T118214 Change-Id: Ifde9bed108422126752e298bd75c04b7630a565d --- M CHANGELOG.md M README.md M server.R M ui.R M utils.R 5 files changed, 80 insertions(+), 134 deletions(-) Approvals: OliverKeyes: Verified; Looks good to me, approved diff --git a/CHANGELOG.md b/CHANGELOG.md index 12412a7..efb55e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Change Log (Patch Notes) All notable changes to this project will be documented in this file. +## 2015/11/10 +- Updated the readme +- Moved certain code blocks to **polloi** for use in other dashboards + ## 2015/11/05 - Added time frame selection - Fixed KPI date range selection (more robust, correct) diff --git a/README.md b/README.md index 7a5ad1c..bf1bcb8 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Search Metrics Dashboard -This project is part of the [Discovery Dashboards](http://searchdata.wmflabs.org/) project. +This project is part of the [Discovery Dashboards](http://discovery.wmflabs.org/) project. ## Quick start @@ -8,7 +8,7 @@ ``` $ R -R> install.packages(c('reshape2', 'ggplot2', 'toOrdinal', 'devtools')) +R> install.packages(c('reshape2', 'ggplot2', 'toOrdinal', 'devtools', 'magrittr', 'xts')) R> devtools::install_git('https://gerrit.wikimedia.org/r/wikimedia/discovery/polloi') ``` diff --git a/server.R b/server.R index 287487c..c677041 100644 --- a/server.R +++ b/server.R @@ -1,4 +1,3 @@ -## Version 0.3.0 source("utils.R") existing_date <- Sys.Date() - 1 @@ -16,22 +15,9 @@ existing_date <<- Sys.Date() } - # This is used to subset for getting the bounds for polloi::subset_by_date_range(): - time_frame_range <- function(tf_selector) { - tf_setting <- input[[tf_selector]] - if ( tf_setting == 'global' ) { - if ( input$timeframe_global == 'custom' ) { - return(input$daterange_global) - } else { - tf_setting <- input$timeframe_global - } - } - return(switch(tf_setting, - all = c(as.Date("2015-04-14"), Sys.Date()-1), - week = c(Sys.Date()-8, Sys.Date()-1), - month = c(Sys.Date()-31, Sys.Date()-1), - quarter = c(Sys.Date()-91, Sys.Date()-1), - custom = input[[paste(tf_selector, "daterange", sep = "_")]])) + # Wrap time_frame_range to provide global settings + time_frame_range <- function(input_local_timeframe, input_local_daterange) { + return(polloi::time_frame_range(input_local_timeframe, input_local_daterange, input$timeframe_global, input$daterange_global)) } ## Desktop value boxes @@ -66,14 +52,14 @@ output$desktop_event_plot <- renderDygraph({ desktop_dygraph_set %>% polloi::smoother(smooth_level = polloi::smooth_switch(input$smoothing_global, input$smoothing_desktop_event)) %>% - polloi::subset_by_date_range(time_frame_range("desktop_event_timeframe")) %>% + polloi::subset_by_date_range(time_frame_range(input$desktop_event_timeframe, input$desktop_event_timeframe_daterange)) %>% polloi::make_dygraph(xlab = "Date", ylab = "Events", title = "Desktop search events, by day") }) output$desktop_load_plot <- renderDygraph({ desktop_load_data %>% polloi::smoother(smooth_level = polloi::smooth_switch(input$smoothing_global, input$smoothing_desktop_load)) %>% - polloi::subset_by_date_range(time_frame_range("desktop_load_timeframe")) %>% + polloi::subset_by_date_range(time_frame_range(input$desktop_load_timeframe, input$desktop_load_timeframe_daterange)) %>% polloi::make_dygraph(xlab = "Date", ylab = "Load time (ms)", title = "Desktop load times, by day", use_si = FALSE) }) @@ -109,14 +95,14 @@ output$mobile_event_plot <- renderDygraph({ mobile_dygraph_set %>% polloi::smoother(smooth_level = polloi::smooth_switch(input$smoothing_global, input$smoothing_mobile_event)) %>% - polloi::subset_by_date_range(time_frame_range("mobile_event_timeframe")) %>% + polloi::subset_by_date_range(time_frame_range(input$mobile_event_timeframe, input$mobile_event_timeframe_daterange)) %>% polloi::make_dygraph(xlab = "Date", ylab = "Events", title = "Mobile search events, by day") }) output$mobile_load_plot <- renderDygraph({ mobile_load_data %>% polloi::smoother(smooth_level = polloi::smooth_switch(input$smoothing_global, input$smoothing_mobile_load)) %>% - polloi::subset_by_date_range(time_frame_range("mobile_load_timeframe")) %>% + polloi::subset_by_date_range(time_frame_range(input$mobile_load_timeframe, input$mobile_load_timeframe_daterange)) %>% polloi::make_dygraph(xlab = "Date", ylab = "Load time (ms)", title = "Mobile search events, by day", use_si = FALSE) }) @@ -152,28 +138,28 @@ output$android_event_plot <- renderDygraph({ android_dygraph_set %>% polloi::smoother(smooth_level = polloi::smooth_switch(input$smoothing_global, input$smoothing_app_event)) %>% - polloi::subset_by_date_range(time_frame_range("app_event_timeframe")) %>% + polloi::subset_by_date_range(time_frame_range(input$app_event_timeframe, input$app_event_timeframe_daterange)) %>% polloi::make_dygraph(xlab = "Date", ylab = "Events", title = "Android mobile app search events, by day") }) output$android_load_plot <- renderDygraph({ android_load_data %>% polloi::smoother(smooth_level = polloi::smooth_switch(input$smoothing_global, input$smoothing_app_load)) %>% - polloi::subset_by_date_range(time_frame_range("app_load_timeframe")) %>% + polloi::subset_by_date_range(time_frame_range(input$app_load_timeframe, input$app_load_timeframe_daterange)) %>% polloi::make_dygraph(xlab = "Date", ylab = "Load time (ms)", title = "Android result load times, by day", use_si = FALSE) }) output$ios_event_plot <- renderDygraph({ ios_dygraph_set %>% polloi::smoother(smooth_level = polloi::smooth_switch(input$smoothing_global, input$smoothing_app_event)) %>% - polloi::subset_by_date_range(time_frame_range("app_event_timeframe")) %>% + polloi::subset_by_date_range(time_frame_range(input$app_event_timeframe, input$app_event_timeframe_daterange)) %>% polloi::make_dygraph(xlab = "Date", ylab = "Events", title = "iOS mobile app search events, by day") }) output$ios_load_plot <- renderDygraph({ ios_load_data %>% polloi::smoother(smooth_level = polloi::smooth_switch(input$smoothing_global, input$smoothing_app_load)) %>% - polloi::subset_by_date_range(time_frame_range("app_load_timeframe")) %>% + polloi::subset_by_date_range(time_frame_range(input$app_load_timeframe, input$app_load_timeframe_daterange)) %>% polloi::make_dygraph(xlab = "Date", ylab = "Load time (ms)", title = "iOS result load times, by day", use_si = FALSE) }) @@ -181,35 +167,35 @@ output$cirrus_aggregate <- renderDygraph({ split_dataset$cirrus[, c(1, 3)] %>% polloi::smoother(smooth_level = polloi::smooth_switch(input$smoothing_global, input$smoothing_fulltext_search)) %>% - polloi::subset_by_date_range(time_frame_range("fulltext_search_timeframe")) %>% + polloi::subset_by_date_range(time_frame_range(input$fulltext_search_timeframe, input$fulltext_search_timeframe_daterange)) %>% polloi::make_dygraph(xlab = "Date", ylab = "Searches", title = "Full-text via API usage by day", legend_name = "Searches") }) output$open_aggregate <- renderDygraph({ split_dataset$open[, c(1, 3)] %>% polloi::smoother(smooth_level = polloi::smooth_switch(input$smoothing_global, input$smoothing_open_search)) %>% - polloi::subset_by_date_range(time_frame_range("open_search_timeframe")) %>% + polloi::subset_by_date_range(time_frame_range(input$open_search_timeframe, input$open_search_timeframe_daterange)) %>% polloi::make_dygraph(xlab = "Date", ylab = "Searches", title = "OpenSearch API usage by day", legend_name = "Searches") }) output$geo_aggregate <- renderDygraph({ split_dataset$geo[, c(1, 3)] %>% polloi::smoother(smooth_level = polloi::smooth_switch(input$smoothing_global, input$smoothing_geo_search)) %>% - polloi::subset_by_date_range(time_frame_range("geo_search_timeframe")) %>% + polloi::subset_by_date_range(time_frame_range(input$geo_search_timeframe, input$geo_search_timeframe_daterange)) %>% polloi::make_dygraph(xlab = "Date", ylab = "Searches", title = "Geo Search API usage by day", legend_name = "Searches") }) output$language_aggregate <- renderDygraph({ split_dataset$language[, c(1, 3)] %>% polloi::smoother(smooth_level = polloi::smooth_switch(input$smoothing_global, input$smoothing_language_search)) %>% - polloi::subset_by_date_range(time_frame_range("language_search_timeframe")) %>% + polloi::subset_by_date_range(time_frame_range(input$language_search_timeframe, input$language_search_timeframe_daterange)) %>% polloi::make_dygraph(xlab = "Date", ylab = "Searches", title = "Language Search API usage by day", legend_name = "Searches") }) output$prefix_aggregate <- renderDygraph({ split_dataset$prefix[, c(1, 3)] %>% polloi::smoother(smooth_level = polloi::smooth_switch(input$smoothing_global, input$smoothing_prefix_search)) %>% - polloi::subset_by_date_range(time_frame_range("prefix_search_timeframe")) %>% + polloi::subset_by_date_range(time_frame_range(input$prefix_search_timeframe, input$prefix_search_timeframe_daterange)) %>% polloi::make_dygraph(xlab = "Date", ylab = "Searches", title = "Prefix Search API usage by day", legend_name = "Searches") }) @@ -217,37 +203,37 @@ output$failure_rate_plot <- renderDygraph({ failure_dygraph_set %>% polloi::smoother(smooth_level = polloi::smooth_switch(input$smoothing_global, input$smoothing_failure_rate)) %>% - polloi::subset_by_date_range(time_frame_range("failure_rate_timeframe")) %>% + polloi::subset_by_date_range(time_frame_range(input$failure_rate_timeframe, input$failure_rate_timeframe_daterange)) %>% polloi::make_dygraph(xlab = "Date", ylab = "Queries", title = "Search Queries with Zero Results, by day") }) output$failure_rate_change_plot <- renderDygraph({ failure_roc_dygraph_set[, c(1, 3)] %>% polloi::smoother(smooth_level = polloi::smooth_switch(input$smoothing_global, input$smoothing_failure_rate)) %>% - polloi::subset_by_date_range(time_frame_range("failure_rate_timeframe")) %>% + polloi::subset_by_date_range(time_frame_range(input$failure_rate_timeframe, input$failure_rate_timeframe_daterange)) %>% polloi::make_dygraph(xlab = "Date", ylab = "Change (%)", title = "Zero Results rate change, by day", legend_name = "Change") }) output$failure_breakdown_plot <- renderDygraph({ failure_breakdown_dygraph_set %>% polloi::smoother(smooth_level = polloi::smooth_switch(input$smoothing_global, input$smoothing_failure_breakdown)) %>% - polloi::subset_by_date_range(time_frame_range("failure_breakdown_timeframe")) %>% + polloi::subset_by_date_range(time_frame_range(input$failure_breakdown_timeframe, input$failure_breakdown_timeframe_daterange)) %>% polloi::make_dygraph(xlab = "Date", ylab = "Zero Results Rate (%)", title = "Zero result rate by search type") }) output$suggestion_dygraph_plot <- renderDygraph({ suggestion_dygraph_set %>% polloi::smoother(smooth_level = polloi::smooth_switch(input$smoothing_global, input$smoothing_failure_suggestions)) %>% - polloi::subset_by_date_range(time_frame_range("failure_suggestions_timeframe")) %>% + polloi::subset_by_date_range(time_frame_range(input$failure_suggestions_timeframe, input$failure_suggestions_timeframe_daterange)) %>% polloi::make_dygraph(xlab = "Date", ylab = "Zero Results Rate (%)", title = "Zero Result Rates with Search Suggestions") }) output$lethal_dose_plot <- renderDygraph({ user_page_visit_dataset %>% polloi::smoother(smooth_level = polloi::smooth_switch(input$smoothing_global, input$smoothing_lethal_dose_plot)) %>% - polloi::subset_by_date_range(time_frame_range("lethal_dose_timeframe")) %>% + polloi::subset_by_date_range(time_frame_range(input$lethal_dose_timeframe, input$lethal_dose_timeframe_daterange)) %>% polloi::make_dygraph(xlab = "", ylab = "Time (s)", title = "Time at which we have lost N% of the users") %>% - dyAxis("x", ticker = "Dygraph.dateTicker", axisLabelFormatter = CustomAxisFormatter, + dyAxis("x", ticker = "Dygraph.dateTicker", axisLabelFormatter = polloi::custom_axis_formatter, axisLabelWidth = 100, pixelsPerLabel = 80) %>% dyLegend(labelsDiv = "lethal_dose_plot_legend") }) @@ -309,11 +295,11 @@ lapply(polloi::subset_by_date_range, from = start_date(date_range), to = Sys.Date() - 1) %>% lapply(function(data_tail) return(data_tail$Median)) if ( date_range == "quarterly" ) { - y <- median(apply(do.call(cbind_fill, x), 1, median, na.rm = TRUE)) + y <- median(apply(do.call(polloi::cbind_fill, x), 1, median, na.rm = TRUE)) return(valueBox(subtitle = "Load time", value = sprintf("%.0fms", y), color = "orange")) } - missing_values <- any(is.na(do.call(cbind_fill, x))) - x %<>% do.call(cbind_fill, .) %>% apply(MARGIN = 1, FUN = median, na.rm = TRUE) + missing_values <- any(is.na(do.call(polloi::cbind_fill, x))) + x %<>% do.call(polloi::cbind_fill, .) %>% apply(MARGIN = 1, FUN = median, na.rm = TRUE) y1 <- median(polloi::half(x)); y2 <- median(polloi::half(x, FALSE)); z <- 100 * (y2 - y1) / y1 if (abs(z) > 0) { return(valueBox(subtitle = sprintf("Load time (%s%.1f%%)", ifelse(missing_values, "~", ""), z), diff --git a/ui.R b/ui.R index b770c1e..87afcce 100644 --- a/ui.R +++ b/ui.R @@ -1,29 +1,10 @@ library(shiny) library(shinydashboard) library(dygraphs) -options(scipen = 500) #Header elements for the visualisation header <- dashboardHeader(title = "Search Metrics", disable = FALSE) -# Standardised input selector for smoothing -smooth_select <- function(input_id, label = "Smoothing") { - return(selectInput(inputId = input_id, label = label, selectize = TRUE, - selected = "global", choices = c("Use Global Setting" = "global", - "No Smoothing" = "day", "Weekly Median" = "week", "Monthly Median" = "month"))) -} -# Standardized selectors for time frame -timeframe_select <- function(input_id, label = "Time Frame") { - return(selectInput(inputId = input_id, label = label, selectize = TRUE, selected = "global", - choices = c("Use Global Setting" = "global", "All available data" = "all", - "Last 7 days" = "week", "Last 30 days" = "month", - "Last 90 days" = "quarter", "Custom" = "custom"))) -} -timeframe_daterange <- function(select_input_id, label = "Custom Date Range") { - return(conditionalPanel(paste0("input.", select_input_id," == 'custom'"), - dateRangeInput(paste(select_input_id, "daterange", sep = "_"), label = label, - start = Sys.Date()-11, end = Sys.Date()-1, min = "2015-04-14"))) -} #Sidebar elements for the search visualisations. sidebar <- dashboardSidebar( @@ -90,13 +71,13 @@ includeMarkdown("./tab_documentation/kpis_summary.md")), tabItem(tabName = "kpi_load_time", fluidRow( - column(smooth_select("smoothing_kpi_load_time"), width = 4), + column(polloi::smooth_select("smoothing_kpi_load_time"), width = 4), column(div(id = "kpi_load_time_series_legend"), width = 8) ), dygraphOutput("kpi_load_time_series"), includeMarkdown("./tab_documentation/kpi_load_time.md")), tabItem(tabName = "kpi_zero_results", - smooth_select("smoothing_kpi_zero_results"), + polloi::smooth_select("smoothing_kpi_zero_results"), dygraphOutput("kpi_zero_results_series"), includeMarkdown("./tab_documentation/kpi_zero_results.md")), tabItem(tabName = "kpi_api_usage", @@ -114,12 +95,12 @@ label = "Include OpenSearch in total", value = TRUE), width = 3), - column(smooth_select("smoothing_kpi_api_usage"), width = 3)), + column(polloi::smooth_select("smoothing_kpi_api_usage"), width = 3)), dygraphOutput("kpi_api_usage_series"), includeMarkdown("./tab_documentation/kpi_api_usage.md")), tabItem(tabName = "kpi_augmented_clickthroughs", fluidRow( - column(smooth_select("smoothing_augmented_clickthroughs"), width = 4), + column(polloi::smooth_select("smoothing_augmented_clickthroughs"), width = 4), column(div(id = "kpi_augmented_clickthroughs_series_legend"), width = 8)), dygraphOutput("kpi_augmented_clickthroughs_series"), includeMarkdown("./tab_documentation/kpi_augmented_clickthroughs.md")), @@ -129,16 +110,16 @@ valueBoxOutput("desktop_event_resultsets"), valueBoxOutput("desktop_event_clickthroughs")), fluidRow( - column(smooth_select("smoothing_desktop_event"), width = 4), - column(timeframe_select("desktop_event_timeframe"), width = 4), - column(timeframe_daterange("desktop_event_timeframe"), width = 4)), + column(polloi::smooth_select("smoothing_desktop_event"), width = 4), + column(polloi::timeframe_select("desktop_event_timeframe"), width = 4), + column(polloi::timeframe_daterange("desktop_event_timeframe"), width = 4)), dygraphOutput("desktop_event_plot"), includeMarkdown("./tab_documentation/desktop_events.md")), tabItem(tabName = "desktop_load", fluidRow( - column(smooth_select("smoothing_desktop_load"), width = 4), - column(timeframe_select("desktop_load_timeframe"), width = 4), - column(timeframe_daterange("desktop_load_timeframe"), width = 4)), + column(polloi::smooth_select("smoothing_desktop_load"), width = 4), + column(polloi::timeframe_select("desktop_load_timeframe"), width = 4), + column(polloi::timeframe_daterange("desktop_load_timeframe"), width = 4)), dygraphOutput("desktop_load_plot"), includeMarkdown("./tab_documentation/desktop_load.md")), tabItem(tabName = "mobile_events", @@ -147,17 +128,17 @@ valueBoxOutput("mobile_event_resultsets"), valueBoxOutput("mobile_event_clickthroughs")), fluidRow( - column(smooth_select("smoothing_mobile_event"), width = 4), - column(timeframe_select("mobile_event_timeframe"), width = 4), - column(timeframe_daterange("mobile_event_timeframe"), width = 4)), + column(polloi::smooth_select("smoothing_mobile_event"), width = 4), + column(polloi::timeframe_select("mobile_event_timeframe"), width = 4), + column(polloi::timeframe_daterange("mobile_event_timeframe"), width = 4)), dygraphOutput("mobile_event_plot"), includeMarkdown("./tab_documentation/mobile_events.md") ), tabItem(tabName = "mobile_load", fluidRow( - column(smooth_select("smoothing_mobile_load"), width = 4), - column(timeframe_select("mobile_load_timeframe"), width = 4), - column(timeframe_daterange("mobile_load_timeframe"), width = 4)), + column(polloi::smooth_select("smoothing_mobile_load"), width = 4), + column(polloi::timeframe_select("mobile_load_timeframe"), width = 4), + column(polloi::timeframe_daterange("mobile_load_timeframe"), width = 4)), dygraphOutput("mobile_load_plot"), includeMarkdown("./tab_documentation/mobile_load.md") ), @@ -167,92 +148,92 @@ valueBoxOutput("app_event_resultsets"), valueBoxOutput("app_event_clickthroughs")), fluidRow( - column(smooth_select("smoothing_app_event"), width = 4), - column(timeframe_select("app_event_timeframe"), width = 4), - column(timeframe_daterange("app_event_timeframe"), width = 4)), + column(polloi::smooth_select("smoothing_app_event"), width = 4), + column(polloi::timeframe_select("app_event_timeframe"), width = 4), + column(polloi::timeframe_daterange("app_event_timeframe"), width = 4)), dygraphOutput("android_event_plot"), dygraphOutput("ios_event_plot"), includeMarkdown("./tab_documentation/app_events.md") ), tabItem(tabName = "app_load", fluidRow( - column(smooth_select("smoothing_app_load"), width = 4), - column(timeframe_select("app_load_timeframe"), width = 4), - column(timeframe_daterange("app_load_timeframe"), width = 4)), + column(polloi::smooth_select("smoothing_app_load"), width = 4), + column(polloi::timeframe_select("app_load_timeframe"), width = 4), + column(polloi::timeframe_daterange("app_load_timeframe"), width = 4)), dygraphOutput("android_load_plot"), dygraphOutput("ios_load_plot"), includeMarkdown("./tab_documentation/app_load.md") ), tabItem(tabName = "fulltext_search", fluidRow( - column(smooth_select("smoothing_fulltext_search"), width = 4), - column(timeframe_select("fulltext_search_timeframe"), width = 4), - column(timeframe_daterange("fulltext_search_timeframe"), width = 4)), + column(polloi::smooth_select("smoothing_fulltext_search"), width = 4), + column(polloi::timeframe_select("fulltext_search_timeframe"), width = 4), + column(polloi::timeframe_daterange("fulltext_search_timeframe"), width = 4)), dygraphOutput("cirrus_aggregate"), includeMarkdown("./tab_documentation/fulltext_basic.md") ), tabItem(tabName = "open_search", fluidRow( - column(smooth_select("smoothing_open_search"), width = 4), - column(timeframe_select("open_search_timeframe"), width = 4), - column(timeframe_daterange("open_search_timeframe"), width = 4)), + column(polloi::smooth_select("smoothing_open_search"), width = 4), + column(polloi::timeframe_select("open_search_timeframe"), width = 4), + column(polloi::timeframe_daterange("open_search_timeframe"), width = 4)), dygraphOutput("open_aggregate"), includeMarkdown("./tab_documentation/open_basic.md") ), tabItem(tabName = "geo_search", fluidRow( - column(smooth_select("smoothing_geo_search"), width = 4), - column(timeframe_select("geo_search_timeframe"), width = 4), - column(timeframe_daterange("geo_search_timeframe"), width = 4)), + column(polloi::smooth_select("smoothing_geo_search"), width = 4), + column(polloi::timeframe_select("geo_search_timeframe"), width = 4), + column(polloi::timeframe_daterange("geo_search_timeframe"), width = 4)), dygraphOutput("geo_aggregate"), includeMarkdown("./tab_documentation/geo_basic.md") ), tabItem(tabName = "prefix_search", fluidRow( - column(smooth_select("smoothing_prefix_search"), width = 4), - column(timeframe_select("prefix_search_timeframe"), width = 4), - column(timeframe_daterange("prefix_search_timeframe"), width = 4)), + column(polloi::smooth_select("smoothing_prefix_search"), width = 4), + column(polloi::timeframe_select("prefix_search_timeframe"), width = 4), + column(polloi::timeframe_daterange("prefix_search_timeframe"), width = 4)), dygraphOutput("prefix_aggregate"), includeMarkdown("./tab_documentation/prefix_basic.md") ), tabItem(tabName = "language_search", fluidRow( - column(smooth_select("smoothing_language_search"), width = 4), - column(timeframe_select("language_search_timeframe"), width = 4), - column(timeframe_daterange("language_search_timeframe"), width = 4)), + column(polloi::smooth_select("smoothing_language_search"), width = 4), + column(polloi::timeframe_select("language_search_timeframe"), width = 4), + column(polloi::timeframe_daterange("language_search_timeframe"), width = 4)), dygraphOutput("language_aggregate"), includeMarkdown("./tab_documentation/language_basic.md") ), tabItem(tabName = "failure_rate", fluidRow( - column(smooth_select("smoothing_failure_rate"), width = 4), - column(timeframe_select("failure_rate_timeframe"), width = 4), - column(timeframe_daterange("failure_rate_timeframe"), width = 4)), + column(polloi::smooth_select("smoothing_failure_rate"), width = 4), + column(polloi::timeframe_select("failure_rate_timeframe"), width = 4), + column(polloi::timeframe_daterange("failure_rate_timeframe"), width = 4)), dygraphOutput("failure_rate_plot"), dygraphOutput("failure_rate_change_plot"), includeMarkdown("./tab_documentation/failure_rate.md") ), tabItem(tabName = "failure_breakdown", fluidRow( - column(smooth_select("smoothing_failure_breakdown"), width = 4), - column(timeframe_select("failure_breakdown_timeframe"), width = 4), - column(timeframe_daterange("failure_breakdown_timeframe"), width = 4)), + column(polloi::smooth_select("smoothing_failure_breakdown"), width = 4), + column(polloi::timeframe_select("failure_breakdown_timeframe"), width = 4), + column(polloi::timeframe_daterange("failure_breakdown_timeframe"), width = 4)), dygraphOutput("failure_breakdown_plot"), includeMarkdown("./tab_documentation/failure_breakdown.md") ), tabItem(tabName = "failure_suggestions", fluidRow( - column(smooth_select("smoothing_failure_suggestions"), width = 4), - column(timeframe_select("failure_suggestions_timeframe"), width = 4), - column(timeframe_daterange("failure_suggestions_timeframe"), width = 4)), + column(polloi::smooth_select("smoothing_failure_suggestions"), width = 4), + column(polloi::timeframe_select("failure_suggestions_timeframe"), width = 4), + column(polloi::timeframe_daterange("failure_suggestions_timeframe"), width = 4)), dygraphOutput("suggestion_dygraph_plot"), includeMarkdown("./tab_documentation/failure_suggests.md") ), tabItem(tabName = "survival", fluidRow( - column(smooth_select("smoothing_lethal_dose_plot"), width = 4), - column(timeframe_select("lethal_dose_timeframe"), width = 4), - column(timeframe_daterange("lethal_dose_timeframe"), width = 4)), + column(polloi::smooth_select("smoothing_lethal_dose_plot"), width = 4), + column(polloi::timeframe_select("lethal_dose_timeframe"), width = 4), + column(polloi::timeframe_daterange("lethal_dose_timeframe"), width = 4)), div(id = "lethal_dose_plot_legend"), dygraphOutput("lethal_dose_plot"), includeMarkdown("./tab_documentation/survival.md") diff --git a/utils.R b/utils.R index 4393a69..5b63b90 100644 --- a/utils.R +++ b/utils.R @@ -132,28 +132,3 @@ start_date <- function(date_range) { return(Sys.Date() - (switch(date_range, daily = 2, weekly = 14, monthly = 60, quarterly = 90) + 1)) } - -# Usage: date_range %>% name(c('start', 'end')) -name <- function(x, labels) { - names(x) <- labels - return(x) -} - -# From: http://r.789695.n4.nabble.com/How-to-join-matrices-of-different-row-length-from-a-list-td3177212.html -cbind_fill <- function(...) { - nm <- lapply(list(...), as.matrix) - n <- max(sapply(nm, nrow)) - do.call(cbind, lapply(nm, function (x) rbind(x, matrix(, n-nrow(x), ncol(x))))) -} - -CustomAxisFormatter <- 'function (d, gran) { - var weekday = new Array(7); - weekday[0]= "Sunday"; - weekday[1] = "Monday"; - weekday[2] = "Tuesday"; - weekday[3] = "Wednesday"; - weekday[4] = "Thursday"; - weekday[5] = "Friday"; - weekday[6] = "Saturday"; - return weekday[d.getDay()] + " (" + (d.getMonth()+1) + "/" + d.getDate() + ")"; -}' -- To view, visit https://gerrit.wikimedia.org/r/252270 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ifde9bed108422126752e298bd75c04b7630a565d Gerrit-PatchSet: 2 Gerrit-Project: wikimedia/discovery/rainbow Gerrit-Branch: master Gerrit-Owner: Bearloga <[email protected]> Gerrit-Reviewer: OliverKeyes <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
