async function navio(data, _options = {}) {
const options = {
height: 300,
attribs: undefined,
x0: 0,
y0: 100,
maxNumDistictForCategorical: 10,
maxNumDistictForOrdered: 90,
howManyItemsShouldSearchForNotNull: 100,
margin: 10,
levelsSeparation: 40,
divisionsColor: "white",
levelConnectionsColor: "rgba(205, 220, 163, 0.5)",
divisionsThreshold: 4,
fmtCounts: d3.format(",.0d"),
legendFont: "14px sans-serif",
nestedFilters: true,
showAttribTitles: true,
attribWidth: 15,
attribRotation: -45,
attribFontSize: 13,
attribFontSizeSelected: 32,
filterFontSize: 10,
tooltipFontSize: 12,
tooltipBgColor: "#b2ddf1",
tooltipMargin: 50,
tooltipArrowSize: 10,
digitsForText: 2,
addAllAttribsRecursionLevel: Infinity, // How many levels depth do we keep on adding nested attributes
addAllAttribsIncludeObjects: true, // Should addAllAttribs include objects
addAllAttribsIncludeArrays: true, // Should addAllAttribs include arrays
nullColor: "#ffedfd", // Color for null values
defaultColorInterpolator: d3.interpolateBlues,
defaultColorInterpolatorDate: d3.interpolatePurples,
defaultColorInterpolatorDiverging: d3.interpolateBrBG,
defaultColorInterpolatorOrdered: d3.interpolateOranges,
defaultColorInterpolatorText: d3.interpolateGreys,
defaultColorRangeBoolean: ["#a1d76a", "#e9a3c9", "white"], //true false null
defaultColorRangeSelected: ["white", "#b5cf6b"],
defaultColorCategorical: d3.schemeCategory10,
showSelectedAttrib: true, // Display the attribute that shows if a row is selected
showSequenceIDAttrib: true, // Display the attribute with the sequence ID
..._options
};
let div = html`<div style="display:block; overflow-x:scroll"></div>`;
// Create the navio
const nv = navio_npm(d3.select(div), options.height);
for (let opt in options) {
if (opt === "id") {
nv.id(options[opt]);
} else if (opt !== "attribs") {
nv[opt] = options[opt];
}
}
// Add the data
nv.data(data);
if (options.attribs) {
nv.addAllAttribs(options.attribs);
} else {
nv.addAllAttribs();
}
const widget = ReactiveWidget(div, {
value: data,
showValue
});
function showValue() {
// TODO update navio selection
// nv.data(data);
// nv.addAllAttribs(options.attribs);
// nv.hardUpdate();
}
nv.updateCallback(() => {
widget.setValue(nv.getVisible());
// div.value = nv.getVisible();
// div.dispatchEvent(new Event("input", { bubbles: true }));
// notify(div);
});
showValue();
// widget.addEventListener("input", () => {
// showValue();
// });
// div.value = data;
widget.nv = nv;
return widget;
}