UNPKG

vue-data-ui

Version:

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

1,157 lines • 71 kB
import { defineAsyncComponent as he, ref as z, computed as U, watch as Ve, shallowRef as ft, onMounted as Tt, onBeforeUnmount as Pt, nextTick as Me, createElementBlock as l, openBlock as a, normalizeStyle as R, normalizeClass as fe, createBlock as Fe, createCommentVNode as g, createVNode as ge, unref as f, createSlots as Rt, withCtx as G, renderSlot as M, normalizeProps as ie, guardReactiveProps as ue, toDisplayString as O, createElementVNode as _, Fragment as m, renderList as $, mergeProps as qe } from "vue"; import { u as Mt, c as Ft, t as Nt, p as q, a as Ut, C as gt, b as Bt, G as Dt, e as Vt, d as He, m as qt, D as mt, X as Ht, j as Wt, k as We, n as Le, i as X, f as D, I as jt, V as pt, v as Z, x as Ne, y as je } from "./index-BLtEpj8j.js"; import { t as Gt, u as Xt } from "./useResponsive-DfdjqQps.js"; import { u as yt } from "./useNestedProp-Bw1KcAmj.js"; import { u as Zt } from "./usePrinter-DnRwTdvS.js"; import { u as Yt } from "./useChartAccessibility-9icAAmYg.js"; import { S as Jt } from "./Slicer-D-HtJC7M.js"; import { u as Qt } from "./useTimeLabels-DFkUfjfs.js"; import Kt from "./img-D-vWHxhM.js"; import { _ as ea } from "./_plugin-vue_export-helper-CHgC5LLL.js"; const A = { LINE: "LINE", BAR: "BAR", DONUT: "DONUT" }, ta = ["SERIE", "SERIES", "DATA", "VALUE", "VALUES", "NUM"]; function aa({ dataset: c, barLineSwitch: C = 6 }) { let y = null, T = null, H = 0; if ((typeof c == "number" || typeof c == "string") && console.warn(`The provided dataset (${c}) is not sufficient to build a chart`), ze(c) && (Y(c) && (c.length < C ? y = A.BAR : y = A.LINE, T = c, H = c.length), Ue(c))) { if (!oa(c)) return console.warn("The objects in the dataset array have a different data structure. Either keys or value types are different."), !1; const ye = Object.keys(c[0]), $e = Object.values(c[0]); if (!ye.some((F) => na(F))) return console.warn("The data type of the dataset objects in the array must contain one of the following keys: DATA, SERIES, VALUE, VALUES, NUM. Casing is not important."), !1; xt($e, (F) => typeof F == "number") && (y = A.DONUT, T = c), xt($e, (F) => Array.isArray(F) && Y(F)) && (kt(c) > C ? y = A.LINE : y = A.BAR, H = kt(c), T = c.map((F) => ({ ...F, data: ia(F, (B) => Y(B)) }))), c = c.map((F) => bt(F)), T = T.map((F) => bt(F)); } return ze(c) && [...new Set(c.flatMap((ye) => Array.isArray(ye)))][0], { dataset: c, type: y, usableDataset: T, maxSeriesLength: H }; } function St(c) { return !c || ze(c) && !c.length; } function ze(c) { return Array.isArray(c); } function Y(c) { if (!ze(c) || St(c)) return !1; const C = c.map((y) => Number(y)); return ![...new Set(C.flatMap((y) => typeof y == "number" && !isNaN(y)))].includes(!1); } function Ue(c) { return !ze(c) || St(c) || !![...new Set(c.flatMap((y) => typeof y == "object" && !Array.isArray(y)))].includes(!1) ? !1 : !c.map((y) => Object.keys(y).length > 0).includes(!1); } function la(c, C) { const y = Object.keys(c).sort(), T = Object.keys(C).sort(); if (y.length !== T.length) return !1; for (let H = 0; H < y.length; H += 1) { const me = y[H], pe = T[H]; if (me !== pe || typeof c[me] != typeof C[pe]) return !1; } return !0; } function oa(c) { if (c.length <= 1) return !0; for (let C = 0; C < c.length; C += 1) for (let y = C + 1; y < c.length; y += 1) if (!la(c[C], c[y])) return !1; return !0; } function na(c) { return ta.includes(c.toUpperCase()); } function xt(c, C) { let y = []; for (let T = 0; T < c.length; T += 1) y.push(C(c[T])); return y.includes(!0); } function kt(c) { return Math.max(...[...c].flatMap((C) => Object.values(C).filter((y) => Y(y)).map((y) => y.length))); } function ia(c, C) { return Object.values(c).filter((y) => C(y))[0]; } function bt(c) { const C = {}; for (let y in c) c.hasOwnProperty(y) && (C[y.toUpperCase()] = c[y]); return C; } const ua = ["id"], ra = ["xmlns", "viewBox"], sa = ["x", "y", "width", "height"], va = ["x", "y", "width", "height"], da = ["width", "height"], ca = ["id"], ha = ["id"], fa = ["id"], ga = ["flood-color"], ma = { key: 0, class: "donut-label-connectors" }, pa = ["d", "stroke", "stroke-width", "filter"], ya = ["cx", "cy", "r", "fill", "filter"], xa = { class: "donut" }, ka = ["d", "fill", "stroke", "stroke-width", "filter"], ba = ["d", "onMouseenter", "onClick"], Sa = { key: 1, class: "donut-labels quick-animation" }, wa = ["cx", "cy", "fill", "stroke", "filter"], Aa = ["text-anchor", "x", "y", "fill", "font-size", "filter"], _a = ["text-anchor", "x", "y", "fill", "font-size", "filter"], La = { key: 2, class: "donut-hollow quick-animation" }, za = ["x", "y", "font-size", "fill"], $a = ["x", "y", "font-size", "fill"], Ca = { key: 0, class: "line-grid" }, Ia = ["x1", "x2", "y1", "y2", "stroke", "stroke-width"], Ea = ["x1", "x2", "y1", "y2", "stroke", "stroke-width"], Oa = { key: 1, class: "line-axis" }, Ta = ["x1", "x2", "y1", "y2", "stroke", "stroke-width"], Pa = ["x1", "x2", "y1", "y2", "stroke", "stroke-width"], Ra = { key: 2, class: "yLabels" }, Ma = ["x1", "x2", "y1", "y2", "stroke", "stroke-width"], Fa = ["x", "y", "font-size", "fill"], Na = { key: 3, class: "periodLabels" }, Ua = ["x1", "x2", "y1", "y2", "stroke", "stroke-width"], Ba = { key: 1 }, Da = ["font-size", "text-anchor", "fill", "transform"], Va = ["font-size", "text-anchor", "fill", "transform", "innerHTML"], qa = { class: "plots" }, Ha = { class: "line-plot-series" }, Wa = ["d", "stroke", "stroke-width"], ja = ["d", "stroke", "stroke-width"], Ga = ["d", "stroke", "stroke-width"], Xa = ["d", "stroke", "stroke-width"], Za = ["cx", "cy", "fill", "stroke"], Ya = { key: 4, class: "dataLabels" }, Ja = ["font-size", "fill", "x", "y"], Qa = { class: "tooltip-traps" }, Ka = ["x", "y", "height", "width", "fill", "onMouseenter", "onClick"], el = { key: 0, class: "line-grid" }, tl = ["x1", "x2", "y1", "y2", "stroke", "stroke-width"], al = ["x1", "x2", "y1", "y2", "stroke", "stroke-width"], ll = { key: 1, class: "line-axis" }, ol = ["x1", "x2", "y1", "y2", "stroke", "stroke-width"], nl = ["x1", "x2", "y1", "y2", "stroke", "stroke-width"], il = { key: 2, class: "yLabels" }, ul = ["x1", "x2", "y1", "y2", "stroke", "stroke-width"], rl = ["x", "y", "font-size", "fill"], sl = { key: 3, class: "periodLabels" }, vl = ["x1", "x2", "y1", "y2", "stroke", "stroke-width"], dl = ["font-size", "text-anchor", "transform", "fill"], cl = { class: "plots" }, hl = ["x", "width", "height", "y", "fill", "stroke", "stroke-width"], fl = ["to"], gl = ["from", "to"], ml = { key: 4, class: "dataLabels" }, pl = ["x", "y", "font-size", "fill"], yl = { class: "tooltip-traps" }, xl = ["x", "y", "height", "width", "fill", "onMouseenter", "onClick"], kl = { key: 6, class: "axis-labels" }, bl = { key: 0 }, Sl = ["font-size", "fill", "x", "y"], wl = { key: 1 }, Al = ["font-size", "fill", "x", "y"], _l = { key: 2 }, Ll = ["font-size", "fill", "transform"], zl = { key: 3 }, $l = ["font-size", "fill", "transform"], Cl = { key: 6, class: "vue-data-ui-watermark" }, Il = ["onClick"], El = ["onClick"], Ol = ["onClick"], Tl = { key: 1, class: "vue-ui-quick-chart-not-processable" }, Pl = { __name: "vue-ui-quick-chart", props: { config: { type: Object, default() { return {}; } }, dataset: { type: [Array, Object, String, Number], default() { return null; } } }, emits: ["selectDatapoint", "selectLegend"], setup(c, { expose: C, emit: y }) { const T = he(() => import("./BaseIcon-Ba5t14Aj.js")), H = he(() => import("./PackageVersion-CnRyWKP-.js")), me = he(() => import("./PenAndPaper-7BWf7zgA.js")), pe = he(() => import("./vue-ui-skeleton-CsMU8DwQ.js")), ye = he(() => import("./Tooltip-CuHsd1IQ.js")), $e = he(() => import("./UserOptions-DGw0HvSp.js")), { vue_ui_quick_chart: F } = Mt(), B = c, J = z(null), Ge = z(null), Xe = z(null), Ze = z(null), Q = z(Ft()), te = z(!1), xe = z(null), ae = z(""), W = z(null), Ye = z(null), Je = z(null), w = z([]), Qe = z(0), Ce = z(0), e = U({ get: () => at(), set: (o) => o }), { svgRef: Ke } = Yt({ config: { text: e.value.title } }), wt = U(() => e.value.showUserOptionsOnChartHover), et = U(() => e.value.keepUserOptionsStateOnChartLeave), Ie = z(!e.value.showUserOptionsOnChartHover); function tt(o = !1) { wt.value && (Ie.value = o); } function at() { const o = yt({ userConfig: B.config, defaultConfig: F }); let s = {}; return o.theme ? s = { ...yt({ userConfig: Ut.vue_ui_quick_chart[o.theme] || B.config, defaultConfig: o }), customPalette: Nt[o.theme] || q } : s = o, B.config && gt(B.config, "zoomStartIndex") ? s.zoomStartIndex = B.config.zoomStartIndex : s.zoomStartIndex = null, B.config && gt(B.config, "zoomEndIndex") ? s.zoomEndIndex = B.config.zoomEndIndex : s.zoomEndIndex = null, s; } Ve(() => B.config, (o) => { e.value = at(), b.value.width = e.value.width, b.value.height = e.value.height, Ie.value = !e.value.showUserOptionsOnChartHover, nt(), Se.value.showTooltip = e.value.showTooltip; }, { deep: !0 }), Ve(() => B.dataset, (o) => { p.value = be.value, x.value.start = 0, x.value.end = p.value.maxSeriesLength, Ce.value += 1; }, { deep: !0 }); const ke = U(() => Bt(e.value.customPalette)), re = y, be = U(() => { const o = aa({ dataset: Dt(B.dataset, [ "serie", "series", "data", "value", "values", "num" ]), barLineSwitch: e.value.chartIsBarUnderDatasetLength }); return o || console.error("VueUiQuickChart : Dataset is not processable"), o; }), p = z(be.value), At = U(() => !!p.value), L = U(() => p.value ? p.value.type : null); Ve(() => L.value, (o) => { o || Vt({ componentName: "VueUiQuickChart", type: "dataset" }); }, { immediate: !0 }); const { isPrinting: Ee, isImaging: Oe, generatePdf: lt, generateImage: ot } = Zt({ elementId: `${L.value}_${Q.value}`, fileName: e.value.title || L.value, options: e.value.userOptionsPrint }), _t = U(() => e.value.showUserOptions && !e.value.title), b = z({ width: e.value.width, height: e.value.height }), Se = z({ showTooltip: e.value.showTooltip }), K = ft(null), se = ft(null); Tt(() => { nt(); }); function nt() { if (e.value.responsive) { const o = Gt(() => { const { width: s, height: t } = Xt({ chart: J.value, title: e.value.title ? Ge.value : null, legend: e.value.showLegend ? Xe.value : null, slicer: [A.BAR, A.LINE].includes(L.value) && e.value.zoomXy && p.value.maxSeriesLength > 1 ? Ze.value : null, source: Ye.value, noTitle: Je.value }); requestAnimationFrame(() => { b.value.width = s, b.value.height = t; }); }); K.value && (se.value && K.value.unobserve(se.value), K.value.disconnect()), K.value = new ResizeObserver(o), se.value = J.value.parentNode, K.value.observe(se.value); } dt(); } Pt(() => { K.value && (se.value && K.value.unobserve(se.value), K.value.disconnect()); }); const Lt = U(() => { switch (L.value) { case A.LINE: return `0 0 ${b.value.width <= 0 ? 10 : b.value.width} ${b.value.height <= 0 ? 10 : b.value.height}`; case A.BAR: return `0 0 ${b.value.width <= 0 ? 10 : b.value.width} ${b.value.height <= 0 ? 10 : b.value.height}`; case A.DONUT: return `0 0 ${b.value.width <= 0 ? 10 : b.value.width} ${b.value.height <= 0 ? 10 : b.value.height}`; default: return `0 0 ${b.value.width <= 0 ? 10 : b.value.width} ${b.value.height <= 0 ? 10 : b.value.height}`; } }); function it(o) { return [...o].map((s) => s.value).reduce((s, t) => s + t, 0); } function we(o) { return e.value.blurOnHover && ![null, void 0].includes(W.value) && W.value !== o ? `url(#blur_${Q.value})` : ""; } function ut(o, s) { w.value.includes(o) ? w.value = w.value.filter((t) => t !== o) : w.value.length < s && w.value.push(o); } const rt = z(null), st = z(null), Te = z(!1); function zt(o, s) { Te.value = !0; let t = o.value; const u = be.value.dataset.find((r, h) => o.id === `donut_${h}`).VALUE; if (w.value.includes(o.id)) { let r = function() { t > u ? (Te.value = !1, cancelAnimationFrame(st.value), p.value = { ...p.value, dataset: p.value.dataset.map((h, P) => o.id === `donut_${P}` ? { ...h, value: u, VALUE: u } : h) }) : (t += u * 0.025, p.value = { ...p.value, dataset: p.value.dataset.map((h, P) => o.id === `donut_${P}` ? { ...h, value: t, VALUE: t } : h) }, st.value = requestAnimationFrame(r)); }; w.value = w.value.filter((h) => h !== o.id), r(); } else if (s.length > 1) { let r = function() { t < u / 100 ? (Te.value = !1, cancelAnimationFrame(rt.value), w.value.push(o.id), p.value = { ...p.value, dataset: p.value.dataset.map((h, P) => o.id === `donut_${P}` ? { ...h, value: 0, VALUE: 0 } : h) }) : (t /= 1.1, p.value = { ...p.value, dataset: p.value.dataset.map((h, P) => o.id === `donut_${P}` ? { ...h, value: t, VALUE: t } : h) }, rt.value = requestAnimationFrame(r)); }; r(); } } const j = z(null); function $t(o) { j.value = o; } const vt = U(() => e.value.donutThicknessRatio < 0.15 ? 0.15 : e.value.donutThicknessRatio > 0.4 ? 0.4 : e.value.donutThicknessRatio), I = U(() => { if (L.value !== A.DONUT) return null; const o = p.value.dataset.map((n, i) => ({ ...n, value: n.VALUE || n.DATA || n.SERIE || n.VALUES || n.NUM || 0, name: n.NAME || n.DESCRIPTION || n.TITLE || n.LABEL || `Serie ${i}`, id: `donut_${i}` })).map((n, i) => ({ ...n, color: n.COLOR ? He(n.COLOR) : ke.value[i + e.value.paletteStartIndex] || q[i + e.value.paletteStartIndex] || q[(i + e.value.paletteStartIndex) % q.length], immutableValue: n.value })); function s(n, i) { return D({ v: isNaN(n.value / it(i)) ? 0 : n.value / it(i) * 100, s: "%", r: e.value.dataLabelRoundingPercentage }); } function t(n) { return n.proportion * 100 > e.value.donutHideLabelUnderPercentage; } function u(n, i) { const S = be.value.dataset.find((E, N) => `donut_${N}` === n).VALUE; return Math.abs(String(Number(S.toFixed(0))).length - String(Number(i.toFixed(0))).length); } function r({ datapoint: n, seriesIndex: i }) { xe.value = { datapoint: n, seriesIndex: i, config: e.value, dataset: o }, W.value = n.id; const S = e.value.tooltipCustomFormat; if (Ne(S) && je(() => S({ datapoint: n, seriesIndex: i, series: o, config: e.value }))) ae.value = S({ datapoint: n, seriesIndex: i, series: o, config: e.value }); else { let k = ""; k += `<div style="width:100%;text-align:center;border-bottom:1px solid ${e.value.tooltipBorderColor};padding-bottom:6px;margin-bottom:3px;">${n.name}</div>`, k += `<div style="display:flex;flex-direction:row;gap:6px;align-items:center;"><svg viewBox="0 0 12 12" height="14" width="14"><circle cx="6" cy="6" r="6" stroke="none" fill="${n.color}"/></svg>`, k += `<b>${X( e.value.formatter, n.value, D({ p: e.value.valuePrefix, v: n.value, s: e.value.valueSuffix, r: e.value.dataLabelRoundingValue }), { datapoint: n, seriesIndex: i } )}</b>`, k += `<span>(${D({ v: n.proportion * 100, s: "%", r: e.value.dataLabelRoundingPercentage })})</span></div>`, ae.value = `<div>${k}</div>`; } te.value = !0; } function h() { te.value = !1, W.value = null, j.value = null; } const P = { centerX: b.value.width / 2, centerY: b.value.height / 2 }, V = o.filter((n) => !w.value.includes(n.id)).map((n) => n.value || 0).reduce((n, i) => n + i, 0), de = o.map((n, i) => ({ ...n, proportion: (n.value || 0) / V, value: n.value || 0, absoluteValue: be.value.dataset.find((S, k) => `donut_${k}` === n.id).VALUE })), le = b.value.width / 2, ce = b.value.height / 2, oe = b.value.height * e.value.donutRadiusRatio; return { dataset: de.filter((n) => !w.value.includes(n.id)), legend: de, drawingArea: P, displayArcPercentage: s, isArcBigEnough: t, useTooltip: r, killTooltip: h, getSpaces: u, total: V, cx: le, cy: ce, radius: oe, chart: qt( { series: o.filter((n) => !w.value.includes(n.id)) }, le, ce, oe, oe, 1.99999, 2, 1, 360, 105.25, b.value.height * vt.value ) }; }), x = z({ start: 0, end: p.value.maxSeriesLength }); function Ct() { dt(); } const ve = z(null); async function dt() { (e.value.zoomStartIndex !== null || e.value.zoomEndIndex !== null) && ve.value ? (e.value.zoomStartIndex !== null && (await Me(), await Me(), ve.value && ve.value.setStartValue(e.value.zoomStartIndex)), e.value.zoomEndIndex !== null && (await Me(), await Me(), ve.value && ve.value.setEndValue(It(e.value.zoomEndIndex + 1)))) : (x.value = { start: 0, end: p.value.maxSeriesLength }, Ce.value += 1); } function It(o) { const s = p.value.maxSeriesLength; return o > s ? s : o < 0 || e.value.zoomStartIndex !== null && o < e.value.zoomStartIndex ? e.value.zoomStartIndex !== null ? e.value.zoomStartIndex + 1 : 1 : o; } const Et = U(() => { if (!e.value.zoomMinimap.show || L.value === A.DONUT) return []; let o = []; Y(p.value.dataset) && (o = p.value.dataset), Ue(p.value.dataset) && (o = p.value.dataset.map((r, h) => ({ values: r.VALUE || r.DATA || r.SERIE || r.SERIES || r.VALUES || r.NUM || 0, id: L.value === A.LINE ? `line_${h}` : `bar_${h}` })).filter((r) => !w.value.includes(r.id))); const s = Y(o) ? o.length : Math.max(...o.map((r) => r.values.length)); let t = []; if (Y(o)) t = o; else for (let r = 0; r < s; r += 1) t.push(o.map((h) => h.values[r] || 0).reduce((h, P) => (h || 0) + (P || 0), 0)); const u = Math.min(...t); return t.map((r) => r + (u < 0 ? Math.abs(u) : 0)); }), v = U(() => { if (L.value !== A.LINE) return null; const o = { height: b.value.height, width: b.value.width }, s = { left: e.value.xyPaddingLeft, top: e.value.xyPaddingTop, right: o.width - e.value.xyPaddingRight, bottom: o.height - e.value.xyPaddingBottom, width: o.width - e.value.xyPaddingLeft - e.value.xyPaddingRight, height: o.height - e.value.xyPaddingTop - e.value.xyPaddingBottom }; let t = []; Y(p.value.dataset) && (t = [ { values: p.value.dataset.slice(x.value.start, x.value.end), absoluteIndices: p.value.dataset.map((n, i) => i).slice(x.value.start, x.value.end), name: e.value.title, color: ke.value[e.value.paletteStartIndex] || q[e.value.paletteStartIndex], id: "line_0" } ]), Ue(p.value.dataset) && (t = p.value.dataset.map((n, i) => ({ ...n, values: n.VALUE || n.DATA || n.SERIE || n.SERIES || n.VALUES || n.NUM || 0, name: n.NAME || n.DESCRIPTION || n.TITLE || n.LABEL || `Serie ${i}`, id: `line_${i}` })).map((n, i) => ({ ...n, color: n.COLOR ? He(n.COLOR) : ke.value[i + e.value.paletteStartIndex] || q[i + e.value.paletteStartIndex] || q[(i + e.value.paletteStartIndex) % q.length], values: n.values.slice(x.value.start, x.value.end), absoluteIndices: n.values.map((S, k) => k).slice(x.value.start, x.value.end) }))); const u = { max: Math.max(...t.filter((n) => !w.value.includes(n.id)).flatMap((n) => n.values)), min: Math.min(...t.filter((n) => !w.value.includes(n.id)).flatMap((n) => n.values)), maxSeries: Math.max(...t.map((n) => n.values.length)) }, r = mt(u.min < 0 ? u.min : 0, u.max < 0 ? 0 : u.max, e.value.xyScaleSegments), h = u.min < 0 ? Math.abs(u.min) : 0, P = u.max < 0 ? s.top : s.bottom - h / (r.max + h) * s.height, V = s.width / u.maxSeries, de = r.ticks.map((n) => ({ y: s.bottom - s.height * ((n + h) / (r.max + h)), x: s.left - 8, value: n })), le = t.map((n, i) => ({ ...n, coordinates: n.values.map((S, k) => ({ x: s.left + V * (k + 1) - V / 2, y: s.bottom - (S + h) / (r.max + h) * s.height, value: S })) })).map((n) => { let i = []; return n.coordinates.forEach((S) => { i.push(`${S.x},${S.y} `); }), { ...n, linePath: i.join(" ") }; }); function ce(n) { W.value = n, j.value = n; const i = t.map((k) => ({ ...k, value: k.values[n], absoluteIndex: k.absoluteIndices[n] })).filter((k) => !w.value.includes(k.id)); xe.value = { datapoint: i, seriesIndex: n, config: e.value, dataset: t }; const S = e.value.tooltipCustomFormat; if (Ne(S) && je(() => S({ datapoint: i, seriesIndex: n, series: t, config: e.value }))) ae.value = S({ datapoint: i, seriesIndex: n, series: t, config: e.value }); else { let k = ""; ee.value[i[0].absoluteIndex] && (k += `<div style="border-bottom:1px solid ${e.value.tooltipBorderColor};padding-bottom:6px;margin-bottom:3px;">${ee.value[i[0].absoluteIndex].text}</div>`), i.forEach((E, N) => { k += ` <div style="display:flex; flex-wrap: wrap; align-items:center; gap:3px;"> <svg viewBox="0 0 12 12" height="14" width="12"><circle cx="6" cy="6" r="6" stroke="none" fill="${E.color}"/></svg> <span>${E.name}:</span> <b>${X( e.value.formatter, E.value, D({ p: e.value.valuePrefix, v: E.value, s: e.value.valueSuffix, r: e.value.dataLabelRoundingValue }), { datapoint: E, seriesIndex: N } )} </b> </div> `; }), ae.value = k; } te.value = !0; } function oe() { W.value = null, j.value = null, te.value = !1; } return { absoluteZero: P, dataset: le.filter((n) => !w.value.includes(n.id)), legend: le, drawingArea: s, extremes: u, slotSize: V, yLabels: de, useTooltip: ce, killTooltip: oe }; }), d = U(() => { if (L.value !== A.BAR) return null; const o = { height: b.value.height, width: b.value.width }, s = { left: e.value.xyPaddingLeft, top: e.value.xyPaddingTop, right: o.width - e.value.xyPaddingRight, bottom: o.height - e.value.xyPaddingBottom, width: o.width - e.value.xyPaddingLeft - e.value.xyPaddingRight, height: o.height - e.value.xyPaddingTop - e.value.xyPaddingBottom }; let t = []; Y(p.value.dataset) && (t = [ { values: p.value.dataset.slice(x.value.start, x.value.end), absoluteIndices: p.value.dataset.map((i, S) => S).slice(x.value.start, x.value.end), name: e.value.title, color: ke.value[e.value.paletteStartIndex] || q[e.value.paletteStartIndex], id: "bar_0" } ]), Ue(p.value.dataset) && (t = p.value.dataset.map((i, S) => ({ ...i, values: i.VALUE || i.DATA || i.SERIE || i.SERIES || i.VALUES || i.NUM || 0, name: i.NAME || i.DESCRIPTION || i.TITLE || i.LABEL || `Serie ${S}`, id: `bar_${S}` })).map((i, S) => ({ ...i, color: i.COLOR ? He(i.COLOR) : ke.value[S + e.value.paletteStartIndex] || q[S + e.value.paletteStartIndex] || q[(S + e.value.paletteStartIndex) % q.length], values: i.values.slice(x.value.start, x.value.end), absoluteIndices: i.values.map((k, E) => E).slice(x.value.start, x.value.end) }))); const u = { max: Math.max(...t.filter((i) => !w.value.includes(i.id)).flatMap((i) => i.values)) < 0 ? 0 : Math.max(...t.filter((i) => !w.value.includes(i.id)).flatMap((i) => i.values)), min: Math.min(...t.filter((i) => !w.value.includes(i.id)).flatMap((i) => i.values)), maxSeries: Math.max(...t.filter((i) => !w.value.includes(i.id)).map((i) => i.values.length)) }, r = mt(u.min < 0 ? u.min : 0, u.max, e.value.xyScaleSegments), h = r.min < 0 ? Math.abs(r.min) : 0, P = s.bottom - h / (r.max + h) * s.height, V = s.width / u.maxSeries, de = r.ticks.map((i) => ({ y: s.bottom - s.height * ((i + h) / (r.max + h)), x: s.left - 8, value: i })), le = t.map((i, S) => ({ ...i, coordinates: i.values.map((k, E) => { const N = (k + h) / (u.max + h) * s.height, Ae = Math.abs(k) / Math.abs(u.min) * (s.height - P), De = h / (u.max + h) * s.height, _e = V / t.filter((ne) => !w.value.includes(ne.id)).length - e.value.barGap / t.filter((ne) => !w.value.includes(ne.id)).length; return { x: s.left + V * E + _e * S + e.value.barGap / 2, y: k > 0 ? s.bottom - N : P, height: k > 0 ? N - De : Ae, value: k, width: _e }; }) })), ce = t.filter((i) => !w.value.includes(i.id)).map((i, S) => ({ ...i, coordinates: i.values.map((k, E) => { const N = (k + h) / (u.max + h) * s.height, Ae = Math.abs(k) / (u.max + h) * s.height, De = h / (u.max + h) * s.height, _e = V / t.filter((ne) => !w.value.includes(ne.id)).length - e.value.barGap / t.filter((ne) => !w.value.includes(ne.id)).length; return { x: s.left + V * E + _e * S + e.value.barGap / 2, y: k > 0 ? s.bottom - N : P, height: k > 0 ? N - De : Ae, value: k, width: _e }; }) })); function oe(i) { W.value = i, j.value = i; const S = t.map((E) => ({ ...E, value: E.values[i], absoluteIndex: E.absoluteIndices[i] })).filter((E) => !w.value.includes(E.id)); xe.value = { datapoint: S, seriesIndex: i, config: e.value, dataset: t }; const k = e.value.tooltipCustomFormat; if (Ne(k) && je(() => k({ datapoint: S, seriesIndex: i, series: t, config: e.value }))) ae.value = k({ point: S, seriesIndex: i, series: t, config: e.value }); else { let E = ""; ee.value[S[0].absoluteIndex] && (E += `<div style="border-bottom:1px solid ${e.value.tooltipBorderColor};padding-bottom:6px;margin-bottom:3px;">${ee.value[S[0].absoluteIndex].text}</div>`), S.forEach((N, Ae) => { E += ` <div style="display:flex; flex-wrap: wrap; align-items:center; gap:3px;"> <svg viewBox="0 0 12 12" height="14" width="12"><rect x=0 y="0" width="12" height="12" rx="1" stroke="none" fill="${N.color}"/></svg> <span>${N.name}:</span> <b>${X( e.value.formatter, N.value, D({ p: e.value.valuePrefix, v: N.value, s: e.value.valueSuffix, r: e.value.dataLabelRoundingValue }), { datapoint: N, seriesIndex: Ae } )} </b> </div> `; }), ae.value = E; } te.value = !0; } function n() { te.value = !1, W.value = null, j.value = null; } return { absoluteZero: P, dataset: ce.filter((i) => !w.value.includes(i.id)), legend: le, drawingArea: s, extremes: u, slotSize: V, yLabels: de, useTooltip: oe, killTooltip: n }; }), ee = U(() => Qt({ values: e.value.xyPeriods, maxDatapoints: p.value.maxSeriesLength, formatter: e.value.datetimeFormatter, start: x.value.start, end: x.value.end })), Pe = z(!1); function ct(o) { Pe.value = o, Qe.value += 1; } function ht() { Se.value.showTooltip = !Se.value.showTooltip; } const Re = z(!1); function Be() { Re.value = !Re.value; } async function Ot({ scale: o = 2 } = {}) { if (!J.value) return; const { width: s, height: t } = J.value.getBoundingClientRect(), u = s / t, { imageUri: r, base64: h } = await Kt({ domElement: J.value, base64: !0, img: !0, scale: o }); return { imageUri: r, base64: h, title: e.value.title, width: s, height: t, aspectRatio: u }; } return C({ getImage: Ot, generatePdf: lt, generateImage: ot, toggleTooltip: ht, toggleAnnotator: Be, toggleFullscreen: ct }), (o, s) => At.value ? (a(), l("div", { key: 0, id: `${L.value}_${Q.value}`, ref_key: "quickChart", ref: J, class: fe({ "vue-ui-quick-chart": !0, "vue-data-ui-wrapper-fullscreen": Pe.value }), style: R(`background:${e.value.backgroundColor};color:${e.value.color};font-family:${e.value.fontFamily}; position: relative; ${e.value.responsive ? "height: 100%" : ""}`), onMouseenter: s[5] || (s[5] = () => tt(!0)), onMouseleave: s[6] || (s[6] = () => tt(!1)) }, [ e.value.userOptionsButtons.annotator ? (a(), Fe(f(me), { key: 0, svgRef: f(Ke), backgroundColor: e.value.backgroundColor, color: e.value.color, active: Re.value, onClose: Be }, null, 8, ["svgRef", "backgroundColor", "color", "active"])) : g("", !0), _t.value ? (a(), l("div", { key: 1, ref_key: "noTitle", ref: Je, class: "vue-data-ui-no-title-space", style: "height:36px; width: 100%;background:transparent" }, null, 512)) : g("", !0), e.value.showUserOptions && (et.value || Ie.value) ? (a(), Fe(f($e), { ref: "details", key: `user_option_${Qe.value}`, backgroundColor: e.value.backgroundColor, color: e.value.color, isPrinting: f(Ee), isImaging: f(Oe), uid: Q.value, hasTooltip: e.value.userOptionsButtons.tooltip && e.value.showTooltip, hasPdf: e.value.userOptionsButtons.pdf, hasImg: e.value.userOptionsButtons.img, hasFullscreen: e.value.userOptionsButtons.fullscreen, hasXls: !1, isTooltip: Se.value.showTooltip, isFullscreen: Pe.value, titles: { ...e.value.userOptionsButtonTitles }, chartElement: J.value, position: e.value.userOptionsPosition, hasAnnotator: e.value.userOptionsButtons.annotator, isAnnotation: Re.value, callbacks: e.value.userOptionsCallbacks, printScale: e.value.userOptionsPrint.scale, onToggleFullscreen: ct, onGeneratePdf: f(lt), onGenerateImage: f(ot), onToggleTooltip: ht, onToggleAnnotator: Be, style: R({ visibility: et.value ? Ie.value ? "visible" : "hidden" : "visible" }) }, Rt({ _: 2 }, [ o.$slots.menuIcon ? { name: "menuIcon", fn: G(({ isOpen: t, color: u }) => [ M(o.$slots, "menuIcon", ie(ue({ isOpen: t, color: u })), void 0, !0) ]), key: "0" } : void 0, o.$slots.optionTooltip ? { name: "optionTooltip", fn: G(() => [ M(o.$slots, "optionTooltip", {}, void 0, !0) ]), key: "1" } : void 0, o.$slots.optionPdf ? { name: "optionPdf", fn: G(() => [ M(o.$slots, "optionPdf", {}, void 0, !0) ]), key: "2" } : void 0, o.$slots.optionImg ? { name: "optionImg", fn: G(() => [ M(o.$slots, "optionImg", {}, void 0, !0) ]), key: "3" } : void 0, o.$slots.optionFullscreen ? { name: "optionFullscreen", fn: G(({ toggleFullscreen: t, isFullscreen: u }) => [ M(o.$slots, "optionFullscreen", ie(ue({ toggleFullscreen: t, isFullscreen: u })), void 0, !0) ]), key: "4" } : void 0, o.$slots.optionAnnotator ? { name: "optionAnnotator", fn: G(({ toggleAnnotator: t, isAnnotator: u }) => [ M(o.$slots, "optionAnnotator", ie(ue({ toggleAnnotator: t, isAnnotator: u })), void 0, !0) ]), key: "5" } : void 0 ]), 1032, ["backgroundColor", "color", "isPrinting", "isImaging", "uid", "hasTooltip", "hasPdf", "hasImg", "hasFullscreen", "isTooltip", "isFullscreen", "titles", "chartElement", "position", "hasAnnotator", "isAnnotation", "callbacks", "printScale", "onGeneratePdf", "onGenerateImage", "style"])) : g("", !0), e.value.title ? (a(), l("div", { key: 3, ref_key: "quickChartTitle", ref: Ge, class: "vue-ui-quick-chart-title", style: R(`background:transparent;color:${e.value.color};font-size:${e.value.titleFontSize}px;font-weight:${e.value.titleBold ? "bold" : "normal"};text-align:${e.value.titleTextAlign}`) }, O(e.value.title), 5)) : g("", !0), L.value ? (a(), l("svg", { key: 4, ref_key: "svgRef", ref: Ke, xmlns: f(Ht), viewBox: Lt.value, style: R(`max-width:100%;overflow:visible;background:transparent;color:${e.value.color}`) }, [ ge(f(H)), o.$slots["chart-background"] && L.value === A.BAR ? (a(), l("foreignObject", { key: 0, x: d.value.drawingArea.left, y: d.value.drawingArea.top, width: d.value.drawingArea.width, height: d.value.drawingArea.height, style: { pointerEvents: "none" } }, [ M(o.$slots, "chart-background", {}, void 0, !0) ], 8, sa)) : g("", !0), o.$slots["chart-background"] && L.value === A.LINE ? (a(), l("foreignObject", { key: 1, x: v.value.drawingArea.left, y: v.value.drawingArea.top, width: v.value.drawingArea.width, height: v.value.drawingArea.height, style: { pointerEvents: "none" } }, [ M(o.$slots, "chart-background", {}, void 0, !0) ], 8, va)) : g("", !0), o.$slots["chart-background"] && L.value === A.DONUT ? (a(), l("foreignObject", { key: 2, x: 0, y: 0, width: b.value.width, height: b.value.height, style: { pointerEvents: "none" } }, [ M(o.$slots, "chart-background", {}, void 0, !0) ], 8, da)) : g("", !0), _("defs", null, [ _("filter", { id: `blur_${Q.value}`, x: "-50%", y: "-50%", width: "200%", height: "200%" }, [ _("feGaussianBlur", { in: "SourceGraphic", stdDeviation: 2, id: `blur_std_${Q.value}` }, null, 8, ha), s[7] || (s[7] = _("feColorMatrix", { type: "saturate", values: "0" }, null, -1)) ], 8, ca), _("filter", { id: `shadow_${Q.value}`, "color-interpolation-filters": "sRGB" }, [ _("feDropShadow", { dx: "0", dy: "0", stdDeviation: "10", "flood-opacity": "0.5", "flood-color": e.value.donutShadowColor }, null, 8, ga) ], 8, fa) ]), L.value === A.DONUT ? (a(), l(m, { key: 3 }, [ e.value.showDataLabels ? (a(), l("g", ma, [ (a(!0), l(m, null, $(I.value.chart, (t, u) => (a(), l(m, null, [ I.value.isArcBigEnough(t) ? (a(), l("path", { key: 0, d: f(Wt)(t, { x: b.value.width / 2, y: b.value.height / 2 }, 16, 16, !1, !1, b.value.height * vt.value), stroke: t.color, "stroke-width": e.value.donutLabelMarkerStrokeWidth, "stroke-linecap": "round", "stroke-linejoin": "round", fill: "none", filter: we(t.id) }, null, 8, pa)) : g("", !0) ], 64))), 256)) ])) : g("", !0), _("circle", { cx: I.value.cx, cy: I.value.cy, r: I.value.radius, fill: e.value.backgroundColor, filter: e.value.donutUseShadow ? `url(#shadow_${Q.value})` : "" }, null, 8, ya), _("g", xa, [ (a(!0), l(m, null, $(I.value.chart, (t, u) => (a(), l("path", { d: t.arcSlice, fill: t.color, stroke: e.value.backgroundColor, "stroke-width": e.value.donutStrokeWidth, filter: we(t.id) }, null, 8, ka))), 256)), (a(!0), l(m, null, $(I.value.chart, (t, u) => (a(), l("path", { d: t.arcSlice, fill: "transparent", onMouseenter: (r) => I.value.useTooltip({ datapoint: t, seriesIndex: u }), onMouseout: s[0] || (s[0] = (r) => I.value.killTooltip()), onClick: (r) => re("selectDatapoint", t) }, null, 40, ba))), 256)) ]), e.value.showDataLabels ? (a(), l("g", Sa, [ (a(!0), l(m, null, $(I.value.chart, (t, u) => (a(), l(m, null, [ I.value.isArcBigEnough(t) ? (a(), l("circle", { key: 0, cx: f(Le)(t).x, cy: f(We)(t) - 3.7, fill: t.color, stroke: e.value.backgroundColor, "stroke-width": 1, r: 3, filter: we(t.id) }, null, 8, wa)) : g("", !0), I.value.isArcBigEnough(t) ? (a(), l("text", { key: 1, "text-anchor": f(Le)(t, !0, 20).anchor, x: f(Le)(t, !0).x, y: f(We)(t), fill: e.value.color, "font-size": e.value.dataLabelFontSize, filter: we(t.id) }, O(I.value.displayArcPercentage(t, I.value.chart)) + " (" + O(f(X)( e.value.formatter, t.value, f(D)({ p: e.value.valuePrefix, v: t.value, s: e.value.valueSuffix, r: e.value.dataLabelRoundingValue }), { datapoint: t, seriesIndex: u } )) + ") ", 9, Aa)) : g("", !0), I.value.isArcBigEnough(t, !0, 20) ? (a(), l("text", { key: 2, "text-anchor": f(Le)(t).anchor, x: f(Le)(t, !0).x, y: f(We)(t) + e.value.dataLabelFontSize, fill: e.value.color, "font-size": e.value.dataLabelFontSize, filter: we(t.id) }, O(t.name), 9, _a)) : g("", !0) ], 64))), 256)) ])) : g("", !0), e.value.donutShowTotal ? (a(), l("g", La, [ _("text", { "text-anchor": "middle", x: I.value.drawingArea.centerX, y: I.value.drawingArea.centerY - e.value.donutTotalLabelFontSize / 2, "font-size": e.value.donutTotalLabelFontSize, fill: e.value.color }, O(e.value.donutTotalLabelText), 9, za), _("text", { "text-anchor": "middle", x: I.value.drawingArea.centerX, y: I.value.drawingArea.centerY + e.value.donutTotalLabelFontSize, "font-size": e.value.donutTotalLabelFontSize, fill: e.value.color }, O(f(D)({ p: e.value.valuePrefix, v: I.value.total, s: e.value.valueSuffix, r: e.value.dataLabelRoundingValue })), 9, $a) ])) : g("", !0) ], 64)) : g("", !0), L.value === A.LINE ? (a(), l(m, { key: 4 }, [ e.value.xyShowGrid ? (a(), l("g", Ca, [ (a(!0), l(m, null, $(v.value.yLabels, (t) => (a(), l(m, null, [ t.y <= v.value.drawingArea.bottom ? (a(), l("line", { key: 0, x1: v.value.drawingArea.left, x2: v.value.drawingArea.right, y1: t.y, y2: t.y, stroke: e.value.xyGridStroke, "stroke-width": e.value.xyGridStrokeWidth, "stroke-linecap": "round" }, null, 8, Ia)) : g("", !0) ], 64))), 256)), (a(!0), l(m, null, $(v.value.extremes.maxSeries + 1, (t, u) => (a(), l("line", { x1: v.value.drawingArea.left + v.value.slotSize * u, x2: v.value.drawingArea.left + v.value.slotSize * u, y1: v.value.drawingArea.top, y2: v.value.drawingArea.bottom, stroke: e.value.xyGridStroke, "stroke-width": e.value.xyGridStrokeWidth, "stroke-linecap": "round" }, null, 8, Ea))), 256)) ])) : g("", !0), e.value.xyShowAxis ? (a(), l("g", Oa, [ _("line", { x1: v.value.drawingArea.left, x2: v.value.drawingArea.left, y1: v.value.drawingArea.top, y2: v.value.drawingArea.bottom, stroke: e.value.xyAxisStroke, "stroke-width": e.value.xyAxisStrokeWidth, "stroke-linecap": "round" }, null, 8, Ta), _("line", { x1: v.value.drawingArea.left, x2: v.value.drawingArea.right, y1: isNaN(v.value.absoluteZero) ? v.value.drawingArea.bottom : v.value.absoluteZero, y2: isNaN(v.value.absoluteZero) ? v.value.drawingArea.bottom : v.value.absoluteZero, stroke: e.value.xyAxisStroke, "stroke-width": e.value.xyAxisStrokeWidth, "stroke-linecap": "round" }, null, 8, Pa) ])) : g("", !0), e.value.xyShowScale ? (a(), l("g", Ra, [ (a(!0), l(m, null, $(v.value.yLabels, (t, u) => (a(), l(m, null, [ t.y <= v.value.drawingArea.bottom ? (a(), l("line", { key: 0, x1: t.x + 4, x2: v.value.drawingArea.left, y1: t.y, y2: t.y, stroke: e.value.xyAxisStroke, "stroke-width": e.value.xyAxisStrokeWidth, "stroke-linecap": "round" }, null, 8, Ma)) : g("", !0), t.y <= v.value.drawingArea.bottom ? (a(), l("text", { key: 1, x: t.x, y: t.y + e.value.xyLabelsYFontSize / 3, "text-anchor": "end", "font-size": e.value.xyLabelsYFontSize, fill: e.value.color }, O(f(X)( e.value.formatter, t.value, f(D)({ p: e.value.valuePrefix, v: t.value, s: e.value.valueSuffix, r: e.value.dataLabelRoundingValue }), { datapoint: t, seriesIndex: u } )), 9, Fa)) : g("", !0) ], 64))), 256)) ])) : g("", !0), e.value.xyShowScale && e.value.xyPeriods.length ? (a(), l("g", Na, [ (a(!0), l(m, null, $(ee.value.map((t) => t.text), (t, u) => (a(), l(m, null, [ !e.value.xyPeriodsShowOnlyAtModulo || e.value.xyPeriodsShowOnlyAtModulo && u % Math.floor((x.value.end - x.value.start) / e.value.xyPeriodsModulo) === 0 || x.value.end - x.value.start <= e.value.xyPeriodsModulo ? (a(), l("line", { key: 0, x1: v.value.drawingArea.left + v.value.slotSize * (u + 1) - v.value.slotSize / 2, x2: v.value.drawingArea.left + v.value.slotSize * (u + 1) - v.value.slotSize / 2, y1: v.value.drawingArea.bottom, y2: v.value.drawingArea.bottom + 4, stroke: e.value.xyAxisStroke, "stroke-width": e.value.xyAxisStrokeWidth, "stroke-linecap": "round" }, null, 8, Ua)) : g("", !0), !e.value.xyPeriodsShowOnlyAtModulo || e.value.xyPeriodsShowOnlyAtModulo && u % Math.floor((x.value.end - x.value.start) / e.value.xyPeriodsModulo) === 0 || x.value.end - x.value.start <= e.value.xyPeriodsModulo ? (a(), l("g", Ba, [ String(t).includes(` `) ? (a(), l("text", { key: 1, "font-size": e.value.xyLabelsXFontSize, "text-anchor": e.value.xyPeriodLabelsRotation > 0 ? "start" : e.value.xyPeriodLabelsRotation < 0 ? "end" : "middle", fill: e.value.color, transform: `translate(${v.value.drawingArea.left + v.value.slotSize * (u + 1) - v.value.slotSize / 2}, ${v.value.drawingArea.bottom + e.value.xyLabelsXFontSize + 6}), rotate(${e.value.xyPeriodLabelsRotation})`, innerHTML: f(jt)({ content: String(t), fontSize: e.value.xyLabelsXFontSize, fill: e.value.color, x: 0, y: 0 }) }, null, 8, Va)) : (a(), l("text", { key: 0, "font-size": e.value.xyLabelsXFontSize, "text-anchor": e.value.xyPeriodLabelsRotation > 0 ? "start" : e.value.xyPeriodLabelsRotation < 0 ? "end" : "middle", fill: e.value.color, transform: `translate(${v.value.drawingArea.left + v.value.slotSize * (u + 1) - v.value.slotSize / 2}, ${v.value.drawingArea.bottom + e.value.xyLabelsXFontSize + 6}), rotate(${e.value.xyPeriodLabelsRotation})` }, O(t), 9, Da)) ])) : g("", !0) ], 64))), 256)) ])) : g("", !0), _("g", qa, [ (a(!0), l(m, null, $(v.value.dataset, (t, u) => (a(), l("g", Ha, [ e.value.lineSmooth ? (a(), l(m, { key: 0 }, [ _("path", { d: `M ${f(pt)(t.coordinates)}`, stroke: e.value.backgroundColor, "stroke-width": e.value.lineStrokeWidth + 1, "stroke-linecap": "round", fill: "none", class: fe({ "quick-animation": !0, "vue-data-ui-line-animated": e.value.lineAnimated }), style: { transition: "all 0.3s ease-in-out" } }, null, 10, Wa), _("path", { d: `M ${f(pt)(t.coordinates)}`, stroke: t.color, "stroke-width": e.value.lineStrokeWidth, "stroke-linecap": "round", fill: "none", class: fe({ "quick-animation": !0, "vue-data-ui-line-animated": e.value.lineAnimated }), style: { transition: "all 0.3s ease-in-out" } }, null, 10, ja) ], 64)) : (a(), l(m, { key: 1 }, [ _("path", { d: `M ${t.linePath}`, stroke: e.value.backgroundColor, "stroke-width": e.value.lineStrokeWidth + 1, "stroke-linecap": "round", fill: "none", class: fe({ "quick-animation": !0, "vue-data-ui-line-animated": e.value.lineAnimated }), style: { transition: "all 0.3s ease-in-out" } }, null, 10, Ga), _("path", { d: `M ${t.linePath}`, stroke: t.color, "stroke-width": e.value.lineStrokeWidth, "stroke-linecap": "round", fill: "none", class: fe({ "quick-animation": !0, "vue-data-ui-line-animated": e.value.lineAnimated }), style: { transition: "all 0.3s ease-in-out" } }, null, 10, Xa) ], 64)), (a(!0), l(m, null, $(t.coordinates, (r, h) => (a(), l("circle", { cx: r.x, cy: f(Z)(r.y), r: 3, fill: t.color, stroke: e.value.backgroundColor, "s