UNPKG

vue-data-ui

Version:

A user-empowering data visualization Vue 3 components library for eloquent data storytelling

1,128 lines (1,124 loc) • 51.7 kB
import { useCssVars as io, defineAsyncComponent as H, ref as d, shallowRef as it, toRefs as co, watch as xe, computed as y, onMounted as ct, onBeforeUnmount as dt, createElementBlock as i, openBlock as s, unref as v, normalizeStyle as N, normalizeClass as R, createBlock as G, createCommentVNode as h, renderSlot as b, createElementVNode as I, withCtx as p, normalizeProps as z, guardReactiveProps as j, createSlots as Ie, withModifiers as vt, createVNode as fe, Fragment as U, renderList as Q, mergeProps as ht, toDisplayString as Z, Teleport as vo, resolveDynamicComponent as ho, createTextVNode as ft, nextTick as bt } from "vue"; import { c as _e, t as fo, i as bo, j as be, o as go, g as gt, l as po, k as mo, m as yo, X as ko, x as Co, d as Pe, as as Ao, au as $o, v as wo, r as Mo, a as xo } from "./lib-2iaAPQ_c.js"; import { t as Io, u as _o } from "./useResponsive-DfdjqQps.js"; import { u as Po, a as Be } from "./useNestedProp-2p4Tjzc8.js"; import { u as Bo, B as So } from "./BaseScanner-BMpwQAfz.js"; import { u as To } from "./usePrinter-ChVMpU2f.js"; import { u as Eo } from "./useSvgExport-ByUukOZt.js"; import { u as Do } from "./useThemeCheck-DGJ31Vi5.js"; import { u as Fo } from "./useUserOptionState-BIvW1Kz7.js"; import { u as Oo } from "./useChartAccessibility-9icAAmYg.js"; import Lo from "./img-CqYIrJ8I.js"; import { _ as No } from "./Shape-12_eh8zD.js"; import Ro from "./Title-DSOZzIrU.js"; import zo from "./Legend-D2xmnFPH.js"; import { _ as jo } from "./_plugin-vue_export-helper-CHgC5LLL.js"; const pt = { table: { th: { backgroundColor: "#1A1A1A", color: "#CCCCCC" }, td: { backgroundColor: "#1A1A1A", color: "#CCCCCC" } }, style: { chart: { backgroundColor: "#1A1A1A", color: "#CCCCCC", title: { color: "#CCCCCC", subtitle: { color: "#757575" } }, legend: { backgroundColor: "#1A1A1A", color: "#CCCCCC" }, arcs: { stroke: "#1A1A1A", labels: { color: "#CCCCCC" } }, ribbons: { stroke: "#1A1A1A", labels: { color: "#CCCCCC", connector: { stroke: "#CCCCCC" }, marker: { stroke: "#1A1A1A" } } } } } }, mt = { table: { th: { backgroundColor: "#FFF8E1", color: "#424242" }, td: { backgroundColor: "#FFF8E1", color: "#424242" } }, style: { chart: { backgroundColor: "#FFF8E1", color: "#424242", title: { color: "#424242", subtitle: { color: "#757575" } }, legend: { backgroundColor: "#FFF8E1", color: "#424242" }, arcs: { stroke: "#FFF8E1", labels: { color: "#424242" } }, ribbons: { stroke: "#FFF8E1", labels: { color: "#424242", connector: { stroke: "#424242" }, marker: { stroke: "#FFF8E1" } } } } } }, yt = { table: { th: { backgroundColor: "#FFF8E1", color: "#424242" }, td: { backgroundColor: "#FFF8E1", color: "#424242" } }, style: { chart: { backgroundColor: "#1E1E1E", color: "#BDBDBD", title: { color: "#FFF8E1", subtitle: { color: "#BDBDBD" } }, legend: { backgroundColor: "#1E1E1E", color: "#BDBDBD" }, arcs: { stroke: "#1E1E1E", labels: { color: "#BDBDBD" } }, ribbons: { stroke: "#1E1E1E", labels: { color: "#BDBDBD", connector: { stroke: "#BDBDBD" }, marker: { stroke: "#1E1E1E" } } } } } }, kt = { table: { th: { backgroundColor: "#1A1A1A", color: "#99AA99" }, td: { backgroundColor: "#1A1A1A", color: "#AACCAA" } }, style: { chart: { backgroundColor: "#1A1A1A", color: "#99AA99", title: { color: "#66CC66", subtitle: { color: "#99AA99" } }, legend: { backgroundColor: "#1A1A1A", color: "#99AA99" }, arcs: { stroke: "#1A1A1A", labels: { color: "#99AA99" } }, ribbons: { stroke: "#1A1A1A", labels: { color: "#99AA99", connector: { stroke: "#99AA99" }, marker: { stroke: "#1A1A1A" } } } } } }, Ct = { table: { th: { backgroundColor: "#fbfafa", color: "#8A9892" }, td: { backgroundColor: "#fbfafa", color: "#8A9892" } }, style: { chart: { backgroundColor: "#fbfafa", color: "#8A9892", title: { color: "#8A9892", subtitle: { color: "#99AA99" } }, legend: { backgroundColor: "#fbfafa", color: "#8A9892" }, arcs: { stroke: "#fbfafa", labels: { color: "#8A9892" } }, ribbons: { stroke: "#fbfafa", labels: { color: "#8A9892", connector: { stroke: "#8A9892" }, marker: { stroke: "#fbfafa" } } } } } }, At = { table: { th: { backgroundColor: "#fbfafa", color: "#8A9892" }, td: { backgroundColor: "#fbfafa", color: "#8A9892" } }, style: { chart: { backgroundColor: "#f6f6fb", color: "#50606C", title: { color: "#50606C", subtitle: { color: "#718890" } }, legend: { backgroundColor: "#f6f6fb", color: "#50606C" }, arcs: { stroke: "#f6f6fb", labels: { color: "#50606C" } }, ribbons: { stroke: "#f6f6fb", labels: { color: "#50606C", connector: { stroke: "#50606C" }, marker: { stroke: "#f6f6fb" } } } } } }, $t = { default: {}, dark: pt, celebration: mt, celebrationNight: yt, hack: kt, zen: Ct, concrete: At }, Da = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, celebration: mt, celebrationNight: yt, concrete: At, dark: pt, default: $t, hack: kt, zen: Ct }, Symbol.toStringTag, { value: "Module" })), Uo = ["id"], Xo = ["id"], Vo = ["xmlns", "viewBox"], Go = ["width", "height"], Yo = { key: 1 }, Wo = ["id", "d"], qo = { key: 2 }, Ho = ["transform"], Qo = ["d", "fill", "stroke", "stroke-width", "onMouseenter", "onMouseleave", "onClick"], Zo = ["d", "fill", "stroke", "stroke-width"], Jo = ["d", "fill"], Ko = ["d", "fill", "stroke", "stroke-width", "onMouseenter", "onClick", "onMouseleave"], ea = ["d", "fill", "stroke", "stroke-width"], ta = ["d", "fill", "stroke", "stroke-width"], oa = ["d", "fill", "stroke", "stroke-width"], aa = { key: 0 }, la = ["x1", "y1", "x2", "y2", "stroke", "stroke-width"], na = ["x1", "y1", "x2", "y2", "stroke", "stroke-width"], ra = ["cx", "cy", "r", "stroke", "stroke-width", "fill"], sa = ["transform", "fill", "text-anchor", "font-size", "font-weight"], ua = { key: 1 }, ia = ["font-size", "font-weight", "fill"], ca = ["href"], da = ["transform", "text-anchor", "font-size", "font-weight", "fill", "innerHTML"], va = { key: 4, class: "vue-data-ui-watermark" }, ha = ["id"], fa = ["onClick"], ba = { key: 7, "data-dom-to-png-ignore": "", class: "reset-wrapper" }, ga = { style: { "text-align": "right", width: "100%" } }, pa = { __name: "vue-ui-chord", props: { dataset: { type: Object, default() { return {}; } }, config: { type: Object, default() { return {}; } } }, emits: ["selectLegend", "selectGroup", "selectRibbon"], setup(wt, { expose: Mt, emit: xt }) { io((e) => ({ v0e648af8: e.slicerColor })); const It = H(() => import("./vue-ui-accordion-Dm0mNNKQ.js")), Se = H(() => import("./BaseIcon-CbVDYv89.js")), _t = H(() => import("./DataTable-BT_IeqPe.js")), Pt = H(() => import("./PackageVersion-Br3DrrFh.js")), Bt = H(() => import("./PenAndPaper-CvyKWfNl.js")), St = H(() => import("./UserOptions-BQO4YFrn.js")), Tt = H(() => import("./BaseDraggableDialog-Z5LfhW87.js")), { vue_ui_chord: Et } = Po(), { isThemeValid: Dt, warnInvalidTheme: Ft } = Do(), T = wt, se = xt, O = d(!!T.dataset && Object.hasOwn(T.dataset, "matrix")), $ = d(_e()), w = d(null), k = d(null), g = d(null), Te = d(0), E = d(null), Ee = d(null), De = d(null), Fe = d(null), Oe = d(null), ge = d(0), pe = d(0), me = d(0), J = d(!1), X = it(null), K = it(null), Le = d(!1), te = d(null), ye = d(null), t = d(Ce()), { loading: Ne, FINAL_DATASET: M, manualLoading: oe } = Bo({ ...co(T), FINAL_CONFIG: t, prepareConfig: Ce, callback: () => { Promise.resolve().then(async () => { await bt(), Y.value.showTable = t.value.table.show; }); }, skeletonDataset: { matrix: [ [12e3, 6e3, 9e3, 3e3], [2e3, 1e4, 2e3, 6001], [8e3, 1600, 8e3, 8001], [1e3, 1e3, 1e3, 7001] ], labels: [], colors: ["#DBDBDB", "#C4C4C4", "#ADADAD", "#969696"] }, skeletonConfig: fo({ defaultConfig: t.value, userConfig: { useCssAnimation: !1, userOptions: { show: !1 }, table: { show: !1 }, style: { chart: { backgroundColor: "#99999930", legend: { backgroundColor: "transparent" }, arcs: { stroke: "#6A6A6A", labels: { show: !1 } }, ribbons: { stroke: "#6A6A6A", underlayerOpacity: 0, labels: { show: !1 } } } } } }) }), { userOptionsVisible: ke, setUserOptionsVisibility: Re, keepUserOptionState: ze } = Fo({ config: t.value }), { svgRef: ee } = Oo({ config: t.value.style.chart.title }), { isPrinting: je, isImaging: Ue, generatePdf: Xe, generateImage: Ve } = To({ elementId: `chord_${$.value}`, fileName: t.value.style.chart.title.text || "vue-ui-chord", options: t.value.userOptions.print }), Y = d({ showTable: t.value.table.show }); function Ce() { const e = Be({ userConfig: T.config, defaultConfig: Et }), a = e.theme; if (!a) return e; if (!Dt.value(e)) return Ft(e), e; const o = Be({ userConfig: $t[a] || T.config, defaultConfig: e }), l = Be({ userConfig: T.config, defaultConfig: o }); return { ...l, customPalette: l.customPalette.length ? l.customPalette : bo[a] || be }; } xe(() => T.config, (e) => { Ne.value || (t.value = Ce()), ke.value = !t.value.userOptions.showOnChartHover, Ae(), ge.value += 1, pe.value += 1, me.value += 1, _.value = t.value.initialRotation, Y.value.showTable = t.value.table.show; }, { deep: !0 }); const Ge = y(() => t.value.debug); xe(() => T.dataset, () => { Ye(), Ae(), ge.value += 1, pe.value += 1, me.value += 1; }); function Ye() { if (go(T.dataset)) { gt({ componentName: "VueUiChord", type: "dataset", debug: Ge.value }), O.value = !1, oe.value = !0; return; } const e = po({ datasetObject: T.dataset, requiredAttributes: ["matrix"] }); if (e.length) { e.forEach((r) => { gt({ componentName: "VueUiChord", type: "datasetAttribute", property: r, debug: Ge.value }); }), O.value = !1, oe.value = !0; return; } const a = T.dataset.matrix; if (!Array.isArray(a) || a.length < 2) { console.warn(`VueUiChord: dataset.matrix requires a minimum of 2 datapoints, for example: matrix:[ [1, 1], [1, 1] ]`), O.value = !1, oe.value = !0; return; } const o = a.length, l = a.findIndex((r) => !Array.isArray(r) || r.length !== o); if (l !== -1) { console.warn( `VueUiChord - Invalid matrix: dataset.matrix at index ${l} has ${Array.isArray(a[l]) ? a[l].length : "NaN"} elements instead of the required ${o} dataset.matrix[${l}] = [${Array.isArray(a[l]) ? a[l].toString() : "invalid"}]` ), O.value = !1, oe.value = !0; return; } O.value = !0, oe.value = !1; } function Ae() { if (Ye(), t.value.responsive) { const e = Io(() => { const { width: a, height: o, heightNoTitle: l, heightSource: r, heightTitle: n, heightLegend: u } = _o({ chart: E.value, title: t.value.style.chart.title.text ? Ee.value : null, legend: t.value.style.chart.legend.show ? De.value : null, source: Fe.value, noTitle: Oe.value }), f = n + u + r + l; a < o ? E.value.style.width = "100%" : (E.value.style.height = "100%", ee.value.style.height = `calc(100% - ${f}px)`); }, 100); X.value && (K.value && X.value.unobserve(K.value), X.value.disconnect()), X.value = new ResizeObserver(e), K.value = E.value.parentNode, X.value.observe(K.value), e(); } We.value = setTimeout(() => { J.value = !0; }, 500); } function Ot() { if (!M.value || !Object.hasOwn(M.value, "matrix") || M.value.matrix.length < 2) { console.warn(`VueUiChord: dataset.matrix requires a minimum of 2 datapoints, for example: matrix:[ [1, 1], [1, 1] ]`), O.value = !1; return; } M.value.matrix.forEach((e, a) => { e.length !== M.value.matrix.length && (console.warn(`VueUiChord - Invalid matrix: dataset.matrix at index ${a} has ${e.length} elements instead of the required ${M.value.matrix.length} dataset.matrix[${a}] = [${e.toString()}] has a length of ${e.length} but should have the same length as the matrix itself (${M.value.matrix.length})`), O.value = !1); }); } const We = d(null); ct(() => { Le.value = !0, Ae(); }); const D = d({ height: 600, width: 600 }), Lt = y(() => t.value.userOptions.show && !t.value.style.chart.title.text), Nt = y(() => mo(t.value.customPalette)), m = y(() => ({ inner: D.value.width * 0.3 * t.value.style.chart.arcs.innerRadiusRatio, outer: D.value.width * 0.34 * t.value.style.chart.arcs.outerRadiusRatio })), Rt = y(() => t.value.style.chart.arcs.padAngle / 100), C = y(() => ({ matrix: M.value.matrix ?? [[0]], labels: M.value.labels ?? [""], colors: M.value.colors && Array.isArray(M.value.colors) && M.value.colors.length ? M.value.colors.map((e) => yo(e)) : M.value.matrix.map((e, a) => Nt.value[a] || be[a] || be[a % be.length]) })); function zt(e, a) { const o = e.length, l = m.value.inner, r = new Array(o).fill(0); let n = 0; for (let c = 0; c < o; c += 1) for (let A = 0; A < o; A += 1) r[c] += e[c][A], n += e[c][A]; const u = (2 * Math.PI - a * o) / n, f = []; let P = 0; for (let c = 0; c < o; c += 1) { const A = P, S = A + r[c] * u; f.push({ index: c, pattern: `pattern_${$.value}_${c}`, startAngle: A, endAngle: S, name: C.value.labels[c], id: _e(), color: C.value.colors[c], proportion: r[c] / n }), P = S + a; } const B = []; for (let c = 0; c < o; c += 1) { const A = e[c].map((F, V) => ({ j: V, v: F })); A.sort((F, V) => V.v - F.v); let S = f[c].startAngle; for (const { j: F, v: V } of A) { const q = S, re = q + V * u; B.push({ index: c, subIndex: F, pattern: `pattern_${$.value}_${c}`, startAngle: q, endAngle: re, value: V, groupName: C.value.labels[c], groupId: f[c].id, groupColor: C.value.colors[c], midAngle: (q + re) / 2, midBaseX: Math.cos((q + re) / 2 - Math.PI / 2) * l, midBaseY: Math.sin((q + re) / 2 - Math.PI / 2) * l }), S = re; } } const L = []; for (const c of B) { const A = B.find( (S) => S.index === c.subIndex && S.subIndex === c.index ); L.push({ source: c, target: A, id: _e() }); } return { groups: f, chords: L }; } const x = y(() => { const e = zt(C.value.matrix, Rt.value); return Ot(), e.chords.sort( (a, o) => Math.max(o.source.value, o.target.value) - Math.max(a.source.value, a.target.value) ), e; }), jt = y(() => { const e = m.value.outer + t.value.style.chart.ribbons.labels.offset + 12, o = t.value.style.chart.ribbons.labels.fontSize * 0.6, l = []; if (k.value) { const n = k.value; if (n.source.value) { const u = String(n.source.value); l.push({ id: n.id + "-src", theta: n.source.midAngle, w: u.length * o / e, midBaseX: n.source.midBaseX, midBaseY: n.source.midBaseY, groupColor: n.source.groupColor, value: n.source.value }); } if (n.target && n.target.value && n.target.value !== n.source.value) { const u = String(n.target.value); l.push({ id: n.id + "-tgt", theta: n.target.midAngle, w: u.length * o / e, midBaseX: n.target.midBaseX, midBaseY: n.target.midBaseY, groupColor: n.target.groupColor, value: n.target.value }); } return l; } function r(n) { x.value.chords.filter((u) => u.source.groupId === n && u.source.value).forEach((u) => { { const f = String(u.source.value); l.push({ id: u.id + "-src", theta: u.source.midAngle, w: f.length * o / e, midBaseX: u.source.midBaseX, midBaseY: u.source.midBaseY, groupColor: u.source.groupColor, value: u.source.value }); } if (u.target && u.target.value && u.target.value !== u.source.value) { const f = String(u.target.value); l.push({ id: u.id + "-tgt", theta: u.target.midAngle, w: f.length * o / e, midBaseX: u.target.midBaseX, midBaseY: u.target.midBaseY, groupColor: u.target.groupColor, value: u.target.value }); } }); } return g.value && r(g.value), w.value && r(w.value.id), l; }), Ut = y(() => { const e = jt.value.map((r) => ({ ...r })).sort((r, n) => r.theta - n.theta), a = t.value.style.chart.ribbons.labels.minSeparationDeg * Math.PI / 180; let o = !0, l = 0; for (; o && l++ < 10; ) { o = !1; for (let f = 1; f < e.length; f += 1) { const P = e[f - 1], B = e[f], L = P.theta + P.w + a; B.theta < L && (B.theta = L, o = !0); } const r = e[0], n = e[e.length - 1], u = n.theta + n.w + a - 2 * Math.PI; r.theta < u && (r.theta = u, o = !0); } return e; }); function qe(e, a, o, l) { const r = e - Math.PI / 2, n = a - Math.PI / 2, u = Math.cos(r) * o, f = Math.sin(r) * o, P = Math.cos(n) * o, B = Math.sin(n) * o, L = Math.cos(n) * l, c = Math.sin(n) * l, A = Math.cos(r) * l, S = Math.sin(r) * l, F = a - e > Math.PI ? 1 : 0; return `M${u},${f} A${o},${o} 0 ${F} 1 ${P},${B} L${L},${c} A${l},${l} 0 ${F} 0 ${A},${S} Z`; } function ue(e, a) { const o = m.value.inner, l = e.startAngle - Math.PI / 2, r = e.endAngle - Math.PI / 2, n = a.startAngle - Math.PI / 2, u = a.endAngle - Math.PI / 2, f = Math.cos(l) * o, P = Math.sin(l) * o, B = Math.cos(r) * o, L = Math.sin(r) * o, c = Math.cos(n) * o, A = Math.sin(n) * o, S = Math.cos(u) * o, F = Math.sin(u) * o, V = e.endAngle - e.startAngle > Math.PI ? 1 : 0, q = a.endAngle - a.startAngle > Math.PI ? 1 : 0; return `M${f},${P}A${o},${o} 0 ${V} 1 ${B},${L}Q0,0 ${c},${A}A${o},${o} 0 ${q} 1 ${S},${F}Q0,0 ${f},${P}Z`; } const He = y(() => _.value * Math.PI / 180); function Xt(e) { return (e.startAngle + e.endAngle) / 2; } function Vt(e) { return ((Xt(e) + He.value) % (2 * Math.PI) + 2 * Math.PI) % (2 * Math.PI); } function Gt(e) { let a = e + He.value; return a = (a % (2 * Math.PI) + 2 * Math.PI) % (2 * Math.PI), a > Math.PI ? "end" : "start"; } function Yt(e) { const a = e - Math.PI / 2, o = Math.cos(a) * (m.value.outer + t.value.style.chart.arcs.labels.offset + 24), l = Math.sin(a) * (m.value.outer + t.value.style.chart.arcs.labels.offset + 24); return `translate(${o},${l})`; } function Wt(e, a, o) { const l = e - Math.PI / 2, r = a - Math.PI / 2, n = Math.cos(l) * o, u = Math.sin(l) * o, f = Math.cos(r) * o, P = Math.sin(r) * o, B = a - e > Math.PI ? 1 : 0; return `M${n},${u} A${o},${o} 0 ${B} 1 ${f},${P}`; } const _ = d(t.value.initialRotation), ae = d(!1); let Qe = 0, Ze = 0; function Je(e) { const a = ee.value.getBoundingClientRect(), o = a.left + a.width / 2, l = a.top + a.height / 2, r = e.clientX ?? e.touches[0].clientX, n = e.clientY ?? e.touches[0].clientY; return Math.atan2(n - l, r - o); } function Ke(e) { !t.value.enableRotation || le.value || (e.preventDefault(), ae.value = !0, Qe = _.value, Ze = Je(e)); } function ie(e) { if (!ae.value) return; const a = Je(e); _.value = Qe + (a - Ze) * 180 / Math.PI; } function ce() { ae.value = !1; } function et(e) { return xo( t.value.style.chart.ribbons.labels.formatter, e, Pe({ p: t.value.style.chart.ribbons.labels.prefix, v: e, s: t.value.style.chart.ribbons.labels.suffix, r: t.value.style.chart.ribbons.labels.rounding }) ); } ct(() => { window.addEventListener("mousemove", ie), window.addEventListener("mouseup", ce), window.addEventListener("touchmove", ie, { passive: !1 }), window.addEventListener("touchend", ce); }), dt(() => { window.removeEventListener("mousemove", ie), window.removeEventListener("mouseup", ce), window.removeEventListener("touchmove", ie), window.removeEventListener("touchend", ce), clearTimeout(We.value), X.value && (K.value && X.value.unobserve(K.value), X.value.disconnect()); }); const de = d(!1); function tt(e) { de.value = e, Te.value += 1; } function qt(e, a) { t.value.events.datapointEnter && t.value.events.datapointEnter({ datapoint: e, seriesIndex: a }), !g.value && (w.value = e); } function Ht(e, a) { w.value = null, t.value.events.datapointLeave && t.value.events.datapointLeave({ datapoint: e, seriesIndex: a }); } function Qt(e, a) { se("selectGroup", e), t.value.events.datapointClick && t.value.events.datapointClick({ datapoint: e, seriesIndex: a }); } function Zt(e, a) { t.value.events.datapointEnter && t.value.events.datapointEnter({ datapoint: e, seriesIndex: a }), !g.value && (k.value = e); } function Jt(e, a) { k.value = null, t.value.events.datapointLeave && t.value.events.datapointLeave({ datapoint: e, seriesIndex: a }); } function Kt(e, a) { se("selectRibbon", e), t.value.events.datapointClick && t.value.events.datapointClick({ datapoint: e, seriesIndex: a }); } function ot(e) { return !g.value && !w.value && !k.value ? 0.8 : (g.value ? g.value === e.source.groupId : w.value ? w.value.id === e.source.groupId : k.value?.id === e.id) ? 1 : 0.1; } function at(e) { return !g.value && !w.value && !k.value || (g.value ? g.value === e.id : w.value ? w.value.id === e.id : [k.value?.source.groupId, k.value?.target.groupId].includes(e.id)) ? 1 : 0.3; } const le = d(!1); function $e() { le.value = !le.value; } function lt() { Y.value.showTable = !Y.value.showTable; } function eo() { return x.value; } const W = d(null); function nt() { const e = t.value.initialRotation; W.value !== null && cancelAnimationFrame(W.value); const a = () => { _.value += (e - _.value) * 0.05, Math.abs(_.value - e) < 0.1 ? (_.value = e, W.value = null) : W.value = requestAnimationFrame(a); }; W.value = requestAnimationFrame(a); } dt(() => { W.value !== null && cancelAnimationFrame(W.value); }); function rt(e) { e === g.value ? (g.value = null, se("selectLegend", null)) : (g.value = e, se("selectLegend", x.value.groups.find((a) => a.id === e))); } const we = y(() => x.value.groups.map((e, a) => ({ name: e.name, color: e.color, shape: "circle", patternIndex: a, pattern: `pattern_${$.value}_${a}`, id: e.id, select: () => rt(e.id), opacity: g.value ? g.value === e.id ? 1 : 0.3 : 1 }))), to = y(() => ({ cy: "chord-div-legend", backgroundColor: t.value.style.chart.legend.backgroundColor, color: t.value.style.chart.legend.color, fontSize: t.value.style.chart.legend.fontSize, paddingBottom: 12, fontWeight: t.value.style.chart.legend.bold ? "bold" : "" })), ve = y(() => { const e = x.value.groups.map((o, l) => ({ name: o.name || l, color: o.color })), a = C.value.matrix; return { head: e, body: a }; }), he = y(() => { const e = [{ name: "", color: null }, ...ve.value.head], a = ve.value.body.map((r, n) => [ ve.value.head[n], ...ve.value.body[n] ]), o = { th: { backgroundColor: t.value.table.th.backgroundColor, color: t.value.table.th.color, outline: t.value.table.th.outline }, td: { backgroundColor: t.value.table.td.backgroundColor, color: t.value.table.td.color, outline: t.value.table.td.outline }, breakpoint: t.value.table.responsiveBreakpoint }; return { colNames: e, head: e, body: a, config: o }; }); function Me(e = null) { bt(() => { const a = C.value.matrix.map((r, n) => [ [C.value.labels[n] || n], r ]), o = [ [t.value.style.chart.title.text], [t.value.style.chart.title.subtitle.text], [ [""], ...C.value.labels.map((r, n) => [r || n]) ] ].concat(a), l = wo(o); e ? e(l) : Mo({ csvContent: l, title: t.value.style.chart.title.text || "vue-ui-chord" }); }); } async function oo({ scale: e = 2 } = {}) { if (!E.value) return; const { width: a, height: o } = E.value.getBoundingClientRect(), l = a / o, { imageUri: r, base64: n } = await Lo({ domElement: E.value, base64: !0, img: !0, scale: e }); return { imageUri: r, base64: n, title: t.value.style.chart.title.text, width: a, height: o, aspectRatio: l }; } function ao(e, a) { return `${C.value.labels[a]}${t.value.style.chart.arcs.labels.showPercentage ? Pe({ p: " (", v: isNaN(e.proportion) ? 0 : e.proportion * 100, s: "%)", r: t.value.style.chart.arcs.labels.roundingPercentage }) : ""}`; } const ne = y(() => { const e = t.value.table.useDialog && !t.value.table.show, a = Y.value.showTable; return { component: e ? Tt : It, title: `${t.value.style.chart.title.text}${t.value.style.chart.title.subtitle.text ? `: ${t.value.style.chart.title.subtitle.text}` : ""}`, props: e ? { backgroundColor: t.value.table.th.backgroundColor, color: t.value.table.th.color, headerColor: t.value.table.th.color, headerBg: t.value.table.th.backgroundColor, isFullscreen: de.value, fullscreenParent: E.value, forcedWidth: Math.min(800, window.innerWidth * 0.8) } : { hideDetails: !0, config: { open: a, maxHeight: 1e4, body: { backgroundColor: t.value.style.chart.backgroundColor, color: t.value.style.chart.color }, head: { backgroundColor: t.value.style.chart.backgroundColor, color: t.value.style.chart.color } } } }; }); xe(() => Y.value.showTable, (e) => { t.value.table.show || (e && t.value.table.useDialog && te.value ? te.value.open() : "close" in te.value && te.value.close()); }); function st() { Y.value.showTable = !1, ye.value && ye.value.setTableIconState(!1); } const lo = y(() => t.value.style.chart.backgroundColor), no = y(() => t.value.style.chart.legend), ro = y(() => t.value.style.chart.title), { exportSvg: so, getSvg: uo } = Eo({ svg: ee, title: ro, legend: no, legendItems: we, backgroundColor: lo }); async function ut({ isCb: e }) { if (e) { const { blob: a, url: o, text: l, dataUrl: r } = await uo(); t.value.userOptions.callbacks.svg({ blob: a, url: o, text: l, dataUrl: r }); } else so(); } return Mt({ getData: eo, getImage: oo, generateCsv: Me, generateImage: Ve, generateSvg: ut, generatePdf: Xe, toggleAnnotator: $e, toggleTable: lt, toggleFullscreen: tt }), (e, a) => (s(), i("div", { ref_key: "chordChart", ref: E, class: R({ "vue-data-ui-component": !0, "vue-ui-chord": !0, "vue-data-ui-wrapper-fullscreen": de.value, "vue-data-ui-responsive": t.value.responsive }), style: N(`font-family:${t.value.style.fontFamily};width:100%; text-align:center;background:${t.value.style.chart.backgroundColor}`), id: `chord_${$.value}`, onMouseenter: a[2] || (a[2] = () => v(Re)(!0)), onMouseleave: a[3] || (a[3] = () => v(Re)(!1)) }, [ t.value.userOptions.buttons.annotator && v(ee) ? (s(), G(v(Bt), { key: 0, color: t.value.style.chart.color, backgroundColor: t.value.style.chart.backgroundColor, active: le.value, svgRef: v(ee), onClose: $e }, { "annotator-action-close": p(() => [ b(e.$slots, "annotator-action-close", {}, void 0, !0) ]), "annotator-action-color": p(({ color: o }) => [ b(e.$slots, "annotator-action-color", z(j({ color: o })), void 0, !0) ]), "annotator-action-draw": p(({ mode: o }) => [ b(e.$slots, "annotator-action-draw", z(j({ mode: o })), void 0, !0) ]), "annotator-action-undo": p(({ disabled: o }) => [ b(e.$slots, "annotator-action-undo", z(j({ disabled: o })), void 0, !0) ]), "annotator-action-redo": p(({ disabled: o }) => [ b(e.$slots, "annotator-action-redo", z(j({ disabled: o })), void 0, !0) ]), "annotator-action-delete": p(({ disabled: o }) => [ b(e.$slots, "annotator-action-delete", z(j({ disabled: o })), void 0, !0) ]), _: 3 }, 8, ["color", "backgroundColor", "active", "svgRef"])) : h("", !0), b(e.$slots, "userConfig", {}, void 0, !0), Lt.value ? (s(), i("div", { key: 1, ref_key: "noTitle", ref: Oe, class: "vue-data-ui-no-title-space", style: "height:36px; width: 100%;background:transparent" }, null, 512)) : h("", !0), t.value.style.chart.title.text ? (s(), i("div", { key: 2, ref_key: "chartTitle", ref: Ee, style: "width:100%;background:transparent;padding-bottom:24px" }, [ (s(), G(Ro, { key: `title_${ge.value}`, config: { title: { cy: "chord-div-title", ...t.value.style.chart.title }, subtitle: { cy: "chord-div-subtitle", ...t.value.style.chart.title.subtitle } } }, null, 8, ["config"])) ], 512)) : h("", !0), I("div", { id: `legend-top-${$.value}` }, null, 8, Xo), t.value.userOptions.show && O.value && (v(ze) || v(ke)) ? (s(), G(v(St), { ref_key: "userOptionsRef", ref: ye, key: `user_option_${Te.value}`, backgroundColor: t.value.style.chart.backgroundColor, color: t.value.style.chart.color, isPrinting: v(je), isImaging: v(Ue), uid: $.value, hasTooltip: !1, hasPdf: t.value.userOptions.buttons.pdf, hasImg: t.value.userOptions.buttons.img, hasSvg: t.value.userOptions.buttons.svg, hasXls: t.value.userOptions.buttons.csv, hasTable: t.value.userOptions.buttons.table, hasLabel: !1, hasFullscreen: t.value.userOptions.buttons.fullscreen, isFullscreen: de.value, chartElement: E.value, position: t.value.userOptions.position, titles: { ...t.value.userOptions.buttonTitles }, hasAnnotator: t.value.userOptions.buttons.annotator, isAnnotation: le.value, callbacks: t.value.userOptions.callbacks, printScale: t.value.userOptions.print.scale, tableDialog: t.value.table.useDialog, onToggleFullscreen: tt, onGeneratePdf: v(Xe), onGenerateCsv: Me, onGenerateImage: v(Ve), onGenerateSvg: ut, onToggleTable: lt, onToggleAnnotator: $e, style: N({ visibility: v(ze) ? v(ke) ? "visible" : "hidden" : "visible" }) }, Ie({ _: 2 }, [ e.$slots.menuIcon ? { name: "menuIcon", fn: p(({ isOpen: o, color: l }) => [ b(e.$slots, "menuIcon", z(j({ isOpen: o, color: l })), void 0, !0) ]), key: "0" } : void 0, e.$slots.optionPdf ? { name: "optionPdf", fn: p(() => [ b(e.$slots, "optionPdf", {}, void 0, !0) ]), key: "1" } : void 0, e.$slots.optionCsv ? { name: "optionCsv", fn: p(() => [ b(e.$slots, "optionCsv", {}, void 0, !0) ]), key: "2" } : void 0, e.$slots.optionImg ? { name: "optionImg", fn: p(() => [ b(e.$slots, "optionImg", {}, void 0, !0) ]), key: "3" } : void 0, e.$slots.optionSvg ? { name: "optionSvg", fn: p(() => [ b(e.$slots, "optionSvg", {}, void 0, !0) ]), key: "4" } : void 0, e.$slots.optionTable ? { name: "optionTable", fn: p(() => [ b(e.$slots, "optionTable", {}, void 0, !0) ]), key: "5" } : void 0, e.$slots.optionFullscreen ? { name: "optionFullscreen", fn: p(({ toggleFullscreen: o, isFullscreen: l }) => [ b(e.$slots, "optionFullscreen", z(j({ toggleFullscreen: o, isFullscreen: l })), void 0, !0) ]), key: "6" } : void 0, e.$slots.optionAnnotator ? { name: "optionAnnotator", fn: p(({ toggleAnnotator: o, isAnnotator: l }) => [ b(e.$slots, "optionAnnotator", z(j({ toggleAnnotator: o, isAnnotator: l })), void 0, !0) ]), key: "7" } : void 0 ]), 1032, ["backgroundColor", "color", "isPrinting", "isImaging", "uid", "hasPdf", "hasImg", "hasSvg", "hasXls", "hasTable", "hasFullscreen", "isFullscreen", "chartElement", "position", "titles", "hasAnnotator", "isAnnotation", "callbacks", "printScale", "tableDialog", "onGeneratePdf", "onGenerateImage", "style"])) : h("", !0), (s(), i("svg", { xmlns: v(ko), ref_key: "svgRef", ref: ee, viewBox: `0 0 ${D.value.width} ${D.value.height}`, preserveAspectRatio: "xMidYMid meet", style: { overflow: "visible" }, class: R({ "vue-ui-chord-rotating": ae.value, "vue-ui-chord-idle": !ae.value }), onMousedown: vt(Ke, ["prevent"]), onTouchstart: vt(Ke, ["prevent"]) }, [ fe(v(Pt)), e.$slots["chart-background"] ? (s(), i("foreignObject", { key: 0, x: 0, y: 0, width: D.value.width <= 0 ? 10 : D.value.width, height: D.value.height <= 0 ? 10 : D.value.height, style: { pointerEvents: "none" } }, [ b(e.$slots, "chart-background", {}, void 0, !0) ], 8, Go)) : h("", !0), t.value.style.chart.arcs.labels.curved ? (s(), i("defs", Yo, [ (s(!0), i(U, null, Q(x.value.groups, (o, l) => (s(), i("path", { key: `labelPath-${l}`, id: `labelPath-${l}_${$.value}`, d: Wt( o.startAngle, o.endAngle, (m.value.inner + m.value.outer) / 2 + t.value.style.chart.arcs.labels.offset ), fill: "none" }, null, 8, Wo))), 128)) ])) : h("", !0), e.$slots.pattern ? (s(), i("g", qo, [ (s(!0), i(U, null, Q(x.value.groups, (o, l) => (s(), i("defs", null, [ b(e.$slots, "pattern", ht({ ref_for: !0 }, { seriesIndex: o.index, patternId: `pattern_${$.value}_${l}` }), void 0, !0) ]))), 256)) ])) : h("", !0), I("g", { transform: `translate(${D.value.width / 2}, ${D.value.height / 2}) rotate(${_.value})` }, [ (s(!0), i(U, null, Q(x.value.groups, (o, l) => (s(), i("g", null, [ (s(), i("path", { class: R({ "vue-ui-chord-arc": !0, "vue-ui-chord-arc-animated": t.value.useCssAnimation && !J.value }), key: `arc-${l}`, d: qe( o.startAngle, o.endAngle, m.value.outer, m.value.inner ), fill: C.value.colors[l], stroke: t.value.style.chart.arcs.stroke, "stroke-width": t.value.style.chart.arcs.strokeWidth, "stroke-linecap": "round", "stroke-linejoin": "round", style: N({ opacity: at(o) }), onMouseenter: (r) => qt(o, l), onMouseleave: (r) => Ht(o, l), onClick: (r) => Qt(o, l) }, null, 46, Qo)), e.$slots.pattern ? (s(), i("path", { class: R({ "vue-ui-chord-arc": !0, "vue-ui-chord-arc-animated": t.value.useCssAnimation && !J.value }), key: `arc-${l}`, d: qe( o.startAngle, o.endAngle, m.value.outer, m.value.inner ), fill: `url(#${o.pattern})`, stroke: t.value.style.chart.arcs.stroke, "stroke-width": t.value.style.chart.arcs.strokeWidth, "stroke-linecap": "round", "stroke-linejoin": "round", style: N({ opacity: at(o), pointerEvents: "none" }) }, null, 14, Zo)) : h("", !0) ]))), 256)), I("g", null, [ (s(!0), i(U, null, Q(w.value ? x.value.chords.filter((o) => o.source.groupId === w.value.id) : g.value ? x.value.chords.filter((o) => o.source.groupId === g.value) : x.value.chords, (o, l) => (s(), i(U, { key: `ribbon-${o.id}` }, [ o.source.value ? (s(), i("path", { key: 0, class: R({ "vue-ui-chord-ribbon": !0, "vue-ui-chord-ribbon-animated": t.value.useCssAnimation && !J.value }), d: ue(o.source, o.target), fill: t.value.style.chart.backgroundColor, style: N({ opacity: t.value.style.chart.ribbons.underlayerOpacity }) }, null, 14, Jo)) : h("", !0), o.source.value ? (s(), i("path", { key: 1, class: R({ "vue-ui-chord-ribbon": !0, "vue-ui-chord-ribbon-animated": t.value.useCssAnimation && !J.value }), d: ue(o.source, o.target), fill: C.value.colors[o.source.index], stroke: t.value.style.chart.ribbons.stroke, "stroke-width": t.value.style.chart.ribbons.strokeWidth, "stroke-linecap": "round", "stroke-linejoin": "round", style: N({ opacity: ot(o) }), onMouseenter: (r) => Zt({ ...o, path: ue(o.source, o.target), color: C.value.colors[o.source.index] }, l), onClick: (r) => Kt({ ...o, color: C.value.colors[o.source.index] }, l), onMouseleave: (r) => Jt({ ...o, color: C.value.colors[o.source.index] }, l) }, null, 46, Ko)) : h("", !0), o.source.value && e.$slots.pattern ? (s(), i("path", { key: 2, class: R({ "vue-ui-chord-ribbon": !0, "vue-ui-chord-ribbon-animated": t.value.useCssAnimation && !J.value }), d: ue(o.source, o.target), fill: `url(#pattern_${$.value}_${o.source.index})`, stroke: t.value.style.chart.ribbons.stroke, "stroke-width": t.value.style.chart.ribbons.strokeWidth, "stroke-linecap": "round", "stroke-linejoin": "round", style: N({ opacity: ot(o), pointerEvents: "none" }) }, null, 14, ea)) : h("", !0) ], 64))), 128)), k.value ? (s(), i("path", { key: 0, d: k.value.path, fill: k.value.color, stroke: t.value.style.chart.ribbons.stroke, "stroke-width": t.value.style.chart.ribbons.strokeWidth, "stroke-linecap": "round", "stroke-linejoin": "round", class: R({ "vue-ui-chord-ribbon": !0 }), style: { pointerEvents: "none" } }, null, 8, ta)) : h("", !0), k.value && e.$slots.pattern ? (s(), i("path", { key: 1, d: k.value.path, fill: `url(#${k.value.source.pattern})`, stroke: t.value.style.chart.ribbons.stroke, "stroke-width": t.value.style.chart.ribbons.strokeWidth, "stroke-linecap": "round", "stroke-linejoin": "round", class: R({ "vue-ui-chord-ribbon": !0 }), style: { pointerEvents: "none" } }, null, 8, oa)) : h("", !0) ]), (w.value || k.value || g.value) && t.value.style.chart.ribbons.labels.show ? (s(), i("g", aa, [ (s(!0), i(U, null, Q(Ut.value, (o) => (s(), i(U, { key: o.id }, [ I("line", { x1: o.midBaseX, y1: o.midBaseY, x2: Math.cos(o.theta - Math.PI / 2) * (m.value.outer + t.value.style.chart.ribbons.labels.offset + 12), y2: Math.sin(o.theta - Math.PI / 2) * (m.value.outer + t.value.style.chart.ribbons.labels.offset + 12), stroke: t.value.style.chart.backgroundColor, "stroke-width": t.value.style.chart.ribbons.labels.connector.strokeWidth * 3, "pointer-events": "none" }, null, 8, la), I("line", { x1: o.midBaseX, y1: o.midBaseY, x2: Math.cos(o.theta - Math.PI / 2) * (m.value.outer + t.value.style.chart.ribbons.labels.offset + 12), y2: Math.sin(o.theta - Math.PI / 2) * (m.value.outer + t.value.style.chart.ribbons.labels.offset + 12), stroke: t.value.style.chart.ribbons.labels.connector.stroke, "stroke-width": t.value.style.chart.ribbons.labels.connector.strokeWidth, "pointer-events": "none" }, null, 8, na), t.value.style.chart.ribbons.labels.marker.show ? (s(), i("circle", { key: 0, cx: Math.cos(o.theta - Math.PI / 2) * (m.value.outer + t.value.style.chart.ribbons.labels.offset + 12), cy: Math.sin(o.theta - Math.PI / 2) * (m.value.outer + t.value.style.chart.ribbons.labels.offset + 12), r: t.value.style.chart.ribbons.labels.marker.radius, stroke: t.value.style.chart.ribbons.labels.marker.stroke, "stroke-width": t.value.style.chart.ribbons.labels.marker.strokeWidth, fill: o.groupColor, "pointer-events": "none" }, null, 8, ra)) : h("", !0), I("text", { transform: ` translate( ${Math.cos(o.theta - Math.PI / 2) * (m.value.outer + t.value.style.chart.ribbons.labels.offset + 24)}, ${Math.sin(o.theta - Math.PI / 2) * (m.value.outer + t.value.style.chart.ribbons.labels.offset + 24)} ) rotate(${-_.value}) `, fill: t.value.style.chart.ribbons.labels.useSerieColor ? o.groupColor : t.value.style.chart.ribbons.labels.color, "text-anchor": Gt(o.theta), "font-size": t.value.style.chart.ribbons.labels.fontSize, "font-weight": t.value.style.chart.ribbons.labels.bold ? "bold" : "normal", dy: ".35em", "pointer-events": "none" }, Z(et(o.value)), 9, sa) ], 64))), 128)) ])) : h("", !0), t.value.style.chart.arcs.labels.show ? (s(), i("g", ua, [ t.value.style.chart.arcs.labels.curved ? (s(!0), i(U, { key: 0 }, Q(x.value.groups, (o, l) => (s(), i("text", { class: "vue-ui-chord-label-curved", key: `curved-label-${l}`, "font-size": t.value.style.chart.arcs.labels.fontSize, "font-weight": t.value.style.chart.arcs.labels.bold ? "bold" : "normal", fill: t.value.style.chart.arcs.labels.adaptColorToBackground ? v(Co)(C.value.colors[l]) : t.value.style.chart.arcs.labels.color }, [ I("textPath", { href: `#labelPath-${l}_${$.value}`, startOffset: "50%", "text-anchor": "middle" }, Z(C.value.labels[l]) + Z(t.value.style.chart.arcs.labels.showPercentage ? v(Pe)({ p: " (", v: isNaN(o.proportion) ? 0 : o.proportion * 100, s: "%)", r: t.value.style.chart.arcs.labels.roundingPercentage }) : ""), 9, ca) ], 8, ia))), 128)) : !w.value && !k.value && !g.value ? (s(!0), i(U, { key: 1 }, Q(x.value.groups, (o, l) => (s(), i("text", { class: "vue-ui-chord-label-straight", key: `label-${l}`, transform: ` ${Yt((o.startAngle + o.endAngle) / 2)} rotate(${-_.value}) `, dy: ".35em", "text-anchor": Vt(o) > Math.PI ? "end" : "start", "font-size": t.value.style.chart.arcs.labels.fontSize, "font-weight": t.value.style.chart.arcs.labels.bold ? "bold" : "normal", fill: t.value.style.chart.arcs.labels.color, innerHTML: v(Ao)({ content: v($o)(ao(o, l)), fontSize: t.value.style.chart.arcs.labels.fontSize, fill: t.value.style.chart.arcs.labels.color, x: 0, y: 0 }) }, null, 8, da))), 128)) : h("", !0) ])) : h("", !0) ], 8, Ho), b(e.$slots, "svg", { svg: { height: 600, width: 600 } }, void 0, !0) ], 42, Vo)), e.$slots.watermark ? (s(), i("div", va, [ b(e.$slots, "watermark", z(j({ isPrinting: v(je) || v(Ue) })), void 0, !0) ])) : h("", !0), I("div", { id: `legend-bottom-${$.value}` }, null, 8, ha), Le.value ? (s(), G(vo, { key: 5, to: t.value.style.chart.legend.position === "top" ? `#legend-top-${$.value}` : `#legend-bottom-${$.value}` }, [ I("div", { ref_key: "chartLegend", ref: De }, [ t.value.style.chart.legend.show ? (s(), G(zo, { key: `legend_${me.value}`, legendSet: we.value, config: to.value, onClickMarker: a[0] || (a[0] = ({ legend: o }) => rt(o.id)) }, Ie({ item: p(({ legend: o }) => [ I("div", { style: N({ opacity: g.value ? g.value === o.id ? 1 : 0.3 : 1 }), onClick: (l) => o.select() }, Z(o.name), 13, fa) ]), _: 2 }, [ e.$slots.pattern ? { name: "legend-pattern", fn: p(({ legend: o, index: l }) => [ fe(No, { shape: o.shape, radius: 30, stroke: "none", plot: { x: 30, y: 30 }, fill: `url(#pattern_${$.value}_${l})` }, null, 8, ["shape", "fill"]) ]), key: "0" } : void 0 ]), 1032, ["legendSet", "config"])) : h("", !0), b(e.$slots, "legend", { legend: we.value }, void 0, !0) ], 512) ], 8, ["to"])) : h("", !0), e.$slots.source ? (s(), i("div", { key: 6, ref_key: "source", ref: Fe, dir: "auto" }, [ b(e.$slots, "source", {}, void 0, !0) ], 512)) : h("", !0), _.value !== t.value.initialRotation ? (s(), i("div", ba, [ b(e.$slots, "reset-action", { reset: nt }, () => [ I("button", { "data-cy-reset": "", tabindex: "0", role: "button", class: "vue-data-ui-refresh-button", style: N({ background: t.value.style.chart.backgroundColor }), onClick: nt }, [ fe(v(Se), { name: "refresh", stroke: t.value.style.chart.color }, null, 8, ["stroke"]) ], 4) ], !0) ])) : h("", !0), O.value && t.value.userOptions.buttons.table ? (s(), G(ho(ne.value.component), ht({ key: 8 }, ne.value.props, { ref_key: "tableUnit", ref: te, onClose: st }), Ie({ content: p(() => [ (s(), G(v(_t), { key: `table_${pe.value}`, colNames: he