问题
I have a simple shiny application (consisting of two files, server.r and ui.r) which uses the rCharts package with Highcharts.
It runs pretty good, but if I choose to make all the bars disappear and then to display them again, they won't rescale. Here is the code, which is based on a simple example provided on rCharts' GitHub:
ui.r
require(rCharts)
options(RCHART_LIB = 'highcharts')
shinyUI(pageWithSidebar(
headerPanel("App title"),
sidebarPanel(
helpText('A simple text.')
),
mainPanel(chartOutput("chart",'highcharts'))
))
server.r
require(rCharts)
options(RCHART_WIDTH = 900)
options(RCHART_HEIGHT = 500)
shinyServer(function(input, output) {
output$chart <- renderChart2({
a <- hPlot(freq ~ Exer, data = plyr::count(MASS::survey, c('Sex', 'Exer')),
type = 'column', group = 'Sex', group.na = 'NA\'s')
a$plotOptions(column = list(dataLabels = list(enabled = T, rotation = -90,
align = 'right', color = '#FFFFFF', x = 4, y = 10)))
a$xAxis(labels = list(rotation = -45, align = 'right'), replace = F)
return(a) })
})
To run the app, I simply type runApp('appFolder')
.
I can't directly post images because at least 10 reputation points are needed but here is a link to a picture showing concretely the bad display that I am talking about: http://imgur.com/0Xfronr . To obtain this bug, just try to hide all series of data and then unhide them.
Even after trying various things (other settings ,other data, other implementation, other browser), the problem is still here. However when I am only displaying the barchart with rCharts only (as simple HTML page, not in a shiny application) this rescaling problem disappears. I think that it comes from the interaction between shiny and rCharts, but I'm unable to find out what is wrong and how to fix it.
来源:https://stackoverflow.com/questions/23388316/rcharts-with-shiny-no-rescaling-of-bars-after-hide-unhide-with-highcharts