Published
Edited
Sep 30, 2021
Importers
Insert cell
Insert cell
viewof attrs = frepr(function attrs(selection, attributes) {
Object.entries(attributes).map(([key, value]) => {
selection.attr(key, value);
});
return selection;
})
Insert cell
viewof styles = frepr(function styles(selection, styles) {
Object.entries(styles).map(([key, value]) => {
selection.style(key, value);
});
})
Insert cell
viewof calls = frepr(function calls(selection, calls) {
calls.map((call) => {
if (Array.isArray(call)) selection.call(...call);
else selection.call(call);
});
})
Insert cell
viewof eachs = frepr(function eachs(selection, eachs) {
eachs.map((each) => {
if (Array.isArray(each)) selection.each(...each);
else selection.each(each);
});
})
Insert cell
viewof properties = frepr(function properties(selection, properties) {
Object.entries(properties).map(([key, value]) => {
selection.property(key, value);
});
})
Insert cell
viewof props = frepr(properties, { name: "props" })
Insert cell
viewof build = frepr(function build(
{ append, classed, text, style, call, property, each, ...attributes },
group
) {
function prepare(group) {
const _el = group.append(append).call(attrs, attributes);
if (classed) _el.classed(classed, true); // wip on this part i suppose
if (text) _el.text(text);
if (style) styles(_el, style);
if (property) properties(_el, property);

if (call) {
if (Array.isArray(call)) calls(_el, call);
else call(_el);
}

if (each) {
if (Array.isArray(each)) eachs(_el, each);
else each(_el);
}

return _el;
}

return group ? prepare(group) : prepare;
})
Insert cell
viewof construct = frepr(function construct(group, options) {
return build(options, group);
})
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more