rCharts闪亮:列堆叠行为

时间:2015-01-05 16:57:17

标签: r highcharts shiny rcharts

我对闪亮和rCharts相对较新 我试图制作一个堆叠的高图情节应用程序。

通常,如果我在图例中排除一​​个变量,则图表会自动调整(y轴,条形图重新组织)。
这在我的应用程序中不起作用。

在这里,您可以找到重现此最小示例的代码:

library(shiny)
library(rCharts)
runApp(list(
  ui = navbarPage("strange stack behavior",
                  tabPanel("highcharts column",
                           pageWithSidebar(
                             headerPanel("stacking"),

                             sidebarPanel(radioButtons("plotType", "Plot type", c("stacked"="percent", "barplot"="")
                             ),
                             width = 2
                             ),                              
                             mainPanel(showOutput("stackchart", "Highcharts"))
                           ))),
  server = (function(input, output) {

      data <- matrix(c(300, 200, 1400, 350, 50, 300, 1350, 700, 3000), nrow=3, byrow = T)
      dimnames(data) <- list(c("xA", "xB", "xC"), c("catA", "catB", "catC"))
      data <- as.data.frame(data)

    output$stackchart <- renderChart2({
      # Create chart
      a <- rCharts:::Highcharts$new()
      a$chart(type = "column")
      a$title(text = "charttitle")
      a$xAxis(categories = rownames(data))
      a$yAxis(title = list(text = "yaxis"))
      a$data(data)
      a$exporting(enabled=T)

      # credits with hyperlink
      a$credits(text = "somethingsomthing", href = "")
      # stacked
      a$plotOptions(
        column = list(stacking = input$plotType)
      )

      # title & subtitle
      a$title(text = "title")
      a$subtitle(text = "subtitle")
      return(a)
    })
  })
))

Thanx任何输入如何理解那里发生的事情!! 最好 托拜厄斯

0 个答案:

没有答案