library(shiny)
library(plotly)
library(ggplot2)
library(ggQC)
# https://www.brodrigues.co/blog/2018-02-16-importing_30gb_of_data/
# scara0 <- read_delim("IoT_Predictive_Maintenance_Demo/scara0","\t", escape_double = FALSE, trim_ws = TRUE)
## why class(scara0) "tbl_df" "tbl" "data.frame"?
# https://github.com/IndrajeetPatil/ggstatsplot
# subplots ----------------------------------------------------------------
rand <- function() {
# set.seed(0)
rnorm(1, mean = 5,sd=3 )
}
ui <- fluidPage(
# includeCSS("styles.css"),
headerPanel(h1("Scara Streams", align = "center")),
br(),
div(actionButton("button", "Traces"), align = "center"), #Traces
br(),
div(plotlyOutput("plot"), id='graph')
)
server <- function(input, output, session) {
p <- plot_ly(
y = c(rand(),rand(),rand()),
type = 'scatter',
mode = 'lines',
line = list(
color = '#25FEFD',
width = 3
)
) %>%
layout(
yaxis = list(range = c(0,30))
)
pp <- plot_ly(
y = c(rand(),rand(),rand()),
type = 'scatter',
mode = 'lines',
line = list(
color = '#636EFA',
width = 3
)
) %>%
layout(
yaxis = list(range = c(0,30))
)
ppp <- plot_ly(
y = c(rand(),rand(),rand()),
type = 'scatter',
mode = 'lines',
line = list(
color = 'brown',
width = 3
)
) %>%
layout(
yaxis = list(range = c(0,30))
)
# pppp <- plot_ly(
# y = c(rand(),rand(),rand()),
# type = 'scatter',
# mode = 'lines',
# line = list(
# color = 'RED',
# width = 3
# )
# ) %>%
#
pppp <-
ggplot(c(rand(),rand(),rand()), aes(x = Run_Number, y = Value)) + #init ggplot
geom_point() + geom_line() + #add the points and lines
stat_QC(method = "XmR", #specify QC charting method
auto.label = T, # Use Autolabels
label.digits = 2, #Use two digit in the label
show.1n2.sigma = T #Show 1 and two sigma lines
) +
stat_QC(method="mR") +
scale_x_continuous(expand = expand_scale(mult = .15)) %>%
layout(
yaxis = list(range = c(0,30))
)
# pppp<-ggplot(rand, aes(x = Cycle, y = rand, group = 1, color=mold_cell)) +
# stat_summary(fun.y = mean, geom = "point") +
# stat_summary(fun.y = mean, geom = "line") +
# stat_QC() + stat_QC_labels() +
# # Show Individuals
# geom_point(alpha= 1/2) +
# stat_QC(n=1, color.qc_limits = "orange") +
# stat_QC_labels(n=1, color.qc_limits = "orange")
s <- subplot(p,pp,ppp,pppp, nrows = 4)
output$plot <- renderPlotly(s)
observeEvent(input$button, {
while(TRUE){
Sys.sleep(1)
plotlyProxy("plot", session) %>%
plotlyProxyInvoke("extendTraces", list(y=list(list(rand()), list(rand()),list(rand()),list(rand()))),list(0,1,2,3))
}
})
}
shinyApp(ui, server)