我的饼状图无法正常显示或显示任何内容

carmen024_6

我用R用Shiny写了一些代码。但是,无论我在尝试什么,我的pieChart都不会显示。是我的数据还是代码错误?图表的数据如下所示:

值名称
dbl chr
17种
10电影
8电视连续剧6游戏
5食物
46随机

library(shiny)
library(shinydashboard)
library(dplyr)

ui <- dashboardPage(

    dashboardHeader(title = "Catnames in Europe"),
    skin = "red",

        dashboardSidebar(
                img(src = "cats_looking.jpg", height = 100, width = 150, align = "left"),
                selectInput("countries",
                            "Choose country:",
                            choices = c("Netherlands","Germany","Turkey","Ireland",
                                    "England","Belgium","Spain","Portugal",
                                    "United Sates","Denmark","Sweden",
                                    "Switzerland","Italy"),
                            selected = "Netherlands",
                            multiple = FALSE,
                            width = '400px'),
              selectInput("years",
                        "Choose Year:",
                        choices = c("2017","2018","2019","2020"),
                        selected = "2019",
                        multiple = FALSE,
                        width = '400px'),
                actionButton("button","Update view",style="color: #fff; background-color: #337ab7; border-color: #2e6da4"),
              tags$div(div_id= "distPie", class ="plot-Output")
              ),
        dashboardBody(fluidRow(
            tabBox(
                tabPanel("Countries",tableOutput("catnametable"),
                     style = "background-color: #ffffff;")),
            tabBox(
                tabPanel("Years",tableOutput("years"),
                     style = "background-color: #ffffff;"),
                tabPanel("Trends in 2019",deliverChart(div_id = "pieChart", running_in_shiny = TRUE),
                         style = "background-color: #ffffff;"))
    )))
server <- function(input, output) {

    output$catnametable <- renderTable({
        countrylist <- CatnamesEurope %>%
            filter(Country %in% input$countries)
    })
    output$years <- renderTable({
        yearlist <- Years2 %>%
            filter(Years_ordered %in% input$years)
    })
    output$pieChart <- renderPieChart(
        div_id = "pieChart",
        data = Trends,
        radius = '75%',
        center_x = '50%',
        center_y = '50%',
        show.label = TRUE,
        show.legend = TRUE, show.tools = TRUE,
        font.size.legend= 12
    )
}

shinyApp(ui = ui, server = server)
Ben

这里有一些尝试。

output由于没有您的全部数据,我注释了一些声明。

我还补充说:

loadEChartsLibrary(),
tags$div(id="pieChart", style="width:100%;height:400px;"),

在您打电话之前deliverChart

library(shiny)
library(shinydashboard)
library(dplyr)
library(ECharts2Shiny)

Trends <- data.frame(
  value = c(17,10,8,6,5,46),
  name = c("Species", "Movies", "TV Series", "Games", "Food", "Random"),
  stringsAsFactors = FALSE
)

ui <- dashboardPage(

  dashboardHeader(title = "Catnames in Europe"),
  skin = "red",

  dashboardSidebar(
    img(src = "cats_looking.jpg", height = 100, width = 150, align = "left"),
    selectInput("countries",
                "Choose country:",
                choices = c("Netherlands","Germany","Turkey","Ireland",
                            "England","Belgium","Spain","Portugal",
                            "United Sates","Denmark","Sweden",
                            "Switzerland","Italy"),
                selected = "Netherlands",
                multiple = FALSE,
                width = '400px'),
    selectInput("years",
                "Choose Year:",
                choices = c("2017","2018","2019","2020"),
                selected = "2019",
                multiple = FALSE,
                width = '400px'),
    actionButton("button","Update view",style="color: #fff; background-color: #337ab7; border-color: #2e6da4"),
    tags$div(div_id= "distPie", class ="plot-Output")
  ),
  dashboardBody(fluidRow(
    tabBox(
      tabPanel("Countries",tableOutput("catnametable"),
               style = "background-color: #ffffff;")),
    tabBox(
      tabPanel("Years",tableOutput("years"),
               style = "background-color: #ffffff;"),
      tabPanel("Trends in 2019", 
               loadEChartsLibrary(),
               tags$div(id="pieChart", style="width:100%;height:400px;"),
               deliverChart(div_id = "pieChart", running_in_shiny = TRUE),
               style = "background-color: #ffffff;"))
  )))
