rCharts - not show x axis elements

拟墨画扇 提交于 2019-12-25 07:07:25

问题


I have a rPlot and I don´t want that it shows the names of the elements below the x axis. I´ve already done it with the following code, but appears an error above the plot. The word is hide, but if I give a double click, copy and paste I see that the word is "undefined". If I take off the line:

,numticks = 'none'

the error does not appear.

I need other solution to hide the names or fix this one.

Thanks in advance!

Luis

ui.R

shinyUI(pageWithSidebar(

  headerPanel("New Application"),

  sidebarPanel(

           selectInput('feature', 'Choose a variable:', colnames(mtcars))


  ),

  mainPanel(
    showOutput('plot32', 'polycharts')
  )
))

server.R

shinyServer(function(input, output) {

  mydata<- reactive({
    Feature<-input$feature
    mtcars2<-cbind(rownames(mtcars),mtcars)
    colnames(mtcars2)<-c("Cars",colnames(mtcars))

    a<-mtcars2[,c("Cars",Feature)]
    colnames(a)<-c("Cars","Feature")
    a
  })


  output$plot32<- renderChart2({
    data2<-mydata()
    Feature<-input$feature
    p1<-rPlot(Feature ~ Cars, color = 'Cars', data = data2, type = 'bar')
    p1$guides(
      color = list(
        numticks = length((data2[,1]))
      ),
      x = list(title="Cars",
               numticks = 'none'
      ),
      y = list(title=input$feature
      )
    )
    p1$addParams(width = 800, height = 400, 
                 title = "Title")
    p1
  })

})


回答1:


Finally, I found a solution:

shinyServer(function(input, output) {

  mydata<- reactive({
    Feature<-input$feature
    mtcars2<-cbind(rownames(mtcars),mtcars)
    colnames(mtcars2)<-c("Cars",colnames(mtcars))

    a<-mtcars2[,c("Cars",Feature)]
    colnames(a)<-c("Cars","Feature")
    a
  })


  output$plot32<- renderChart2({
    data2<-mydata()
    Feature<-input$feature
    p1<-rPlot(Feature ~ Cars, color = 'Cars', data = data2, type = 'bar')
    p1$guides(
      color = list(
        numticks = length((data2[,1]))
      ),

x = list(title="Cars", ticks='' ),

y = list(title=input$feature
      )
    )
    p1$addParams(width = 800, height = 400, 
                 title = "Title")
    p1
  })

})


来源:https://stackoverflow.com/questions/25955887/rcharts-not-show-x-axis-elements

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!