I have a plotly chart that has a dropdown menu. I have seen examples where the number of entries in the dropdown list is constant. How does one create a dropdown menu with a variable number of entries?
Two examples:
... layout( title=grTitle, yaxis = yAxis, xaxis=xAxis,
showlegend = FALSE, hoverlabel = "right", margin = list(l = 50, r = 50, t = 60, b = 100),
annotations = list(text = outCap,
font = list(size = 12), showarrow = FALSE, xref = 'paper', x = 0, yref = 'paper', y = -0.4) ,
updatemenus = list(
list(
type = 'dropdown',
active = 0,
buttons = list(
list(method = "restyle",
args = list("transforms[0].value", unique(f.ctyDISL_PLT$geoname)[1]),
label = unique(f.ctyDISL_PLT$geoname)[1]),
list(method = "restyle",
args = list("transforms[0].value", unique(f.ctyDISL_PLT$geoname)[2]),
label = unique(f.ctyDISL_PLT$geoname)[2]),
list(method = "restyle",
args = list("transforms[0].value", unique(f.ctyDISL_PLT$geoname)[3]),
label = unique(f.ctyDISL_PLT$geoname)[3]))
Is there a way to set the value of the "updatemenus" to the results of a function?
Like this:
...layout( title=grTitle, yaxis = yAxis, xaxis=xAxis,
showlegend = FALSE, hoverlabel = "right", margin = list(l = 50, r = 50, t = 60, b = 100),
annotations = list(text = outCap,
font = list(size = 12), showarrow = FALSE, xref = 'paper', x = 0, yref = 'paper', y = -0.4),
updatemenus = genDropdown(...)
TIA
AB