UNPKG

vue-data-ui

Version:

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

1,130 lines • 54.4 kB
import { defineAsyncComponent as ee, ref as d, computed as L, useSlots as Ga, onMounted as sa, watch as N, nextTick as na, shallowRef as ze, onBeforeUnmount as Za, createElementBlock as ie, openBlock as S, unref as p, normalizeClass as ja, normalizeStyle as ae, createCommentVNode as H, createElementVNode as B, createBlock as R, createSlots as qa, withCtx as x, renderSlot as k, normalizeProps as V, guardReactiveProps as G, createVNode as Ja, Teleport as Ka, toDisplayString as ia, createTextVNode as Qa } from "vue"; import { u as el, c as al, a as ll, p as Z, b as tl, C as pe, d as ol, D as $e, k as le, i as te, e as va, a4 as rl, G as ul, ae as sl, o as nl, f as il, y as ca, v as vl, w as cl, z as dl, s as ve, l as hl } from "./index-q-LPw2IT.js"; import { d as yl, t as fl, u as gl, c as pl, a as da, l as C, r as Ie, b as P, p as ha } from "./useResponsive-DfdjqQps.js"; import { u as ya } from "./useNestedProp-04aFeUYu.js"; import { u as ml } from "./usePrinter-DX7efa1s.js"; import { u as bl } from "./useUserOptionState-BIvW1Kz7.js"; import { u as xl } from "./useChartAccessibility-9icAAmYg.js"; import Ll from "./Legend-DcDSkq99.js"; import kl from "./Title-B55R8CAZ.js"; import { S as Cl } from "./Slicer-BarTZZDU.js"; import { u as wl } from "./useTimeLabels-DkzmKfZn.js"; import Sl from "./img-Ctts6JQb.js"; import { _ as zl } from "./_plugin-vue_export-helper-CHgC5LLL.js"; const $l = ["id"], Il = ["id"], Ml = ["id"], Tl = ["onClick"], Ol = { key: 3, class: "vue-data-ui-watermark" }, Rl = ["innerHTML"], Pl = { __name: "vue-ui-xy-canvas", props: { dataset: { type: Array, default() { return []; } }, config: { type: Object, default() { return {}; } } }, emits: ["selectLegend"], setup(Me, { expose: fa, emit: ga }) { const pa = ee(() => import("./vue-ui-accordion-D46i_gkB.js")), ma = ee(() => import("./DataTable-rj9-mAwF.js")), ba = ee(() => import("./NonSvgPenAndPaper-W2N17kLY.js")), xa = ee(() => import("./vue-ui-skeleton-DS0KyQM7.js")), La = ee(() => import("./Tooltip-BMOddG-M.js")), ka = ee(() => import("./UserOptions-DVzyjG-W.js")), { vue_ui_xy_canvas: Ca } = el(), g = Me, Y = d(al()), F = d(null), oe = d(null), n = d(null), y = d(1), E = d(1), ce = d(!1), c = d(null), de = d(""), Te = d(null), $ = d([]), j = d(1), _ = d(!0), q = d(!0), me = d(null), Oe = d(0), Re = d(0), he = d(!1), Pe = d(null), Fe = d(null), Ee = d(null), Ae = d(null), be = d(0), xe = d(0), Le = d(0), M = d(null), De = d(!1), ke = L(() => !!g.dataset && g.dataset.length), wa = ga, Sa = Ga(); sa(() => { Sa["chart-background"] && console.warn("VueUiXyCanvas does not support the #chart-background slot."); }); const a = L({ get: () => Ye(), set: (e) => e }), { userOptionsVisible: Ce, setUserOptionsVisibility: Ne, keepUserOptionState: He } = bl({ config: a.value }), { svgRef: T } = xl({ config: a.value.style.chart.title }); function Ye() { const e = ya({ userConfig: g.config, defaultConfig: Ca }); let l = {}; return e.theme ? l = { ...ya({ userConfig: tl.vue_ui_xy_canvas[e.theme] || g.config, defaultConfig: e }), customPalette: ll[e.theme] || Z } : l = e, g.config && pe(g.config, "style.chart.scale.min") ? l.style.chart.scale.min = g.config.style.chart.scale.min : l.style.chart.scale.min = null, g.config && pe(g.config, "style.chart.scale.max") ? l.style.chart.scale.max = g.config.style.chart.scale.max : l.style.chart.scale.max = null, g.config && pe(g.config, "style.chart.zoom.startIndex") ? l.style.chart.zoom.startIndex = g.config.style.chart.zoom.startIndex : l.style.chart.zoom.startIndex = null, g.config && pe(g.config, "style.chart.zoom.endIndex") ? l.style.chart.zoom.endIndex = g.config.style.chart.zoom.endIndex : l.style.chart.zoom.endIndex = null, l; } N(() => g.config, (e) => { a.value = Ye(), Ce.value = !a.value.userOptions.showOnChartHover, we(), be.value += 1, xe.value += 1, Le.value += 1, u.value.showTable = a.value.table.show, u.value.showDataLabels = a.value.style.chart.dataLabels.show, u.value.stacked = a.value.style.chart.stacked, u.value.showTooltip = a.value.style.chart.tooltip.show; }, { deep: !0 }), N(() => g.dataset, () => { we(), be.value += 1, xe.value += 1, Le.value += 1; }, { deep: !0 }); const _e = d(a.value.style.chart.aspectRatio), { isPrinting: Ue, isImaging: We, generatePdf: Xe, generateImage: Be } = ml({ elementId: `xy_canvas_${Y.value}`, fileName: a.value.style.chart.title.text || "vue-ui-xy-canvas", options: a.value.userOptions.print }), u = d({ showTable: a.value.table.show, showDataLabels: a.value.style.chart.dataLabels.show, stacked: a.value.style.chart.stacked, showTooltip: a.value.style.chart.tooltip.show }); function Ve(e) { he.value = e, Re.value += 1; } const Ge = L(() => ol(a.value.customPalette)), I = L(() => J.value ? Math.max(...J.value.filter((e, l) => !$.value.includes(e.absoluteIndex)).map((e) => e.series.length)) : 0), t = L(() => { const e = y.value - y.value * (a.value.style.chart.paddingProportions.left + a.value.style.chart.paddingProportions.right); return { canvasWidth: y.value, canvasHeight: E.value, left: y.value * a.value.style.chart.paddingProportions.left, top: E.value * a.value.style.chart.paddingProportions.top, right: y.value - y.value * a.value.style.chart.paddingProportions.right, bottom: E.value - E.value * a.value.style.chart.paddingProportions.bottom, width: e, height: E.value - E.value * (a.value.style.chart.paddingProportions.top + a.value.style.chart.paddingProportions.bottom), slot: e / (r.value.end - r.value.start) }; }); function Ze(e, l) { return e / l; } function za({ hasAutoScale: e, series: l, min: o, max: s, scale: i, yOffset: b, individualHeight: v, stackIndex: f = null }) { return l.map((W, z) => { const D = i.min < 0 ? Math.abs(i.min) : 0, X = Ze(W + D, D + i.max); let se, ne; e && (se = i.min, ne = Ze(W - se, i.max - se)); let O = 0; return f === null ? O = t.value.bottom - t.value.height * (e ? ne : X) : O = t.value.bottom - b - v * (e ? ne : X), { x: t.value.left + t.value.slot * z + t.value.slot / 2, y: O, value: W }; }); } const m = L(() => { const e = a.value.style.chart.scale.min !== null ? a.value.style.chart.scale.min : Math.min(...J.value.filter((v, f) => !$.value.includes(v.absoluteIndex)).flatMap((v) => v.series.slice(r.value.start, r.value.end))), l = a.value.style.chart.scale.max !== null ? a.value.style.chart.scale.max : Math.max(...J.value.filter((v, f) => !$.value.includes(v.absoluteIndex)).flatMap((v) => v.series.slice(r.value.start, r.value.end))), o = $e(e < 0 ? e : 0, l === e ? e + 1 < 0 ? 0 : e + 1 : l < 0 ? 0 : l, a.value.style.chart.scale.ticks), s = o.min < 0 ? Math.abs(o.min) : 0, i = t.value.bottom - t.value.height * (s / (o.max + s)), b = o.ticks.map((v) => ({ y: t.value.bottom - t.value.height * ((v + s) / (o.max + s)), x: t.value.left - 8, value: v })); return { absoluteMin: s, max: l, min: e, scale: o, yLabels: b, zero: i }; }), $a = L(() => h.value.map((e) => ` <div style="display:flex;flex-direction:row;gap:6px;align-items:center;"> <svg viewBox="0 0 10 10" height="12" width="12"> <circle cx="5" cy="5" r="5" fill="${e.color}"/> </svg> <span>${e.name ? e.name + ": " : ""}</span> <span>${le( a.value.style.chart.dataLabels.formatter, e.series[c.value], te({ p: e.prefix || "", v: e.series[c.value], s: e.suffix || "", r: e.rounding || 0 }), { datapoint: e, seriesIndex: c.value } )}</span> </div> `)), J = L(() => g.dataset.map((e, l) => ({ ...e, series: rl({ data: ul(e.series), threshold: a.value.downsample.threshold }), absoluteIndex: l, color: va(e.color || Ge.value[l] || Z[l] || Z[l % Z.length]) }))); N(I, (e) => { e && je(); }); const h = L(() => sl(J.value.filter((e, l) => !$.value.includes(e.absoluteIndex))).map((e, l) => ({ ...e, series: e.series.slice(r.value.start, r.value.end) })).map((e, l) => { let o = [null, void 0].includes(e.scaleMin) ? Math.min(...e.series) || 0 : e.scaleMin, s = [null, void 0].includes(e.scaleMax) ? Math.max(...e.series) || 1 : e.scaleMax; o === s && (o = o >= 0 ? s - 1 : o, s = s >= 0 ? s : o + 1), e.series.filter((O) => ![null, void 0].includes(O)).map((O) => (O - o) / (s - o)); const i = { valueMin: o, valueMax: s }, b = e.scaleSteps || a.value.style.chart.scale.ticks; let v; e.autoScaling ? v = $e(i.valueMin, i.valueMax, b) : v = $e(i.valueMin < 0 ? i.valueMin : 0, i.valueMax <= 0 ? 0 : i.valueMax, b); const f = u.value.stacked ? t.value.height * (1 - e.cumulatedStackRatio) : 0, W = u.value.stacked ? t.value.height / a.value.style.chart.stackGap : 0, z = u.value.stacked ? t.value.height * e.stackRatio - W : t.value.height, D = v.min < 0 ? Math.abs(v.min) : 0; let X; e.autoScaling && u.value.stacked && s <= 0 ? X = t.value.bottom - f - z : X = t.value.bottom - f - z * (D / (v.max + D)); const se = v.ticks.map((O, Va) => ({ y: t.value.bottom - f - z * (Va / (v.ticks.length - 1)), x: t.value.left - 8, value: O })), ne = za({ hasAutoScale: u.value.stacked && e.autoScaling, series: e.series, min: u.value.stacked ? o : m.value.min, max: u.value.stacked ? s : m.value.max, scale: u.value.stacked ? v : m.value.scale, yOffset: f, individualHeight: z, stackIndex: u.value.stacked ? l : null }); return { ...e, coordinatesLine: ne, min: o, max: s, localScale: v, localZero: X, localMin: D, localYLabels: se, yOffset: f, individualHeight: z }; })), r = d({ start: 0, end: I.value }); function je() { Je(); } const qe = d(null); async function Je() { await na(), await na(); const { startIndex: e, endIndex: l } = a.value.style.chart.zoom, o = qe.value, s = I.value; (e != null || l != null) && o ? (e != null && o.setStartValue(e), l != null && o.setEndValue(Ia(l + 1))) : (r.value = { start: 0, end: s }, Oe.value += 1); } function Ia(e) { const l = I.value; return e > l ? l : e < 0 || a.value.style.chart.zoom.startIndex !== null && e < a.value.style.chart.zoom.startIndex ? a.value.style.chart.zoom.startIndex !== null ? a.value.style.chart.zoom.startIndex + 1 : 1 : e; } const Ma = L(() => h.value.filter((e) => ["line", "plot", void 0].includes(e.type))), w = L(() => h.value.filter((e) => e.type === "bar")); function Ta() { if (!T.value) return; const e = oe.value.offsetWidth, l = oe.value.offsetHeight; T.value.width = e * j.value * 2, T.value.height = l * j.value * 2, y.value = e * j.value * 2, E.value = l * j.value * 2, n.value.scale(j.value, j.value), re(); } function Oa() { if (n.value.clearRect(0, 0, 1e4, 1e4), n.value.fillStyle = a.value.style.chart.backgroundColor, n.value.fillRect(0, 0, t.value.canvasWidth, t.value.canvasHeight), u.value.stacked) a.value.style.chart.grid.y.verticalLines.show && r.value.end - r.value.start < a.value.style.chart.grid.y.verticalLines.hideUnderXLength ? h.value.forEach((e) => { for (let l = 0; l < r.value.end - r.value.start + 1; l += 1) C( n.value, [ { x: t.value.left + t.value.slot * l, y: t.value.bottom - e.yOffset - e.individualHeight }, { x: t.value.left + t.value.slot * l, y: t.value.bottom - e.yOffset } ], { color: a.value.style.chart.grid.y.verticalLines.color } ); }) : a.value.style.chart.grid.y.verticalLines.show && r.value.end - r.value.start >= a.value.style.chart.grid.y.verticalLines.hideUnderXLength && h.value.forEach((e) => { for (let l = r.value.start; l < r.value.end; l += 1) l % Math.floor((r.value.end - r.value.start) / a.value.style.chart.grid.y.timeLabels.modulo) === 0 && C( n.value, [ { x: t.value.left + t.value.slot * (l - r.value.start) + t.value.slot / 2, y: t.value.bottom - e.yOffset - e.individualHeight }, { x: t.value.left + t.value.slot * (l - r.value.start) + t.value.slot / 2, y: t.value.bottom - e.yOffset } ], { color: a.value.style.chart.grid.y.verticalLines.color } ); }), a.value.style.chart.grid.x.horizontalLines.show && (a.value.style.chart.grid.x.horizontalLines.alternate ? h.value.forEach((e) => { e.localYLabels.forEach((l, o) => { o < e.localYLabels.length - 1 && Ie( n.value, [ { x: t.value.left, y: l.y }, { x: t.value.right, y: l.y }, { x: t.value.right, y: e.localYLabels[o + 1].y }, { x: t.value.left, y: e.localYLabels[o + 1].y } ], { fillColor: o % 2 === 0 ? "transparent" : ve(a.value.style.chart.grid.x.horizontalLines.color, a.value.style.chart.grid.x.horizontalLines.opacity), strokeColor: "transparent" } ); }); }) : h.value.forEach((e) => { e.localYLabels.slice(r.value.start, r.value.end).forEach((l) => { C( n.value, [ { x: t.value.left, y: l.y }, { x: t.value.right, y: l.y } ], { color: a.value.style.chart.grid.x.horizontalLines.color } ); }); })), a.value.style.chart.grid.zeroLine.show && h.value.forEach((e) => { C( n.value, [ { x: t.value.left, y: e.localZero }, { x: t.value.right, y: e.localZero } ], { color: a.value.style.chart.grid.zeroLine.color, lineDash: a.value.style.chart.grid.zeroLine.dashed ? [10, 10] : [0, 0] } ); }), a.value.style.chart.grid.y.axisLabels.show && h.value.forEach((e) => { C( n.value, [ { x: t.value.left, y: t.value.bottom - e.yOffset }, { x: t.value.left, y: t.value.bottom - e.yOffset - e.individualHeight } ], { color: e.color } ), C( n.value, [ { x: t.value.right, y: t.value.bottom - e.yOffset }, { x: t.value.right, y: t.value.bottom - e.yOffset - e.individualHeight } ], { color: e.color } ); }), h.value.forEach((e) => { P( n.value, e.name, y.value / 35, t.value.bottom - e.yOffset - e.individualHeight / 2, { align: "center", rotation: -90, color: e.color, font: `${Math.round(y.value / 40 * a.value.style.chart.grid.y.axisLabels.fontSizeRatio)}px ${a.value.style.fontFamily}` } ); }); else { if (a.value.style.chart.grid.y.verticalLines.show && r.value.end - r.value.start < a.value.style.chart.grid.y.verticalLines.hideUnderXLength) for (let e = 0; e < r.value.end - r.value.start + 1; e += 1) C( n.value, [ { x: t.value.left + t.value.slot * e, y: t.value.top }, { x: t.value.left + t.value.slot * e, y: t.value.bottom } ], { color: a.value.style.chart.grid.y.verticalLines.color } ); else if (a.value.style.chart.grid.y.verticalLines.show && r.value.end - r.value.start >= a.value.style.chart.grid.y.verticalLines.hideUnderXLength) for (let e = r.value.start; e < r.value.end; e += 1) e % Math.floor((r.value.end - r.value.start) / a.value.style.chart.grid.y.timeLabels.modulo) === 0 && C( n.value, [ { x: t.value.left + t.value.slot * (e - r.value.start) + t.value.slot / 2, y: t.value.top }, { x: t.value.left + t.value.slot * (e - r.value.start) + t.value.slot / 2, y: t.value.bottom } ], { color: a.value.style.chart.grid.y.verticalLines.color } ); a.value.style.chart.grid.x.horizontalLines.show && (a.value.style.chart.grid.x.horizontalLines.alternate ? m.value.yLabels.forEach((e, l) => { l < m.value.yLabels.length - 1 && Ie( n.value, [ { x: t.value.left, y: e.y }, { x: t.value.right, y: e.y }, { x: t.value.right, y: m.value.yLabels[l + 1].y }, { x: t.value.left, y: m.value.yLabels[l + 1].y } ], { fillColor: l % 2 === 0 ? "transparent" : ve(a.value.style.chart.grid.x.horizontalLines.color, a.value.style.chart.grid.x.horizontalLines.opacity), strokeColor: "transparent" } ); }) : m.value.yLabels.forEach((e) => { C( n.value, [ { x: t.value.left, y: e.y }, { x: t.value.right, y: e.y } ], { color: a.value.style.chart.grid.x.horizontalLines.color } ); })), a.value.style.chart.grid.y.showAxis && C( n.value, [ { x: t.value.left, y: t.value.top }, { x: t.value.left, y: t.value.bottom } ], { color: a.value.style.chart.grid.y.axisColor, lineWidth: a.value.style.chart.grid.y.axisThickness } ), a.value.style.chart.grid.x.showAxis && C( n.value, [ { x: t.value.left, y: t.value.bottom }, { x: t.value.right, y: t.value.bottom } ], { color: a.value.style.chart.grid.x.axisColor, lineWidth: a.value.style.chart.grid.x.axisThickness } ), a.value.style.chart.grid.zeroLine.show && C( n.value, [ { x: t.value.left, y: m.value.zero }, { x: t.value.right, y: m.value.zero } ], { color: a.value.style.chart.grid.zeroLine.color, lineDash: a.value.style.chart.grid.zeroLine.dashed ? [10, 10] : [0, 0] } ); } a.value.style.chart.grid.y.axisName && P( n.value, a.value.style.chart.grid.y.axisName, y.value - y.value / 40 * a.value.style.chart.grid.y.axisLabels.fontSizeRatio * 1.2, t.value.bottom - t.value.height / 2, { font: `${a.value.style.chart.grid.y.axisLabels.bold ? "bold " : ""}${Math.round(y.value / 40 * a.value.style.chart.grid.y.axisLabels.fontSizeRatio)}px ${a.value.style.fontFamily}`, color: a.value.style.chart.color, align: "center", rotation: 90 } ), a.value.style.chart.grid.x.axisName && P( n.value, a.value.style.chart.grid.x.axisName, y.value / 2, E.value, { font: `${a.value.style.chart.grid.y.axisLabels.bold ? "bold " : ""}${Math.round(y.value / 40 * a.value.style.chart.grid.y.axisLabels.fontSizeRatio)}px ${a.value.style.fontFamily}`, color: a.value.style.chart.color, align: "center" } ); } function Ra(e) { for (let l = 0; l < e.coordinatesLine.length; l += 1) { const o = (c.value === l ? y.value / 150 : a.value.style.chart.line.plots.show ? y.value / 200 : 0) * a.value.style.chart.line.plots.radiusRatio; da( n.value, { x: e.coordinatesLine[l].x, y: e.coordinatesLine[l].y }, o, { color: a.value.style.chart.backgroundColor, fillStyle: e.color } ); } } function Pa() { h.value.forEach((e) => { e.showYMarker && ue(e) && P( n.value, le( a.value.style.chart.dataLabels.formatter, ue(e).value, te({ p: e.prefix || a.value.style.chart.grid.y.axisLabels.prefix || "", v: ue(e).value, s: e.suffix || a.value.style.chart.grid.y.axisLabels.suffix || "", r: e.rounding || a.value.style.chart.grid.y.axisLabels.rounding || 0 }), { datapoint: ue(e), seriesIndex: null } ), t.value.left - 8 + a.value.style.chart.grid.y.axisLabels.offsetX, ue(e).y, { align: "right", font: `${a.value.style.chart.grid.y.axisLabels.bold ? "bold " : ""}${Math.round(y.value / 40 * a.value.style.chart.grid.y.axisLabels.fontSizeRatio)}px ${a.value.style.fontFamily}`, color: e.color } ); }); } function Fa() { a.value.style.chart.grid.y.axisLabels.show && (u.value.stacked ? h.value.forEach((e) => { e.localYLabels.forEach((l, o) => { P( n.value, le( a.value.style.chart.dataLabels.formatter, l.value, te({ p: e.prefix || a.value.style.chart.grid.y.axisLabels.prefix || "", v: l.value, s: e.suffix || a.value.style.chart.grid.y.axisLabels.suffix || "", r: e.rounding || a.value.style.chart.grid.y.axisLabels.rounding || 0 }), { datapoint: l, seriesIndex: o } ), l.x + a.value.style.chart.grid.y.axisLabels.offsetX, l.y, { align: "right", font: `${a.value.style.chart.grid.y.axisLabels.bold ? "bold " : ""}${Math.round(y.value / 40 * a.value.style.chart.grid.y.axisLabels.fontSizeRatio)}px ${a.value.style.fontFamily}`, color: e.color, globalAlpha: e.showYMarker && ![null, void 0].includes(c.value) ? 0.2 : 1 } ); }); }) : m.value.yLabels.forEach((e, l) => { P( n.value, le( a.value.style.chart.dataLabels.formatter, e.value, te({ p: a.value.style.chart.grid.y.axisLabels.prefix || "", v: e.value, s: a.value.style.chart.grid.y.axisLabels.suffix || "", r: a.value.style.chart.grid.y.axisLabels.rounding || 0 }), { datapoint: e, seriesIndex: l } ), e.x + a.value.style.chart.grid.y.axisLabels.offsetX, e.y, { align: "right", font: `${a.value.style.chart.grid.y.axisLabels.bold ? "bold " : ""}${Math.round(y.value / 40 * a.value.style.chart.grid.y.axisLabels.fontSizeRatio)}px ${a.value.style.fontFamily}`, color: a.value.style.chart.grid.y.axisLabels.color, globalAlpha: h.value.some((o) => o.showYMarker) && ![null, void 0].includes(c.value) ? 0.2 : 1 } ); })); } function Ea(e) { for (let l = 0; l < e.coordinatesLine.length; l += 1) P( n.value, le( a.value.style.chart.dataLabels.formatter, e.coordinatesLine[l].value, te({ p: e.prefix || "", v: e.coordinatesLine[l].value, s: e.suffix || "", r: e.rounding || 0 }), { datapoint: e.coordinatesLine[l], seriesIndex: l } ), e.coordinatesLine[l].x, e.coordinatesLine[l].y + a.value.style.chart.dataLabels.offsetY, { align: "center", font: `${a.value.style.chart.dataLabels.bold ? "bold " : ""}${Math.round(y.value / 40 * a.value.style.chart.dataLabels.fontSizeRatio)}px ${a.value.style.fontFamily}`, color: a.value.style.chart.dataLabels.useSerieColor ? e.color : a.value.style.chart.dataLabels.color } ); } const U = L(() => wl({ values: a.value.style.chart.grid.y.timeLabels.values, maxDatapoints: I.value, formatter: a.value.style.chart.grid.y.timeLabels.datetimeFormatter, start: 0, end: a.value.style.chart.grid.y.timeLabels.values.length })); function Aa() { for (let e = r.value.start; e < r.value.end; e += 1) (r.value.end - r.value.start < a.value.style.chart.grid.y.timeLabels.modulo || r.value.end - r.value.start >= a.value.style.chart.grid.y.timeLabels.modulo && (e % Math.floor((r.value.end - r.value.start) / a.value.style.chart.grid.y.timeLabels.modulo) === 0 || e === c.value + r.value.start && a.value.style.chart.grid.y.timeLabels.showMarker)) && P( n.value, U.value[e] ? U.value[e].text : e + 1, t.value.left + t.value.slot * (e - r.value.start) + t.value.slot / 2, t.value.bottom + y.value / a.value.style.chart.grid.y.timeLabels.offsetY, { align: a.value.style.chart.grid.y.timeLabels.rotation === 0 ? "center" : a.value.style.chart.grid.y.timeLabels.rotation > 0 ? "left" : "right", font: `${a.value.style.chart.grid.y.timeLabels.bold ? "bold " : ""}${Math.round(y.value / 40 * a.value.style.chart.grid.y.timeLabels.fontSizeRatio)}px ${a.value.style.fontFamily}`, color: a.value.style.chart.grid.y.timeLabels.showMarker ? ve(a.value.style.chart.grid.y.timeLabels.color, c.value !== null ? c.value + r.value.start === e ? 100 : 20 : 100) : a.value.style.chart.grid.y.timeLabels.color, rotation: a.value.style.chart.grid.y.timeLabels.rotation } ); } function Ke() { C( n.value, [ { x: t.value.left + t.value.slot * c.value + t.value.slot / 2, y: t.value.top }, { x: t.value.left + t.value.slot * c.value + t.value.slot / 2, y: t.value.bottom } ], { color: a.value.style.chart.selector.color, lineDash: a.value.style.chart.selector.dashed ? [8, 8] : [0, 0], lineWidth: 2 } ); } function Da() { M.value && C( n.value, [ { x: t.value.left, y: M.value }, { x: t.value.right, y: M.value } ], { color: a.value.style.chart.selector.color, lineDash: a.value.style.chart.selector.dashed ? [8, 8] : [0, 0], lineWidth: 2 } ); } function Na() { w.value.forEach((e, l) => { for (let o = 0; o < e.coordinatesLine.length; o += 1) Ie( n.value, [ { x: t.value.left + t.value.slot * o + t.value.slot / 10 + (u.value.stacked ? 0 : t.value.slot / w.value.length * l - (l === 0 ? 0 : t.value.slot / (5 * w.value.length) * l)), y: u.value.stacked ? e.localZero : m.value.zero }, { x: t.value.left + t.value.slot * o + t.value.slot / 10 + (u.value.stacked ? 0 : t.value.slot / w.value.length * l - (l === 0 ? 0 : t.value.slot / (5 * w.value.length) * l)) + t.value.slot * 0.8 / (u.value.stacked ? 1 : w.value.length), y: u.value.stacked ? e.localZero : m.value.zero }, { x: t.value.left + t.value.slot * o + t.value.slot / 10 + (u.value.stacked ? 0 : t.value.slot / w.value.length * l - (l === 0 ? 0 : t.value.slot / (5 * w.value.length) * l)) + t.value.slot * 0.8 / (u.value.stacked ? 1 : w.value.length), y: e.coordinatesLine[o].y }, { x: t.value.left + t.value.slot * o + t.value.slot / 10 + (u.value.stacked ? 0 : t.value.slot / w.value.length * l - (l === 0 ? 0 : t.value.slot / (5 * w.value.length) * l)), y: e.coordinatesLine[o].y } ], { strokeColor: a.value.style.chart.backgroundColor, gradient: { type: "linear", start: { x: e.coordinatesLine[o].x, y: e.coordinatesLine[o].y }, end: { x: e.coordinatesLine[o].x, y: u.value.stacked ? e.localZero : m.value.zero }, stops: [ { offset: 0, color: e.color }, { offset: 1, color: a.value.style.chart.bar.gradient.show ? hl(e.color, 0.5) : e.color } ] } } ), u.value.showDataLabels && [!0, void 0].includes(e.dataLabels) && P( n.value, le( a.value.style.chart.dataLabels.formatter, e.coordinatesLine[o].value, te({ p: e.prefix || "", v: e.coordinatesLine[o].value, s: e.suffix || "", r: e.rounding || 0 }), { datapoint: e.coordinatesLine[o], seriesIndex: o } ), t.value.left + t.value.slot * o + t.value.slot / 10 + (u.value.stacked ? 0 : t.value.slot / w.value.length * l - (l === 0 ? 0 : t.value.slot / (5 * w.value.length) * l)) + t.value.slot * 0.4 / (u.value.stacked ? 1 : w.value.length), (e.coordinatesLine[o].value < 0 ? u.value.stacked ? e.localZero : m.value.zero : e.coordinatesLine[o].y) + a.value.style.chart.dataLabels.offsetY, { align: "center", font: `${Math.round(y.value / 40 * a.value.style.chart.dataLabels.fontSizeRatio)}px ${a.value.style.fontFamily}`, color: a.value.style.chart.dataLabels.useSerieColor ? e.color : a.value.style.chart.dataLabels.color, strokeColor: a.value.style.chart.backgroundColor, lineWidth: 0.8 } ); }); } function Ha(e) { e.useArea ? u.value.stacked ? ha( n.value, [{ x: e.coordinatesLine[0].x, y: e.localZero }, ...e.coordinatesLine, { x: e.coordinatesLine.at(-1).x, y: e.localZero }], { fillColor: ve(e.color, a.value.style.chart.area.opacity), strokeColor: "transparent" } ) : ha( n.value, [{ x: e.coordinatesLine[0].x, y: m.value.zero }, ...e.coordinatesLine, { x: e.coordinatesLine.at(-1).x, y: m.value.zero }], { fillColor: ve(e.color, a.value.style.chart.area.opacity), strokeColor: "transparent" } ) : C(n.value, e.coordinatesLine, { color: e.color, lineWidth: 3 }); } function Ya() { h.value.forEach((e, l) => { C( n.value, [ { x: t.value.left, y: t.value.bottom - e.yOffset }, { x: t.value.right, y: t.value.bottom - e.yOffset } ], { color: a.value.style.chart.grid.x.horizontalLines.color, lineWidth: 1 } ); }); } function re() { Oa(), _.value ? (c.value !== null && a.value.style.chart.selector.show && Ke(), Na(), u.value.stacked && a.value.style.chart.grid.x.showAxis && Ya(), Ma.value.forEach((e) => { (e.type === "line" || !e.type) && Ha(e), q.value && (Ra(e), u.value.showDataLabels && [!0, void 0].includes(e.dataLabels) && Ea(e)); }), me.value = pl(T.value)) : (me.value && (n.value.clearRect(0, 0, 1e4, 1e4), n.value.drawImage(me.value, 0, 0)), c.value !== null && a.value.style.chart.selector.show && Ke(), c.value !== null && h.value.forEach((e) => { if (e.type === "line" || !e.type || e.type === "plot") { if (!e.coordinatesLine[c.value]) return; e.coordinatesLine[c.value].x !== void 0 && e.coordinatesLine[c.value].y !== void 0 && da( n.value, { x: e.coordinatesLine[c.value].x, y: e.coordinatesLine[c.value].y }, y.value / 150 * a.value.style.chart.line.plots.radiusRatio, { color: a.value.style.chart.backgroundColor, fillStyle: e.color } ); } })), a.value.style.chart.grid.y.timeLabels.show && Aa(), a.value.style.chart.selector.show && a.value.style.chart.selector.showHorizontalSelector && Da(), Fa(), Pa(), _.value = !1; } const ye = yl(() => { q.value = !0, Ta(); }, I.value > 200 ? 10 : 1, !q.value); function ue(e) { if ([null, void 0].includes(c.value) || !e.coordinatesLine[c.value]) return !1; const { y: l, value: o } = e.coordinatesLine[c.value]; return { y: l, value: o }; } function _a(e) { const { left: l, top: o } = T.value.getBoundingClientRect(), s = e.clientX - l; if (M.value = (e.clientY - o) * 2, (M.value < t.value.top || M.value > t.value.bottom) && (M.value = null), s * 2 < t.value.left || s * 2 > t.value.right) { ce.value = !1, c.value = null; return; } const i = s * 2 - t.value.left; if (c.value = Math.floor(i / t.value.slot), ce.value = !0, !q.value) return; let b = ""; const v = a.value.style.chart.tooltip.customFormat; ca(v) && dl(() => v({ seriesIndex: c.value, datapoint: h.value.map((f) => ({ shape: f.shape || null, name: f.name, color: f.color, type: f.type || "line", value: f.series.find((W, z) => z === c.value) })), series: h.value, config: a.value })) ? de.value = v({ seriesIndex: c.value, datapoint: h.value.map((f) => ({ shape: f.shape || null, name: f.name, color: f.color, type: f.type || "line", value: f.series.find((W, z) => z === c.value) })), series: h.value, config: a.value }) : (a.value.style.chart.grid.y.timeLabels.values.slice(r.value.start, r.value.end)[c.value] && (b += `<div style="padding-bottom: 6px; margin-bottom: 4px; border-bottom: 1px solid ${a.value.style.chart.tooltip.borderColor}; width:100%">${U.value.slice(r.value.start, r.value.end)[c.value].text}</div>`), b += $a.value.join(""), de.value = b), q.value = !1; } N(() => c.value, (e) => { ye(); }), N(() => r.value, (e) => { _.value = !0, re(); }, { deep: !0 }), N(() => u.value.showDataLabels, (e) => { _.value = !0, re(); }), N(() => M.value, (e) => { e && re(); }), N(() => u.value.stacked, (e) => { _.value = !0, q.value = !0, ye(); }); function Ua() { ce.value = !1, c.value = null, de.value = "", M.value = null, re(); } const A = ze(null), K = ze(null), Q = ze(null); sa(() => { De.value = !0, we(); }); function we() { if (nl(g.dataset) ? il({ componentName: "VueUiXyCanvas", type: "dataset" }) : T.value && (n.value = T.value.getContext("2d", { willReadFrequently: !0 })), a.value.responsive) { const e = fl(() => { const { width: l, height: o } = gl({ chart: F.value, title: a.value.style.chart.title.text ? Pe.value : null, legend: a.value.style.chart.legend.show ? Fe.value : null, slicer: a.value.style.chart.zoom.show && I.value > 1 ? Ee.value : null, source: Ae.value }); requestAnimationFrame(() => { _e.value = `${l} / ${o}`; }); }); A.value && (K.value && A.value.unobserve(K.value), A.value.disconnect()), A.value = new ResizeObserver(e), K.value = F.value.parentNode, A.value.observe(K.value); } Q.value && Q.value.disconnect(), Q.value = new ResizeObserver((e) => { for (const l of e) l.contentBoxSize && oe.value && (_.value = !0, ye()); }), Q.value.observe(oe.value), Je(); } Za(() => { Q.value && Q.value.disconnect(), A.value && (K.value && A.value.unobserve(K.value), A.value.disconnect()); }); function Qe(e) { wa("selectLegend", h.value.find((l) => l.absoluteIndex === e)), $.value.includes(e) ? $.value = $.value.filter((l) => l !== e) : $.value.push(e), _.value = !0, ye(); } const ea = L(() => J.value.map((e, l) => ({ ...e, name: e.name, color: va(e.color) || Ge.value[l] || Z[l] || Z[l % Z.length], shape: e.shape || "circle", prefix: e.prefix || "", suffix: e.suffix || "", rounding: e.rounding || 0 })).map((e) => ({ ...e, opacity: $.value.includes(e.absoluteIndex) ? 0.5 : 1, segregate: () => Qe(e.absoluteIndex), isSegregated: $.value.includes(e.absoluteIndex) }))), Wa = L(() => ({ cy: "donut-div-legend", backgroundColor: a.value.style.chart.legend.backgroundColor, color: a.value.style.chart.legend.color, fontSize: a.value.style.chart.legend.fontSize, paddingBottom: 12, fontWeight: a.value.style.chart.legend.bold ? "bold" : "" })), fe = L(() => { const e = [""].concat(h.value.map((i) => i.name)).concat(' <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M18 16v2a1 1 0 0 1 -1 1h-11l6 -7l-6 -7h11a1 1 0 0 1 1 1v2" /></svg>'); let l = []; for (let i = 0; i < I.value; i += 1) { const b = h.value.map((v) => v.series[i] ?? 0).reduce((v, f) => v + f, 0); l.push([a.value.style.chart.grid.y.timeLabels.values.slice(r.value.start, r.value.end)[i] ? U.value.slice(r.value.start, r.value.end)[i].text : i + 1].concat(h.value.map((v) => (v.series[i] ?? 0).toFixed(a.value.table.rounding))).concat((b ?? 0).toFixed(a.value.table.rounding))); } const o = { th: { backgroundColor: a.value.table.th.backgroundColor, color: a.value.table.th.color, outline: a.value.table.th.outline }, td: { backgroundColor: a.value.table.td.backgroundColor, color: a.value.table.td.color, outline: a.value.table.td.outline }, breakpoint: a.value.table.responsiveBreakpoint }, s = [a.value.table.columnNames.period].concat(h.value.map((i) => i.name)).concat(a.value.table.columnNames.total); return { head: e, body: l.slice(0, r.value.end - r.value.start), config: o, colNames: s }; }), aa = L(() => { if (h.value.length === 0) return { head: [], body: [], config: {}, columnNames: [] }; const e = h.value.map((o) => ({ label: o.name, color: o.color, type: o.type })), l = []; for (let o = r.value.start; o < r.value.end; o += 1) { const s = [a.value.style.chart.grid.y.timeLabels.values[o] ? U.value[o].text : o + 1]; h.value.forEach((i) => { s.push(Number((i.series[o] || 0).toFixed(a.value.table.rounding))); }), l.push(s); } return { head: e, body: l }; }); function la(e = null) { const l = [[a.value.style.chart.title.text], [a.value.style.chart.title.subtitle.text], [""]], o = ["", ...aa.value.head.map((v) => v.label)], s = aa.value.body, i = l.concat([o]).concat(s), b = vl(i); e ? e(b) : cl({ csvContent: b, title: a.value.style.chart.title.text || "vue-ui-xy-canvas" }); } function Xa() { return h.value; } function ta() { u.value.showTable = !u.value.showTable; } function oa() { u.value.showDataLabels = !u.value.showDataLabels; } function ra() { u.value.stacked = !u.value.stacked; } function ua() { u.value.showTooltip = !u.value.showTooltip; } const ge = d(!1); function Se() { ge.value = !ge.value; } async function Ba({ scale: e = 2 } = {}) { if (!F.value) return; const { width: l, height: o } = F.value.getBoundingClientRect(), s = l / o, { imageUri: i, base64: b } = await Sl({ domElement: F.value, base64: !0, img: !0, scale: e }); return { imageUri: i, base64: b, title: a.value.style.chart.title.text, width: l, height: o, aspectRatio: s }; } return fa({ getData: Xa, getImage: Ba, generateCsv: la, generatePdf: Xe, generateImage: Be, toggleTable: ta, toggleLabels: oa, toggleStack: ra, toggleTooltip: ua, toggleAnnotator: Se, toggleFullscreen: Ve }), (e, l) => (S(), ie("div", { style: ae(`width:100%; position:relative; ${a.value.responsive ? "height: 100%" : ""}`), ref_key: "xy", ref: F, id: `xy_canvas_${Y.value}`, class: ja(`vue-ui-donut ${he.value ? "vue-data-ui-wrapper-fullscreen" : ""}`), onMouseenter: l[5] || (l[5] = () => p(Ne)(!0)), onMouseleave: l[6] || (l[6] = () => p(Ne)(!1)) }, [ a.value.style.chart.title.text ? (S(), ie("div", { key: 0, ref_key: "chartTitle", ref: Pe, style: ae(`width:100%;background:${a.value.style.chart.backgroundColor};`) }, [ (S(), R(kl, { key: `title_${be.value}`, config: { title: { cy: "xy-canvas-title", ...a.value.style.chart.title }, subtitle: { cy: "xy-canvas-subtitle", ...a.value.style.chart.title.subtitle } } }, null, 8, ["config"])) ], 4)) : H("", !0), B("div", { id: `legend-top-${Y.value}` }, null, 8, Il), a.value.userOptions.show && ke.value && (p(He) || p(Ce)) ? (S(), R(p(ka), { ref: "details", key: `user_option_${Re.value}`, backgroundColor: a.value.style.chart.backgroundColor, color: a.value.style.chart.color, isPrinting: p(Ue), isImaging: p(We), uid: Y.value, hasTooltip: a.value.userOptions.buttons.tooltip && a.value.style.chart.tooltip.show, hasPdf: a.value.userOptions.buttons.pdf, hasImg: a.value.userOptions.buttons.img, hasXls: a.value.userOptions.buttons.csv, hasLabel: a.value.userOptions.buttons.labels, hasStack: Me.dataset.length > 1 && a.value.userOptions.buttons.stack, hasFullscreen: a.value.userOptions.buttons.fullscreen, hasTable: r.value.end - r.value.start < 200 && a.value.userOptions.buttons.table, isFullscreen: he.value, isTooltip: u.value.showTooltip, isStacked: u.value.stacked, titles: { ...a.value.userOptions.buttonTitles }, chartElement: F.value, position: a.value.userOptions.position, hasAnnotator: a.value.userOptions.buttons.annotator, isAnnotation: ge.value, callbacks: a.value.userOptions.callbacks, printScale: a.value.userOptions.print.scale, onToggleFullscreen: Ve, onGeneratePdf: p(Xe), onGenerateCsv: la, onGenerateImage: p(Be), onToggleTable: ta, onToggleLabels: oa, onToggleStack: ra, onToggleTooltip: ua, onToggleAnnotator: Se, style: ae({ visibility: p(He) ? p(Ce) ? "visible" : "hidden" : "visible" }) }, qa({ _: 2 }, [ e.$slots.menuIcon ? { name: "menuIcon", fn: x(({ isOpen: o, color: s }) => [ k(e.$slots, "menuIcon", V(G({ isOpen: o, color: s })), void 0, !0) ]), key: "0" } : void 0, e.$slots.optionTooltip ? { name: "optionTooltip", fn: x(() => [ k(e.$slots, "optionTooltip", {}, void 0, !0) ]), key: "1" } : void 0, e.$slots.optionPdf ? { name: "optionPdf", fn: x(() => [ k(e.$slots, "optionPdf", {}, void 0, !0) ]), key: "2" } : void 0, e.$slots.optionCsv ? { name: "optionCsv", fn: x(() => [ k(e.$slots, "optionCsv", {}, void 0, !0) ]), key: "3" } : void 0, e.$slots.optionImg ? { name: "optionImg", fn: x(() => [ k(e.$slots, "optionImg", {}, void 0, !0) ]), key: "4" } : void 0, e.$slots.optionTable ? { name: "optionTable", fn: x(() => [ k(e.$slots, "optionTable", {}, void 0, !0) ]), key: "5" } : void 0, e.$slots.optionLabels ? { name: "optionLabels", fn: x(() => [ k(e.$slots, "optionLabels", {}, void 0, !0) ]), key: "6" } : void 0, e.$slots.optionStack ? { name: "optionStack", fn: x(() => [ k(e.$slots, "optionStack", {}, void 0, !0) ]), key: "7" } : void 0, e.$slots.optionFullscreen ? { name: "optionFullscreen", fn: x(({ toggleFullscreen: o, isFullscreen: s }) => [ k(e.$slots, "optionFullscreen", V(G({ toggleFullscreen: o, isFullscreen: s })), void 0, !0) ]), key: "8" } : void 0, e.$slots.optionAnnotator ? { name: "optionAnnotator", fn: x(({ toggleAnnotator: o, isAnnotator: s }) => [ k(e.$slots, "optionAnnotator", V(G({ toggleAnnotator: o, isAnnotator: s })), void 0, !0) ]), key: "9" } : void 0 ]), 1032, ["backgroundColor", "color", "isPrinting", "isImaging", "uid", "hasTooltip", "hasPdf", "hasImg", "hasXls", "hasLabel", "hasStack", "hasFullscreen", "hasTable", "isFullscreen", "isTooltip", "isStacked", "titles", "chartElement", "position", "hasAnnotator", "isAnnotation", "callbacks", "printScale", "onGeneratePdf", "onGenerateImage", "style"])) : H("", !0), B("div", { class: "vue-ui-xy-canvas", style: ae(`position: relative; aspect-ratio: ${_e.value}`), ref_key: "container", ref: oe }, [ ke.value ? (S(), ie("canvas", { key: 0, ref_key: "canvas", ref: T, style: { width: "100%", height: "100%" }, onMousemove: l[0] || (l[0] = (o) => _a(o)), onMouseleave: Ua }, null, 544)) : (S(), R(p(xa), { key: 1, config: { type: "line", style: { backgroundColor: a.value.style.chart.backgroundColor, line: { axis: { color: "#CCCCCC" }, path: { color: "#CCCCCC", strokeWidth: 0.5 } } } } }, null, 8, ["config"])), Ja(p(La), { show: u.value.showTooltip && ce.value, backgroundColor: a.value.style.chart.tooltip.backgroundColor, color: a.value.style.chart.tooltip.color, fontSize: a.value.style.chart.tooltip.fontSize, borderRadius: a.value.style.chart.tooltip.borderRadius, borderColor: a.value.style.chart.tooltip.borderColor, borderWidth: a.value.style.chart.tooltip.borderWidth, position: a.value.style.chart.tooltip.position, offsetY: a.value.style.chart.tooltip.offsetY, parent: p(T), content: de.value, isFullscreen: he.value, backgroundOpacity: a.value.style.chart.tooltip.backgroundOpacity, isCustom: p(ca)(a.value.style.chart.tooltip.customFormat), smooth: a.value.style.chart.tooltip.smooth, backdropFilter: a.value.style.chart.tooltip.backdropFilter }, { "tooltip-before": x(() => [ k(e.$slots, "tooltip-before", V(G({ ...Te.value })), void 0, !0) ]), "tooltip-after": x(() => [ k(e.$slots, "tooltip-after", V(G({ ...Te.value })), void 0, !0) ]), _: 3 }, 8, ["show", "backgroundColor", "color", "fontSize", "borderRadius", "borderColor", "borderWidth", "position", "offsetY", "parent", "content", "isFullscreen", "backgroundOpacity", "isCustom", "smooth", "backdropFilter"]) ], 4), B("div", { ref_key: "chartSlicer", ref: Ee, style: ae(`width:100%;background:${a.value.style.chart.backgroundColor}`), "data-dom-to-png-ignore": "" }, [ a.value.style.chart.zoom.show && I.value > 1 ? (S(), R(Cl, { ref_key: "slicerComponent", ref: qe, key: `slicer_${Oe.value}`, background: a.value.style.chart.zoom.color, borderColor: a.value.style.chart.backgroundColor, fontSize: a.value.style.chart.zoom.fontSize, useResetSlot: a.value.style.chart.zoom.useResetSlot, labelLeft: a.value.style.chart.grid.y.timeLabels.values[r.value.start] ? U.value[r.value.start].text : "", labelRight: a.value.style.chart.grid.y.timeLabels.values[r.value.end - 1] ? U.value[r.value.end - 1].text : "", textColor: a.value.style.chart.color, inputColor: a.value.sty