Bearloga has submitted this change and it was merged.

Change subject: Update annotations format & add range selector
......................................................................


Update annotations format & add range selector

Change-Id: I3aeb331138078a5679f108ccb53fa626cd8bb0bf
---
M server.R
1 file changed, 58 insertions(+), 25 deletions(-)

Approvals:
  Bearloga: Verified; Looks good to me, approved



diff --git a/server.R b/server.R
index c493c36..eabd925 100644
--- a/server.R
+++ b/server.R
@@ -1,3 +1,7 @@
+library(shiny)
+library(shinydashboard)
+library(dygraphs)
+
 source("utils.R")
 
 existing_date <- Sys.Date() - 1
@@ -54,7 +58,8 @@
       polloi::smoother(smooth_level = 
polloi::smooth_switch(input$smoothing_global, input$smoothing_desktop_event)) 
%>%
       
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") %>%
-      dygraphs::dyAnnotation(as.Date("2016-07-12"), "A", "Schema switch")
+      dyRangeSelector %>%
+      dyEvent(as.Date("2016-07-12"), "A (schema switch)", labelLoc = "bottom")
   })
 
   output$desktop_load_plot <- renderDygraph({
@@ -62,7 +67,8 @@
       polloi::smoother(smooth_level = 
polloi::smooth_switch(input$smoothing_global, input$smoothing_desktop_load)) %>%
       
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) %>%
-      dygraphs::dyAnnotation(as.Date("2016-07-12"), "A", "Schema switch")
+      dyRangeSelector %>%
+      dyEvent(as.Date("2016-07-12"), "A (schema switch)", labelLoc = "bottom")
   })
 
   ## Mobile value boxes
@@ -98,14 +104,16 @@
     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(input$mobile_event_timeframe, 
input$mobile_event_timeframe_daterange)) %>%
-      polloi::make_dygraph(xlab = "Date", ylab = "Events", title = "Mobile 
search events, by day")
+      polloi::make_dygraph(xlab = "Date", ylab = "Events", title = "Mobile 
search events, by day") %>%
+      dyRangeSelector
   })
 
   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(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)
+      polloi::make_dygraph(xlab = "Date", ylab = "Load time (ms)", title = 
"Mobile search events, by day", use_si = FALSE) %>%
+      dyRangeSelector
   })
 
   ## App value boxes
@@ -141,28 +149,32 @@
     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(input$app_event_timeframe, 
input$app_event_timeframe_daterange)) %>%
-      polloi::make_dygraph(xlab = "Date", ylab = "Events", title = "Android 
mobile app search events, by day")
+      polloi::make_dygraph(xlab = "Date", ylab = "Events", title = "Android 
mobile app search events, by day") %>%
+      dyRangeSelector
   })
 
   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(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)
+      polloi::make_dygraph(xlab = "Date", ylab = "Load time (ms)", title = 
"Android result load times, by day", use_si = FALSE) %>%
+      dyRangeSelector
   })
 
   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(input$app_event_timeframe, 
input$app_event_timeframe_daterange)) %>%
-      polloi::make_dygraph(xlab = "Date", ylab = "Events", title = "iOS mobile 
app search events, by day")
+      polloi::make_dygraph(xlab = "Date", ylab = "Events", title = "iOS mobile 
app search events, by day") %>%
+      dyRangeSelector
   })
 
   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(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)
+      polloi::make_dygraph(xlab = "Date", ylab = "Load time (ms)", title = 
"iOS result load times, by day", use_si = FALSE) %>%
+      dyRangeSelector
   })
 
   ## API plots
@@ -170,35 +182,40 @@
     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(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")
+      polloi::make_dygraph(xlab = "Date", ylab = "Searches", title = 
"Full-text via API usage by day", legend_name = "Searches") %>%
+      dyRangeSelector
   })
 
   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(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")
+      polloi::make_dygraph(xlab = "Date", ylab = "Searches", title = 
"OpenSearch API usage by day", legend_name = "Searches") %>%
+      dyRangeSelector
   })
 
   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(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")
+      polloi::make_dygraph(xlab = "Date", ylab = "Searches", title = "Geo 
Search API usage by day", legend_name = "Searches") %>%
+      dyRangeSelector
   })
 
   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(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")
+      polloi::make_dygraph(xlab = "Date", ylab = "Searches", title = "Language 
Search API usage by day", legend_name = "Searches") %>%
+      dyRangeSelector
   })
 
   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(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")
+      polloi::make_dygraph(xlab = "Date", ylab = "Searches", title = "Prefix 
Search API usage by day", legend_name = "Searches") %>%
+      dyRangeSelector
   })
 
   # Failure plots