server <- function(input, output) {

  output$catnametable <- renderTable({
    #countrylist <- CatnamesEurope %>%
    #  filter(Country %in% input$countries)
  })
  output$years <- renderTable({
    #yearlist <- Years2 %>%
    #  filter(Years_ordered %in% input$years)
  })

  output$pieChart <- renderPieChart(
    div_id = "pieChart",
    data = Trends,
    radius = '75%',
    center_x = '50%',
    center_y = '50%',
    show.label = TRUE,
    show.legend = TRUE, show.tools = TRUE,
    font.size.legend= 12
  )
}

shinyApp(ui = ui, server = server)

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

有人可以解释为什么我的Python图无法显示任何内容吗?

来自分类Dev

高图不显示任何内容

来自分类Dev

即使查询有效,我的Google饼图也没有显示任何数据。ASP.NET MVC

来自分类Dev

无法在枢轴屏幕上显示饼图(amchart-quickchart)

来自分类Dev

PHP GD库无法显示图片-饼图

来自分类Dev

我的网站无法正常显示

来自分类Dev

简易饼图不显示

来自分类Dev

创建了jquery行,但没有显示任何内容,on('hover')方法也无法正常工作

来自分类Dev

高图饼图应按升序显示

来自分类Dev

高图饼图应按升序显示

来自分类Dev

我的JFrame没有显示任何内容

来自分类Dev

我无法让我的按钮以正常大小显示

来自分类Dev

为什么散景散布图不显示任何内容?

来自分类Dev

我的电脑在听并且无法前进,没有显示错误或其他任何内容

来自分类Dev

Highcharts饼图在空时显示轮廓

来自分类Dev

highcharts-ng未显示饼图

来自分类Dev

饼图的标签文本未显示

来自分类Dev

密谋:饼图仅显示图例

来自分类Dev

Sencha Touch 2饼图未显示

来自分类Dev

饼图未显示预期输出

来自分类Dev

如何使用highcharts显示多个饼图

来自分类Dev

功能不显示饼图

来自分类Dev

log4j2到电锯无法正常工作-电锯的“ Zeroconf”选项卡中未显示任何内容

来自分类Dev

为什么我的第一个标签显示在饼图的后面?

来自分类Dev

在QGIS中,我想按区域而不是按国家显示一个饼图

来自分类Dev

画布饼图:有 ctx.FillText() 问题,所以我的标签没有正确显示

来自分类Dev

我希望谷歌饼图显示 pieSliceText 被四舍五入整数

来自分类Dev

饼图的内部显示标签,饼图外部显示百分比

来自分类Dev

动态确定要显示的饼图数量,并使用CanvasJS在单个页面上显示每个饼图

Related 相关文章

  1. 1

    有人可以解释为什么我的Python图无法显示任何内容吗?

  2. 2

    高图不显示任何内容

  3. 3

    即使查询有效,我的Google饼图也没有显示任何数据。ASP.NET MVC

  4. 4

    无法在枢轴屏幕上显示饼图(amchart-quickchart)

  5. 5

    PHP GD库无法显示图片-饼图

  6. 6

    我的网站无法正常显示

  7. 7

    简易饼图不显示

  8. 8

    创建了jquery行,但没有显示任何内容,on('hover')方法也无法正常工作

  9. 9

    高图饼图应按升序显示

  10. 10

    高图饼图应按升序显示

  11. 11

    我的JFrame没有显示任何内容

  12. 12

    我无法让我的按钮以正常大小显示

  13. 13

    为什么散景散布图不显示任何内容?

  14. 14

    我的电脑在听并且无法前进,没有显示错误或其他任何内容

  15. 15

    Highcharts饼图在空时显示轮廓

  16. 16

    highcharts-ng未显示饼图

  17. 17

    饼图的标签文本未显示

  18. 18

    密谋:饼图仅显示图例

  19. 19

    Sencha Touch 2饼图未显示

  20. 20

    饼图未显示预期输出

  21. 21

    如何使用highcharts显示多个饼图

  22. 22

    功能不显示饼图

  23. 23

    log4j2到电锯无法正常工作-电锯的“ Zeroconf”选项卡中未显示任何内容

  24. 24

    为什么我的第一个标签显示在饼图的后面?

  25. 25

    在QGIS中,我想按区域而不是按国家显示一个饼图

  26. 26

    画布饼图:有 ctx.FillText() 问题,所以我的标签没有正确显示

  27. 27

    我希望谷歌饼图显示 pieSliceText 被四舍五入整数

  28. 28

    饼图的内部显示标签,饼图外部显示百分比

  29. 29

    动态确定要显示的饼图数量,并使用CanvasJS在单个页面上显示每个饼图

热门标签

归档