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
level_order_input("x.order", "X Order", items = c("Healthy", "Disease"))
#> <div class="vizmodules-level-order">
#> <label class="control-label" id="x.order-label" for="x.order">X Order</label>
#> <div id="x.order" style="width: 100%; font-size: 0px; min-height: 25px;" class="jqui-orderInput">
#> <div data-value="Healthy" class="btn btn-default" style="margin: 1px">Healthy</div>
#> <div data-value="Disease" class="btn btn-default" style="margin: 1px">Disease</div>
#> </div>
#> <iframe srcdoc="<p>cant catch me</p>" class="jqui_self_cleaning_script" style="width:0;height:0;border:none;display:none !important" onload="$(function(){setTimeout(function(){shinyjqui.msgCallback({"ui":"[id='x.order']","type":"interaction","func":"sortable","operation":"enable","options":{"connectWith":"false","remove":"function(e, ui){if(!$(e.target).children().length)$(e.target).empty();}"},"debug":false,"_js_idx":{"ui":false,"type":false,"func":false,"operation":false,"options":{"connectWith":false,"remove":true},"debug":false}}); $(".jqui_self_cleaning_script").remove();}, 10);});"></iframe>
#> </div>
# 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")
)
#> <div class="vizmodules-level-order">
#> <label class="control-label" id="x.order-label" for="x.order">X Order</label>
#> <div id="x.order" style="width: 100%; font-size: 0px; min-height: 25px;" class="jqui-orderInput">
#> <div data-value="setosa" class="btn btn-default" style="margin: 1px">setosa</div>
#> <div data-value="versicolor" class="btn btn-default" style="margin: 1px">versicolor</div>
#> <div data-value="virginica" class="btn btn-default" style="margin: 1px">virginica</div>
#> </div>
#> <iframe srcdoc="<p>cant catch me</p>" class="jqui_self_cleaning_script" style="width:0;height:0;border:none;display:none !important" onload="$(function(){setTimeout(function(){shinyjqui.msgCallback({"ui":"[id='x.order']","type":"interaction","func":"sortable","operation":"enable","options":{"connectWith":"false","remove":"function(e, ui){if(!$(e.target).children().length)$(e.target).empty();}"},"debug":false,"_js_idx":{"ui":false,"type":false,"func":false,"operation":false,"options":{"connectWith":false,"remove":true},"debug":false}}); $(".jqui_self_cleaning_script").remove();}, 10);});"></iframe>
#> </div>