繁体   English   中英

在Shiny App中呈现Highcharter饼图时出错

[英]Error in rendering Highcharter Pie chart in Shiny App

我正在尝试在具有2个用户控件的Shiny应用程序中使用highcharter绘制饼图。 以下是相关的UI代码:

column(
                  6,
                  fluidRow(
                    column(6,selectInput('type','Select Builder/Owner',
                                         choices = c('Builder'="Builder",'Owner Group'="`Owner Group`"))),
                    column(6, sliderInput('minvsl',"Select minimum number of vessels",min=1,value=10,max=100))
                  ),
                  highchartOutput('Builder',width='100%', height = '600px')
                )

这是呈现图表的服务器代码:

output$Builder <- renderHighchart({
ByBuilder <-   orderbook %>% dplyr::group_by_(input$type) %>% dplyr::summarise(Count=n()) %>%
    filter(Count>=input$minvsl)

    highchart() %>%
    hc_add_series(ByBuilder,hcaes_(x=input$type,y="Count"), type="pie",
                  dataLabels=list(enabled=TRUE),innerSize= '40%', size ='80%',
                  tooltip=list(pointFormat = paste('{point.y} ships<br/><b>{point.percentage:.1f}%</b>'))) %>%
    hc_add_theme(hc_theme_smpl()) %>%
    hc_title(text = paste("Construction by", input$type))%>%
    hc_subtitle(text = paste("Control the min. number of constructions by the numeric slider"))
})

这将返回以下错误:

Warning: Error in mutate_impl: Column `x` is of unsupported type quoted call

不知道为什么。 这里是一些测试数据:

structure(list(Builder = c("Hyundai Mipo", "Onomichi Dockyd", 
"Onomichi Dockyd", "Hyundai Mipo", "Hyundai Mipo", "Hyundai Mipo", 
"Samsung HI", "Samsung HI", "Samsung HI", "Samsung HI"), `Owner Group` = c("SK Holdings", 
"Nissen Kaiun", "Nissen Kaiun", "Overseas Shipholding", "Overseas Shipholding", 
"Sonatrach Petroleum", "Mitsui & Co", "Mitsui & Co", "Mitsui & Co", 
"Mitsui & Co")), row.names = c(NA, -10L), class = c("tbl_df", 
"tbl", "data.frame"))

我正在使用highcharter 0.6.0版本。

虽然我仍然想绕着tidyeval摇头,但我认为这可能是个问题,但这是一种快速的方法,尽管不是最优雅的方法,它可以起作用:

output$Builder <- renderHighchart({
ByBuilder <-   orderbook %>% dplyr::group_by_(input$type) %>% dplyr::summarise(Count=n()) %>%
    filter(Count>=input$minvsl)
colnames(ByBuilder)[1] <- "test"
    highchart() %>%
      hc_add_series(ByBuilder,hcaes(x='test',y="Count"), type="pie",
                  dataLabels=list(enabled=TRUE),innerSize= '40%', size ='80%',
                  tooltip=list(pointFormat = paste('{point.y} ships<br/><b>{point.percentage:.1f}%</b>'))) %>%
    hc_add_theme(hc_theme_smpl()) %>%
    hc_title(text = paste("Construction by", input$type))%>%
    hc_subtitle(text = paste("Control the min. number of constructions by the numeric slider"))
})

只是添加了一个列名而不是input$type

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM