Last active
August 3, 2016 15:59
-
-
Save charliejhadley/bea1b693fb88ce79677833a1ea82b793 to your computer and use it in GitHub Desktop.
Weird Plotly when deployed to Shiny
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Type.of.policy | Name.Policy | Valid.from..b. | Valid.until..c... | ||
---|---|---|---|---|---|
1 | Leave policy | Maternity leave | 1994-06-10 | 1994-10-18 | |
2 | Leave policy | Maternity leave | 1994-10-19 | 1999-12-14 | |
3 | Leave policy | Maternity leave | 1999-12-15 | 2002-11-23 | |
4 | Leave policy | Maternity leave | 2002-11-24 | 2006-09-30 | |
5 | Leave policy | Maternity leave | 2006-10-01 | 2016-08-03 | |
6 | Leave policy | Maternity leave | 2014-12-01 | 2016-08-03 | |
7 | Leave policy | Parental leave | 1999-12-15 | 2002-01-09 | |
8 | Leave policy | Parental leave | 2002-01-10 | 2013-03-07 | |
9 | Leave policy | Parental leave | 2013-03-08 | 2015-04-04 | |
10 | Leave policy | Parental leave | 2015-04-05 | 2016-08-03 | |
11 | Leave policy | paternity Leave: birth and adoption | 2002-12-08 | 2010-04-05 | |
12 | Leave policy | paternity Leave: birth and adoption | 2010-04-06 | 2015-04-04 | |
13 | Leave policy | paternity Leave: birth and adoption | 2015-04-05 | 2016-08-03 | |
14 | Leave policy | paternity Leave: birth and adoption | 2014-12-01 | 2016-08-03 | |
15 | Leave policy | Adoption leave | 2002-12-08 | 2006-09-30 | |
16 | Leave policy | Adoption leave | 2006-10-01 | 2016-08-03 | |
17 | Leave policy | Adoption leave | 2014-12-01 | 2016-08-03 | |
18 | Leave policy | Maternity allowance | 1994-06-11 | 2000-04-01 | |
19 | Leave policy | Maternity allowance | 2000-04-02 | 2003-04-05 | |
20 | Leave policy | Maternity allowance | 2003-04-06 | 2006-09-30 | |
21 | Leave policy | Maternity allowance | 2006-10-01 | 2014-03-31 | |
22 | Leave policy | Maternity allowance | 2014-04-01 | 2016-08-03 | |
23 | Leave policy | Maternity allowance | 2014-12-01 | 2016-08-03 | |
24 | Leave policy | Statutory Maternity Pay (SMP) | 1994-06-11 | 2003-04-05 | |
25 | Leave policy | Statutory Maternity Pay (SMP) | 2003-04-06 | 2006-09-30 | |
26 | Leave policy | Statutory Maternity Pay (SMP) | 2006-10-01 | 2016-08-03 | |
27 | Leave policy | Statutory Maternity Pay (SMP) | 2014-12-01 | 2016-08-03 | |
28 | Leave policy | Statutory Paternity Pay: birth and adoption | 2002-12-08 | 2010-04-05 | |
29 | Leave policy | Statutory Paternity Pay: birth and adoption | 2010-04-06 | 2015-04-04 | |
30 | Leave policy | Statutory Paternity Pay: birth and adoption | 2015-04-05 | 2016-08-03 | |
31 | Leave policy | Statutory Paternity Pay: birth and adoption | 2014-12-01 | 2016-08-03 | |
32 | Leave policy | Statutory Adoption pay | 2002-12-08 | 2015-09-30 | |
33 | Leave policy | Statutory Adoption pay | 2006-10-01 | 2015-04-04 | |
34 | Leave policy | Statutory Adoption pay | 2015-04-05 | 2016-08-03 | |
35 | Leave policy | Statutory Adoption pay | 2014-12-01 | 2016-08-03 | |
36 | Pretend Policy | Pretend Policy | 2014-12-01 | 2016-08-03 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "Foo" | |
output: html_document | |
--- | |
```{r setup, include=FALSE} | |
knitr::opts_chunk$set(echo = TRUE) | |
``` | |
## R Markdown | |
```{r} | |
timeline_data <- read.csv("https://gist.githubusercontent.com/martinjhnhadley/2cd4bb8ded9d69e32311fd26be9290b7/raw/3ba100dc0415c8e9222e1901a68cf0e8e164f329/dump.csv", stringsAsFactors = F) | |
timeline_data$Valid.from..b. <- as.Date(timeline_data$Valid.from..b.) | |
timeline_data$Valid.until..c... <- as.Date(timeline_data$Valid.until..c...) | |
``` | |
```{r} | |
library(ggplot2) | |
library(plotly) | |
ggplotly(ggplot( | |
timeline_data, | |
aes( | |
x = Valid.from..b., | |
xend = Valid.until..c..., | |
y = Name.Policy, | |
yend = Name.Policy, | |
colour = Type.of.policy | |
) | |
) + | |
geom_segment(size = 4) + | |
geom_segment( | |
aes( | |
x = Valid.from..b. - 25, | |
xend = Valid.from..b., | |
y = Name.Policy, | |
yend = Name.Policy | |
), | |
colour = "black", | |
size = 4, | |
arrow=arrow(type = "closed") | |
) + | |
xlab("Date") + ylab(""), tooltip = "text") | |
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
library(plotly) | |
timeline_data <- read.csv("https://gist.githubusercontent.com/martinjhnhadley/2cd4bb8ded9d69e32311fd26be9290b7/raw/3ba100dc0415c8e9222e1901a68cf0e8e164f329/dump.csv", stringsAsFactors = F) | |
timeline_data$Valid.from..b. <- as.Date(timeline_data$Valid.from..b.) | |
timeline_data$Valid.until..c... <- as.Date(timeline_data$Valid.until..c...) | |
shinyServer( | |
function(input, output){ | |
output$timeline <- renderPlotly({ | |
ggplotly(ggplot( | |
timeline_data, | |
aes( | |
x = Valid.from..b., | |
xend = Valid.until..c..., | |
y = Name.Policy, | |
yend = Name.Policy, | |
colour = Type.of.policy | |
) | |
) + | |
geom_segment(size = 4) + | |
geom_segment( | |
aes( | |
x = Valid.from..b. - 25, | |
xend = Valid.from..b., | |
y = Name.Policy, | |
yend = Name.Policy | |
), | |
colour = "black", | |
size = 4, | |
arrow=arrow(type = "closed") | |
) + | |
xlab("Date") + ylab(""), tooltip = "text") | |
}) | |
} | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
library(plotly) | |
shinyUI( | |
fluidPage( | |
wellPanel("some stuff"), | |
plotlyOutput("timeline") | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment