r-单击时尝试高亮显示时出现绘图错误



我有一个在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

我发现情节和闪光的错误非常令人困惑,所以我们非常感谢您的帮助。

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

最新更新