【问题标题】:Plotly Error When Trying to Highlight on Click尝试在点击时突出显示时出现 Plotly 错误
【发布时间】:2022-01-04 01:03:51
【问题描述】:

我有一个要在 Shiny 中渲染的绘图条形图。当我点击一个栏时,我想突出显示它。但是,我当前的代码返回错误:Error: 'options' must be a fully named list, or have no names (NULL)

代码:

number_of_debates_from_1803_1910 <- fread("~/projects/hansard-shiny/app-data/introduction/number_of_debates_from_1803_1910.csv")

  number_of_debates_from_1803_1910 %>%
    highlight_key(~decade) %>%
    plot_ly(data=number_of_debates_from_1803_1910, 
          x = ~decade, 
          y = ~no_of_debates, 
          type = 'bar', 
          text = ~paste0("Decade: ", "<b>", decade, "</b>", "\n",
                         "Number of Debates: ", "<b>", no_of_debates, "</b>", "\n"),
          hoverinfo = "text",
          marker = list(color = 'rgb(158,202,225)',
                        line = list(color = 'rgb(8,48,107)',
                                    width = 1.5))) %>% 
    layout(title = paste0("The Hansard Parliamentary Debates", "\n", "Debate Count by Decade: 1803—1910"),
           xaxis = list(title = ""),
           yaxis = list(title = "")) %>%
    highlight(on = "plotly_click", off = "plotly_doubleclick") %>%
    config(displayModeBar = F) 
  

数据:

decade,no_of_debates
1800,926
1810,2435
1820,2400
1830,7848
1840,7398
1850,8835
1860,10660
1870,14051
1880,31509
1890,31857
1900,49725
1910,5631

我发现 plotly 和 Shiny 错误非常令人困惑,因此非常感谢您的帮助。

【问题讨论】:

    标签: r shiny plotly


    【解决方案1】:

    我很笨。我需要删除:data=number_of_debates_from_1803_1910

    【讨论】:

      猜你喜欢
      • 2022-01-04
      • 2017-07-06
      • 2014-05-24
      • 1970-01-01
      • 2017-05-20
      • 1970-01-01
      • 2021-03-22
      • 1970-01-01
      • 2015-04-08
      相关资源
      最近更新 更多