2015-02-10 28 views

cevap

4

El ile yapmanın yolları vardır. Özel bir js oluşturmanız gerekir.

js<-"$(function() { 
     var $elie = $(document.getElementsByClassName('form-group shiny-input-container')); 
    rotate(270); 
    function rotate(degree) {   
     $elie.css({ WebkitTransform: 'rotate(' + degree + 'deg)'}); 
     $elie.css({ '-moz-transform': 'rotate(' + degree + 'deg)'}); 
    } 
});" 

Hala ihtiyacı: Burada

bunu böyle js değiştirmeniz gerekir döndür sadece bir eleman çalışmak istiyorsanız herşey

#Libs 
    require(c('shiny')) 
    js<-"$(function() { 
     var $elie = $('div'); 
     rotate(25); 
     function rotate(degree) {   
      $elie.css({ WebkitTransform: 'rotate(' + degree + 'deg)'}); 
      $elie.css({ '-moz-transform': 'rotate(' + degree + 'deg)'}); 
      timer = setTimeout(function() { 
       rotate(++degree); 
      },100); 
     } 
    });" 


    renderInputs <- function(prefix) { 
     wellPanel(
     fluidRow(
      column(3, 
       sliderInput(paste0(prefix, "_", "n_obs"), "View a specific date", min = as.Date('1980-05-15'), max = Sys.Date(), value = as.Date('2000-01-01'), 
       #sliderInput("date_range", "Choose Date Range:", min = as.Date("2016-02-01"), max = Sys.Date(), value = c(as.Date("2016-02-25"), Sys.Date()) 
       ), 
       verbatimTextOutput("info") 
     ), 
      column(9, 
       plotOutput("plot1", 
          click = "plot_click", 
          dblclick = "plot_dblclick", 
          hover = "plot_hover", 
          brush = "plot_brush") 
     ) 
     ) 
    ) 
    } 

    ui <- shinyUI(fluidPage(theme="simplex.min.css", 
          tags$style(type="text/css", 
             "label {font-size: 12px;}", 
             ".recalculating {opacity: 1.0;}" 
          ), 
          tags$head(
           tags$style(HTML(" 
               @import url('//fonts.googleapis.com/css?family=Lobster|Cabin:400,700'); 

               h1 { 
               font-family: 'Lobster', cursive; 
               font-weight: 500; 
               line-height: 1.1; 
               color: #48ca3b; 
               } 

               ")), 
           tags$script(HTML(js)) 
          ), 

          # Application title 
          tags$h2("Google!!!"), 
          p("An adaptation of the", 
           tags$a(href="https://google.com", "Google"), 
           "from", 
           tags$a(href="https://duckduckgo.com/", "DuckDuckGo"), 
           "to get the best possible results without selling yourself"), 
          hr(), 

          fluidRow(
           column(6, tags$h3("Scenario A")), 
           column(6, tags$h3("Scenario B")) 
          ), 
          fluidRow(
           column(12, renderInputs("a")) 
          ), 
          fluidRow(
           column(6, 
            plotOutput("a_distPlot", height = "600px") 
          ), 
           column(6, 
            plotOutput("b_distPlot", height = "600px") 
          ) 
          ) 
          ) 
       ) 


    server <- function(input, output) { 
     output$plot1 <- renderPlot({ 
     plot(mtcars$wt, mtcars$mpg) 
     }) 

     output$info <- renderText({ 
     xy_str <- function(e) { 
      if(is.null(e)) return("NULL\n") 
      paste0("x=", round(e$x, 1), " y=", round(e$y, 1), "\n") 
     } 
     xy_range_str <- function(e) { 
      if(is.null(e)) return("NULL\n") 
      paste0("xmin=", round(e$xmin, 1), " xmax=", round(e$xmax, 1), 
       " ymin=", round(e$ymin, 1), " ymax=", round(e$ymax, 1)) 
     } 

     paste0(
      "click: ", xy_str(input$plot_click), 
      "dblclick: ", xy_str(input$plot_dblclick), 
      "hover: ", xy_str(input$plot_hover), 
      "brush: ", xy_range_str(input$plot_brush) 
     ) 
     }) 
    } 

    shinyApp(ui, server) 


    ################################ 

döner çılgın tırmanmak uygulaması kayan sürgü ve padding gibi işlevselliği düzeltmek ve döndürmek istediğiniz tüm elemanlara özel bir kimlik eklemek için biraz iş yapın: böylece istemediğiniz öğe üzerine js uygulayamayacağınızdan emin olun. ilk örnek, ama ag olmalı ood başlangıç ​​noktası.

+0

thankyou! Bunun bir başlangıç ​​olabileceğini görebiliyorum. Birincisi gerçekten çılgın! Sadece kaydırılan kaydırıcı ile ikinci olanı iyi görünüyor, ancak kaydırıcının hala kaydırıcıyı aşağı-yukarı hareket ettirmek için sağ-sol fare hareketini algıladığını öne sürdüğünüz gibi. Bu tamir edilebilir mi? – Andy

+0

Evet. En iyi tahminim, bununla ilişkili js'den fonksiyonların üzerine yazılmasıdır. Başka bir yol ise, parlak kaydırıcıyı kullanmamanız ve kendi kodlarınızı kullanarak, diğer kaynaklardan bazı kodları kullanmanızdır: https://jqueryui.com/slider/#multiple-vertical – Stanislav

İlgili konular