R svgPanZoom adjust size and add locator

I am currently working on a brilliant application with the awesome svgPanZoom package, and I have two questions that remain unresolved for me:

(1) You can dynamically adjust the size of the graph. I tried to do this after the code (as in https://stackoverflow.com/questions/33522860/svgplot-error-in-shiny ):

library(shiny)
library(svglite)
library(svgPanZoom)
library(ggplot2)
library(plyr)

data.df <- data.frame(Plant = c("Plant1", "Plant1", "Plant1", "Plant2", "Plant2", 
                                "Plant2"), Type = c(1, 2, 3, 1, 2, 3), Axis1 = c(0.2, -0.4, 0.8, -0.2, -0.7, 
                                                                                 0.1), Axis2 = c(0.5, 0.3, -0.1, -0.3, -0.1, -0.8))

ui <- shinyUI(bootstrapPage(

  svgPanZoomOutput(outputId = "main_plot")

))

server = shinyServer(function(input, output) {
  output$main_plot <- renderSvgPanZoom({
    p <- ggplot(data.df, aes(x = Axis1, y = Axis2, shape = Plant, color = Type)) + geom_point(size = 5)
    svgPanZoom(p, controlIconsEnabled = T, width = 10, height = 16)
  })
})

runApp(list(ui=ui,server=server))

but nothing happened :( Do you have an idea?

(2) Do you know if a locator can be included in this code (as in PlotOutput)

() , ​​. , ( svgPanZoom). , X Y, , , ,

svg-pan-zoom, , , R

!

!

Cha

+4
1

1): . , , shinyjqui . jqui_resizabled() ui. : jqui_resizabled(svgPanZoomOutput(outputId = "main_plot")). .

gif (: resizable) : https://github.com/Yang-Tang/shinyjqui.

:

library(shiny)
library(svglite)
library(svgPanZoom)
library(ggplot2)
library(plyr)
library(shinyjqui)

data.df <- data.frame(Plant = c("Plant1", "Plant1", "Plant1", "Plant2", "Plant2", 
                                "Plant2"), Type = c(1, 2, 3, 1, 2, 3), Axis1 = c(0.2, -0.4, 0.8, -0.2, -0.7, 
                                                                                 0.1), Axis2 = c(0.5, 0.3, -0.1, -0.3, -0.1, -0.8))

ui <- shinyUI(bootstrapPage(

  jqui_resizabled(svgPanZoomOutput(outputId = "main_plot"))

))

server = shinyServer(function(input, output) {
  output$main_plot <- renderSvgPanZoom({
    p <- ggplot(data.df, aes(x = Axis1, y = Axis2, shape = Plant, color = Type)) + geom_point(size = 5)
    svgPanZoom(p, controlIconsEnabled = T, width = 10, height = 16)
  })
})

runApp(list(ui=ui,server=server))

2) . -, . , smd .

+2

Source: https://habr.com/ru/post/1656515/


All Articles