sortableLegend = function (colorOptions) {
const legend = Plot.legend({ color: colorOptions });
function onUpdate() {
const value = [];
for (let span of legend.querySelectorAll("span")) {
value.push(span.__data__);
}
legend.value = value;
legend.dispatchEvent(new CustomEvent("input"));
}
onUpdate();
sortable.create(legend, { onUpdate });
return legend;
}