Drag-and-drop control for the order of a categorical axis
Source:R/level_order.R
level_order_input.RdA shinyjqui::orderInput() laid out to fill one organize_inputs() grid
cell, listing the levels of a categorical column as buttons that can be
dragged into the order they should be plotted in. Its value is the levels in
their current order, a character vector.
Arguments
- inputId
The input ID, namespaced as for any other input (e.g.
ns("x.order")).- label
The label shown above the control.
- items
Character vector of levels to show, in order, typically from
level_order_choices().NULLor empty renders an empty, hidden control.- tooltip
Optional tooltip text shown on hover.
- width
The CSS width of the control.
Details
The control hides its grid cell whenever it has no items, which is how
setup_level_order() takes it off screen for a column it cannot order (a
numeric one, or one with more levels than are practical to drag). A cell hidden
with hide_input() stays hidden either way.
Examples
if (FALSE) { # interactive()
level_order_input("x.order", "X Order", items = c("Healthy", "Disease"))
# The items for a column of a data frame, in the order they are drawn by default
level_order_input("x.order", "X Order",
items = level_order_choices(example_iris, "Species")
)
}