#' Plots PEP
#'
#'
#' @param bluQPEPinput PEP JSON file input
#' @return HTML plot of PEP result ("bluQPlotPEP.html")
#' @import widgetframe
#' @import htmlwidgets
#' @import jsonlite
#' @import scales
#' @import ggplot2
#' @import plotly
#' @examples
#' bluQPlotPEPjsonFile(system.file("extdata", "PEP_sample.json", package = "bluQPlotPEP"))
#' @export
bluQPlotPEPjsonFile <- function(bluQPEPinput) {
df1<- jsonlite::fromJSON(bluQPEPinput, flatten=TRUE)
df1$Timestamp<-as.POSIXct(df1$Timestamp)
ggp <- ggplot2::ggplot(data=df1, aes(x=df1$Timestamp, y=df1$Result, group=1, text=paste('Plant: ',df1$Plant,'\n',
'SampleID: ',df1$SampleID,'\n',
'BatchID: ',df1$BatchID,'\n',
'LotID: ',df1$LotID,'\n',
'Timestamp: ',df1$Timestamp,'\n',
'PEP Result: ',df1$Result, '\n'))) +
ggplot2::scale_colour_manual(name="", values =c("violet","#0072B2"))+
ggplot2::geom_point(aes(colour=df1$Result), size=4) +
ggplot2::geom_point(aes(shape=df1$Plant), size=2) +
ggplot2::theme(legend.title = element_blank()) +
ggplot2::geom_line(color='deepskyblue3') +
ggplot2::theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
ggplot2::scale_x_datetime(labels = scales::date_format("%b-%d-%Y"))
ggpl <- plotly::ggplotly(ggp, tooltip = 'text')
htmlwidgets::saveWidget(widgetframe::frameableWidget(ggpl),'bluQPlotPEP.html',selfcontained=TRUE)
#rawhtml <- readBin('bluQPlotPEP.html', raw(), file.info('bluQPlotPEP.html')$size)
#return(rawhtml)
#data <- readLines('bluQPlotPEP.html')
#return(list(text = paste(data, collapse = "\n")))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.