Look my code for observeEvent
UI:
actionButton("plot", "Plotar!"),
SERVER:
#-----------------------START OBSERVE--------------------------------
observeEvent(input$plot,
#-------------------------Campo gerar histograma--------------------------
output$histograma <-renderPlot({
capabilidade_LE = qcc(data = capabilidade_LE, type="xbar", plot = TRUE)
process.capability(object = capabilidade_LE, spec.limits = c(input$lininf,input$linsup))
}),
#-------------------------------------------------------------------------
output$histograma2 <-renderPlot({
capabilidade2 = qcc(data = capabilidade2, type="xbar", plot = TRUE, lines(x = "red", y = "yellow"))
process.capability(object = capabilidade2, spec.limits = c(input$lininf,input$linsup))
}),
#------------------------Grafico de normalidade---------------------------
output$normalidade <-renderPlot({
ss.study.ca(normalidade_LE, LSL = input$lininf, USL = input$linsup, Target = ((input$lininf+input$linsup)/2),alpha = 0.05, f.main = "Teste de Normalidade")
}),
#-------------------------------------------------------------------------
output$normalidade2 <-renderPlot({
ss.study.ca(normalidade2, LSL = input$lininf, USL = input$linsup, Target = ((input$lininf+input$linsup)/2),alpha = 0.05, f.main = "Teste de Normalidade")
})
) #Close OBSERVE
BUT, i need to Source my SERVER.R with another file called DATA.R, where contains my SQL code to find some data in DATABASE to plot a graph. Look:
DATA.R
query <-
"select
cod_ordem_producao as Ordem,
dim_ext_tubo as Diametro,
esp_par_tubo as Parede,
cod_aqa as AQA,
tmo_ciclo_plan as Ciclo,
dth_criacao_reg as Data,
dsc_aco as Grau,
val_lim_escoamento as LE,
val_tensao_residual as TR
from
QT_QTS.PLA_ORDEM_PRODUCAO
where DIM_EXT_TUBO = 244.48
and esp_par_tubo = 11.99
and VAL_LIM_ESCOAMENTO != 0
order by DTH_CRIACAO_REG desc"
df <- dbGetQuery(
connection_reportUser,
query
)
df
tabela_saida = df
valor_le = df$LE
valor_tr = df$TR
relacao_ts = (valor_le/valor_tr)
#------------------------------------Calculo pra Capabilidade---------------------
capabilidade_LE <- valor_le
capabilidade_LE = matrix(valor_le, nrow = 1, ncol = length(valor_le), byrow = TRUE)
normalidade_LE = matrix(valor_le, nrow = length(valor_le), ncol = 1, byrow = TRUE)
capabilidade2 <- relacao_ts
capabilidade2 = matrix(relacao_ts, nrow = 1, ncol = length(relacao_ts), byrow = TRUE)
normalidade2 = matrix(relacao_ts, nrow = length(relacao_ts), ncol = 1, byrow = TRUE)
That last part, what plot's the graph, this last part of the code needs to wait for the button to be pressed to run. Otherwise, it will generate an error.
How can I fix it?