UNPKG

vue-data-ui

Version:

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

1,042 lines (1,041 loc) • 74.4 kB
import { useCssVars as zt, defineAsyncComponent as Z, computed as g, ref as S, toRefs as St, watch as fe, onMounted as Ft, nextTick as pe, createElementBlock as o, openBlock as a, unref as n, normalizeStyle as y, normalizeClass as w, createBlock as oe, createCommentVNode as h, renderSlot as C, withCtx as A, normalizeProps as R, guardReactiveProps as E, createSlots as Ee, createVNode as ge, createElementVNode as u, toDisplayString as c, Fragment as _, renderList as m, createTextVNode as Q, resolveDynamicComponent as Nt, mergeProps as Bt, withKeys as Dt } from "vue"; import { c as Lt, t as It, i as Ot, j as O, k as Pt, l as _e, g as se, m as me, o as Rt, a as j, d as F, X as Et, s as B, h as Ve, x as Me, a3 as je, a4 as Vt, a5 as ee, a6 as P, v as Mt, r as jt } from "./lib-2iaAPQ_c.js"; import { u as Xt, a as xe } from "./useNestedProp-2p4Tjzc8.js"; import { u as Gt, B as Ut } from "./BaseScanner-BMpwQAfz.js"; import { u as Wt } from "./usePrinter-ChVMpU2f.js"; import { u as Yt } from "./useSvgExport-ByUukOZt.js"; import { u as Ht } from "./useThemeCheck-DGJ31Vi5.js"; import { u as qt } from "./useTableResponsive-Cbx-ACcP.js"; import { u as Kt } from "./useUserOptionState-BIvW1Kz7.js"; import { u as Zt } from "./useChartAccessibility-9icAAmYg.js"; import Jt from "./img-CqYIrJ8I.js"; import { _ as Qt } from "./_plugin-vue_export-helper-CHgC5LLL.js"; const Xe = { style: { chart: { backgroundColor: "#1A1A1A", color: "#CCCCCC", layout: { grandTotal: { color: "#CCCCCC" }, roots: { stroke: "#1A1A1A", labels: { name: { color: "#CCCCCC" } } }, verticalSeparator: { stroke: "#1A1A1A" }, branches: { labels: { color: "#CCCCCC" } }, nuts: { selected: { labels: { dataLabels: { color: "#CCCCCC" }, core: { total: { color: "#CCCCCC" }, value: { color: "#CCCCCC" } } } } }, legend: { color: "#CCCCCC" }, title: { color: "#CCCCCC", subtitle: { color: "#757575" } } } } }, table: { th: { backgroundColor: "#1A1A1A", color: "#CCCCCC" }, td: { backgroundColor: "#1A1A1A", color: "#CCCCCC" } } }, Ge = { style: { chart: { backgroundColor: "#FFF8E1", color: "#424242", layout: { grandTotal: { color: "#424242" }, roots: { stroke: "#FFF8E1", labels: { name: { color: "#424242" } } }, verticalSeparator: { stroke: "#FFF8E1" }, branches: { borderRadius: 0, labels: { color: "#424242" } }, nuts: { selected: { labels: { dataLabels: { color: "#424242" }, core: { total: { color: "#424242" }, value: { color: "#424242" } } } } }, legend: { color: "#424242" }, title: { color: "#424242", subtitle: { color: "#757575" } } } } }, table: { th: { backgroundColor: "#FFF8E1", color: "#424242" }, td: { backgroundColor: "#FFF8E1", color: "#424242" } } }, Ue = { style: { chart: { backgroundColor: "#1E1E1E", color: "#BDBDBD", layout: { grandTotal: { color: "#BDBDBD" }, roots: { stroke: "#1E1E1E", labels: { name: { color: "#BDBDBD" } } }, verticalSeparator: { stroke: "#1E1E1E" }, branches: { borderRadius: 0, labels: { color: "#BDBDBD" } }, nuts: { selected: { labels: { dataLabels: { color: "#BDBDBD" }, core: { total: { color: "#BDBDBD" }, value: { color: "#BDBDBD" } } } } }, legend: { color: "#BDBDBD" }, title: { color: "#FFF8E1", subtitle: { color: "#BDBDBD" } } } } }, table: { th: { backgroundColor: "#1E1E1E", color: "#BDBDBD" }, td: { backgroundColor: "#1E1E1E", color: "#BDBDBD" } } }, We = { style: { chart: { backgroundColor: "#1A1A1A", color: "#99AA99", layout: { grandTotal: { color: "#99CC99" }, roots: { stroke: "#1A1A1A", labels: { name: { color: "#AACCAA" } } }, verticalSeparator: { stroke: "#1A1A1A" }, branches: { borderRadius: 0, labels: { color: "#AACCAA" } }, nuts: { selected: { labels: { dataLabels: { color: "#AACCAA" }, core: { total: { color: "#99CC99" }, value: { color: "#AACCAA" } } } } }, legend: { color: "#99AA99" }, title: { color: "#66CC66", subtitle: { color: "#99AA99" } } } } }, table: { th: { backgroundColor: "#1A1A1A", color: "#99AA99" }, td: { backgroundColor: "#1A1A1A", color: "#AACCAA" } } }, Ye = { style: { chart: { backgroundColor: "#fbfafa", color: "#8A9892", layout: { grandTotal: { color: "#A0AC94" }, roots: { stroke: "#fbfafa", labels: { name: { color: "#A0AC94" } } }, verticalSeparator: { stroke: "#fbfafa" }, branches: { borderRadius: 12, labels: { color: "#A0AC94" } }, nuts: { selected: { labels: { dataLabels: { color: "#A0AC94" }, core: { total: { color: "#8A9892" }, value: { color: "#A0AC94" } } } } }, legend: { color: "#99AA99" }, title: { color: "#8A9892", subtitle: { color: "#99AA99" } } } } }, table: { th: { backgroundColor: "#fbfafa", color: "#8F837A" }, td: { backgroundColor: "#fbfafa", color: "#8F837A" } } }, He = { style: { chart: { backgroundColor: "#f6f6fb", color: "#50606C", layout: { grandTotal: { color: "#61747E" }, roots: { stroke: "#f6f6fb", labels: { name: { color: "#8A9892" } } }, verticalSeparator: { stroke: "#f6f6fb" }, branches: { borderRadius: 0, labels: { color: "#8A9892" } }, nuts: { selected: { labels: { dataLabels: { color: "#8A9892" }, core: { total: { color: "#8A9892" }, value: { color: "#61747E" } } } } }, legend: { color: "#61747E" }, title: { color: "#50606C", subtitle: { color: "#61747E" } } } } } }, qe = { default: {}, dark: Xe, celebration: Ge, celebrationNight: Ue, hack: We, zen: Ye, concrete: He }, Co = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, celebration: Ge, celebrationNight: Ue, concrete: He, dark: Xe, default: qe, hack: We, zen: Ye }, Symbol.toStringTag, { value: "Module" })), el = ["id"], tl = { key: 1, ref: "noTitle", class: "vue-data-ui-no-title-space", style: "height:36px; width: 100%;background:transparent" }, ll = ["xmlns", "viewBox"], al = ["width", "height"], ol = { key: 1 }, sl = ["fill", "font-weight", "font-size", "x", "y"], nl = ["fill", "font-weight", "font-size", "x", "y"], ul = ["id"], rl = ["stop-color"], il = ["stop-color"], cl = ["id"], dl = ["stop-color"], vl = ["stop-color"], yl = ["id"], hl = ["stop-color"], bl = ["stop-color"], fl = ["stop-color"], pl = ["id"], gl = ["stop-color"], _l = ["stop-color"], ml = ["stop-color"], xl = ["id"], kl = ["stop-color"], Cl = ["stop-color"], wl = ["stop-color"], Al = { key: 2 }, $l = ["x", "y", "font-size", "font-weight", "fill"], Tl = ["x", "y", "font-size", "font-weight", "fill"], zl = ["id"], Sl = ["stop-color"], Fl = ["stop-color"], Nl = ["d", "stroke", "fill"], Bl = ["cx", "cy", "r", "fill"], Dl = ["cx", "cy", "r", "fill", "stroke", "stroke-width", "onClick"], Ll = { key: 3 }, Il = ["x", "y", "font-size", "fill", "onClick"], Ol = { key: 0 }, Pl = ["x", "y", "fill", "font-size", "font-weight"], Rl = ["x", "y", "height", "width", "fill", "rx", "onClick"], El = ["x", "y", "height", "width", "fill", "rx", "stroke", "stroke-width", "onClick"], Vl = { key: 4 }, Ml = ["x", "y", "fill", "font-size", "onClick"], jl = ["d", "stroke"], Xl = ["fill", "cx", "cy", "r", "onClick"], Gl = { key: 5 }, Ul = ["x", "y", "font-size", "font-weight", "fill"], Wl = ["x1", "x2", "y1", "y2", "stroke", "stroke-width"], Yl = ["y", "height", "width"], Hl = { style: { width: "100%", height: "100%", display: "flex", "align-items": "center", "justify-content": "center", "flex-direction": "column" } }, ql = { style: { display: "flex", "align-items": "center", "justify-content": "center", gap: "12px", "flex-wrap": "wrap", "flex-direction": "row" } }, Kl = { viewBox: "0 0 20 20", height: "16", width: "16" }, Zl = ["fill"], Jl = { key: 7 }, Ql = ["y", "height", "width"], ea = { style: { width: "100%", height: "100%", display: "flex", "align-items": "center", "justify-content": "center", "flex-direction": "column" } }, ta = { style: { display: "flex", "align-items": "center", "justify-content": "center", gap: "12px", "flex-wrap": "wrap", "flex-direction": "row" } }, la = { viewBox: "0 0 20 20", height: "16", width: "16" }, aa = ["fill"], oa = ["cx", "cy", "fill"], sa = ["d", "stroke"], na = ["cx", "cy", "fill"], ua = ["d", "stroke"], ra = ["cx", "cy", "fill"], ia = ["cx", "cy", "fill"], ca = ["x", "y", "fill", "font-size", "font-weight"], da = ["x", "y", "fill", "font-size", "font-weight"], va = ["x", "text-anchor", "y", "fill", "font-size"], ya = ["x", "text-anchor", "y", "fill", "font-size"], ha = ["x", "text-anchor", "y", "fill", "font-size"], ba = ["x", "text-anchor", "y", "fill", "font-size"], fa = ["x", "text-anchor", "y", "fill", "font-size"], pa = ["x", "y", "font-size", "fill"], ga = ["x", "y", "font-size", "fill"], _a = ["x", "y", "font-size", "fill"], ma = { key: 4, class: "vue-data-ui-watermark" }, xa = { key: 5, ref: "source", dir: "auto" }, ka = { class: "vue-ui-data-table" }, Ca = { key: 0 }, wa = ["data-cell"], Aa = { style: { display: "flex", "align-items": "center", gap: "5px", "justify-content": "flex-end", width: "100%", "padding-right": "3px" } }, $a = { key: 0 }, Ta = { key: 1 }, za = ["data-cell"], Sa = { style: { display: "flex", "align-items": "center", gap: "5px", "justify-content": "flex-end", width: "100%", "padding-right": "3px" } }, Fa = { key: 0 }, Na = { key: 1 }, Ba = ["data-cell"], Da = { style: { display: "flex", "align-items": "center", gap: "5px", "justify-content": "flex-end", width: "100%", "padding-right": "3px" } }, La = { key: 0 }, Ia = { key: 1 }, Oa = ["data-cell"], Pa = { style: { display: "flex", "align-items": "center", gap: "5px", "justify-content": "flex-end", width: "100%", "padding-right": "3px" } }, Ra = { key: 0 }, Ea = { key: 1 }, Va = ["data-cell"], Ma = { style: { display: "flex", "align-items": "center", gap: "5px", "justify-content": "flex-end", width: "100%", "padding-right": "3px" } }, ja = { key: 0 }, Xa = { key: 1 }, Ga = ["data-cell"], Ua = { style: { display: "flex", "align-items": "center", gap: "5px", "justify-content": "flex-end", width: "100%", "padding-right": "3px" } }, Wa = { key: 0 }, Ya = { key: 1 }, Ha = ["data-cell"], qa = { style: { display: "flex", "align-items": "center", gap: "5px", "justify-content": "flex-end", width: "100%", "padding-right": "3px" } }, Ka = { key: 0 }, Za = { key: 1 }, Ja = ["data-cell"], Qa = { style: { display: "flex", "align-items": "center", gap: "5px", "justify-content": "flex-end", width: "100%", "padding-right": "3px" } }, eo = ["data-cell"], to = { style: { display: "flex", "align-items": "center", gap: "5px", "justify-content": "flex-end", width: "100%", "padding-right": "3px" } }, lo = ["data-cell"], ao = { style: { display: "flex", "align-items": "center", gap: "5px", "justify-content": "flex-end", width: "100%", "padding-right": "3px" } }, oo = ["data-cell"], so = { style: { display: "flex", "align-items": "center", gap: "5px", "justify-content": "flex-end", width: "100%", "padding-right": "3px" } }, no = ["data-cell"], uo = { style: { display: "flex", "align-items": "center", gap: "5px", "justify-content": "flex-end", width: "100%", "padding-right": "3px" } }, ro = { __name: "vue-ui-chestnut", props: { config: { type: Object, default() { return {}; } }, dataset: { type: Array, default() { return []; } } }, emits: ["selectRoot", "selectBranch", "selectNut"], setup(Ke, { expose: Ze, emit: Je }) { zt((l) => ({ v2e18205a: l.tdo })); const ke = Z(() => import("./BaseIcon-CbVDYv89.js")), Qe = Z(() => import("./vue-ui-accordion-Dm0mNNKQ.js")), et = Z(() => import("./PenAndPaper-CvyKWfNl.js")), tt = Z(() => import("./UserOptions-BQO4YFrn.js")), lt = Z(() => import("./PackageVersion-Br3DrrFh.js")), at = Z(() => import("./BaseDraggableDialog-Z5LfhW87.js")), { vue_ui_chestnut: ot } = Xt(), { isThemeValid: st, warnInvalidTheme: nt } = Ht(), V = Ke, Ce = g(() => !!V.dataset && V.dataset.length), $ = S(Lt()), Y = S(null), we = S(0), J = S(null), ne = S(null), e = S(ce()), { loading: Ae, FINAL_DATASET: ue } = Gt({ ...St(V), FINAL_CONFIG: e, prepareConfig: ce, skeletonDataset: [ { name: "_", color: "#969696", branches: [ { name: "_", value: 32, breakdown: [ { name: "_", value: 16, color: "#CACACA" }, { name: "_", value: 16, color: "#6A6A6A" } ] }, { name: "_", value: 16, breakdown: [ { name: "_", value: 8, color: "#CACACA" }, { name: "_", value: 8, color: "#6A6A6A" } ] }, { name: "_", value: 8, breakdown: [ { name: "_", value: 4, color: "#CACACA" }, { name: "_", value: 4, color: "#6A6A6A" } ] }, { name: "_", value: 4, breakdown: [ { name: "_", value: 2, color: "#CACACA" }, { name: "_", value: 2, color: "#6A6A6A" } ] } ] }, { name: "_", color: "#C4C4C4", branches: [ { name: "_", value: 24, breakdown: [ { name: "_", value: 12, color: "#CACACA" }, { name: "_", value: 12, color: "#6A6A6A" } ] }, { name: "_", value: 12, breakdown: [ { name: "_", value: 6, color: "#CACACA" }, { name: "_", value: 6, color: "#6A6A6A" } ] }, { name: "_", value: 6, breakdown: [ { name: "_", value: 3, color: "#CACACA" }, { name: "_", value: 3, color: "#6A6A6A" } ] }, { name: "_", value: 2, breakdown: [ { name: "_", value: 1, color: "#CACACA" }, { name: "_", value: 1, color: "#6A6A6A" } ] } ] } ], skeletonConfig: It({ defaultConfig: e.value, userConfig: { userOptions: { show: !1 }, table: { show: !1 }, style: { chart: { backgroundColor: "#99999930", layout: { grandTotal: { show: !1 }, roots: { stroke: "#6A6A6A", labels: { show: !1 } }, verticalSeparator: { stroke: "transparent" }, branches: { stroke: "#6A6A6A", underlayerColor: "#6A6A6A90", labels: { show: !1, dataLabels: { show: !1 } } } } } } } }) }), { userOptionsVisible: re, setUserOptionsVisibility: $e, keepUserOptionState: Te } = Kt({ config: e.value }), { svgRef: ie } = Zt({ config: e.value.style.chart.layout.title }); function ce() { const l = xe({ userConfig: V.config, defaultConfig: ot }), r = l.theme; if (!r) return l; if (!st.value(l)) return nt(l), l; const t = xe({ userConfig: qe[r] || V.config, defaultConfig: l }), s = xe({ userConfig: V.config, defaultConfig: t }); return { ...s, customPalette: s.customPalette.length ? s.customPalette : Ot[r] || O }; } fe(() => V.config, (l) => { e.value = ce(), re.value = !e.value.userOptions.showOnChartHover, X.value.showTable = e.value.table.show, Ie(); }, { deep: !0 }); const { isPrinting: ze, isImaging: Se, generatePdf: Fe, generateImage: Ne } = Wt({ elementId: `vue-ui-chestnut_${$.value}`, fileName: e.value.style.chart.layout.title.text || "vue-ui-chestnut", options: e.value.userOptions.print }), ut = g(() => e.value.userOptions.show), de = g(() => Pt(e.value.customPalette)), X = S({ showTable: e.value.table.show }); fe(e, () => { X.value = { showTable: e.value.table.show }; }, { immediate: !0 }); const Be = S(null), rt = g(() => e.value.table.responsiveBreakpoint), i = S({ gap: 6, padding: { top: 102, left: 12, right: 12, bottom: 96 }, width: 1024, height: 0, branchSize: 32, branchStart: 128 }), z = g(() => ({ left: i.value.padding.left, top: i.value.padding.top, right: i.value.width - i.value.padding.right, bottom: i.value.height - i.value.padding.bottom, width: i.value.width - (i.value.padding.left + i.value.padding.right), height: i.value.height - (i.value.padding.top + i.value.padding.bottom), seedX: i.value.padding.left + 64 })), D = g(() => ue.value.flatMap((l) => (l.branches || []).map((r) => r.value || 0)).reduce((l, r) => l + r, 0)), N = g(() => (ue.value.forEach((l, r) => { _e({ datasetObject: l, requiredAttributes: ["name", "branches"] }).forEach((t) => { se({ componentName: "VueUiChestnut", type: "datasetSerieAttribute", property: t, index: r, debug: te.value }); }), l.branches && l.branches.forEach((t, s) => { _e({ datasetObject: t, requiredAttributes: ["name", "value"] }).forEach((f) => { se({ componentName: "VueUiChestnut", type: "datasetSerieAttribute", property: f, index: `${r} - ${s}`, debug: te.value }); }), t.breakdown && t.breakdown.forEach((f, p) => { _e({ datasetObject: f, requiredAttributes: ["name", "value"] }).forEach((b) => { se({ componentName: "VueUiChestnut", type: "datasetSerieAttribute", property: b, index: `${r} - ${s} - ${p}`, debug: te.value }); }); }); }); }), ue.value.map((l, r) => { const t = (l.branches || []).map((s) => s.value || 0).reduce((s, f) => s + f, 0); return { ...l, color: me(l.color) || de.value[r] || O[r] || O[r % O.length], id: l.id || `root_${r}_${$.value}`, type: "root", total: t, rootIndex: r, branches: (l.branches || []).map((s, f) => ({ ...s, rootName: l.name, rootIndex: r, color: me(l.color) || de.value[r] || O[r] || O[r % O.length], value: s.value >= 0 ? s.value : 0, id: s.id || `branch_${r}_${f}_${$.value}`, proportionToRoot: s.value / t, type: "branch", breakdown: (s.breakdown || []).map((p, b) => ({ table: { rootName: l.name, rootValue: t, rootToTotal: t / D.value, branchName: s.name, branchValue: s.value, branchToTotal: s.value / D.value, branchToRoot: s.value / t, nutName: p.name, nutValue: p.value, nutToTotal: p.value / D.value, nutToRoot: p.value / t, nutToBranch: p.value / s.value }, ...p, type: "nut", branchName: s.name, rootName: l.name, branchTotal: s.value >= 0 ? s.value : 0, proportionToBranch: p.value / s.value, proportionToRoot: p.value / t, proportionToTree: p.value / D.value, rootIndex: r, id: p.id || `nut_${r}_${f}_${b}_${$.value}`, color: me(p.color) || de.value[b] || O[b] || O[b % O.length], value: p.value >= 0 ? p.value : 0 })) })) }; }))); function it() { return N.value; } const H = Je, ct = g(() => N.value.flatMap((l) => l.branches).length), dt = g(() => Math.max(...N.value.map((l) => l.branches.map((r) => r.value).reduce((r, t) => r + t, 0)))), vt = g(() => Math.max(...N.value.flatMap((l) => l.branches.map((r) => r.value)))), De = g(() => 256 + i.value.padding.left), G = g(() => N.value.sort((l, r) => r.total - l.total).map((l, r) => { const t = z.value.height / N.value.length / 2, s = l.total / dt.value * (t > 64 ? 64 : t); return { ...l, x: z.value.seedX, y: z.value.top + z.value.height / N.value.length * (r + 1) - (z.value.height / N.value.length / 2 + i.value.gap / 2), r: s < i.value.branchSize / 2 ? i.value.branchSize / 2 : s }; })), yt = g(() => e.value.style.chart.layout.branches.widthRatio <= 0 ? 0.1 : e.value.style.chart.layout.branches.widthRatio > 1.8 ? 1.8 : e.value.style.chart.layout.branches.widthRatio), ht = g(() => G.value.flatMap((l) => l.branches)), U = g(() => ht.value.sort((l, r) => r.value - l.value).map((l, r) => ({ ...l, y1: r * i.value.branchSize + z.value.top + r * i.value.gap, y2: r * i.value.branchSize + i.value.branchSize, x1: De.value, x2: 384 * l.value / vt.value * yt.value + De.value }))); function bt(l) { const r = G.value.find((t) => t.rootIndex === l.rootIndex); return { x: r.x, y: r.y, r: r.r }; } const d = S(null), M = S(null), x = S(null), L = S(null); function T() { d.value = null, x.value = null, L.value = null; } function I(l) { return L.value ? L.value === null ? !0 : l.type === "root" ? l.id === L.value.id : l.rootIndex === L.value.rootIndex : d.value === null && x.value === null ? !0 : l.type === "nut" ? d.value.id === l.id : l.type === "branch" ? x.value.id === l.id : l.type === "root" ? x.value && x.value.rootIndex === l.rootIndex || d.value && d.value.rootIndex === l.rootIndex : !1; } function ft(l) { T(), pe(() => { d.value = l, x.value = l, M.value = je( { series: l.breakdown }, l.x2 + 24 + e.value.style.chart.layout.nuts.offsetX, l.y1 + i.value.branchSize / 2, 80, 80 ), H("selectNut", l.breakdown); }); } function W() { d.value = null, M.value = null, H("selectNut", null); } function ve(l) { x.value && x.value.id === l.id ? (x.value = null, T(), H("selectBranch", null)) : (T(), x.value = l, H("selectBranch", l)); } function Le(l) { L.value && L.value.id === l.id ? (T(), H("selectRoot", null)) : (T(), L.value = l, H("selectRoot", l)); } function pt() { return z.value.bottom - (d.value.y1 + 180) < 0 ? 0 : z.value.bottom; } function q(l) { return l.proportion * 100 > e.value.style.chart.layout.nuts.selected.labels.dataLabels.hideUnderValue; } Ft(() => { Ie(); }); const te = g(() => e.value.debug); function Ie() { Rt(V.dataset) && se({ componentName: "VueUiChestnut", type: "dataset", debug: te.value }); const l = ct.value * (i.value.branchSize + i.value.gap) + i.value.padding.top + i.value.padding.bottom; i.value.height = l; } const v = g(() => { const l = [ e.value.table.th.translations.rootName, e.value.table.th.translations.rootValue, e.value.table.th.translations.rootToTotal, e.value.table.th.translations.branchName, e.value.table.th.translations.branchValue, e.value.table.th.translations.branchToRoot, e.value.table.th.translations.branchToTotal, e.value.table.th.translations.nutName, e.value.table.th.translations.nutValue, e.value.table.th.translations.nutToBranch, e.value.table.th.translations.nutToRoot, e.value.table.th.translations.nutToTotal ], r = N.value.flatMap((t, s) => t.branches.flatMap((f, p) => f.breakdown.flatMap((b, k) => b.table))); return { head: l, body: r }; }); function ye(l = null) { pe(() => { const r = [[e.value.style.chart.layout.title.text], [e.value.style.chart.layout.title.subtitle.text], [""], ["Grand total", D.value], [""]], t = v.value.head, s = v.value.body.map((b, k) => [ v.value.body[k - 1] && v.value.body[k - 1].rootName === b.rootName ? "" : b.rootName, v.value.body[k - 1] && v.value.body[k - 1].rootName === b.rootName ? "" : b.rootValue, v.value.body[k - 1] && v.value.body[k - 1].rootName === b.rootName ? "" : b.rootToTotal, v.value.body[k - 1] && v.value.body[k - 1].branchName === b.branchName ? "" : b.branchName, v.value.body[k - 1] && v.value.body[k - 1].branchName === b.branchName ? "" : b.branchValue, v.value.body[k - 1] && v.value.body[k - 1].branchName === b.branchName ? "" : b.branchToRoot, v.value.body[k - 1] && v.value.body[k - 1].branchName === b.branchName ? "" : b.branchToTotal, b.nutName, b.nutValue, b.nutToBranch, b.nutToRoot, b.nutToTotal ]), f = r.concat([t]).concat(s), p = Mt(f); l ? l(p) : jt({ csvContent: p, title: e.value.style.chart.layout.title.text || "vue-ui-chestnut" }); }); } const K = S(!1); function Oe(l) { K.value = l, we.value += 1; } function Pe() { X.value.showTable = !X.value.showTable; } const le = S(!1); function he() { le.value = !le.value; } async function gt({ scale: l = 2 } = {}) { if (!Y.value) return; const { width: r, height: t } = Y.value.getBoundingClientRect(), s = r / t, { imageUri: f, base64: p } = await Jt({ domElement: Y.value, base64: !0, img: !0, scale: l }); return { imageUri: f, base64: p, title: e.value.style.chart.layout.title.text, width: r, height: t, aspectRatio: s }; } function _t(l) { const r = bt(l), t = l.x1, s = l.y1, f = i.value.branchSize, p = r.x + r.r / 2, b = r.y, k = 20; return [ `M ${t},${s}`, `C ${t - k},${s} ${t - k},${s} ${p},${b}`, `C ${p},${b} ${t - k},${s + f} ${t},${s + f}`, "Z" ].join(" "); } const ae = g(() => { const l = e.value.table.useDialog && !e.value.table.show, r = X.value.showTable; return { component: l ? at : Qe, title: `${e.value.style.chart.layout.title.text}${e.value.style.chart.layout.title.subtitle.text ? `: ${e.value.style.chart.layout.title.subtitle.text}` : ""}`, props: l ? { backgroundColor: e.value.table.th.backgroundColor, color: e.value.table.th.color, headerColor: e.value.table.th.color, headerBg: e.value.table.th.backgroundColor, isFullscreen: K.value, fullscreenParent: Y.value, forcedWidth: Math.min(800, window.innerWidth * 0.8) } : { hideDetails: !0, config: { open: r, maxHeight: 1e4, body: { backgroundColor: e.value.style.chart.backgroundColor, color: e.value.style.chart.color }, head: { backgroundColor: e.value.style.chart.backgroundColor, color: e.value.style.chart.color } } } }; }); fe(() => X.value.showTable, async (l) => { e.value.table.show || (l && e.value.table.useDialog && J.value ? (await pe(), J.value.open()) : "close" in J.value && J.value.close()); }); const { isResponsive: mt } = qt(Be, rt); function be() { X.value.showTable = !1, ne.value && ne.value.setTableIconState(!1); } const xt = g(() => N.value.map((l, r) => ({ ...l, display: `${l.name}: ${j( e.value.style.chart.layout.roots.labels.formatter, l.total, F({ p: e.value.style.chart.layout.legend.prefix, v: l.total, s: e.value.style.chart.layout.legend.suffix, r: e.value.style.chart.layout.legend.roundingValue }), { datapoint: l } )} (${F({ v: l.total / D.value * 100, s: "%", r: e.value.style.chart.layout.legend.roundingPercentage })})` }))), kt = g(() => xt.value.map((l) => ({ color: l.color, name: l.display, shape: "circle" }))), Ct = g(() => e.value.style.chart.backgroundColor), wt = g(() => ({ ...e.value.style.chart.layout.legend, textAlign: "center", show: !0, position: "bottom" })), At = g(() => e.value.style.chart.layout.title), { exportSvg: $t, getSvg: Tt } = Yt({ svg: ie, title: At, legend: wt, legendItems: kt, backgroundColor: Ct, titleEmbedded: !0 }); async function Re({ isCb: l }) { if (l) { const { blob: r, url: t, text: s, dataUrl: f } = await Tt(); e.value.userOptions.callbacks.svg({ blob: r, url: t, text: s, dataUrl: f }); } else $t(); } return Ze({ getData: it, getImage: gt, generatePdf: Fe, generateCsv: ye, generateImage: Ne, generateSvg: Re, toggleTable: Pe, toggleAnnotator: he, toggleFullscreen: Oe }), (l, r) => (a(), o("div", { class: w(`vue-data-ui-component vue-ui-chestnut ${K.value ? "vue-data-ui-wrapper-fullscreen" : ""}`), ref_key: "chestnutChart", ref: Y, id: `vue-ui-chestnut_${$.value}`, style: y(`font-family:${e.value.style.fontFamily};width:100%; text-align:center;background:${e.value.style.chart.backgroundColor}`), onMouseenter: r[1] || (r[1] = () => n($e)(!0)), onMouseleave: r[2] || (r[2] = () => n($e)(!1)) }, [ e.value.userOptions.buttons.annotator ? (a(), oe(n(et), { key: 0, svgRef: n(ie), backgroundColor: e.value.style.chart.backgroundColor, color: e.value.style.chart.color, active: le.value, onClose: he }, { "annotator-action-close": A(() => [ C(l.$slots, "annotator-action-close", {}, void 0, !0) ]), "annotator-action-color": A(({ color: t }) => [ C(l.$slots, "annotator-action-color", R(E({ color: t })), void 0, !0) ]), "annotator-action-draw": A(({ mode: t }) => [ C(l.$slots, "annotator-action-draw", R(E({ mode: t })), void 0, !0) ]), "annotator-action-undo": A(({ disabled: t }) => [ C(l.$slots, "annotator-action-undo", R(E({ disabled: t })), void 0, !0) ]), "annotator-action-redo": A(({ disabled: t }) => [ C(l.$slots, "annotator-action-redo", R(E({ disabled: t })), void 0, !0) ]), "annotator-action-delete": A(({ disabled: t }) => [ C(l.$slots, "annotator-action-delete", R(E({ disabled: t })), void 0, !0) ]), _: 3 }, 8, ["svgRef", "backgroundColor", "color", "active"])) : h("", !0), ut.value ? (a(), o("div", tl, null, 512)) : h("", !0), e.value.userOptions.show && Ce.value && (n(Te) || n(re)) ? (a(), oe(n(tt), { ref_key: "userOptionsRef", ref: ne, key: `user_options_${we.value}`, backgroundColor: e.value.style.chart.backgroundColor, color: e.value.style.chart.color, isImaging: n(Se), isPrinting: n(ze), uid: $.value, hasPdf: e.value.userOptions.buttons.pdf, hasImg: e.value.userOptions.buttons.img, hasSvg: e.value.userOptions.buttons.svg, hasXls: e.value.userOptions.buttons.csv, hasTable: e.value.userOptions.buttons.table, hasFullscreen: e.value.userOptions.buttons.fullscreen, isFullscreen: K.value, titles: { ...e.value.userOptions.buttonTitles }, chartElement: Y.value, position: e.value.userOptions.position, hasAnnotator: e.value.userOptions.buttons.annotator, isAnnotation: le.value, callbacks: e.value.userOptions.callbacks, printScale: e.value.userOptions.print.scale, tableDialog: e.value.table.useDialog, onToggleFullscreen: Oe, onGeneratePdf: n(Fe), onGenerateCsv: ye, onGenerateImage: n(Ne), onGenerateSvg: Re, onToggleTable: Pe, onToggleAnnotator: he, style: y({ visibility: n(Te) ? n(re) ? "visible" : "hidden" : "visible" }) }, Ee({ _: 2 }, [ l.$slots.menuIcon ? { name: "menuIcon", fn: A(({ isOpen: t, color: s }) => [ C(l.$slots, "menuIcon", R(E({ isOpen: t, color: s })), void 0, !0) ]), key: "0" } : void 0, l.$slots.optionPdf ? { name: "optionPdf", fn: A(() => [ C(l.$slots, "optionPdf", {}, void 0, !0) ]), key: "1" } : void 0, l.$slots.optionCsv ? { name: "optionCsv", fn: A(() => [ C(l.$slots, "optionCsv", {}, void 0, !0) ]), key: "2" } : void 0, l.$slots.optionImg ? { name: "optionImg", fn: A(() => [ C(l.$slots, "optionImg", {}, void 0, !0) ]), key: "3" } : void 0, l.$slots.optionSvg ? { name: "optionSvg", fn: A(() => [ C(l.$slots, "optionSvg", {}, void 0, !0) ]), key: "4" } : void 0, l.$slots.optionTable ? { name: "optionTable", fn: A(() => [ C(l.$slots, "optionTable", {}, void 0, !0) ]), key: "5" } : void 0, l.$slots.optionFullscreen ? { name: "optionFullscreen", fn: A(({ toggleFullscreen: t, isFullscreen: s }) => [ C(l.$slots, "optionFullscreen", R(E({ toggleFullscreen: t, isFullscreen: s })), void 0, !0) ]), key: "6" } : void 0, l.$slots.optionAnnotator ? { name: "optionAnnotator", fn: A(({ toggleAnnotator: t, isAnnotator: s }) => [ C(l.$slots, "optionAnnotator", R(E({ toggleAnnotator: t, isAnnotator: s })), void 0, !0) ]), key: "7" } : void 0 ]), 1032, ["backgroundColor", "color", "isImaging", "isPrinting", "uid", "hasPdf", "hasImg", "hasSvg", "hasXls", "hasTable", "hasFullscreen", "isFullscreen", "titles", "chartElement", "position", "hasAnnotator", "isAnnotation", "callbacks", "printScale", "tableDialog", "onGeneratePdf", "onGenerateImage", "style"])) : h("", !0), i.value.height > 0 ? (a(), o("svg", { key: 3, ref_key: "svgRef", ref: ie, xmlns: n(Et), class: w({ "vue-data-ui-fullscreen--on": K.value, "vue-data-ui-fulscreen--off": !K.value }), viewBox: `0 0 ${i.value.width <= 0 ? 10 : i.value.width} ${i.value.height <= 0 ? 10 : i.value.height}`, style: y(`overflow:visible;background:transparent;color:${e.value.style.chart.color}`) }, [ ge(n(lt)), l.$slots["chart-background"] ? (a(), o("foreignObject", { key: 0, x: 0, y: 0, width: i.value.width <= 0 ? 10 : i.value.width, height: i.value.height <= 0 ? 10 : i.value.height, style: { pointerEvents: "none" } }, [ C(l.$slots, "chart-background", {}, void 0, !0) ], 8, al)) : h("", !0), d.value ? h("", !0) : (a(), o("g", ol, [ e.value.style.chart.layout.title.text ? (a(), o("text", { key: 0, "text-anchor": "middle", fill: e.value.style.chart.layout.title.color, "font-weight": e.value.style.chart.layout.title.bold ? "bold" : "normal", "font-size": e.value.style.chart.layout.title.fontSize, x: i.value.width / 2, y: 12 + e.value.style.chart.layout.title.fontSize + e.value.style.chart.layout.title.offsetY, onClick: T }, c(e.value.style.chart.layout.title.text), 9, sl)) : h("", !0), e.value.style.chart.layout.title.subtitle.text ? (a(), o("text", { key: 1, "text-anchor": "middle", fill: e.value.style.chart.layout.title.subtitle.color, "font-weight": e.value.style.chart.layout.title.subtitle.bold ? "bold" : "normal", "font-size": e.value.style.chart.layout.title.subtitle.fontSize, x: i.value.width / 2, y: 48 + e.value.style.chart.layout.title.subtitle.fontSize + e.value.style.chart.layout.title.subtitle.offsetY, onClick: T }, c(e.value.style.chart.layout.title.subtitle.text), 9, nl)) : h("", !0) ])), u("defs", null, [ (a(!0), o(_, null, m(N.value, (t, s) => (a(), o("radialGradient", { cx: "50%", cy: "50%", r: "50%", fx: "50%", fy: "50%", id: `root_gradient_${$.value}_${t.rootIndex}` }, [ u("stop", { offset: "0%", "stop-color": n(B)(n(Ve)(t.color, 0.05), 100 - e.value.style.chart.layout.roots.gradientIntensity) }, null, 8, rl), u("stop", { offset: "100%", "stop-color": t.color }, null, 8, il) ], 8, ul))), 256)), (a(!0), o(_, null, m(N.value, (t) => (a(), o("linearGradient", { x1: "0%", y1: "0%", x2: "100%", y2: "0%", id: `branch_gradient_${$.value}_${t.rootIndex}` }, [ u("stop", { offset: "0%", "stop-color": t.color }, null, 8, dl), u("stop", { offset: "100%", "stop-color": n(B)(n(Ve)(t.color, 0.02), 100 - e.value.style.chart.layout.branches.gradientIntensity) }, null, 8, vl) ], 8, cl))), 256)), u("radialGradient", { cx: "50%", cy: "50%", r: "50%", fx: "50%", fy: "50%", id: `nutpick_${$.value}` }, [ u("stop", { offset: "0%", "stop-color": n(B)("#FFFFFF", 0) }, null, 8, hl), u("stop", { offset: "80%", "stop-color": n(B)("#FFFFFF", e.value.style.chart.layout.nuts.selected.gradientIntensity) }, null, 8, bl), u("stop", { offset: "100%", "stop-color": n(B)("#FFFFFF", 0) }, null, 8, fl) ], 8, yl), u("radialGradient", { cx: "50%", cy: "50%", r: "50%", fx: "50%", fy: "50%", id: `nut_${$.value}` }, [ u("stop", { offset: "0%", "stop-color": n(B)("#FFFFFF", 0) }, null, 8, gl), u("stop", { offset: "80%", "stop-color": n(B)("#FFFFFF", e.value.style.chart.layout.nuts.gradientIntensity) }, null, 8, _l), u("stop", { offset: "100%", "stop-color": n(B)("#FFFFFF", 0) }, null, 8, ml) ], 8, pl), u("radialGradient", { cx: "50%", cy: "50%", r: "50%", fx: "50%", fy: "50%", id: `nut_underlayer_${$.value}` }, [ u("stop", { offset: "0%", "stop-color": n(B)(e.value.style.chart.backgroundColor, 100) }, null, 8, kl), u("stop", { offset: "80%", "stop-color": n(B)(e.value.style.chart.backgroundColor, 60) }, null, 8, Cl), u("stop", { offset: "100%", "stop-color": n(B)(e.value.style.chart.backgroundColor, 0) }, null, 8, wl) ], 8, xl) ]), e.value.style.chart.layout.grandTotal.show ? (a(), o("g", Al, [ u("text", { x: z.value.seedX, y: 32 + e.value.style.chart.layout.grandTotal.offsetY, "font-size": e.value.style.chart.layout.grandTotal.fontSize, "font-weight": e.value.style.chart.layout.grandTotal.bold ? "bold" : "normal", fill: e.value.style.chart.layout.grandTotal.color, "text-anchor": "middle", onClick: T }, c(e.value.style.chart.layout.grandTotal.text), 9, $l), u("text", { x: z.value.seedX, y: 38 + e.value.style.chart.layout.grandTotal.fontSize + e.value.style.chart.layout.grandTotal.offsetY, "font-size": e.value.style.chart.layout.grandTotal.fontSize, "font-weight": e.value.style.chart.layout.grandTotal.bold ? "bold" : "normal", fill: e.value.style.chart.layout.grandTotal.color, "text-anchor": "middle", onClick: T }, c(n(j)( e.value.style.chart.layout.grandTotal.formatter, D.value, n(F)({ p: e.value.style.chart.layout.grandTotal.prefix, v: D.value, s: e.value.style.chart.layout.grandTotal.suffix, r: e.value.style.chart.layout.grandTotal.roundingValue }) )), 9, Tl) ])) : h("", !0), (a(!0), o(_, null, m(U.value, (t) => (a(), o("g", null, [ u("defs", null, [ u("linearGradient", { id: `link_grad_${t.id}` }, [ u("stop", { offset: "0%", "stop-color": t.color }, null, 8, Sl), u("stop", { offset: "100%", "stop-color": n(B)(t.color, e.value.style.chart.layout.links.opacity) }, null, 8, Fl) ], 8, zl) ]), u("path", { d: _t(t), stroke: n(B)(t.color, e.value.style.chart.layout.links.opacity), fill: `url(#link_grad_${t.id})`, "stroke-linecap": "round", "stroke-linejoin": "round", style: y(`opacity:${I(t) ? 1 : 0}`), onClick: T }, null, 12, Nl) ]))), 256)), (a(!0), o(_, null, m(G.value, (t) => (a(), o("circle", { cx: t.x, cy: t.y, r: t.r, fill: e.value.style.chart.layout.roots.underlayerColor, stroke: "none", style: y(`cursor:pointer; opacity:${I(t) ? 1 : 0.05}`) }, null, 12, Bl))), 256)), (a(!0), o(_, null, m(G.value, (t, s) => (a(), o("circle", { cx: t.x, cy: t.y, r: t.r, fill: e.value.style.chart.layout.roots.useGradient ? `url(#root_gradient_${$.value}_${t.rootIndex})` : t.color, stroke: e.value.style.chart.layout.roots.stroke, "stroke-width": e.value.style.chart.layout.roots.strokeWidth, style: y(`cursor:pointer; opacity:${I(t) ? 1 : 0.05}`), onClick: (f) => Le(t) }, null, 12, Dl))), 256)), e.value.style.chart.layout.roots.labels.show ? (a(), o("g", Ll, [ (a(!0), o(_, null, m(G.value, (t, s) => (a(), o("text", { x: t.x, y: t.y + e.value.style.chart.layout.roots.labels.fontSize / 2.6, "text-anchor": "middle", "font-size": e.value.style.chart.layout.roots.labels.fontSize, fill: e.value.style.chart.layout.roots.labels.adaptColorToBackground ? n(Me)(t.color) : e.value.style.chart.layout.roots.labels.color, "font-weight": "bold", style: y(`cursor:pointer; opacity:${I(t) ? 1 : 0.05}`), onClick: (f) => Le(t) }, c(n(j)( e.value.style.chart.layout.roots.labels.formatter, t.total, n(F)({ p: e.value.style.chart.layout.roots.labels.prefix, v: t.total, s: e.value.style.chart.layout.roots.labels.suffix, r: e.value.style.chart.layout.roots.labels.roundingValue }), { datapoint: t } )), 13, Il))), 256)), (a(!0), o(_, null, m(G.value, (t) => (a(), o("g", null, [ d.value && t.rootIndex === d.value.rootIndex || x.value && t.rootIndex === x.value.rootIndex || L.value && t.rootIndex === L.value.rootIndex ? (a(), o("g", Ol, [ u("text", { x: t.x, y: t.y + t.r + 24, "text-anchor": "middle", fill: e.value.style.chart.layout.roots.labels.name.color, "font-size": e.value.style.chart.layout.roots.labels.name.fontSize, "font-weight": e.value.style.chart.layout.roots.labels.name.bold ? "bold" : "normal", onClick: T }, c(t.name), 9, Pl) ])) : h("", !0) ]))), 256)) ])) : h("", !0), (a(!0), o(_, null, m(U.value, (t) => (a(), o("rect", { x: t.x1, y: t.y1, height: i.value.branchSize, width: t.x2 - t.x1, fill: e.value.style.chart.layout.branches.underlayerColor, rx: e.value.style.chart.layout.branches.borderRadius, stroke: "none", style: y(`opacity:${I(t) ? 1 : 0.05}`), onClick: (s) => ve(t) }, null, 12, Rl))), 256)), (a(!0), o(_, null, m(U.value, (t, s) => (a(), o("rect", { x: t.x1, y: t.y1, height: i.value.branchSize, width: t.x2 - t.x1, fill: e.value.style.chart.layout.branches.useGradient ? `url(#branch_gradient_${$.value}_${t.rootIndex})` : t.color, rx: e.value.style.chart.layout.branches.borderRadius, stroke: e.value.style.chart.layout.branches.stroke, "stroke-width": e.value.style.chart.layout.branches.strokeWidth, style: y(`cursor:pointer; opacity:${I(t) ? 1 : 0.05}`), onClick: (f) => ve(t) }, null, 12, El))), 256)), e.value.style.chart.layout.branches.labels.dataLabels.show ? (a(), o("g", Vl, [ (a(!0), o(_, null, m(U.value, (t) => (a(), o("g", null, [ t.proportionToRoot * 100 > e.value.style.chart.layout.branches.labels.dataLabels.hideUnderValue ? (a(), o("text", { key: 0, x: t.x1 + 6, y: t.y1 + i.value.branchSize / 1.5, "text-anchor": "start", fill: n(Me)(t.color), "font-size": e.value.style.chart.layout.branches.labels.dataLabels.fontSize, "font-weight": "bold", style: y(`cursor:pointer; opacity:${I(t) ? 1 : 0.05}`), onClick: (s) => ve(t) }, c(n(j)( e.value.style.chart.layout.branches.labels.dataLabels.formatter, t.value, n(F)({ p: e.value.style.chart.layout.branches.labels.dataLabels.prefix, v: t.value, s: e.value.style.chart.layout.branches.labels.dataLabels.suffix, r: e.value.style.chart.layout.branches.labels.dataLabels.roundingValue }), { datapoint: t } )), 13, Ml)) : h("", !0) ]))), 256)) ])) : h("", !0), (a(!0), o(_, null, m(U.value, (t, s) => (a(), o("g", null, [ (a(!0), o(_, null, m(n(je)( { series: t.breakdown, base: 1 }, t.x2 + 24 + e.value.style.chart.layout.nuts.offsetX, t.y1 + i.value.branchSize / 2, i.value.branchSize / 3, i.value.branchSize / 3 ), (f, p) => (a(), o("path", { d: f.path, stroke: f.color, "stroke-width": 10, fill: "none", style: y(`opacity:${I(t) ? 1 : 0.1}`) }, null, 12, jl))), 256)), u("circle", { fill: e.value.style.chart.layout.nuts.useGradient ? `url(#nut_${$.value})` : "transparent", cx: t.x2 + 24 + e.value.style.chart.layout.nuts.offsetX, cy: t.y1 + i.value.branchSize / 2, r: i.value.branchSize / 2 + 2, onClick: (f) => ft(t), style: y(`cursor:pointer;opacity:${I(t) ? 1 : 0.1}`) }, null, 12, Xl) ]))), 256)), e.value.style.chart.layout.branches.labels.show && !x.value ? (a(), o("g", Gl, [ (a(!0), o(_, null, m(U.value, (t) => (a(), o("text", { x: t.x2 + i.value.branchSize + 24 + e.value.style.chart.layout.nuts.offsetX, y: t.y1 + i.value.branchSize / 2 + 5, "font-size": e.value.style.chart.layout.branches.labels.fontSize, "font-weight": e.value.style.chart.layout.branches.labels.bold ? "bold" : "normal", fill: e.value.style.chart.layout.branches.labels.color, "text-anchor": "start", style: y(`opacity:${I(t) ? 1 : 0.1}`) }, c(t.name), 13, Ul))), 256)) ])) : h("", !0), u("line", { x1: 256 + i.value.padding.left, x2: 256 + i.value.padding.left, y1: z.value.top, y2: z.value.bottom, stroke: e.value.style.chart.layout.verticalSeparator.stroke, "stroke-width": e.value.style.chart.layout.verticalSeparator.strokeWidth }, null, 8, Wl), !d.value && !x.value ? (a(), o("foreignObject", { key: 6, x: 0, y: z.value.bottom, height: i.value.height - z.value.bottom, width: i.value.width, style: { overflow: "visible" }, "data-no-svg-export": "", onClick: T }, [ u("div", Hl, [ u("div", ql, [ (a(!0), o(_, null, m(G.value, (t) => (a(), o("div", { style: y(`display:flex;align-items:center;gap:3px;flex-direction:row;font-size:${e.value.style.chart.layout.legend.fontSize}px;`) }, [ (a(), o("svg", Kl, [ u("circle", { cx: "10", cy: "10", r: "10", fill: t.color, stroke: "none" }, null, 8, Zl) ])),