I tried to output a higher quality image by resizing the imageOutput in shiny.
It's true that when I try to use shinyjqui, I can resize it interactively, but it doesn't change the aspect ratio of the plot, so it doesn't make sense.
Perhaps this is due to the fact that I am specifying the width and height of the image file, but I don't know how to solve this.
library(ggplot2)
library(shiny)
library(shinyjqui)
# Define UI for app that draws a histogram ----
ui <- fluidPage(
titlePanel("Hello Shiny!"),
mainPanel(
h3("Low resolution"),
jqui_resizable(plotOutput(outputId = "Plot")),
hr(),
h3("High resolution"),
jqui_resizable(imageOutput("myImage", height = "100%", width = "100%"))
)
)
# Define server logic required to draw a histogram ----
server <- function(input, output, session) {
output$Plot <- renderPlot({
g <- ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width)) + geom_point()
return(g)
}
#height = 200, width = 200 Adding This code, I cant move picture
)
# Plot the data ####
output$myImage <- renderImage({
g <- ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width)) + geom_point()
# A temp file to save the output.
# This file will be removed later by renderImage
outfile <- tempfile(fileext = '.png')
# Generate the PNG
png(outfile,
width = 200*8,
height = 200*8,
res = 72*8)
print(g)
dev.off()
# Return a list containing the filename
list(src = outfile,
contentType = 'image/png',
width = "100%",
height = "100%",
alt = "This is alternate text")}, deleteFile = TRUE)}
shinyApp(ui, server)