Skip to content

Commit

Permalink
about panel, slider tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Moore committed May 30, 2015
1 parent db4f803 commit 03402bb
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 29 deletions.
27 changes: 18 additions & 9 deletions server.R
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ colnames(clean) <- c("Severity", "No. vehicles",
"Light conditions", "Weather conditions", "Light conditions", "Weather conditions",
"Road conditions", "Special conditions", "Postcode") "Road conditions", "Special conditions", "Postcode")


map_choice <- function(inp){
switch(inp,
"Severity" = list(var="severity", type="factor"),
"Casualties" = list(var="no_casualt", type="int"),
"Time" = list(var="a_time_hr", type="int"),
"Vehicles" = list(var="no_vehicle", type="int"),
"Speed limit" = list(var="speed_limi", type="int"),
list(var="none", type="none"))
}

shinyServer(function(input, output, session) { shinyServer(function(input, output, session) {


getData <- reactive({ getData <- reactive({
Expand Down Expand Up @@ -89,13 +99,8 @@ shinyServer(function(input, output, session) {


updateRadioButtons(session, "color_mob", selected=input$color) updateRadioButtons(session, "color_mob", selected=input$color)


col <- switch(input$color, col <- map_choice(input$color)
"Severity" = list(var="severity", type="factor"), scale <- map_choice(input$scale)
"Casualties" = list(var="no_casualt", type="int"),
"Time" = list(var="a_time_hr", type="int"),
"Vehicles" = list(var="no_vehicle", type="int"),
"Speed limit" = list(var="speed_limi", type="int"),
list(var="none", type="none"))


pal <- c("#A52278", "#993086", "#8C3C97", pal <- c("#A52278", "#993086", "#8C3C97",
"#6D328A", "#4E2B81", "#3B264B", "#180B11", "#000000") "#6D328A", "#4E2B81", "#3B264B", "#180B11", "#000000")
Expand All @@ -118,15 +123,19 @@ shinyServer(function(input, output, session) {


if(col$var == "none"){ if(col$var == "none"){
l <- leafletProxy("mymap", session, data=ax) %>% l <- leafletProxy("mymap", session, data=ax) %>%
addCircleMarkers(~long, ~lat, radius=~1+(no_vehicle**1.5), fillOpacity=getAlpha(), addCircleMarkers(~long, ~lat,
radius=~input$base+(eval(parse(text=scale$var))**1.5),
fillOpacity=getAlpha(),
color=NA, popup=~text, fillColor = "black", color=NA, popup=~text, fillColor = "black",
layerId=paste0("p", 1:nrow(ax))) %>% layerId=paste0("p", 1:nrow(ax))) %>%
removeControl(layerId="legend") removeControl(layerId="legend")


} else { } else {


l <- leafletProxy("mymap", session, data=ax) %>% l <- leafletProxy("mymap", session, data=ax) %>%
addCircleMarkers(~long, ~lat, radius=~1+(no_vehicle**1.5), fillOpacity=getAlpha(), addCircleMarkers(~long, ~lat,
radius=~input$base+(eval(parse(text=scale$var))**1.5),
fillOpacity=getAlpha(),
color=NA, popup=~text, fillColor = ~col_fn(col)(ax[[col$var]]), color=NA, popup=~text, fillColor = ~col_fn(col)(ax[[col$var]]),
layerId=paste0("p", 1:nrow(ax))) %>% layerId=paste0("p", 1:nrow(ax))) %>%
addLegend("bottomleft", pal=col_fn(col), values=ax[[col$var]], addLegend("bottomleft", pal=col_fn(col), values=ax[[col$var]],
Expand Down
4 changes: 4 additions & 0 deletions styles.css
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -155,3 +155,7 @@ label.control-label[for=scale]{
.nav-tabs{ .nav-tabs{
margin-bottom: 5px; margin-bottom: 5px;
} }

p.intro{
margin-bottom: 15px;
}
56 changes: 38 additions & 18 deletions ui.R
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ $( 'div#mymap' ).append(spinner.el);"),
width = 360, height = "auto", width = 360, height = "auto",


h2(), h2(),
p(strong("Blackspot"), " shows vechicle collisions in", p(class="intro",
"the city of Edinburgh, UK. Data from:", strong("Blackspot"), " shows vechicle collisions in",
"the city of Edinburgh, UK. Data from",
a("Edinburgh Open Data.", a("Edinburgh Open Data.",
href="http://www.edinburghopendata.info/dataset/vehicle-collisions")), href="http://www.edinburghopendata.info/dataset/vehicle-collisions",
target="_blank")),


tabsetPanel( tabsetPanel(
tabPanel("Controls", tabPanel("Controls",
Expand All @@ -51,18 +53,19 @@ $( 'div#mymap' ).append(spinner.el);"),
), ),


column(6, column(6,
# div(style="display:inline-block; height: 150px;",
selectInput("scale", label="Scale by:", width=120, selectInput("scale", label="Scale by:", width=120,
choices=c("None", "Severity", "Casualties", "Time", selected="Vehicles",
"Vehicles", "Speed limit"))#) choices=c("Casualties", "Vehicles"))#)
) )
), ),


hr(), hr(class="thin"),
p("Under development by", p("Under development by",
a("@benjaminlmoore", href="http://twitter.com/benjaminlmoore"), a("@benjaminlmoore", href="http://twitter.com/benjaminlmoore",
target="_blank"),
HTML("&bull;"), "See the code on ", HTML("&bull;"), "See the code on ",
a("github", href="http://github.com/blmoore/blackspot"), a("github", href="http://github.com/blmoore/blackspot",
target="_blank"),
class="foot") class="foot")
), ),


Expand All @@ -71,15 +74,32 @@ $( 'div#mymap' ).append(spinner.el);"),
plotOutput("monthTotals", height = "120px") plotOutput("monthTotals", height = "120px")
), ),
tabPanel("About", tabPanel("About",

p("Explore vehicle collisions recorded in Edinburgh",
hr(class="thin"), "between 2010 and 2013 in this interactive data visualisation."
p("Under active development by ", ),
a("@benjaminlmoore", href="http://twitter.com/benjaminlmoore"), p("Blackspot is written in ",
HTML("&mdash;"), "code available on ", a("Shiny,", href="http://shiny.rstudio.com/", target="_blank"),
a("github", href="http://github.com/blmoore/blackspot"), "a web application framework for the R language.",
"(original Shiny code adapted from", "Maps are built with ",
a("Superzip", href="https://github.com/jcheng5/superzip"), a("leaflet.js", href="http://leafletjs.com/", target="_blank"),
"by Joe Cheng).", class="foot") "via the",
a("R language bindings,", href="https://rstudio.github.io/leaflet/",
target="_blank"),
"and using map data from",
a("Open Street Map.", href="http://www.openstreetmap.org/copyright",
target="_blank")
),
p("Project under development by ",
a("@benjaminlmoore", href="http://twitter.com/benjaminlmoore",
target="_blank"),
HTML("&mdash;"),
"see the full code on ",
a("github", href="http://github.com/blmoore/blackspot",
target="_blank"),
"or run locally with:"
),
pre("shiny::runGitHub('blmoore/blackspot')"),
hr(class="thin")
) )
# end about panel # end about panel
), ),
Expand Down
12 changes: 10 additions & 2 deletions www/ion.rangeSlider.skinFlat.css
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -60,17 +60,19 @@
width: 16px; height: 18px; width: 16px; height: 18px;
top: 22px; top: 22px;
background-position: 0 -120px; background-position: 0 -120px;
border: none;
box-shadow: none;
} }
.irs-slider.state_hover, .irs-slider:hover { .irs-slider.state_hover, .irs-slider:hover {
background-position: 0 -150px; background-position: 0 -150px;
} }


.irs-min, .irs-max { .irs-min, .irs-max {
color: #999; color: #999;
font-size: 10px; line-height: 1.333; font-size: 10px; line-height: 1.333;
text-shadow: none; text-shadow: none;
top: 0; padding: 1px 3px; top: 0; padding: 1px 3px;
background: #e1e4e9; /* background: #e1e4e9; */
-moz-border-radius: 4px; -moz-border-radius: 4px;
border-radius: 4px; border-radius: 4px;
} }
Expand Down Expand Up @@ -104,3 +106,9 @@


.irs-disabled { .irs-disabled {
} }


#irs-active-slider, .irs-slider:hover {
background: url(../img/sprite-skin-flat.png) repeat-x;
background-position: 0 -120px;
}

0 comments on commit 03402bb

Please sign in to comment.