-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathREADME.Rmd
83 lines (69 loc) · 1.68 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```
Unfinished `htmlwidget` wrapper for [`EventDrops`](https://github.com/marmelab/EventDrops)
### Example
```
# install from github
# devtools::install_github("timelyportfolio/eventdropR")
library(eventdropR)
# make some sample data
df <- data.frame(
# random times 30 days plus or minus current time
date = Sys.time() + runif(1000, -30, 30) * 24 * 60 * 60,
# make up five groups
group = paste0("grp_", LETTERS[runif(1000,1,5)]),
stringsAsFactors = FALSE
)
# defaults
# date argument not needed since the date is in column date
eventdrop(
df,
name = "group" #if df column named "name" would not need
)
# demonstrate how to set some options
eventdrop(
df,
name = "group",
labelsWidth = 150,
hasBottomAxis = TRUE,
mouseover = htmlwidgets::JS('function(d){console.log(d)}')
)
# demonstrate how to use with shiny and get events
# can easily build this into our htmlwidget
ed <- eventdrop(
df,
name = "group",
mouseover = htmlwidgets::JS(
'
function(d){
console.log(d);
if(typeof(Shiny)!=="undefined") {
Shiny.onInputChange("eventdrop_click", {data:d});
}
}
'
)
)
ed
# now integrate in simple shiny app
library(shiny)
shinyApp(
ui = ed,
server = function(input, output, session){
observeEvent(input$eventdrop_click,{
str(input$eventdrop_click)
})
}
)
```
### Code of Conduct
Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by its terms.