@@ -208,14 +225,18 @@
       
polloi::subset_by_date_range(time_frame_range(input$failure_rate_timeframe, 
input$failure_rate_timeframe_daterange)) %>%
       polloi::make_dygraph(xlab = "Date", ylab = "Zero Results Rate (%)", 
title = "Zero Results Rate, by day",
                            legend_name = "ZRR") %>%
-      dyAnnotation(as.Date("2016-02-01"), text = "A", tooltip = "Format 
Switch")
+      dyRangeSelector(fillColor = "") %>%
+      dyEvent(as.Date("2016-02-01"), "A (format switch)", labelLoc = "bottom") 
%>%
+      dyEvent(as.Date("2016-03-16"), "Completion Suggester Deployed", labelLoc 
= "bottom")
   })
 
   output$failure_rate_change_plot <- renderDygraph({
     polloi::data_select(input$failure_rate_automata, 
failure_roc_with_automata, failure_roc_no_automata) %>%
       polloi::smoother(smooth_level = 
polloi::smooth_switch(input$smoothing_global, input$smoothing_failure_rate)) %>%
       
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")
+      polloi::make_dygraph(xlab = "Date", ylab = "Change (%)", title = "Zero 
Results rate change, by day", legend_name = "Change") %>%
+      dyRangeSelector(fillColor = "", strokeColor = "") %>%
+      dyEvent(as.Date("2016-03-16"), "Completion Suggester Deployed", labelLoc 
= "bottom")
   })
 
   output$failure_breakdown_plot <- renderDygraph({
@@ -242,9 +263,10 @@
       dySeries(grep("More Like", colnames(xts_data), value = TRUE), color = 
"#984EA3") %>%
       dySeries(grep("Geospatial", colnames(xts_data), value = TRUE), color = 
"#A65628") %>%
       dySeries(grep("Regex", colnames(xts_data), value = TRUE), color = 
"#FF7f00") %>%
+      dyRangeSelector(fillColor = "") %>%
       # Remember to update the tab documentation with details about the 
annotations!
-      dyAnnotation(as.Date("2016-02-01"), text = "A", tooltip = "Format 
Switch",
-                   series = grep("Prefix", colnames(xts_data), value = 
TRUE)[1])
+      dyEvent(as.Date("2016-02-01"), "A (format switch)", labelLoc = "bottom") 
%>%
+      dyEvent(as.Date("2016-03-16"), "Completion Suggester Deployed", labelLoc 
= "bottom")
   })
 
   output$suggestion_dygraph_plot <- renderDygraph({
@@ -252,7 +274,9 @@
       polloi::smoother(smooth_level = 
polloi::smooth_switch(input$smoothing_global, 
input$smoothing_failure_suggestions)) %>%
       
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") %>%
-      dyAnnotation(as.Date("2016-02-01"), text = "A", tooltip = "Format 
Switch")
+      dyRangeSelector(fillColor = "") %>%
+      dyEvent(as.Date("2016-02-01"), "A (format switch)", labelLoc = "bottom") 
%>%
+      dyEvent(as.Date("2016-03-16"), "Completion Suggester Deployed", labelLoc 
= "bottom")
   })
 
   output$language_selector_container <- renderUI({
@@ -310,7 +334,8 @@
       
polloi::subset_by_date_range(time_frame_range(input$failure_langproj_timeframe, 
input$failure_langproj_timeframe_daterange)) %>%
       polloi::make_dygraph(xlab = "", ylab = "Zero Results Rate (%)", title = 
"Zero result rate by language and project") %>%
       dyLegend(show = "always", width = 400, labelsDiv = 
"failure_langproj_legend") %>%
-      dyAxis("x", axisLabelFormatter = polloi::custom_axis_formatter)
+      dyAxis("x", axisLabelFormatter = polloi::custom_axis_formatter) %>%
+      dyRangeSelector(fillColor = "")
   })
 
   # Survival
@@ -321,7 +346,8 @@
       polloi::make_dygraph(xlab = "", ylab = "Time (s)", title = "Time at 
which we have lost N% of the users") %>%
       dyAxis("x", ticker = "Dygraph.dateTicker", axisLabelFormatter = 
polloi::custom_axis_formatter,
              axisLabelWidth = 100, pixelsPerLabel = 80) %>%
-      dyLegend(labelsDiv = "lethal_dose_plot_legend")
+      dyLegend(labelsDiv = "lethal_dose_plot_legend") %>%
+      dyRangeSelector(fillColor = "", strokeColor = "")
   })
 
   ## KPI Summary Boxes
@@ -519,7 +545,8 @@
              dyOptions(strokeWidth = 2, colors = RColorBrewer::brewer.pal(5, 
"Set2")[5:1],
                        drawPoints = FALSE, pointSize = 3, labelsKMB = TRUE,
                        includeZero = TRUE) %>%
-             dyCSS(css = system.file("custom.css", package = "polloi")))
+             dyCSS(css = system.file("custom.css", package = "polloi")) %>%
+             dyRangeSelector)
   })
   output$kpi_zero_results_series <- renderDygraph({
     smooth_level <- input$smoothing_kpi_zero_results
@@ -550,7 +577,9 @@
                        drawPoints = FALSE, pointSize = 3, labelsKMB = TRUE,
                        includeZero = TRUE) %>%
              dyCSS(css = system.file("custom.css", package = "polloi")) %>%
-             dyAnnotation(as.Date("2016-02-01"), text = "A", tooltip = "Format 
Switch"))
+             dyRangeSelector(fillColor = "") %>%
+             dyEvent(as.Date("2016-02-01"), "A (format switch)", labelLoc = 
"bottom") %>%
+             dyEvent(as.Date("2016-03-16"), "Completion Suggester Deployed", 
labelLoc = "bottom"))
   })
   output$kpi_api_usage_series <- renderDygraph({
     smooth_level <- input$smoothing_kpi_api_usage
@@ -580,7 +609,8 @@
                          includeZero = input$kpi_api_usage_series_log_scale,
                          logscale = input$kpi_api_usage_series_log_scale
                ) %>%
-               dyCSS(css = system.file("custom.css", package = "polloi")))
+               dyCSS(css = system.file("custom.css", package = "polloi")) %>%
+               dyRangeSelector)
     }
     api_usage_change <- transform(api_usage,
                                   cirrus = polloi::percent_change(cirrus),
@@ -600,7 +630,8 @@
              dyOptions(strokeWidth = 3, colors = RColorBrewer::brewer.pal(6, 
"Set2"),
                        drawPoints = FALSE, pointSize = 3, labelsKMB = TRUE,
                        includeZero = TRUE) %>%
-             dyCSS(css = system.file("custom.css", package = "polloi")))
+             dyCSS(css = system.file("custom.css", package = "polloi")) %>%
+             dyRangeSelector)
   })
   output$kpi_augmented_clickthroughs_series <- renderDygraph({
     start_date <- Sys.Date() - switch(input$kpi_summary_date_range_selector, 
daily = 1, weekly = 8, monthly = 31, quarterly = 91)
@@ -610,7 +641,9 @@
     polloi::make_dygraph(data = smoothed_data, xlab = "Date", ylab = "Rates", 
"User engagement (augmented clickthroughs) by day") %>%
       dySeries(name = colnames(smoothed_data)[2], strokeWidth = 1.5, 
strokePattern = "dashed") %>%
       dySeries(name = colnames(smoothed_data)[3], strokeWidth = 1.5, 
strokePattern = "dashed") %>%
-      dyLegend(labelsDiv = "kpi_augmented_clickthroughs_series_legend")
+      dyLegend(labelsDiv = "kpi_augmented_clickthroughs_series_legend") %>%
+      dyRangeSelector(fillColor = "", strokeColor = "") %>%
+      dyEvent(as.Date("2016-03-16"), "Completion Suggester Deployed", labelLoc 
= "bottom")
   })
 
   # Check datasets for missing data and notify user which datasets are missing 
data (if any)

-- 
To view, visit https://gerrit.wikimedia.org/r/303576
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I3aeb331138078a5679f108ccb53fa626cd8bb0bf
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/discovery/rainbow
Gerrit-Branch: master
Gerrit-Owner: Bearloga <mpo...@wikimedia.org>
Gerrit-Reviewer: Bearloga <mpo...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to