I’ve been struggling to create a dropdown menu that works. I can physically make it, but it doesn’t change my data. I’ve tried a number of different solutions, including this one. I can make that example work fine, but for some reason, I can’t convert it into what I want to show. The output graph looks like:
I want to show a dropdown that breaks the countries into the top 10 by GDP, the top 25 by GDP, and then one choice (the default) that shows all of the countries.
The code I have to create the graph is:
size <- list(
size = 10
)
a <- list(
title = “”,
tickangle = -45,
tickfont = size
)
asian_gdp %>%
plot_ly(type = “bar”,
x = ~Country,
y = ~GDP ($M)
,
marker = list(color = “rgb(158,202,225)”,
line = list(color = “blue”, width = 1.0))
) %>%
layout(title = “”,
xaxis = a,
yaxis = list(title = “GDP ($M)”),
autosize = F,
height = 600,
width = 900,
margin = list(r = 10,
l = 10,
t = 20)
)
Can anyone assist with this? Many thanks in advance!
(If you want to try with the actual data, here it is trimmed down to just the two columns needed for the output.)