0

I have a plotly bar chart that I am rendering in Shiny. When I click on a bar, I would like to highlight it. My current code, however, returns the error: Error: 'options' must be a fully named list, or have no names (NULL).

Code:

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) 
  

Data:

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

I find plotly and Shiny errors to be pretty confusing, so help is very appreciated.

1 Answer 1

1

I'm dumb. I needed to delete: data=number_of_debates_from_1803_1910.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.