vue-data-ui
Version:
A user-empowering data visualization Vue 3 components library for eloquent data storytelling
79 lines (78 loc) • 2.67 kB
JavaScript
import { ref as p, watch as m, resolveComponent as x, createElementBlock as o, openBlock as e, Fragment as r, renderList as y, createCommentVNode as l, createElementVNode as h, createBlock as f } from "vue";
const P = ["x1", "y1", "x2", "y2", "stroke", "stroke-width"], v = ["x1", "y1", "x2", "y2", "stroke", "stroke-width"], C = {
__name: "RecursiveLinks",
props: {
dataset: {
type: Array,
default: () => []
},
color: {
type: String,
default: "#DDDDDD"
},
backgroundColor: {
type: String,
default: "#FFFFFF"
}
},
setup(n) {
const g = n, c = p([]);
return m(
() => g.dataset,
(i) => {
const u = i || [];
u.forEach((a) => {
a.nodes && a.nodes.length > 0 && a.nodes.forEach((t) => {
t.ancestor !== a && (t.ancestor = a);
});
}), c.value = u;
},
{ immediate: !0 }
), (i, u) => {
const a = x("RecursiveLinks", !0);
return e(), o(r, null, [
(e(!0), o(r, null, y(c.value, (t, k) => (e(), o(r, {
key: `level_${k}`
}, [
t.polygonPath && t.polygonPath.coordinates ? (e(!0), o(r, { key: 0 }, y(t.polygonPath.coordinates, (s, d) => (e(), o(r, {
key: `node_${k}_${d}`
}, [
t.ancestor && t.ancestor.polygonPath ? (e(), o(r, { key: 0 }, [
h("line", {
x1: s.x,
y1: s.y,
x2: t.ancestor.polygonPath.coordinates[0].x,
y2: t.ancestor.polygonPath.coordinates[0].y,
stroke: n.backgroundColor,
"stroke-width": t.circleRadius / 1.5
}, null, 8, P),
h("line", {
x1: s.x,
y1: s.y,
x2: t.ancestor.polygonPath.coordinates[0].x,
y2: t.ancestor.polygonPath.coordinates[0].y,
stroke: n.color,
"stroke-width": t.circleRadius / 2
}, null, 8, v)
], 64)) : l("", !0)
], 64))), 128)) : l("", !0)
], 64))), 128)),
(e(!0), o(r, null, y(c.value, (t) => (e(), o(r, {
key: `children_${t.uid || t.name}`
}, [
t.polygonPath && t.polygonPath.coordinates ? (e(), o(r, { key: 0 }, [
t.nodes && t.nodes.length > 0 ? (e(), f(a, {
key: 0,
dataset: t.nodes,
color: n.color,
backgroundColor: n.backgroundColor
}, null, 8, ["dataset", "color", "backgroundColor"])) : l("", !0)
], 64)) : l("", !0)
], 64))), 128))
], 64);
};
}
};
export {
C as default
};