Skip to content

Commit 793ad29

Browse files
author
Nick Heyek
committed
Plot improvements
1 parent def840b commit 793ad29

1 file changed

Lines changed: 18 additions & 17 deletions

File tree

  • experiment-trait-data-visualizer

experiment-trait-data-visualizer/app.R

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,26 @@ rownames(seasons) <- paste0('[', seasons$start_date, ']', ' - ', '[', seasons$en
1919
# set page UI
2020
ui <- fluidPage(
2121

22-
title = "TERRA-REF Experimental Data",
22+
column(width=8, offset=2,
23+
title = "TERRA-REF Experimental Data",
2324

24-
h1('TERRA-REF Experimental Data'),
25+
h1('TERRA-REF Experimental Data'),
2526

26-
# season menu
27-
selectInput('selectedSeason', 'Season', rownames(seasons)),
27+
# season menu
28+
selectInput('selectedSeason', 'Season', rownames(seasons)),
2829

29-
hr(),
30+
hr(),
3031

31-
h3('Trait Data'),
32+
h3('Trait Data'),
3233

33-
# variable menu to be rendered when variables for a given season are parsed in server()
34-
uiOutput('selectVariable'),
34+
# variable menu to be rendered when variables for a given season are parsed in server()
35+
uiOutput('selectVariable'),
3536

36-
plotOutput('traitPlot'),
37+
plotOutput('traitPlot'),
3738

38-
hr(),
39-
h3('Managements Data'),
39+
hr(),
40+
h3('Managements Data'),
4041

41-
fluidRow(
4242
timevisOutput('timeline')
4343
)
4444

@@ -82,7 +82,7 @@ getManagementsData <- function(startDate, endDate) {
8282
while (endDate - currDate != 0) {
8383
# get management data for each day
8484
currMgmtData <- betydb_query(table='managements', date=paste0('~', currDate))
85-
fullMgmtData <- rbind(fullMgmtData, currMgmtData)
85+
fullMgmtData <- rbind(fullMgmtData, currMgmtData[c('date', 'mgmttype')])
8686
currDate <- currDate + days(1)
8787
}
8888

@@ -103,7 +103,7 @@ server <- function(input, output) {
103103
# render menu for selecting variable to view data for
104104
output$selectVariable <- renderUI({
105105

106-
# get access to 'fullTraitData'
106+
# get access to 'fullTraitData' from cache
107107
data.cache(cache.name=cacheName(), loadTraitData, startDate=seasonStartDate(), endDate=seasonEndDate(), frequency='daily')
108108

109109
# get unique variable ids from observations in current season
@@ -124,7 +124,7 @@ server <- function(input, output) {
124124
# render plot for selected variable
125125
output$traitPlot <- renderPlot({
126126

127-
# get access to 'fullTraitData'
127+
# get access to 'fullTraitData' from cache
128128
data.cache(cache.name=cacheName(), loadTraitData, startDate=seasonStartDate(), endDate=seasonEndDate())
129129

130130
# only render plot of a variable is selected
@@ -143,7 +143,8 @@ server <- function(input, output) {
143143
geom_boxplot(aes(group=cut_width(as.Date(date), 1))) +
144144
labs(title=title,
145145
x="Observation Dates", y=variableIdData$units) +
146-
theme(text = element_text(size=20), axis.text.x = element_text(angle=45, hjust=1))
146+
theme(text = element_text(size=20), axis.text.x = element_text(angle=45, hjust=1)) +
147+
expand_limits(y=0) + xlim(seasonStartDate(), seasonEndDate())
147148
}
148149
})
149150

@@ -152,7 +153,7 @@ server <- function(input, output) {
152153
mgmtData <- getManagementsData(startDate=seasonStartDate(), endDate=seasonEndDate())
153154
timelineData <- data.frame(
154155
id=1:nrow(mgmtData),
155-
content=mgmtData$mgmttype,
156+
content=paste0(mgmtData$mgmttype),
156157
start=as.Date(mgmtData$date)
157158
)
158159
timevis(timelineData)

0 commit comments

Comments
 (0)