-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.R
53 lines (48 loc) · 1.7 KB
/
app.R
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
library(shiny)
library(rCharts)
bd<-readRDS("bd.rds")
odchart<-readRDS("od.rds")
gtmed<-readRDS("gtmed.rds")
# Define UI ----
ui <- shinyUI(fluidPage(
headerPanel('Séries de Tempo'),
sidebarPanel(
selectInput('var', label= 'Selecione a série desejada',
choices = c("Despesa"=1,
"Casos de dengue"=2,
"Interesse ao longo do tempo"=3),
selected = 1),
mainPanel(
showOutput("myChart", "nvd3"))
)
)
)
# Define server logic ----
server = function(input, output) {
output$myChart <- renderChart2({
if(input$var==1){
q <- nPlot(VLIQ ~ Data, data = odchart, type = 'lineChart')
q$xAxis(tickFormat="#!function(d) {return d3.time.format.utc('%Y-%m')(new Date(d * 24 * 60 * 60 * 1000));}!#")
q$chart(forceY = c(0,4000))
q$yAxis(axisLabel = 'Valor Liquidado - R$ mil',width=60)
q$chart(showLegend = FALSE)
}
if(input$var==2){
q <- nPlot(Casos ~ Data, data = bd, type = 'lineChart')
q$xAxis(tickFormat="#!function(d) {return d3.time.format.utc('%Y-%m')(new Date(d * 24 * 60 * 60 * 1000));}!#")
q$chart(forceY = c(0,60000))
q$yAxis(axisLabel = 'Casos Confirmados de Dengue',width=60)
q$chart(showLegend = FALSE)
}
if(input$var==3){
q <- nPlot(Media ~ Data, data = gtmed, type = 'lineChart')
q$xAxis(tickFormat="#!function(d) {return d3.time.format.utc('%Y-%m')(new Date(d * 24 * 60 * 60 * 1000));}!#")
q$chart(forceY = c(0,100))
q$yAxis(axisLabel = 'Google Trends - Interesse Sintomas Dengue',width=60)
q$chart(showLegend = FALSE)
}
q
})
}
# Run the app ----
shinyApp(ui = ui, server = server)