4

私は現在、すばらしいパッケージ svgPanZoom を使用して Shiny アプリに取り組んでおり、未解決のままの 2 つの質問があります。

(1)グラフのサイズを動的にカスタマイズすることは可能ですか。私はコードに従ってそれをやろうとしました( 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))

しかし、何も起こりませんでした:( アイデアはありますか?

(2)このコードに (PlotOutput のように) ロケーターを含めることができるかどうか知っていますか?

主なアイデアは、直交座標系で (細胞の) 画像をプロットし、その画像をクリックして細胞の核を見つけることです。画像上のセルが非常に小さいため、ユーザーがズームする必要がある場合があります (そのため、私は svgPanZoom を使用しています)。したがって、取得したい X と Y は、ユーザーがズームを使用しても、正規直交システム全体のものです。

svg-pan-zoom を使用してズーム後にカーソルの位置を確認しましたが、R からのものではないようです

アイデアをありがとうございました!

素敵な日曜日の夜を!

チャ

4

1 に答える 1

2

1) について: リンクが機能しなくなりました。しかし、おそらく素晴らしいshinyjquiパッケージはあなたにとって興味深いものです. jqui_resizabled()UIに関数を追加できます。あなたの例では、次のようになりますjqui_resizabled(svgPanZoomOutput(outputId = "main_plot"))。出力の左下隅に小さな灰色の記号が表示されます。

小さな gif の例 (セクション: サイズ変更可能) とその他の興味深い関数を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 else はもっと良い方法を知っているかもしれません。

于 2017-10-29T17:34:30.733 に答える