Bearloga has uploaded a new change for review.
https://gerrit.wikimedia.org/r/271816
Change subject: Add smoothing and sharing options
......................................................................
Add smoothing and sharing options
- Weekly and monthly medians smoothing like the other Discovery
Dashboards have.
- Adds embedding parameters in URL for easier sharing, especially
for browser breakdown tab.
- Known conflict with sending people to a specific tab via the
hash in the URL. That is, you can send someone to a specific
tab OR embed the settings/selections in the URL, but not both.
Bug: T127507
Change-Id: Ic035973bcff582cbe32e73b67b863f58141c9936
---
M server.R
M ui.R
2 files changed, 36 insertions(+), 15 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/wikimedia/discovery/prince
refs/changes/16/271816/1
diff --git a/server.R b/server.R
index 1771e0a..436cbd5 100644
--- a/server.R
+++ b/server.R
@@ -3,7 +3,7 @@
existing_date <- Sys.Date() - 1
-shinyServer(function(input, output){
+shinyServer(function(input, output, session){
if(Sys.Date() != existing_date) {
read_clickthrough()
@@ -14,8 +14,11 @@
existing_date <<- Sys.Date()
}
+ shinyURL.server(session)
+
output$clickthrough_rate_dygraph <- renderDygraph({
clickthrough_rate %>%
+ polloi::smoother(smooth_level =
polloi::smooth_switch(input$smoothing_global,
input$smoothing_clickthrough_rate)) %>%
polloi::make_dygraph(xlab = "Date", ylab = "Clickthrough rate (%)",
title = "Wikipedia portal clickthrough rate") %>%
dyCSS(css = "www/inverse.css") %>%
dyAxis("x", axisLabelFormatter = polloi::custom_axis_formatter,
axisLabelWidth = 70) %>%
@@ -25,9 +28,9 @@
})
output$action_breakdown_dygraph <- renderDygraph({
- polloi::make_dygraph(
- data = action_breakdown,
- xlab = "Date", ylab = "Actions (%)", title = "Actions on the Wikipedia
portal") %>%
+ action_breakdown %>%
+ polloi::smoother(smooth_level =
polloi::smooth_switch(input$smoothing_global,
input$smoothing_action_breakdown)) %>%
+ polloi::make_dygraph(xlab = "Date", ylab = "Actions (%)", title =
"Actions on the Wikipedia portal") %>%
dyCSS(css = "www/inverse.css") %>%
dyAxis("x", axisLabelFormatter = polloi::custom_axis_formatter,
axisLabelWidth = 70) %>%
dyLegend(labelsDiv = "action_breakdown_legend", show = "always", width =
400) %>%
@@ -37,9 +40,9 @@
})
output$dwelltime_dygraph <- renderDygraph({
- polloi::make_dygraph(
- data = dwelltime_data,
- xlab = "Date", ylab = "Dwell Time (Seconds)", title = "Time spent on the
Wikipedia portal") %>%
+ dwelltime_data %>%
+ polloi::smoother(smooth_level =
polloi::smooth_switch(input$smoothing_global, input$smoothing_dwelltime)) %>%
+ polloi::make_dygraph(xlab = "Date", ylab = "Dwell Time (Seconds)", title
= "Time spent on the Wikipedia portal") %>%
dyCSS(css = "www/inverse.css") %>%
dyAxis("x", axisLabelFormatter = polloi::custom_axis_formatter,
axisLabelWidth = 70) %>%
dyAnnotation(as.Date("2015-12-07"), text = "A",
@@ -49,6 +52,7 @@
output$country_breakdown_dygraph <- renderDygraph({
country_data %>%
+ polloi::smoother(smooth_level =
polloi::smooth_switch(input$smoothing_global,
input$smoothing_country_breakdown)) %>%
polloi::make_dygraph(xlab = "", ylab = "Users (%)", title = "Geographic
breakdown of portal visitors") %>%
dyCSS(css = "www/inverse.css") %>%
dyAxis("x", axisLabelFormatter = polloi::custom_axis_formatter,
axisLabelWidth = 70) %>%
@@ -95,6 +99,7 @@
output$browser_breakdown_dygraph <- renderDygraph({
ua_data[ua_data$browser %in% input$browser_selector, , ] %>%
reshape2::dcast(date ~ browser, fun.aggregate = sum) %>%
+ polloi::smoother(smooth_level =
polloi::smooth_switch(input$smoothing_global,
input$smoothing_browser_breakdown)) %>%
polloi::make_dygraph(xlab = "Date", ylab = "Share (%)", title = "Browser
breakdown of portal visitors") %>%
dyCSS(css = "www/inverse.css") %>%
dyLegend(labelsDiv = "browser_breakdown_legend", show = "always", width
= 400)
@@ -102,6 +107,7 @@
output$pageview_dygraph <- renderDygraph({
pageview_data %>%
+ polloi::smoother(smooth_level =
polloi::smooth_switch(input$smoothing_global, input$smoothing_pageviews)) %>%
polloi::make_dygraph(xlab = "Date", ylab = "Pageviews", title =
"Pageviews to the Wikipedia Portal") %>%
dyCSS(css = "www/inverse.css") %>%
dyAxis("x", axisLabelFormatter = polloi::custom_axis_formatter,
axisLabelWidth = 70)
diff --git a/ui.R b/ui.R
index fba5e1a..da8bbef 100644
--- a/ui.R
+++ b/ui.R
@@ -1,8 +1,8 @@
library(shiny)
library(shinydashboard)
library(dygraphs)
+library(shinyURL)
options(scipen = 500)
-source("functions.R")
#Header elements for the visualisation
header <- dashboardHeader(title = "Wikipedia Portal Traffic", disable = FALSE)
@@ -12,32 +12,45 @@
tags$link(rel = "stylesheet", type = "text/css", href = "stylesheet.css"),
tags$script(src = "custom.js")
),
- sidebarMenu(menuItem(text = "Clickthrough rate", tabName =
"clickthrough_rate"),
- menuItem(text = "Action breakdown", tabName =
"action_breakdown"),
- menuItem(text = "Dwell time", tabName = "dwell_data"),
- menuItem(text = "Geographic breakdown", tabName =
"country_breakdown"),
- menuItem(text = "Browser breakdown", tabName =
"browser_breakdown", badgeColor = "light-blue", badgeLabel = "New!"),
- menuItem(text = "Pageviews", tabName = "pageview_tab",
badgeColor = "light-blue", badgeLabel = "New!")
+ sidebarMenu(menuItem("Traffic",
+ menuSubItem(text = "Clickthrough rate", tabName =
"clickthrough_rate"),
+ menuSubItem(text = "Action breakdown", tabName =
"action_breakdown"),
+ menuSubItem(text = "Dwell time", tabName =
"dwell_data"),
+ menuSubItem(text = "Geographic breakdown", tabName =
"country_breakdown"),
+ menuSubItem(text = "Browser breakdown", tabName =
"browser_breakdown"),
+ menuSubItem(text = "Pageviews", tabName =
"pageview_tab"),
+ icon = icon("line-chart")),
+ menuItem(text = "Global Settings",
+ selectInput(inputId = "smoothing_global", label =
"Smoothing", selectize = TRUE, selected = "day",
+ choices = c("No Smoothing" = "day", "Weekly
Median" = "week", "Monthly Median" = "month")),
+ br(style = "line-height:25%;"), icon = icon("cog", lib
= "glyphicon")),
+ menuItem(text = "Sharing Options", shinyURL.ui(tinyURL = FALSE),
+ p("Dashboard settings stored in URL.", style =
"padding-bottom: 10px;"),
+ icon = icon("share-alt", lib = "glyphicon"))
)
)
body <- dashboardBody(
tabItems(
tabItem(tabName = "clickthrough_rate",
+ polloi::smooth_select("smoothing_clickthrough_rate"),
dygraphOutput("clickthrough_rate_dygraph"),
includeMarkdown("./tab_documentation/clickthrough_rate.md")
),
tabItem(tabName = "action_breakdown",
+ polloi::smooth_select("smoothing_action_breakdown"),
div(dygraphOutput("action_breakdown_dygraph"),
div(id = "action_breakdown_legend",
style = "height: 60px; padding-top: 30px; padding-left:
20px;")),
includeMarkdown("./tab_documentation/breakdown.md")
),
tabItem(tabName = "dwell_data",
+ polloi::smooth_select("smoothing_dwelltime"),
dygraphOutput("dwelltime_dygraph"),
includeMarkdown("./tab_documentation/dwelltime.md")
),
tabItem(tabName = "country_breakdown",
+ polloi::smooth_select("smoothing_country_breakdown"),
div(dygraphOutput("country_breakdown_dygraph"),
div(id = "country_breakdown_legend",
style = "height: 60px; padding-top: 30px; padding-left:
20px;"),
@@ -55,7 +68,8 @@
helpText("Case insensitive & accepts
comma-separated input."),
uiOutput("browser_selector_container"),
width = 3),
- column(div(dygraphOutput("browser_breakdown_dygraph"),
+
column(div(polloi::smooth_select("smoothing_browser_breakdown"),
+ dygraphOutput("browser_breakdown_dygraph"),
div(id = "browser_breakdown_legend",
style = "height: 60px; padding-top: 30px;
padding-left: 20px;"),
style = "width: 100%; background-color:
#222D32; color: #ECF0F5; padding-top: 10px;"),
@@ -63,6 +77,7 @@
includeMarkdown("./tab_documentation/browsers.md")
),
tabItem(tabName = "pageview_tab",
+ polloi::smooth_select("smoothing_pageviews"),
dygraphOutput("pageview_dygraph"),
includeMarkdown("./tab_documentation/pageviews.md")
)
--
To view, visit https://gerrit.wikimedia.org/r/271816
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic035973bcff582cbe32e73b67b863f58141c9936
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/discovery/prince
Gerrit-Branch: master
Gerrit-Owner: Bearloga <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits