vvplot 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/Selection.js CHANGED
@@ -1,6 +1,6 @@
1
- import { computed, isRef, reactive, unref, onMounted, nextTick, getCurrentScope, onScopeDispose, getCurrentInstance, shallowRef, watch, toValue, useTemplateRef, createElementBlock, openBlock, mergeProps, renderSlot, createCommentVNode, createTextVNode, toDisplayString, inject, normalizeStyle, createElementVNode, createBlock, Fragment, renderList, createVNode, toHandlers, normalizeProps, resolveDynamicComponent, guardReactiveProps, mergeModels, useModel, createPropsRestProxy, ref, useId, Teleport, useSlots, useAttrs, provide } from "vue";
1
+ import { computed, isRef, reactive, unref, getCurrentScope, onScopeDispose, toValue, watch, shallowRef, getCurrentInstance, onMounted, useTemplateRef, nextTick, createElementBlock, openBlock, mergeProps, renderSlot, createCommentVNode, createTextVNode, toDisplayString, inject, normalizeStyle, createElementVNode, createBlock, Fragment, renderList, createVNode, toHandlers, normalizeProps, resolveDynamicComponent, guardReactiveProps, mergeModels, useModel, createPropsRestProxy, ref, useId, Teleport, useSlots, useAttrs, provide } from "vue";
2
2
  import { theme_base, theme_default, themeBuild, themePreprocess, themeMerge } from "./theme.js";
3
- import { vecutils, intraaction, numutils, intrazip, GEnumLevel, oob_squish_any, dropNull, emitEvent, plus, categorize, obj_merge, interaction, unique, oob_squish_infinite, str_c, serializeSVG } from "./utils.js";
3
+ import { vecutils, intraaction, numutils, intrazip, GEnumLevel, plus, oob_squish_any, dropNull, emitEvent, categorize, obj_merge, interaction, unique, oob_squish_infinite, str_c, serializeSVG } from "./utils.js";
4
4
  import vvscale from "./scale.js";
5
5
  import vvbreak from "./break.js";
6
6
  import vvlabel from "./label.js";
@@ -48,21 +48,6 @@ function reactiveComputed(fn) {
48
48
  }
49
49
  const isClient = typeof window !== "undefined" && typeof document !== "undefined";
50
50
  typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope;
51
- function toArray(value) {
52
- return Array.isArray(value) ? value : [value];
53
- }
54
- function getLifeCycleTarget(target) {
55
- return getCurrentInstance();
56
- }
57
- function tryOnMounted(fn, sync = true, target) {
58
- const instance = getLifeCycleTarget();
59
- if (instance)
60
- onMounted(fn, target);
61
- else if (sync)
62
- fn();
63
- else
64
- nextTick(fn);
65
- }
66
51
  const defaultWindow = isClient ? window : void 0;
67
52
  function unrefElement(elRef) {
68
53
  var _a;
@@ -126,68 +111,12 @@ function useResizeObserver(target, callback, options = {}) {
126
111
  stop
127
112
  };
128
113
  }
129
- function useElementSize(target, initialSize = { width: 0, height: 0 }, options = {}) {
130
- const { window: window2 = defaultWindow, box = "content-box" } = options;
131
- const isSVG = computed(() => {
132
- var _a, _b;
133
- return (_b = (_a = unrefElement(target)) == null ? void 0 : _a.namespaceURI) == null ? void 0 : _b.includes("svg");
134
- });
135
- const width = shallowRef(initialSize.width);
136
- const height = shallowRef(initialSize.height);
137
- const { stop: stop1 } = useResizeObserver(
138
- target,
139
- ([entry]) => {
140
- const boxSize = box === "border-box" ? entry.borderBoxSize : box === "content-box" ? entry.contentBoxSize : entry.devicePixelContentBoxSize;
141
- if (window2 && isSVG.value) {
142
- const $elem = unrefElement(target);
143
- if ($elem) {
144
- const rect = $elem.getBoundingClientRect();
145
- width.value = rect.width;
146
- height.value = rect.height;
147
- }
148
- } else {
149
- if (boxSize) {
150
- const formatBoxSize = toArray(boxSize);
151
- width.value = formatBoxSize.reduce((acc, { inlineSize }) => acc + inlineSize, 0);
152
- height.value = formatBoxSize.reduce((acc, { blockSize }) => acc + blockSize, 0);
153
- } else {
154
- width.value = entry.contentRect.width;
155
- height.value = entry.contentRect.height;
156
- }
157
- }
158
- },
159
- options
160
- );
161
- tryOnMounted(() => {
162
- const ele = unrefElement(target);
163
- if (ele) {
164
- width.value = "offsetWidth" in ele ? ele.offsetWidth : initialSize.width;
165
- height.value = "offsetHeight" in ele ? ele.offsetHeight : initialSize.height;
166
- }
167
- });
168
- const stop2 = watch(
169
- () => unrefElement(target),
170
- (ele) => {
171
- width.value = ele ? initialSize.width : 0;
172
- height.value = ele ? initialSize.height : 0;
173
- }
174
- );
175
- function stop() {
176
- stop1();
177
- stop2();
178
- }
179
- return {
180
- width,
181
- height,
182
- stop
183
- };
184
- }
185
114
  const NO = () => false;
186
115
  const extend = Object.assign;
187
- const TELEPORT = Symbol(``);
188
- const SUSPENSE = Symbol(``);
189
- const KEEP_ALIVE = Symbol(``);
190
- const BASE_TRANSITION = Symbol(
116
+ const TELEPORT = /* @__PURE__ */ Symbol(``);
117
+ const SUSPENSE = /* @__PURE__ */ Symbol(``);
118
+ const KEEP_ALIVE = /* @__PURE__ */ Symbol(``);
119
+ const BASE_TRANSITION = /* @__PURE__ */ Symbol(
191
120
  ``
192
121
  );
193
122
  const locStub = {
@@ -311,14 +240,28 @@ class Tokenizer {
311
240
  getPos(index) {
312
241
  let line2 = 1;
313
242
  let column = index + 1;
314
- for (let i = this.newlines.length - 1; i >= 0; i--) {
315
- const newlineIndex = this.newlines[i];
316
- if (index > newlineIndex) {
317
- line2 = i + 2;
318
- column = index - newlineIndex;
319
- break;
243
+ const length = this.newlines.length;
244
+ let j = -1;
245
+ if (length > 100) {
246
+ let l = -1;
247
+ let r = length;
248
+ while (l + 1 < r) {
249
+ const m = l + r >>> 1;
250
+ this.newlines[m] < index ? l = m : r = m;
251
+ }
252
+ j = l;
253
+ } else {
254
+ for (let i = length - 1; i >= 0; i--) {
255
+ if (index > this.newlines[i]) {
256
+ j = i;
257
+ break;
258
+ }
320
259
  }
321
260
  }
261
+ if (j >= 0) {
262
+ line2 = j + 2;
263
+ column = index - this.newlines[j];
264
+ }
322
265
  return {
323
266
  column,
324
267
  line: line2,
@@ -1748,7 +1691,7 @@ const vvgeom = {
1748
1691
  if (orientation == "y") return ds.y ?? [];
1749
1692
  },
1750
1693
  validate(d) {
1751
- if (isNaN(+d.x) || isNaN(+d.y)) return null;
1694
+ if (isNaN(d.x) || isNaN(d.y)) return null;
1752
1695
  return d;
1753
1696
  }
1754
1697
  },
@@ -1763,7 +1706,7 @@ const vvgeom = {
1763
1706
  if (orientation == "y") return (ds.y ?? []).concat(ds.yend ?? []);
1764
1707
  },
1765
1708
  validate(d) {
1766
- if (isNaN(+d.x) || isNaN(+d.y) || isNaN(+d.xend) || isNaN(+d.yend)) return null;
1709
+ if (isNaN(d.x) || isNaN(d.y) || isNaN(d.xend) || isNaN(d.yend)) return null;
1767
1710
  return d;
1768
1711
  }
1769
1712
  },
@@ -1782,7 +1725,7 @@ const vvgeom = {
1782
1725
  if (orientation == "y") return (ds.y ?? []).concat(psum(ds.y ?? [], ds.dy ?? 0) ?? []);
1783
1726
  },
1784
1727
  validate(d) {
1785
- if (isNaN(+d.x) || isNaN(+d.y) || isNaN(+d.xend) || isNaN(+d.yend)) return null;
1728
+ if (isNaN(d.x) || isNaN(d.y) || isNaN(d.xend) || isNaN(d.yend)) return null;
1786
1729
  return d;
1787
1730
  }
1788
1731
  },
@@ -1828,7 +1771,7 @@ const vvgeom = {
1828
1771
  }
1829
1772
  },
1830
1773
  validate(d) {
1831
- if (isNaN(+d.xmin) || isNaN(+d.ymin) || isNaN(+d.xmax) || isNaN(+d.ymax)) return null;
1774
+ if (isNaN(d.xmin) || isNaN(d.ymin) || isNaN(d.xmax) || isNaN(d.ymax)) return null;
1832
1775
  return d;
1833
1776
  }
1834
1777
  },
@@ -1843,7 +1786,7 @@ const vvgeom = {
1843
1786
  if (orientation == "y") return (ds.ymin ?? []).concat(ds.ymax ?? []);
1844
1787
  },
1845
1788
  validate(d) {
1846
- if (isNaN(+d.xmin) || isNaN(+d.ymin) || isNaN(+d.xmax) || isNaN(+d.ymax)) return null;
1789
+ if (isNaN(d.xmin) || isNaN(d.ymin) || isNaN(d.xmax) || isNaN(d.ymax)) return null;
1847
1790
  return d;
1848
1791
  }
1849
1792
  },
@@ -1879,7 +1822,7 @@ const vvgeom = {
1879
1822
  if (orientation == "y") return ds.y ?? [];
1880
1823
  },
1881
1824
  validate(d) {
1882
- if (isNaN(+d.x) || isNaN(+d.y)) return null;
1825
+ if (isNaN(d.x) || isNaN(d.y)) return null;
1883
1826
  return d;
1884
1827
  }
1885
1828
  },
@@ -1894,22 +1837,88 @@ const vvgeom = {
1894
1837
  if (orientation == "y") return (ds.y ?? []).concat(ds.yend ?? []);
1895
1838
  },
1896
1839
  validate(d) {
1897
- if (isNaN(+d.x) || isNaN(+d.xend) || isNaN(+d.y) || isNaN(+d.yend)) return null;
1840
+ if (isNaN(d.x) || isNaN(d.xend) || isNaN(d.y) || isNaN(d.yend)) return null;
1841
+ return d;
1842
+ }
1843
+ },
1844
+ boxplot: {
1845
+ scale_attrs: ["fill", "color", "linewidth", "linetype", "alpha"],
1846
+ coord_scale(ds, levels) {
1847
+ let xnudge = ds.xnudge ?? 0, ynudge = ds.ynudge ?? 0;
1848
+ if (ds.x) {
1849
+ let x2 = psum(levels.x?.apply?.(ds.x) ?? ds.x, xnudge), xmin = psum(x2, ds.width?.map?.((x3) => -x3 / 2) ?? -0.5, xnudge), xmax = psum(x2, ds.width?.map?.((x3) => +x3 / 2) ?? 0.5, xnudge), lwisker = psum(ds.lwisker, ynudge), Q1 = psum(ds.Q1, ynudge), median = psum(ds.median, ynudge), Q3 = psum(ds.Q3, ynudge), uwisker = psum(ds.uwisker, ynudge), outliers = vecutils.apply(
1850
+ ($x, { y: ys, $raw }, nudge) => psum(ys, nudge).map(($y, i) => ({ x: $x, y: $y, $raw: $raw[i] })),
1851
+ x2,
1852
+ ds.outliers ?? [],
1853
+ ynudge
1854
+ ), $ymin = psum(ds.min, ynudge), $ymax = psum(ds.max, ynudge);
1855
+ return {
1856
+ x: x2,
1857
+ xmin,
1858
+ xmax,
1859
+ lwisker,
1860
+ Q1,
1861
+ median,
1862
+ Q3,
1863
+ uwisker,
1864
+ outliers,
1865
+ $xmin: xmin,
1866
+ $xmax: xmax,
1867
+ $ymin,
1868
+ $ymax
1869
+ };
1870
+ } else if (ds.y) {
1871
+ let y2 = psum(levels.y?.apply?.(ds.y) ?? ds.y, ynudge), ymin = psum(y2, ds.height?.map?.((y3) => -y3 / 2) ?? -0.5, ynudge), ymax = psum(y2, ds.height?.map?.((y3) => +y3 / 2) ?? 0.5, ynudge), lwisker = psum(ds.lwisker, xnudge), Q1 = psum(ds.Q1, xnudge), median = psum(ds.median, xnudge), Q3 = psum(ds.Q3, xnudge), uwisker = psum(ds.uwisker, xnudge), outliers = vecutils.apply(
1872
+ ($y, { x: xs, $raw }, nudge) => psum(xs, nudge).map(($x, i) => ({ x: $x, y: $y, $raw: $raw[i] })),
1873
+ y2,
1874
+ ds.outliers ?? [],
1875
+ xnudge
1876
+ ), $xmin = psum(ds.xmin, xnudge), $xmax = psum(ds.xmax, xnudge);
1877
+ return {
1878
+ y: y2,
1879
+ ymin,
1880
+ ymax,
1881
+ lwisker,
1882
+ Q1,
1883
+ median,
1884
+ Q3,
1885
+ uwisker,
1886
+ outliers,
1887
+ $xmin,
1888
+ $xmax,
1889
+ $ymin: ymin,
1890
+ $ymax: ymax
1891
+ };
1892
+ }
1893
+ return {};
1894
+ },
1895
+ get_range(ds, orientation) {
1896
+ if (orientation == "x") return ds.x || (ds.min ?? []).concat(ds.max ?? []);
1897
+ if (orientation == "y") return ds.y || (ds.min ?? []).concat(ds.max ?? []);
1898
+ },
1899
+ validate(d) {
1900
+ if ([d.$xmin, d.$xmax, d.$ymin, d.$ymax].some((v) => isNaN(v))) return null;
1898
1901
  return d;
1899
1902
  }
1900
1903
  }
1901
1904
  };
1902
1905
  const vvstat = {
1903
- blank: Object.assign(function(data) {
1904
- let missingAes = ["x", "y"].filter((a) => data[a] == null);
1905
- if (missingAes.length > 0)
1906
- throw new Error(`Missing aesthetics for GeomBlank: "${missingAes.join('", "')}"`);
1906
+ /**
1907
+ * identity transformation
1908
+ * keep data points as is
1909
+ */
1910
+ identity: Object.assign(function(data) {
1907
1911
  return data;
1908
- }, { core_attrs: ["x", "y"] }),
1912
+ }, { core_attrs: ["x", "y", "xnudge", "ynudge"] }),
1913
+ /**
1914
+ * line transformation
1915
+ * connect data points in the order of one variable
1916
+ * { x, y } => { x, y, xend, yend }
1917
+ */
1909
1918
  line: Object.assign(function(data, { orientation = "x" } = {}) {
1910
1919
  let missingAes = ["x", "y"].filter((a) => data[a] == null);
1911
1920
  if (missingAes.length > 0)
1912
- throw new Error(`Missing aesthetics for GeomLine: "${missingAes.join('", "')}"`);
1921
+ throw new Error(`Missing aesthetics for "StatLine": "${missingAes.join('", "')}"`);
1913
1922
  let group = data.group ?? new Array(data.x.length).fill(null);
1914
1923
  let groups = Object.values(group.reduce((acc, cur, i) => {
1915
1924
  acc[cur] ??= [];
@@ -1929,25 +1938,35 @@ const vvstat = {
1929
1938
  result.yend = order2.map((i) => data.y[i]);
1930
1939
  return result;
1931
1940
  }, { core_attrs: ["x", "y", "xnudge", "ynudge"] }),
1941
+ /**
1942
+ * linerange transformation
1943
+ * { x, ymin, ymax } => { x, y, xend, yend }
1944
+ * { y, xmin, xmax } => { y, x, yend, xend }
1945
+ */
1932
1946
  linerange: Object.assign(function(data) {
1933
1947
  if (data.x != null) {
1934
1948
  let missingAes = ["x", "ymin", "ymax"].filter((a) => data[a] == null);
1935
1949
  if (missingAes.length > 0)
1936
- throw new Error(`Missing aesthetics for GeomLinerange: "${missingAes.join('", "')}"`);
1950
+ throw new Error(`Missing aesthetics for "StatLinerange": "${missingAes.join('", "')}"`);
1937
1951
  return (({ x: x2, ymin, ymax, ...etc }) => ({ x: x2, xend: x2, y: ymin, yend: ymax, ...etc }))(data);
1938
1952
  } else if (data.y != null) {
1939
1953
  let missingAes = ["y", "xmin", "xmax"].filter((a) => data[a] == null);
1940
1954
  if (missingAes.length > 0)
1941
- throw new Error(`Missing aesthetics for GeomLinerange: "${missingAes.join('", "')}"`);
1955
+ throw new Error(`Missing aesthetics for "StatLinerange": "${missingAes.join('", "')}"`);
1942
1956
  return (({ y: y2, xmin, xmax, ...etc }) => ({ y: y2, yend: y2, x: xmin, xend: xmax, ...etc }))(data);
1943
1957
  } else {
1944
- throw new Error(`Missing aesthetics for GeomLinerange: x,ymin,ymax or y,xmin,xmax`);
1958
+ throw new Error(`Missing aesthetics for "StatLinerange": x,ymin,ymax or y,xmin,xmax`);
1945
1959
  }
1946
1960
  }, { core_attrs: ["x", "y", "xmin", "xmax", "ymin", "ymax", "xnudge", "ynudge"] }),
1961
+ /**
1962
+ * path transformation
1963
+ * connect data points in appearance order
1964
+ * { x, y } => { x, y, xend, yend }
1965
+ */
1947
1966
  path: Object.assign(function(data) {
1948
1967
  let missingAes = ["x", "y"].filter((a) => data[a] == null);
1949
1968
  if (missingAes.length > 0)
1950
- throw new Error(`Missing aesthetics for GeomPath: "${missingAes.join('", "')}"`);
1969
+ throw new Error(`Missing aesthetics for "StatPath": "${missingAes.join('", "')}"`);
1951
1970
  let group = data.group ?? new Array(data.x.length).fill(null);
1952
1971
  let groups = Object.values(group.reduce((acc, cur, i) => {
1953
1972
  acc[cur] ??= [];
@@ -1965,27 +1984,40 @@ const vvstat = {
1965
1984
  result.yend = order2.map((i) => data.y[i]);
1966
1985
  return result;
1967
1986
  }, { core_attrs: ["x", "y", "xnudge", "ynudge"] }),
1987
+ /**
1988
+ * segment transformation
1989
+ * { x, y, xend?, yend? } => { x, y, xend, yend }
1990
+ */
1968
1991
  segment: Object.assign(function(data) {
1969
1992
  if (data.xend == null) data.xend = data.x;
1970
1993
  if (data.yend == null) data.yend = data.y;
1971
1994
  let missingAes = ["x", "y", "xend", "yend"].filter((a) => data[a] == null);
1972
1995
  if (missingAes.length > 0)
1973
- throw new Error(`Missing aesthetics for GeomSegment: "${missingAes.join('", "')}"`);
1996
+ throw new Error(`Missing aesthetics for "StatSegment": "${missingAes.join('", "')}"`);
1974
1997
  return data;
1975
1998
  }, { core_attrs: ["x", "y", "xend", "yend", "xnudge", "ynudge"] }),
1999
+ /**
2000
+ * stick transformation
2001
+ * { x, y, dx, dy } => { x, y, xend, yend }
2002
+ */
1976
2003
  stick: Object.assign(function(data) {
1977
2004
  if (data.dx == null) data.dx = Array(data.x.length).fill(0);
1978
2005
  if (data.dy == null) data.dy = Array(data.y.length).fill(0);
1979
2006
  let missingAes = ["x", "y", "dx", "dy"].filter((a) => data[a] == null);
1980
2007
  if (missingAes.length > 0)
1981
- throw new Error(`Missing aesthetics for GeomStick: "${missingAes.join('", "')}"`);
2008
+ throw new Error(`Missing aesthetics for "StatStick": "${missingAes.join('", "')}"`);
1982
2009
  return data;
1983
2010
  }, { core_attrs: ["x", "y", "dx", "dy", "xnudge", "ynudge"] }),
2011
+ /**
2012
+ * curve transformation
2013
+ * { x, y } => { points }
2014
+ * { points } => { points }
2015
+ */
1984
2016
  curve: Object.assign(function(data) {
1985
2017
  if (data.points != null) return data;
1986
2018
  let missingAes = ["x", "y"].filter((a) => data[a] == null);
1987
2019
  if (missingAes.length > 0)
1988
- throw new Error(`Missing aesthetics for GeomCurve: "${missingAes.join('", "')}" or "points"`);
2020
+ throw new Error(`Missing aesthetics for "StatCurve": "${missingAes.join('", "')}" or "points"`);
1989
2021
  let keys = Object.keys(data).filter((k) => !["x", "y"].includes(k) && !k.startsWith("$"));
1990
2022
  let group = intraaction(Object.fromEntries(keys.map((k) => [k, data[k]])));
1991
2023
  let cut = intraaction({
@@ -2003,17 +2035,26 @@ const vvstat = {
2003
2035
  }
2004
2036
  return result;
2005
2037
  }, { core_attrs: ["x", "y", "xnudge", "ynudge"] }),
2038
+ /**
2039
+ * point transformation
2040
+ * { x, y } => { x, y }
2041
+ */
2006
2042
  point: Object.assign(function(data) {
2007
2043
  let missingAes = ["x", "y"].filter((a) => data[a] == null);
2008
2044
  if (missingAes.length > 0)
2009
- throw new Error(`Missing aesthetics for GeomPoint: "${missingAes.join('", "')}"`);
2045
+ throw new Error(`Missing aesthetics for "StatPoint": "${missingAes.join('", "')}"`);
2010
2046
  return data;
2011
2047
  }, { core_attrs: ["x", "y", "xnudge", "ynudge"] }),
2048
+ /**
2049
+ * polygon transformation
2050
+ * { x, y } => { points }
2051
+ * { points } => { points }
2052
+ */
2012
2053
  polygon: Object.assign(function(data) {
2013
2054
  if (data.points != null) return data;
2014
2055
  let missingAes = ["x", "y"].filter((a) => data[a] == null);
2015
2056
  if (missingAes.length > 0)
2016
- throw new Error(`Missing aesthetics for GeomPolygon: "${missingAes.join('", "')}" or "points"`);
2057
+ throw new Error(`Missing aesthetics for "StatPolygon": "${missingAes.join('", "')}" or "points"`);
2017
2058
  let keys = Object.keys(data).filter((k) => !["x", "y"].includes(k) && !k.startsWith("$"));
2018
2059
  let group = intraaction(Object.fromEntries(keys.map((k) => [k, data[k]])));
2019
2060
  let cut = intraaction({
@@ -2031,12 +2072,20 @@ const vvstat = {
2031
2072
  }
2032
2073
  return result;
2033
2074
  }, { core_attrs: ["points", "xnudge", "ynudge"] }),
2075
+ /**
2076
+ * rect transformation
2077
+ * { xmin, xmax, ymin, ymax } => { xmin, xmax, ymin, ymax }
2078
+ */
2034
2079
  rect: Object.assign(function(data) {
2035
2080
  let missingAes = ["xmin", "xmax", "ymin", "ymax"].filter((a) => data[a] == null);
2036
2081
  if (missingAes.length > 0)
2037
- throw new Error(`Missing aesthetics for GeomRect: "${missingAes.join('", "')}"`);
2082
+ throw new Error(`Missing aesthetics for "StatRect": "${missingAes.join('", "')}"`);
2038
2083
  return data;
2039
2084
  }, { core_attrs: ["xmin", "xmax", "ymin", "ymax", "xnudge", "ynudge"] }),
2085
+ /**
2086
+ * tile transformation
2087
+ * { x, y, width?, height? } => { x, y, width, height }
2088
+ */
2040
2089
  tile: Object.assign(function(data) {
2041
2090
  if (data.width == null && data.x.some((x2) => typeof x2 === "string")) {
2042
2091
  data.width = Array(data.x.length).fill(1);
@@ -2046,31 +2095,44 @@ const vvstat = {
2046
2095
  }
2047
2096
  let missingAes = ["x", "y", "width", "height"].filter((a) => data[a] == null);
2048
2097
  if (missingAes.length > 0)
2049
- throw new Error(`Missing aesthetics for GeomTile: "${missingAes.join('", "')}"`);
2098
+ throw new Error(`Missing aesthetics for "StatTile": "${missingAes.join('", "')}"`);
2050
2099
  return data;
2051
2100
  }, { core_attrs: ["x", "y", "width", "height", "xnudge", "ynudge"] }),
2101
+ /**
2102
+ * text transformation
2103
+ * { x, y, label } => { x, y, label }
2104
+ */
2052
2105
  text: Object.assign(function(data) {
2053
2106
  let missingAes = ["x", "y", "label"].filter((a) => data[a] == null);
2054
2107
  if (missingAes.length > 0)
2055
- throw new Error(`Missing aesthetics for GeomText: "${missingAes.join('", "')}"`);
2108
+ throw new Error(`Missing aesthetics for "StatText": "${missingAes.join('", "')}"`);
2056
2109
  return data;
2057
2110
  }, { core_attrs: ["x", "y", "xnudge", "ynudge", "label", "text-length"] }),
2111
+ /**
2112
+ * textsegment transformation
2113
+ * { x, y, xend, yend, label } => { x, y, xend, yend, label }
2114
+ */
2058
2115
  textsegment: Object.assign(function(data) {
2059
2116
  if (data.xend == null) data.xend = data.x;
2060
2117
  if (data.yend == null) data.yend = data.y;
2061
2118
  let missingAes = ["x", "y", "xend", "yend", "label"].filter((a) => data[a] == null);
2062
2119
  if (missingAes.length > 0)
2063
- throw new Error(`Missing aesthetics for GeomTextsegment: "${missingAes.join('", "')}"`);
2120
+ throw new Error(`Missing aesthetics for "StatTextsegment": "${missingAes.join('", "')}"`);
2064
2121
  return data;
2065
2122
  }, { core_attrs: ["x", "y", "xend", "yend", "xnudge", "ynudge", "label"] }),
2123
+ /**
2124
+ * histogram transformation
2125
+ * { x } => { xmin, xmax, ymin, ymax }
2126
+ * { y } => { ymin, ymax, xmin, xmax }
2127
+ */
2066
2128
  histogram: Object.assign(function(data, { bins = 30, binwidth, breaks } = {}) {
2067
2129
  if (data.x != null && data.y != null)
2068
- throw new Error(`Histogram only supports x or y, not both`);
2130
+ throw new Error(`"StatHistogram" only supports "x" or "y", not both`);
2069
2131
  let values = data.x ?? data.y;
2070
2132
  if (values == null)
2071
- throw new Error(`Missing aesthetics for GeomHistogram: x or y`);
2133
+ throw new Error(`Missing aesthetics for "StatHistogram": "x" or "y"`);
2072
2134
  if (values.some((x2) => typeof x2 !== "number"))
2073
- throw new Error(`"stat.histogram" requires a continuous aesthetic`);
2135
+ throw new Error(`"StatHistogram" requires a continuous aesthetic`);
2074
2136
  if (breaks) {
2075
2137
  breaks.sort((a, b) => a - b);
2076
2138
  } else {
@@ -2116,14 +2178,19 @@ const vvstat = {
2116
2178
  }) => ({ xmin, xmax, ymin, ymax, ...etc }))(result);
2117
2179
  }
2118
2180
  }, { core_attrs: ["x", "y", "xnudge", "ynudge"] }),
2181
+ /**
2182
+ * bar transformation
2183
+ * { x } => { x, y, height }
2184
+ * { y } => { x, y, width }
2185
+ */
2119
2186
  bar: Object.assign(function(data) {
2120
2187
  if (data.x != null && data.y != null)
2121
- throw new Error(`Bar only supports x or y, not both`);
2188
+ throw new Error(`"StatBar" only supports "x" or "y", not both`);
2122
2189
  let values = data.x ?? data.y;
2123
2190
  if (values == null)
2124
- throw new Error(`Missing aesthetics for GeomBar: x or y`);
2191
+ throw new Error(`Missing aesthetics for "StatBar": "x" or "y"`);
2125
2192
  if (values.some((x2) => typeof x2 === "number"))
2126
- throw new Error(`"stat.bar" requires a discrete aesthetic`);
2193
+ throw new Error(`"StatBar" requires a discrete aesthetic`);
2127
2194
  let keys = Object.keys(data).filter((k) => !["x", "y"].includes(k) && !k.startsWith("$"));
2128
2195
  let group = intraaction(Object.fromEntries(keys.map((k) => [k, data[k]])));
2129
2196
  let inter = intraaction({ group: group ?? 0, value: values });
@@ -2144,14 +2211,64 @@ const vvstat = {
2144
2211
  return (({ value, count, ...etc }) => ({ y: value, x: count.map((x2) => x2 / 2), width: count, ...etc }))(result);
2145
2212
  }
2146
2213
  }, { core_attrs: ["x", "y", "xnudge", "ynudge"] }),
2214
+ /**
2215
+ * boxplot transformation
2216
+ * { x, y } => { x, min, lwisker, Q1, median, Q3, uwisker, max, outliers }
2217
+ * { x, y } => { y, min, lwisker, Q1, median, Q3, uwisker, max, outliers }
2218
+ */
2219
+ boxplot: Object.assign(function(data, {}) {
2220
+ let missingAes = ["x", "y"].filter((a) => data[a] == null);
2221
+ if (missingAes.length > 0)
2222
+ throw new Error(`Missing aesthetics for "StatBoxplot": "${missingAes.join('", "')}"`);
2223
+ let isXdiscrete = data.x.some((x2) => typeof x2 !== "number");
2224
+ let isYdiscrete = data.y.some((y2) => typeof y2 !== "number");
2225
+ if (isXdiscrete && isYdiscrete)
2226
+ throw new Error(`Both "x" and "y" are discrete, "StatBoxplot" requires one continuous and one discrete aesthetic`);
2227
+ if (!isXdiscrete && !isYdiscrete)
2228
+ throw new Error(`Both "x" and "y" are continuous, "StatBoxplot" requires one continuous and one discrete aesthetic`);
2229
+ let [valueAes, cateAes] = isXdiscrete ? ["y", "x"] : ["x", "y"];
2230
+ let keys = Object.keys(data).filter((k) => k != valueAes && !k.startsWith("$"));
2231
+ let group = intraaction(Object.fromEntries(keys.map((k) => [k, data[k]])));
2232
+ let inter = intraaction({ group: group ?? 0, cate: data[cateAes] });
2233
+ let groupIdx = Map.groupBy(inter.map((_, i) => i), (_, i) => inter.categories[inter[i]]);
2234
+ let cates = Array.from(groupIdx.keys()), $raw = Array.from(groupIdx.values()).map((arr) => arr.map((idx) => data.$raw[idx])), val = Array.from(groupIdx.values()).map((arr) => arr.map((idx) => data[valueAes][idx]));
2235
+ let min = val.map((v) => numutils.min(v)), Q1 = val.map((v) => numutils.quantile(v, 0.25)), median = val.map((v) => numutils.quantile(v, 0.5)), Q3 = val.map((v) => numutils.quantile(v, 0.75)), max = val.map((v) => numutils.max(v)), IQR = val.map((_, i) => Q3[i] - Q1[i]), lwisker = val.map((_, i) => Math.max(min[i], Q1[i] - 1.5 * IQR[i])), uwisker = val.map((_, i) => Math.min(max[i], Q3[i] + 1.5 * IQR[i])), outliers = Array.from(groupIdx.values()).map((arr, i) => {
2236
+ let ids = arr.filter((idx) => data[valueAes][idx] < lwisker[i] || data[valueAes][idx] > uwisker[i]);
2237
+ return {
2238
+ [valueAes]: ids.map((idx) => data[valueAes][idx]),
2239
+ $raw: ids.map((idx) => data.$raw[idx])
2240
+ };
2241
+ });
2242
+ let result = {
2243
+ $raw,
2244
+ $group: cates.map((x2) => x2.group),
2245
+ min,
2246
+ lwisker,
2247
+ Q1,
2248
+ median,
2249
+ Q3,
2250
+ uwisker,
2251
+ max,
2252
+ outliers
2253
+ };
2254
+ for (let key of keys) {
2255
+ result[key] = cates.map((x2) => x2.group).map((i) => group.categories[i][key]);
2256
+ }
2257
+ return result;
2258
+ }, { core_attrs: ["x", "y", "xnudge", "ynudge"] }),
2259
+ /**
2260
+ * density transformation
2261
+ * { x } => { points }
2262
+ * { y } => { points }
2263
+ */
2147
2264
  density: Object.assign(function(data, { n = 512, kernel = "gaussian" } = {}) {
2148
2265
  if (data.x != null && data.y != null)
2149
- throw new Error(`Density only supports x or y, not both`);
2266
+ throw new Error(`"StatDensity" only supports "x" or "y", not both`);
2150
2267
  let values = data.x ?? data.y;
2151
2268
  if (values == null)
2152
- throw new Error(`Missing aesthetics for GeomDensity: x or y`);
2269
+ throw new Error(`Missing aesthetics for "StatDensity": "x" or "y"`);
2153
2270
  if (values.some((x2) => typeof x2 !== "number"))
2154
- throw new Error(`"stat.density" requires a continuous aesthetic`);
2271
+ throw new Error(`"StatDensity" requires a continuous aesthetic`);
2155
2272
  kernel = density_kernels[kernel];
2156
2273
  if (!kernel) {
2157
2274
  throw new Error(`kernel must be one of ${Object.keys(density_kernels).map((k) => `"${k}"`).join(", ")}`);
@@ -2709,12 +2826,14 @@ class GLayer {
2709
2826
  }
2710
2827
  let values = this.$data[aes];
2711
2828
  if (!values?.length) continue;
2712
- if ($$levels?.[aes] != null) {
2713
- scale.level = $$levels[aes];
2714
- } else if (values.some((v) => typeof v === "string")) {
2715
- scale.level = GEnumLevel.from(values);
2716
- } else {
2717
- scale.extent = numutils.extent(values);
2829
+ if (!scale.asis) {
2830
+ if ($$levels?.[aes] != null) {
2831
+ scale.level = $$levels[aes];
2832
+ } else if (values.some((v) => typeof v === "string")) {
2833
+ scale.level = GEnumLevel.from(values);
2834
+ } else {
2835
+ scale.extent = numutils.extent(values);
2836
+ }
2718
2837
  }
2719
2838
  this.applyScale(aes, scale);
2720
2839
  }
@@ -2740,10 +2859,8 @@ class GLayer {
2740
2859
  applyScale(aes, scale) {
2741
2860
  let values = this.$data[aes];
2742
2861
  if (values == null) return;
2743
- if (scale.level != null) {
2744
- values = scale.level.apply(values);
2745
- }
2746
- values.extent = scale.limits;
2862
+ if (scale.level) values = scale.level.apply(values);
2863
+ if (scale.limits) values.extent = scale.limits;
2747
2864
  scale.aes = aes;
2748
2865
  this.data[aes] = scale(values);
2749
2866
  this.scales[aes] = scale;
@@ -2776,12 +2893,14 @@ class GPlot {
2776
2893
  if (values.length != 0) {
2777
2894
  let scale = new Scale(scales?.[aes] ?? vvscale[aes].default());
2778
2895
  scale.aesthetics = aes;
2779
- if (levels?.[aes] != null) {
2780
- scale.level = levels[aes];
2781
- } else if (values.some((v) => typeof v === "string")) {
2782
- scale.level = GEnumLevel.from(values);
2783
- } else if (!scale.asis) {
2784
- scale.extent = numutils.extent(values);
2896
+ if (!scale.asis) {
2897
+ if (levels?.[aes] != null) {
2898
+ scale.level = levels[aes];
2899
+ } else if (values.some((v) => typeof v === "string")) {
2900
+ scale.level = GEnumLevel.from(values);
2901
+ } else {
2902
+ scale.extent = numutils.extent(values);
2903
+ }
2785
2904
  }
2786
2905
  if (scale.title == null) {
2787
2906
  scale.title = this.layers.map((layer) => layer.$fns?.[aes]).find((s) => s != null);
@@ -2845,46 +2964,48 @@ class GPlot {
2845
2964
  let result = {};
2846
2965
  this._range = range;
2847
2966
  if (this.levels.x) {
2848
- let min = +(range?.xmin ?? -0.5) - (add.x?.min ?? 0), max = +(range?.xmax ?? this.levels.x.length - 0.5) + (add.x?.max ?? 0);
2967
+ let min = +(range?.xmin ?? -0.5) - (+add.x?.min || 0), max = +(range?.xmax ?? this.levels.x.length - 0.5) + (+add.x?.max || 0);
2849
2968
  result.x = new DiscreteCoordScale(this.levels.x, { min, max });
2850
2969
  } else {
2851
2970
  let $min = range?.xmin ?? this.extents.x?.min ?? 0, $max = range?.xmax ?? this.extents.x?.max ?? 0;
2852
- let min = +$min - (add.x?.min ?? 0), max = +$max + (add.x?.max ?? 0);
2971
+ let min = plus($min, -add.x?.min || 0), max = plus($max, +add.x?.max || 0);
2853
2972
  let dmin = minRange?.x ?? 1;
2854
2973
  if (max - min < dmin) {
2855
2974
  if (range?.xmax == null && range?.xmin != null) {
2856
- max = min + dmin;
2975
+ max = plus(min, +dmin);
2857
2976
  } else if (range?.xmax != null && range?.xmin == null) {
2858
- min = max - dmin;
2977
+ min = plus(max, -dmin);
2859
2978
  } else {
2860
- max = (max + min) / 2 + dmin / 2;
2861
- min = max - dmin;
2979
+ let interval = max - min;
2980
+ max = plus(max, -interval / 2 + dmin / 2);
2981
+ min = plus(max, -dmin);
2862
2982
  }
2863
2983
  }
2864
- if ($min instanceof Date || $max instanceof Date) {
2984
+ if (min instanceof Date || max instanceof Date) {
2865
2985
  result.x = new DatetimeCoordScale({ min, max });
2866
2986
  } else {
2867
2987
  result.x = new ContinuousCoordScale({ min, max });
2868
2988
  }
2869
2989
  }
2870
2990
  if (this.levels.y) {
2871
- let min = +(range?.ymin ?? -0.5) - (add.y?.min ?? 0), max = +(range?.ymax ?? this.levels.y.length - 0.5) + (add.y?.max ?? 0);
2991
+ let min = +(range?.ymin ?? -0.5) - (+add.y?.min || 0), max = +(range?.ymax ?? this.levels.y.length - 0.5) + (+add.y?.max || 0);
2872
2992
  result.y = new DiscreteCoordScale(this.levels.y, { min, max });
2873
2993
  } else {
2874
2994
  let $min = range?.ymin ?? this.extents.y?.min ?? 0, $max = range?.ymax ?? this.extents.y?.max ?? 0;
2875
- let min = +$min - (add.y?.min ?? 0), max = +$max + (add.y?.max ?? 0);
2995
+ let min = plus($min, -add.y?.min), max = plus($max, +add.y?.max || 0);
2876
2996
  let dmin = minRange?.y ?? 1;
2877
2997
  if (max - min < dmin) {
2878
2998
  if (range?.ymax == null && range?.ymin != null) {
2879
- max = min + dmin;
2999
+ max = plus(min, +dmin);
2880
3000
  } else if (range?.ymax != null && range?.ymin == null) {
2881
- min = max - dmin;
3001
+ min = plus(max, -dmin);
2882
3002
  } else {
2883
- max = (max + min) / 2 + dmin / 2;
2884
- min = max - dmin;
3003
+ let interval = max - min;
3004
+ max = plus(max, -interval / 2 + dmin / 2);
3005
+ min = plus(max, -dmin);
2885
3006
  }
2886
3007
  }
2887
- if ($min instanceof Date || $max instanceof Date) {
3008
+ if (min instanceof Date || max instanceof Date) {
2888
3009
  result.y = new DatetimeCoordScale({ min, max });
2889
3010
  } else {
2890
3011
  result.y = new ContinuousCoordScale({ min, max });
@@ -2934,23 +3055,13 @@ class DiscreteCoordScale extends Function {
2934
3055
  constructor(level, { min, max } = {}) {
2935
3056
  const scale = min == max ? (x2) => 0 : (x2) => (+x2 - min) / (max - min);
2936
3057
  scale.range = { min, max };
2937
- scale.limits = { min, max };
2938
3058
  scale.level = level;
2939
- scale.invert = (w) => w * (max - min) + min;
2940
3059
  Object.setPrototypeOf(scale, DiscreteCoordScale.prototype);
2941
3060
  return scale;
2942
3061
  }
2943
- expand({ min: mmin = 0, max: mmax = 0 } = {}) {
2944
- let $min = 0, $max = this.level.length, $interval = $max;
2945
- let min = $min - mmin * $interval, max = $max + mmax * $interval;
2946
- const scale = min == max ? (x2) => 0 : (x2) => (+x2 - min) / (max - min);
2947
- scale.invert = (w) => w * (max - min) + min;
2948
- scale.range = this.range;
2949
- scale.level = this.level;
2950
- scale.title = this.title;
2951
- scale.limits = { min, max };
2952
- Object.setPrototypeOf(scale, DiscreteCoordScale.prototype);
2953
- return scale;
3062
+ invert(w) {
3063
+ let { min, max } = this.range;
3064
+ return w * (max - min) + min;
2954
3065
  }
2955
3066
  get breaks() {
2956
3067
  return Array.from(this.level);
@@ -2961,35 +3072,19 @@ class DiscreteCoordScale extends Function {
2961
3072
  }
2962
3073
  class ContinuousCoordScale extends Function {
2963
3074
  constructor(domain) {
2964
- let min = +domain.min, max = +domain.max;
2965
- const scale = min == max ? (x2) => 0.5 : (x2) => (+x2 - min) / (max - min);
3075
+ let { min, max } = domain;
3076
+ const scale = min == max ? (x2) => isFinite(x2) ? 0.5 : x2 : (x2) => (+x2 - min) / (max - min);
2966
3077
  scale.range = { min, max };
2967
- scale.limits = { min, max };
2968
- Object.setPrototypeOf(scale, ContinuousCoordScale.prototype);
2969
- return scale;
2970
- }
2971
- expand({ min: mmin = 0, max: mmax = 0 } = {}) {
2972
- let { min: $min, max: $max } = this.limits;
2973
- let $interval = $max - $min;
2974
- let min = $min - mmin * $interval, max = $max + mmax * $interval;
2975
- const scale = min == max ? (x2) => 0.5 : (x2) => (+x2 - min) / (max - min);
2976
- scale.range = this.range;
2977
- scale.level = this.level;
2978
- scale.title = this.title;
2979
- scale.limits = { min, max };
2980
3078
  Object.setPrototypeOf(scale, ContinuousCoordScale.prototype);
2981
3079
  return scale;
2982
3080
  }
2983
3081
  invert(w) {
2984
- let { min, max } = this.limits;
2985
- return w * (max - min) + min;
3082
+ let { min, max } = this.range;
3083
+ return plus(min, w * (max - min));
2986
3084
  }
2987
3085
  get breaks() {
2988
3086
  return vvbreak.number();
2989
3087
  }
2990
- get minorBreaks() {
2991
- return vvbreak.number({ minor: true });
2992
- }
2993
3088
  }
2994
3089
  class DatetimeCoordScale extends ContinuousCoordScale {
2995
3090
  constructor(domain) {
@@ -2997,15 +3092,6 @@ class DatetimeCoordScale extends ContinuousCoordScale {
2997
3092
  Object.setPrototypeOf(scale, DatetimeCoordScale.prototype);
2998
3093
  return scale;
2999
3094
  }
3000
- expand({ min: mmin = 0, max: mmax = 0 } = {}) {
3001
- let scale = super.expand({ min: mmin, max: mmax });
3002
- Object.setPrototypeOf(scale, DatetimeCoordScale.prototype);
3003
- return scale;
3004
- }
3005
- invert(w) {
3006
- let { min, max } = this.limits;
3007
- return new Date(w * (max - min) + min);
3008
- }
3009
3095
  get breaks() {
3010
3096
  return vvbreak.datetime();
3011
3097
  }
@@ -3014,25 +3100,28 @@ class DatetimeCoordScale extends ContinuousCoordScale {
3014
3100
  }
3015
3101
  }
3016
3102
  class GAxis {
3017
- constructor(scale, { extend: extend2, breaks, labels, minorBreaks, titles } = {}) {
3103
+ constructor(scale, { breaks, labels, minorBreaks, titles } = {}) {
3018
3104
  this.scale = scale;
3019
- this.limits = scale?.limits;
3020
- this.extend = extend2 ?? 0;
3105
+ this.range = scale?.range;
3021
3106
  this.breaks = breaks ?? scale.breaks;
3022
3107
  this.labels = labels ?? vvlabel.auto();
3023
3108
  this.titles = titles ?? vvlabel.asis();
3024
- this.minorBreaks = minorBreaks ?? scale.minorBreaks;
3025
- }
3026
- getBindings({ limits = this.limits, extend: extend2 = this.extend } = {}) {
3027
- let breaks = this.breaks, minorBreaks = this.minorBreaks;
3028
- let { min, max } = limits, interval = max - min || 0;
3029
- min = min == null ? min : min - extend2 * interval;
3030
- max = max == null ? max : max + extend2 * interval;
3031
- if (typeof breaks == "function") breaks = breaks(limits);
3032
- breaks = Array.isArray(breaks) ? breaks.sort((a, b) => a - b) : [];
3033
- if (typeof minorBreaks == "function") minorBreaks = minorBreaks(limits);
3034
- minorBreaks = Array.isArray(minorBreaks) ? minorBreaks.sort((a, b) => a - b) : [];
3035
- let labels = this.labels, titles = this.titles;
3109
+ this.minorBreaks = minorBreaks ?? breaks ?? scale.minorBreaks ?? scale.breaks;
3110
+ }
3111
+ getBindings({ range, expandMult } = {}) {
3112
+ let majorBreaks = this.breaks, minorBreaks = this.minorBreaks, labels = this.labels, titles = this.titles;
3113
+ let min = range?.min ?? this?.range?.min, max = range?.max ?? this?.range?.max, interval = max - min || 0;
3114
+ min = min == null ? min : plus(min, -(expandMult?.min ?? 0) * interval);
3115
+ max = max == null ? max : plus(max, +(expandMult?.max ?? 0) * interval);
3116
+ function normalizeBreaks(val) {
3117
+ if (val.position != null) return val;
3118
+ return { position: val };
3119
+ }
3120
+ if (typeof majorBreaks == "function") majorBreaks = majorBreaks({ min, max });
3121
+ majorBreaks = Array.isArray(majorBreaks) ? majorBreaks.map(normalizeBreaks) : [];
3122
+ let breaks = majorBreaks.map((x2) => x2.position);
3123
+ if (typeof minorBreaks == "function") minorBreaks = minorBreaks({ min, max, minor: true });
3124
+ minorBreaks = Array.isArray(minorBreaks) ? minorBreaks.map(normalizeBreaks) : [];
3036
3125
  if (typeof labels === "function") labels = breaks.map(labels);
3037
3126
  if (!Array.isArray(labels)) {
3038
3127
  labels = [];
@@ -3042,11 +3131,11 @@ class GAxis {
3042
3131
  if (typeof titles === "function") titles = breaks.map(titles);
3043
3132
  if (!Array.isArray(titles)) {
3044
3133
  titles = [];
3045
- } else if (titles.length != titles.length) {
3134
+ } else if (titles.length != breaks.length) {
3046
3135
  throw new Error("Length of titles must be the same as breaks");
3047
3136
  }
3048
3137
  return {
3049
- majorBreaks: breaks,
3138
+ majorBreaks,
3050
3139
  minorBreaks,
3051
3140
  ticks: breaks.map((position, i) => ({ position, label: labels[i], title: titles[i] }))
3052
3141
  };
@@ -3054,7 +3143,7 @@ class GAxis {
3054
3143
  }
3055
3144
  const _hoisted_1$7 = ["font-size"];
3056
3145
  const _hoisted_2$6 = { key: 0 };
3057
- const _sfc_main$T = {
3146
+ const _sfc_main$W = {
3058
3147
  __name: "CoreText",
3059
3148
  props: {
3060
3149
  x: { type: Number, default: 0 },
@@ -3108,12 +3197,12 @@ const _sfc_main$T = {
3108
3197
  return {
3109
3198
  x: __props.x,
3110
3199
  y: __props.y,
3111
- fill: __props.color,
3112
- "fill-opacity": __props.alpha,
3113
- stroke: __props.stroke,
3200
+ fill: __props.color || null,
3201
+ "fill-opacity": __props.alpha == 1 ? null : __props.alpha,
3202
+ stroke: __props.stroke || null,
3114
3203
  "stroke-width": __props.linewidth,
3115
3204
  "stroke-dasharray": parseLineType(__props.linetype),
3116
- "stroke-opacity": __props.alpha,
3205
+ "stroke-opacity": __props.alpha == 1 ? null : __props.alpha,
3117
3206
  transform,
3118
3207
  textLength: __props.textLength,
3119
3208
  lengthAdjust: __props.textLength ? "spacingAndGlyphs" : null,
@@ -3143,7 +3232,7 @@ const _sfc_main$T = {
3143
3232
  }), [
3144
3233
  renderSlot(_ctx.$slots, "default", {}, () => [
3145
3234
  __props.title ? (openBlock(), createElementBlock("title", _hoisted_2$6, toDisplayString(__props.title), 1)) : createCommentVNode("", true),
3146
- createTextVNode(" " + toDisplayString(__props.text), 1)
3235
+ createTextVNode(" " + toDisplayString(__props.text.replace(/ /g, " ")), 1)
3147
3236
  ])
3148
3237
  ], 16, _hoisted_1$7);
3149
3238
  };
@@ -3155,14 +3244,14 @@ const _hoisted_3$4 = {
3155
3244
  class: "vvplot-interactive",
3156
3245
  fill: "transparent"
3157
3246
  };
3158
- const _hoisted_4$3 = ["width"];
3247
+ const _hoisted_4$3 = ["width", "cursor"];
3159
3248
  const _hoisted_5$2 = {
3160
3249
  key: 0,
3161
3250
  class: "vvplot-interactive",
3162
3251
  fill: "transparent"
3163
3252
  };
3164
3253
  const _hoisted_6$2 = ["x"];
3165
- const _sfc_main$S = {
3254
+ const _sfc_main$V = {
3166
3255
  __name: "CoreAxisH",
3167
3256
  props: {
3168
3257
  coord: String,
@@ -3260,7 +3349,7 @@ const _sfc_main$S = {
3260
3349
  style: { transition: __props.transition }
3261
3350
  });
3262
3351
  }
3263
- return result.filter((t) => t.stroke != null);
3352
+ return result.filter((t) => t.stroke != null).sort((a, b) => a.x1 - b.x1);
3264
3353
  });
3265
3354
  const tickTexts = computed(() => {
3266
3355
  let isTop = __props.theme.tick_position == "top";
@@ -3301,7 +3390,7 @@ const _sfc_main$S = {
3301
3390
  }
3302
3391
  });
3303
3392
  }
3304
- return result.filter((t) => t.text.fill != null);
3393
+ return result.filter((t) => t.text.fill != null).sort((a, b) => a.text.x - b.text.x);
3305
3394
  });
3306
3395
  const iRef = useTemplateRef("i");
3307
3396
  function getPosition(event) {
@@ -3344,6 +3433,7 @@ const _sfc_main$S = {
3344
3433
  e.target.setPointerCapture(e.pointerId);
3345
3434
  e.target.onpointermove = (ev) => {
3346
3435
  movementX += ev.movementX;
3436
+ if (!pointerMoved) return;
3347
3437
  let dh = oob_squish_any(-movementX, { min: boundary.hmin - hmin0, max: boundary.hmax - hmax0 });
3348
3438
  let { xmin, xmax, ymin, ymax } = __props.pos2coord({ hmin: hmin0 + dh, hmax: hmax0 + dh });
3349
3439
  Object.assign(rangePreview, { xmin, xmax, ymin, ymax });
@@ -3352,6 +3442,7 @@ const _sfc_main$S = {
3352
3442
  e.target.onpointermove = null;
3353
3443
  e.target.onpointerup = null;
3354
3444
  e.target.style.cursor = null;
3445
+ if (!pointerMoved) return;
3355
3446
  moveTimer = setTimeout(() => {
3356
3447
  applyTransform(act, ev);
3357
3448
  movementX = 0;
@@ -3457,11 +3548,13 @@ const _sfc_main$S = {
3457
3548
  }
3458
3549
  }
3459
3550
  function applyTransform(act, event) {
3460
- if (!Object.keys(dropNull(rangePreview) ?? {}).length) return;
3461
- if (!emitEvent(act.emit, rangePreview, event)) {
3462
- emit(act.action, rangePreview, event);
3551
+ let coord = dropNull(rangePreview) ?? {};
3552
+ if (!Object.keys(coord).length) return;
3553
+ let e = new PointerEvent(event.type, event);
3554
+ if (!emitEvent(act.emit, coord, e)) {
3555
+ emit(act.action, coord, e);
3463
3556
  }
3464
- emit("rangechange", rangePreview);
3557
+ emit("rangechange", coord);
3465
3558
  let xmin, xmax, ymin, ymax;
3466
3559
  Object.assign(rangePreview, { xmin, xmax, ymin, ymax });
3467
3560
  }
@@ -3508,23 +3601,27 @@ const _sfc_main$S = {
3508
3601
  y1: 0,
3509
3602
  y2: 0
3510
3603
  }, axisLine.value), null, 16, _hoisted_2$5),
3604
+ _cache[1] || (_cache[1] = createTextVNode()),
3511
3605
  (openBlock(true), createElementBlock(Fragment, null, renderList(tickLines.value, (tick) => {
3512
3606
  return openBlock(), createElementBlock("line", mergeProps({ ref_for: true }, tick), null, 16);
3513
3607
  }), 256)),
3608
+ _cache[2] || (_cache[2] = createTextVNode()),
3514
3609
  (openBlock(true), createElementBlock(Fragment, null, renderList(tickTexts.value, (tick) => {
3515
3610
  return openBlock(), createElementBlock("g", mergeProps({ ref_for: true }, tick.wrapper), [
3516
- createVNode(_sfc_main$T, mergeProps({ ref_for: true }, tick.text), null, 16)
3611
+ createVNode(_sfc_main$W, mergeProps({ ref_for: true }, tick.text), null, 16)
3517
3612
  ], 16);
3518
3613
  }), 256)),
3614
+ _cache[3] || (_cache[3] = createTextVNode()),
3519
3615
  createElementVNode("g", _hoisted_3$4, [
3520
3616
  createElementVNode("rect", mergeProps({
3521
3617
  width: width.value,
3522
3618
  height: 10,
3523
3619
  y: -5
3524
3620
  }, toHandlers(axisVOn, true), {
3525
- class: { "vvplot-cursor-grab": __props.action.some?.((a) => a.action == "move") }
3621
+ cursor: __props.action.some?.((a) => a.action == "move") ? "grab" : null
3526
3622
  }), null, 16, _hoisted_4$3)
3527
3623
  ]),
3624
+ _cache[4] || (_cache[4] = createTextVNode()),
3528
3625
  __props.action.some?.((a) => a.action == "rescale") ? (openBlock(), createElementBlock("g", _hoisted_5$2, [
3529
3626
  createElementVNode("rect", {
3530
3627
  width: 20,
@@ -3533,6 +3630,7 @@ const _sfc_main$S = {
3533
3630
  style: { "cursor": "ew-resize" },
3534
3631
  onPointerdown: axisRescaleLeftPointerdown
3535
3632
  }, null, 32),
3633
+ _cache[0] || (_cache[0] = createTextVNode()),
3536
3634
  createElementVNode("rect", {
3537
3635
  width: 20,
3538
3636
  height: 10,
@@ -3542,7 +3640,8 @@ const _sfc_main$S = {
3542
3640
  onPointerdown: axisRescaleRightPointerdown
3543
3641
  }, null, 40, _hoisted_6$2)
3544
3642
  ])) : createCommentVNode("", true),
3545
- axisTitle.value.text ? (openBlock(), createBlock(_sfc_main$T, normalizeProps(mergeProps({ key: 1 }, axisTitle.value)), null, 16)) : createCommentVNode("", true)
3643
+ _cache[5] || (_cache[5] = createTextVNode()),
3644
+ axisTitle.value.text ? (openBlock(), createBlock(_sfc_main$W, normalizeProps(mergeProps({ key: 1 }, axisTitle.value)), null, 16)) : createCommentVNode("", true)
3546
3645
  ], 12, _hoisted_1$6);
3547
3646
  };
3548
3647
  }
@@ -3553,14 +3652,14 @@ const _hoisted_3$3 = {
3553
3652
  class: "vvplot-interactive",
3554
3653
  fill: "transparent"
3555
3654
  };
3556
- const _hoisted_4$2 = ["height"];
3655
+ const _hoisted_4$2 = ["height", "cursor"];
3557
3656
  const _hoisted_5$1 = {
3558
3657
  key: 0,
3559
3658
  class: "vvplot-interactive",
3560
3659
  fill: "transparent"
3561
3660
  };
3562
3661
  const _hoisted_6$1 = ["y"];
3563
- const _sfc_main$R = {
3662
+ const _sfc_main$U = {
3564
3663
  __name: "CoreAxisV",
3565
3664
  props: {
3566
3665
  coord: String,
@@ -3658,7 +3757,7 @@ const _sfc_main$R = {
3658
3757
  style: { transition: __props.transition }
3659
3758
  });
3660
3759
  }
3661
- return result.filter((t) => t.stroke != null);
3760
+ return result.filter((t) => t.stroke != null).sort((a, b) => a.y1 - b.y1);
3662
3761
  });
3663
3762
  const tickTexts = computed(() => {
3664
3763
  let isRight = __props.theme.tick_position == "right";
@@ -3699,7 +3798,7 @@ const _sfc_main$R = {
3699
3798
  }
3700
3799
  });
3701
3800
  }
3702
- return result.filter((t) => t.text.fill != null);
3801
+ return result.filter((t) => t.text.fill != null).sort((a, b) => a.text.y - b.text.y);
3703
3802
  });
3704
3803
  const iRef = useTemplateRef("i");
3705
3804
  function getPosition(event) {
@@ -3742,6 +3841,7 @@ const _sfc_main$R = {
3742
3841
  e.target.setPointerCapture(e.pointerId);
3743
3842
  e.target.onpointermove = (ev) => {
3744
3843
  movementY += ev.movementY;
3844
+ if (!pointerMoved) return;
3745
3845
  let dv = oob_squish_any(-movementY, { min: boundary.vmin - vmin0, max: boundary.vmax - vmax0 });
3746
3846
  let { xmin, xmax, ymin, ymax } = __props.pos2coord({ vmin: vmin0 + dv, vmax: vmax0 + dv });
3747
3847
  Object.assign(rangePreview, { xmin, xmax, ymin, ymax });
@@ -3750,6 +3850,7 @@ const _sfc_main$R = {
3750
3850
  e.target.onpointermove = null;
3751
3851
  e.target.onpointerup = null;
3752
3852
  e.target.style.cursor = null;
3853
+ if (!pointerMoved) return;
3753
3854
  moveTimer = setTimeout(() => {
3754
3855
  applyTransform(act, ev);
3755
3856
  movementY = 0;
@@ -3855,11 +3956,13 @@ const _sfc_main$R = {
3855
3956
  }
3856
3957
  }
3857
3958
  function applyTransform(act, event) {
3858
- if (!Object.keys(dropNull(rangePreview) ?? {}).length) return;
3859
- if (!emitEvent(act.emit, rangePreview, event)) {
3860
- emit(act.action, rangePreview, event);
3959
+ let coord = dropNull(rangePreview) ?? {};
3960
+ if (!Object.keys(coord).length) return;
3961
+ let e = new PointerEvent(event.type, event);
3962
+ if (!emitEvent(act.emit, coord, e)) {
3963
+ emit(act.action, coord, e);
3861
3964
  }
3862
- emit("rangechange", rangePreview);
3965
+ emit("rangechange", coord);
3863
3966
  let xmin, xmax, ymin, ymax;
3864
3967
  Object.assign(rangePreview, { xmin, xmax, ymin, ymax });
3865
3968
  }
@@ -3906,23 +4009,27 @@ const _sfc_main$R = {
3906
4009
  y1: 0,
3907
4010
  y2: height.value
3908
4011
  }, axisLine.value), null, 16, _hoisted_2$4),
4012
+ _cache[1] || (_cache[1] = createTextVNode()),
3909
4013
  (openBlock(true), createElementBlock(Fragment, null, renderList(tickLines.value, (tick) => {
3910
4014
  return openBlock(), createElementBlock("line", mergeProps({ ref_for: true }, tick), null, 16);
3911
4015
  }), 256)),
4016
+ _cache[2] || (_cache[2] = createTextVNode()),
3912
4017
  (openBlock(true), createElementBlock(Fragment, null, renderList(tickTexts.value, (tick) => {
3913
4018
  return openBlock(), createElementBlock("g", mergeProps({ ref_for: true }, tick.wrapper), [
3914
- createVNode(_sfc_main$T, mergeProps({ ref_for: true }, tick.text), null, 16)
4019
+ createVNode(_sfc_main$W, mergeProps({ ref_for: true }, tick.text), null, 16)
3915
4020
  ], 16);
3916
4021
  }), 256)),
4022
+ _cache[3] || (_cache[3] = createTextVNode()),
3917
4023
  createElementVNode("g", _hoisted_3$3, [
3918
4024
  createElementVNode("rect", mergeProps({
3919
4025
  width: 10,
3920
4026
  height: height.value,
3921
4027
  x: -5
3922
4028
  }, toHandlers(axisVOn, true), {
3923
- class: { "vvplot-cursor-grab": __props.action.some?.((a) => a.action == "move") }
4029
+ cursor: __props.action.some?.((a) => a.action == "move") ? "grab" : null
3924
4030
  }), null, 16, _hoisted_4$2)
3925
4031
  ]),
4032
+ _cache[4] || (_cache[4] = createTextVNode()),
3926
4033
  __props.action.some?.((a) => a.action == "rescale") ? (openBlock(), createElementBlock("g", _hoisted_5$1, [
3927
4034
  createElementVNode("rect", {
3928
4035
  width: 10,
@@ -3931,6 +4038,7 @@ const _sfc_main$R = {
3931
4038
  style: { "cursor": "ns-resize" },
3932
4039
  onPointerdown: axisRescaleTopPointerdown
3933
4040
  }, null, 32),
4041
+ _cache[0] || (_cache[0] = createTextVNode()),
3934
4042
  createElementVNode("rect", {
3935
4043
  width: 10,
3936
4044
  height: 20,
@@ -3940,12 +4048,13 @@ const _sfc_main$R = {
3940
4048
  onPointerdown: axisRescaleBottomPointerdown
3941
4049
  }, null, 40, _hoisted_6$1)
3942
4050
  ])) : createCommentVNode("", true),
3943
- axisTitle.value.text ? (openBlock(), createBlock(_sfc_main$T, normalizeProps(mergeProps({ key: 1 }, axisTitle.value)), null, 16)) : createCommentVNode("", true)
4051
+ _cache[5] || (_cache[5] = createTextVNode()),
4052
+ axisTitle.value.text ? (openBlock(), createBlock(_sfc_main$W, normalizeProps(mergeProps({ key: 1 }, axisTitle.value)), null, 16)) : createCommentVNode("", true)
3944
4053
  ], 12, _hoisted_1$5);
3945
4054
  };
3946
4055
  }
3947
4056
  };
3948
- const _sfc_main$Q = {
4057
+ const _sfc_main$T = {
3949
4058
  __name: "CoreAxis",
3950
4059
  props: {
3951
4060
  theme: { type: Object, default: () => ({}) },
@@ -3954,8 +4063,8 @@ const _sfc_main$Q = {
3954
4063
  },
3955
4064
  setup(__props) {
3956
4065
  const axis = {
3957
- h: _sfc_main$S,
3958
- v: _sfc_main$R
4066
+ h: _sfc_main$V,
4067
+ v: _sfc_main$U
3959
4068
  };
3960
4069
  return (_ctx, _cache) => {
3961
4070
  return __props.position != "none" ? (openBlock(), createBlock(resolveDynamicComponent(axis[__props.orientation]), {
@@ -3966,7 +4075,7 @@ const _sfc_main$Q = {
3966
4075
  };
3967
4076
  }
3968
4077
  };
3969
- const _sfc_main$P = {
4078
+ const _sfc_main$S = {
3970
4079
  __name: "CoreGridH",
3971
4080
  props: {
3972
4081
  majorBreaks: { type: Array, default: () => [] },
@@ -3985,8 +4094,8 @@ const _sfc_main$P = {
3985
4094
  const majorLines = computed(() => {
3986
4095
  let result = [];
3987
4096
  for (let line2 of __props.majorBreaks) {
3988
- if (line2?.position == null) line2 = { position: +line2 };
3989
4097
  let pos = __props.coord2pos({ v: line2.position }).v;
4098
+ if (isNaN(pos)) continue;
3990
4099
  let tsl = pos * (__props.activeTransform.scaleV - 1) + __props.activeTransform.translateV;
3991
4100
  let position = pos + __props.layout.t;
3992
4101
  if (position + tsl < 0 || position + tsl > height.value) continue;
@@ -4007,8 +4116,9 @@ const _sfc_main$P = {
4007
4116
  const minorLines = computed(() => {
4008
4117
  let result = [];
4009
4118
  for (let line2 of __props.minorBreaks) {
4010
- if (line2?.position == null) line2 = { position: +line2 };
4119
+ if (__props.majorBreaks.some((ml) => ml.position == line2.position)) continue;
4011
4120
  let pos = __props.coord2pos({ v: line2.position }).v;
4121
+ if (isNaN(pos)) continue;
4012
4122
  let tsl = pos * (__props.activeTransform.scaleV - 1) + __props.activeTransform.translateV;
4013
4123
  let position = pos + __props.layout.t;
4014
4124
  if (position + tsl < 0 || position + tsl > height.value) continue;
@@ -4024,16 +4134,12 @@ const _sfc_main$P = {
4024
4134
  style: { transition: __props.transition }
4025
4135
  });
4026
4136
  }
4027
- return result.filter((l) => l.stroke !== null && majorLines.value.every((ml) => ml.y1 !== l.y1));
4137
+ return result.filter((l) => l.stroke !== null);
4028
4138
  });
4139
+ const lines = computed(() => minorLines.value.concat(majorLines.value).sort((a, b) => a.y1 - b.y1));
4029
4140
  return (_ctx, _cache) => {
4030
4141
  return openBlock(), createElementBlock("g", null, [
4031
- (openBlock(true), createElementBlock(Fragment, null, renderList(minorLines.value, (line2) => {
4032
- return openBlock(), createElementBlock("line", mergeProps({ ref_for: true }, line2, {
4033
- style: { transition: __props.transition }
4034
- }), null, 16);
4035
- }), 256)),
4036
- (openBlock(true), createElementBlock(Fragment, null, renderList(majorLines.value, (line2) => {
4142
+ (openBlock(true), createElementBlock(Fragment, null, renderList(lines.value, (line2) => {
4037
4143
  return openBlock(), createElementBlock("line", mergeProps({ ref_for: true }, line2, {
4038
4144
  style: { transition: __props.transition }
4039
4145
  }), null, 16);
@@ -4042,7 +4148,7 @@ const _sfc_main$P = {
4042
4148
  };
4043
4149
  }
4044
4150
  };
4045
- const _sfc_main$O = {
4151
+ const _sfc_main$R = {
4046
4152
  __name: "CoreGridV",
4047
4153
  props: {
4048
4154
  majorBreaks: { type: Array, default: () => [] },
@@ -4061,8 +4167,8 @@ const _sfc_main$O = {
4061
4167
  const majorLines = computed(() => {
4062
4168
  let result = [];
4063
4169
  for (let line2 of __props.majorBreaks) {
4064
- if (line2?.position == null) line2 = { position: +line2 };
4065
4170
  let pos = __props.coord2pos({ h: line2.position }).h;
4171
+ if (isNaN(pos)) continue;
4066
4172
  let tsl = pos * (__props.activeTransform.scaleH - 1) + __props.activeTransform.translateH;
4067
4173
  let position = pos + __props.layout.l;
4068
4174
  if (position + tsl < 0 || position + tsl > width.value) continue;
@@ -4083,8 +4189,9 @@ const _sfc_main$O = {
4083
4189
  const minorLines = computed(() => {
4084
4190
  let result = [];
4085
4191
  for (let line2 of __props.minorBreaks) {
4086
- if (line2?.position == null) line2 = { position: +line2 };
4192
+ if (__props.majorBreaks.some((ml) => ml.position == line2.position)) continue;
4087
4193
  let pos = __props.coord2pos({ h: line2.position }).h;
4194
+ if (isNaN(pos)) continue;
4088
4195
  let tsl = pos * (__props.activeTransform.scaleH - 1) + __props.activeTransform.translateH;
4089
4196
  let position = pos + __props.layout.l;
4090
4197
  if (position + tsl < 0 || position + tsl > width.value) continue;
@@ -4100,21 +4207,21 @@ const _sfc_main$O = {
4100
4207
  style: { transition: __props.transition }
4101
4208
  });
4102
4209
  }
4103
- return result.filter((l) => l.stroke !== null && majorLines.value.every((ml) => ml.x1 !== l.x1));
4210
+ return result.filter((l) => l.stroke !== null);
4104
4211
  });
4212
+ const lines = computed(() => minorLines.value.concat(majorLines.value).sort((a, b) => a.x1 - b.x1));
4105
4213
  return (_ctx, _cache) => {
4106
4214
  return openBlock(), createElementBlock("g", null, [
4107
- (openBlock(true), createElementBlock(Fragment, null, renderList(minorLines.value, (line2) => {
4108
- return openBlock(), createElementBlock("line", mergeProps({ ref_for: true }, line2), null, 16);
4109
- }), 256)),
4110
- (openBlock(true), createElementBlock(Fragment, null, renderList(majorLines.value, (line2) => {
4111
- return openBlock(), createElementBlock("line", mergeProps({ ref_for: true }, line2), null, 16);
4215
+ (openBlock(true), createElementBlock(Fragment, null, renderList(lines.value, (line2) => {
4216
+ return openBlock(), createElementBlock("line", mergeProps({ ref_for: true }, line2, {
4217
+ style: { transition: __props.transition }
4218
+ }), null, 16);
4112
4219
  }), 256))
4113
4220
  ]);
4114
4221
  };
4115
4222
  }
4116
4223
  };
4117
- const _sfc_main$N = {
4224
+ const _sfc_main$Q = {
4118
4225
  __name: "CoreCanvasCurve",
4119
4226
  props: {
4120
4227
  extendX: { type: Number, default: 0 },
@@ -4123,8 +4230,9 @@ const _sfc_main$N = {
4123
4230
  coord2pos: Function,
4124
4231
  layout: Object
4125
4232
  },
4126
- emits: ["click", "contextmenu", "pointerenter", "pointerleave", "pointermove", "pointerdown", "pointerup"],
4233
+ emits: ["click", "contextmenu", "singleclick", "dblclick", "pointermove", "pointerdown", "pointerup", "wheel"],
4127
4234
  setup(__props, { expose: __expose, emit: __emit }) {
4235
+ let events = ["click", "contextmenu", "singleclick", "dblclick", "pointermove", "pointerdown", "pointerup", "wheel"];
4128
4236
  const emit = __emit;
4129
4237
  const vBind = computed(() => ({
4130
4238
  width: __props.layout.fullWidth * (1 + __props.extendX * 2),
@@ -4179,17 +4287,21 @@ const _sfc_main$N = {
4179
4287
  }
4180
4288
  }
4181
4289
  }
4182
- canvas2.onclick = function(e) {
4183
- const rect = canvas2.getBoundingClientRect();
4184
- const x2 = e.clientX - rect.left;
4185
- const y2 = e.clientY - rect.top;
4186
- for (const [path, data] of path_data) {
4187
- if (ctx.isPointInPath(path, x2, y2)) {
4188
- emit("click", e, data);
4189
- break;
4290
+ for (let evt of events) {
4291
+ canvas2.addEventListener(evt, function(e) {
4292
+ if (e._vhandled) return;
4293
+ const rect = canvas2.getBoundingClientRect();
4294
+ const x2 = e.clientX - rect.left;
4295
+ const y2 = e.clientY - rect.top;
4296
+ for (const [path, data] of path_data) {
4297
+ if (ctx.isPointInPath(path, x2, y2)) {
4298
+ emit(evt, e, data);
4299
+ e._vhandled = true;
4300
+ break;
4301
+ }
4190
4302
  }
4191
- }
4192
- };
4303
+ });
4304
+ }
4193
4305
  return canvas2;
4194
4306
  });
4195
4307
  watch(layerCanvas, (node) => containerRef.value.replaceChildren(node));
@@ -4219,7 +4331,158 @@ const _sfc_main$N = {
4219
4331
  };
4220
4332
  }
4221
4333
  };
4222
- const _sfc_main$M = {
4334
+ const _sfc_main$P = {
4335
+ __name: "CoreCanvasBoxplot",
4336
+ props: {
4337
+ extendX: { type: Number, default: 0 },
4338
+ extendY: { type: Number, default: 0 },
4339
+ data: Object,
4340
+ coord2pos: Function,
4341
+ layout: Object
4342
+ },
4343
+ emits: ["click", "contextmenu", "singleclick", "dblclick", "pointermove", "pointerdown", "pointerup", "wheel"],
4344
+ setup(__props, { expose: __expose, emit: __emit }) {
4345
+ let events = ["click", "contextmenu", "singleclick", "dblclick", "pointermove", "pointerdown", "pointerup", "wheel"];
4346
+ const emit = __emit;
4347
+ const vBind = computed(() => ({
4348
+ width: __props.layout.fullWidth * (1 + __props.extendX * 2),
4349
+ height: __props.layout.fullHeight * (1 + __props.extendY * 2),
4350
+ x: -__props.layout.l - __props.layout.fullWidth * __props.extendX,
4351
+ y: -__props.layout.t - __props.layout.fullHeight * __props.extendY
4352
+ }));
4353
+ const containerRef = useTemplateRef("container");
4354
+ const layerCanvas = computed(() => {
4355
+ if (containerRef.value == null) return;
4356
+ const canvas2 = document.createElement("canvas");
4357
+ canvas2.width = __props.layout.fullWidth * (1 + __props.extendX * 2);
4358
+ canvas2.height = __props.layout.fullHeight * (1 + __props.extendY * 2);
4359
+ const ctx = canvas2.getContext("2d");
4360
+ ctx.clearRect(0, 0, canvas2.width, canvas2.height);
4361
+ ctx.translate(__props.layout.l + __props.layout.fullWidth * __props.extendX, __props.layout.t + __props.layout.fullHeight * __props.extendY);
4362
+ let path_data = /* @__PURE__ */ new Map();
4363
+ for (const group of __props.data) {
4364
+ for (let {
4365
+ x: x2,
4366
+ xmin,
4367
+ xmax,
4368
+ y: y2,
4369
+ ymin,
4370
+ ymax,
4371
+ lwisker,
4372
+ Q1,
4373
+ median,
4374
+ Q3,
4375
+ uwisker,
4376
+ outliers,
4377
+ $xmin,
4378
+ $xmax,
4379
+ $ymin,
4380
+ $ymax,
4381
+ fill = "white",
4382
+ color = "black",
4383
+ linewidth = 1,
4384
+ linetype,
4385
+ alpha,
4386
+ "translate-x": translateX = 0,
4387
+ "translate-y": translateY = 0,
4388
+ $raw
4389
+ } of group) {
4390
+ if (color === "transparent") continue;
4391
+ const { hmin: rx1, hmax: rx2, vmin: ry1, vmax: ry2 } = __props.coord2pos(x2 == null ? { ymin, ymax, xmin: Q1, xmax: Q3 } : { xmin, xmax, ymin: Q1, ymax: Q3 });
4392
+ const { h: lx1, v: ly1 } = __props.coord2pos(x2 == null ? { y: y2, x: lwisker } : { x: x2, y: lwisker });
4393
+ const { h: lx2, v: ly2 } = __props.coord2pos(x2 == null ? { y: y2, x: uwisker } : { x: x2, y: uwisker });
4394
+ const { h: mx1, v: my1 } = __props.coord2pos(x2 == null ? { y: ymin, x: median } : { x: xmin, y: median });
4395
+ const { h: mx2, v: my2 } = __props.coord2pos(x2 == null ? { y: ymax, x: median } : { x: xmax, y: median });
4396
+ const { h: uwx1, v: uwy1 } = __props.coord2pos(x2 == null ? { y: ymin * 0.25 + ymax * 0.75, x: uwisker } : { x: xmin * 0.25 + xmax * 0.75, y: uwisker });
4397
+ const { h: uwx2, v: uwy2 } = __props.coord2pos(x2 == null ? { y: ymin * 0.75 + ymax * 0.25, x: uwisker } : { x: xmin * 0.75 + xmax * 0.25, y: uwisker });
4398
+ const { h: lwx1, v: lwy1 } = __props.coord2pos(x2 == null ? { y: ymin * 0.25 + ymax * 0.75, x: lwisker } : { x: xmin * 0.25 + xmax * 0.75, y: lwisker });
4399
+ const { h: lwx2, v: lwy2 } = __props.coord2pos(x2 == null ? { y: ymin * 0.75 + ymax * 0.25, x: lwisker } : { x: xmin * 0.75 + xmax * 0.25, y: lwisker });
4400
+ ctx.globalAlpha = alpha;
4401
+ ctx.setLineDash(parseLineType(linetype));
4402
+ const linepath2d = new Path2D();
4403
+ linepath2d.moveTo(lx1 + translateX, ly1 + translateY);
4404
+ linepath2d.lineTo(lx2 + translateX, ly2 + translateY);
4405
+ const wiskerpath2d = new Path2D();
4406
+ wiskerpath2d.moveTo(uwx1 + translateX, uwy1 + translateY);
4407
+ wiskerpath2d.lineTo(uwx2 + translateX, uwy2 + translateY);
4408
+ wiskerpath2d.moveTo(lwx1 + translateX, lwy1 + translateY);
4409
+ wiskerpath2d.lineTo(lwx2 + translateX, lwy2 + translateY);
4410
+ ctx.lineWidth = linewidth;
4411
+ if (color !== "none") {
4412
+ ctx.strokeStyle = color;
4413
+ ctx.stroke(linepath2d);
4414
+ ctx.stroke(wiskerpath2d);
4415
+ }
4416
+ const rectpath2d = new Path2D();
4417
+ rectpath2d.rect(rx1 + translateX, ry1 + translateY, rx2 - rx1, ry2 - ry1);
4418
+ if (fill !== "none") {
4419
+ ctx.fillStyle = fill;
4420
+ ctx.fill(rectpath2d);
4421
+ }
4422
+ if (color != null) {
4423
+ ctx.strokeStyle = color;
4424
+ ctx.stroke(rectpath2d);
4425
+ }
4426
+ path_data.set(rectpath2d, $raw);
4427
+ const medianpath2d = new Path2D();
4428
+ medianpath2d.moveTo(mx1 + translateX, my1 + translateY);
4429
+ medianpath2d.lineTo(mx2 + translateX, my2 + translateY);
4430
+ ctx.lineWidth = linewidth * 2;
4431
+ if (color !== "none") {
4432
+ ctx.strokeStyle = color;
4433
+ ctx.stroke(medianpath2d);
4434
+ }
4435
+ for (let { x: x3, y: y3, $raw: $raw2 } of outliers) {
4436
+ const { h: ox, v: oy } = __props.coord2pos({ x: x3, y: y3 });
4437
+ const outlierpath2d = new Path2D();
4438
+ outlierpath2d.arc(ox + translateX, oy + translateY, 2, 0, Math.PI * 2);
4439
+ if (fill !== "none") {
4440
+ ctx.fillStyle = color;
4441
+ ctx.fill(outlierpath2d);
4442
+ }
4443
+ path_data.set(outlierpath2d, $raw2);
4444
+ }
4445
+ }
4446
+ }
4447
+ for (let evt of events) {
4448
+ canvas2.addEventListener(evt, function(e) {
4449
+ if (e._vhandled) return;
4450
+ const rect = canvas2.getBoundingClientRect();
4451
+ const x2 = e.clientX - rect.left;
4452
+ const y2 = e.clientY - rect.top;
4453
+ for (const [path, data] of path_data) {
4454
+ if (ctx.isPointInPath(path, x2, y2)) {
4455
+ emit(evt, e, data);
4456
+ e._vhandled = true;
4457
+ break;
4458
+ }
4459
+ }
4460
+ });
4461
+ }
4462
+ return canvas2;
4463
+ });
4464
+ watch(layerCanvas, (node) => containerRef.value.replaceChildren(node));
4465
+ __expose({
4466
+ dispatchEvent: (event) => layerCanvas.value?.dispatchEvent?.(event)
4467
+ });
4468
+ function parseLineType(linetype) {
4469
+ if (linetype == null) return [];
4470
+ if (Array.isArray(linetype)) return linetype;
4471
+ if (linetype === "solid") return [];
4472
+ if (linetype === "dashed") return [4, 4];
4473
+ if (linetype === "dotted") return [1, 3];
4474
+ if (linetype === "dotdash") return [1, 3, 4, 3];
4475
+ if (linetype === "longdash") return [8, 4];
4476
+ if (linetype === "twodash") return [2, 2, 6, 2];
4477
+ if (linetype.includes(" ")) return linetype;
4478
+ return linetype.split("").map((v) => +("0x" + v));
4479
+ }
4480
+ return (_ctx, _cache) => {
4481
+ return openBlock(), createElementBlock("foreignObject", mergeProps(vBind.value, { ref: "container" }), null, 16);
4482
+ };
4483
+ }
4484
+ };
4485
+ const _sfc_main$O = {
4223
4486
  __name: "CoreCanvasLine",
4224
4487
  props: {
4225
4488
  extendX: { type: Number, default: 0 },
@@ -4228,8 +4491,9 @@ const _sfc_main$M = {
4228
4491
  coord2pos: Function,
4229
4492
  layout: Object
4230
4493
  },
4231
- emits: ["click", "contextmenu", "pointerenter", "pointerleave", "pointermove", "pointerdown", "pointerup"],
4494
+ emits: ["click", "contextmenu", "singleclick", "dblclick", "pointermove", "pointerdown", "pointerup", "wheel"],
4232
4495
  setup(__props, { expose: __expose, emit: __emit }) {
4496
+ let events = ["click", "contextmenu", "singleclick", "dblclick", "pointermove", "pointerdown", "pointerup", "wheel"];
4233
4497
  const emit = __emit;
4234
4498
  const vBind = computed(() => ({
4235
4499
  width: __props.layout.fullWidth * (1 + __props.extendX * 2),
@@ -4277,17 +4541,21 @@ const _sfc_main$M = {
4277
4541
  }
4278
4542
  }
4279
4543
  }
4280
- canvas2.onclick = function(e) {
4281
- const rect = canvas2.getBoundingClientRect();
4282
- const x2 = e.clientX - rect.left;
4283
- const y2 = e.clientY - rect.top;
4284
- for (const [path, data] of path_data) {
4285
- if (ctx.isPointInPath(path, x2, y2)) {
4286
- emit("click", e, data);
4287
- break;
4544
+ for (let evt of events) {
4545
+ canvas2.addEventListener(evt, function(e) {
4546
+ if (e._vhandled) return;
4547
+ const rect = canvas2.getBoundingClientRect();
4548
+ const x2 = e.clientX - rect.left;
4549
+ const y2 = e.clientY - rect.top;
4550
+ for (const [path, data] of path_data) {
4551
+ if (ctx.isPointInPath(path, x2, y2)) {
4552
+ emit(evt, e, data);
4553
+ e._vhandled = true;
4554
+ break;
4555
+ }
4288
4556
  }
4289
- }
4290
- };
4557
+ });
4558
+ }
4291
4559
  return canvas2;
4292
4560
  });
4293
4561
  watch(layerCanvas, (node) => containerRef.value.replaceChildren(node));
@@ -4311,7 +4579,7 @@ const _sfc_main$M = {
4311
4579
  };
4312
4580
  }
4313
4581
  };
4314
- const _sfc_main$L = {
4582
+ const _sfc_main$N = {
4315
4583
  __name: "CoreCanvasPoint",
4316
4584
  props: {
4317
4585
  extendX: { type: Number, default: 0 },
@@ -4320,8 +4588,9 @@ const _sfc_main$L = {
4320
4588
  coord2pos: Function,
4321
4589
  layout: Object
4322
4590
  },
4323
- emits: ["click", "contextmenu", "pointerenter", "pointerleave", "pointermove", "pointerdown", "pointerup"],
4591
+ emits: ["click", "contextmenu", "singleclick", "dblclick", "pointermove", "pointerdown", "pointerup", "wheel"],
4324
4592
  setup(__props, { expose: __expose, emit: __emit }) {
4593
+ let events = ["click", "contextmenu", "singleclick", "dblclick", "pointermove", "pointerdown", "pointerup", "wheel"];
4325
4594
  const emit = __emit;
4326
4595
  const paths = {
4327
4596
  triangle: (s) => `M0-${s * 2 / 3}L${s * 0.577},${s / 3}L-${s * 0.577},${s / 3}Z`,
@@ -4389,17 +4658,21 @@ const _sfc_main$L = {
4389
4658
  }
4390
4659
  }
4391
4660
  }
4392
- canvas2.onclick = function(e) {
4393
- const rect = canvas2.getBoundingClientRect();
4394
- const x2 = e.clientX - rect.left;
4395
- const y2 = e.clientY - rect.top;
4396
- for (const [path, data] of path_data) {
4397
- if (ctx.isPointInPath(path, x2, y2)) {
4398
- emit("click", e, data);
4399
- break;
4661
+ for (let evt of events) {
4662
+ canvas2.addEventListener(evt, function(e) {
4663
+ if (e._vhandled) return;
4664
+ const rect = canvas2.getBoundingClientRect();
4665
+ const x2 = e.clientX - rect.left;
4666
+ const y2 = e.clientY - rect.top;
4667
+ for (const [path, data] of path_data) {
4668
+ if (ctx.isPointInPath(path, x2, y2)) {
4669
+ emit(evt, e, data);
4670
+ e._vhandled = true;
4671
+ break;
4672
+ }
4400
4673
  }
4401
- }
4402
- };
4674
+ });
4675
+ }
4403
4676
  return canvas2;
4404
4677
  });
4405
4678
  watch(layerCanvas, (node) => containerRef.value.replaceChildren(node));
@@ -4411,7 +4684,7 @@ const _sfc_main$L = {
4411
4684
  };
4412
4685
  }
4413
4686
  };
4414
- const _sfc_main$K = {
4687
+ const _sfc_main$M = {
4415
4688
  __name: "CoreCanvasPolygon",
4416
4689
  props: {
4417
4690
  extendX: { type: Number, default: 0 },
@@ -4420,8 +4693,9 @@ const _sfc_main$K = {
4420
4693
  coord2pos: Function,
4421
4694
  layout: Object
4422
4695
  },
4423
- emits: ["click", "contextmenu", "pointerenter", "pointerleave", "pointermove", "pointerdown", "pointerup"],
4696
+ emits: ["click", "contextmenu", "singleclick", "dblclick", "pointermove", "pointerdown", "pointerup", "wheel"],
4424
4697
  setup(__props, { expose: __expose, emit: __emit }) {
4698
+ let events = ["click", "contextmenu", "singleclick", "dblclick", "pointermove", "pointerdown", "pointerup", "wheel"];
4425
4699
  const emit = __emit;
4426
4700
  const vBind = computed(() => ({
4427
4701
  width: __props.layout.fullWidth * (1 + __props.extendX * 2),
@@ -4473,17 +4747,21 @@ const _sfc_main$K = {
4473
4747
  }
4474
4748
  }
4475
4749
  }
4476
- canvas2.onclick = function(e) {
4477
- const rect = canvas2.getBoundingClientRect();
4478
- const x2 = e.clientX - rect.left;
4479
- const y2 = e.clientY - rect.top;
4480
- for (const [path, data] of path_data) {
4481
- if (ctx.isPointInPath(path, x2, y2)) {
4482
- emit("click", e, data);
4483
- break;
4750
+ for (let evt of events) {
4751
+ canvas2.addEventListener(evt, function(e) {
4752
+ if (e._vhandled) return;
4753
+ const rect = canvas2.getBoundingClientRect();
4754
+ const x2 = e.clientX - rect.left;
4755
+ const y2 = e.clientY - rect.top;
4756
+ for (const [path, data] of path_data) {
4757
+ if (ctx.isPointInPath(path, x2, y2)) {
4758
+ emit(evt, e, data);
4759
+ e._vhandled = true;
4760
+ break;
4761
+ }
4484
4762
  }
4485
- }
4486
- };
4763
+ });
4764
+ }
4487
4765
  return canvas2;
4488
4766
  });
4489
4767
  watch(layerCanvas, (node) => containerRef.value.replaceChildren(node));
@@ -4507,7 +4785,7 @@ const _sfc_main$K = {
4507
4785
  };
4508
4786
  }
4509
4787
  };
4510
- const _sfc_main$J = {
4788
+ const _sfc_main$L = {
4511
4789
  __name: "CoreCanvasRect",
4512
4790
  props: {
4513
4791
  extendX: { type: Number, default: 0 },
@@ -4516,8 +4794,9 @@ const _sfc_main$J = {
4516
4794
  coord2pos: Function,
4517
4795
  layout: Object
4518
4796
  },
4519
- emits: ["click", "contextmenu", "pointerenter", "pointerleave", "pointermove", "pointerdown", "pointerup"],
4797
+ emits: ["click", "contextmenu", "singleclick", "dblclick", "pointermove", "pointerdown", "pointerup", "wheel"],
4520
4798
  setup(__props, { expose: __expose, emit: __emit }) {
4799
+ let events = ["click", "contextmenu", "singleclick", "dblclick", "pointermove", "pointerdown", "pointerup", "wheel"];
4521
4800
  const emit = __emit;
4522
4801
  const vBind = computed(() => ({
4523
4802
  width: __props.layout.fullWidth * (1 + __props.extendX * 2),
@@ -4567,17 +4846,21 @@ const _sfc_main$J = {
4567
4846
  }
4568
4847
  }
4569
4848
  }
4570
- canvas2.onclick = function(e) {
4571
- const rect = canvas2.getBoundingClientRect();
4572
- const x2 = e.clientX - rect.left;
4573
- const y2 = e.clientY - rect.top;
4574
- for (const [path, data] of path_data) {
4575
- if (ctx.isPointInPath(path, x2, y2)) {
4576
- emit("click", e, data);
4577
- break;
4849
+ for (let evt of events) {
4850
+ canvas2.addEventListener(evt, function(e) {
4851
+ if (e._vhandled) return;
4852
+ const rect = canvas2.getBoundingClientRect();
4853
+ const x2 = e.clientX - rect.left;
4854
+ const y2 = e.clientY - rect.top;
4855
+ for (const [path, data] of path_data) {
4856
+ if (ctx.isPointInPath(path, x2, y2)) {
4857
+ emit(evt, e, data);
4858
+ e._vhandled = true;
4859
+ break;
4860
+ }
4578
4861
  }
4579
- }
4580
- };
4862
+ });
4863
+ }
4581
4864
  return canvas2;
4582
4865
  });
4583
4866
  watch(layerCanvas, (node) => containerRef.value.replaceChildren(node));
@@ -4601,7 +4884,7 @@ const _sfc_main$J = {
4601
4884
  };
4602
4885
  }
4603
4886
  };
4604
- const _sfc_main$I = {
4887
+ const _sfc_main$K = {
4605
4888
  __name: "CoreCanvasText",
4606
4889
  props: {
4607
4890
  extendX: { type: Number, default: 0 },
@@ -4610,8 +4893,9 @@ const _sfc_main$I = {
4610
4893
  coord2pos: Function,
4611
4894
  layout: Object
4612
4895
  },
4613
- emits: ["click", "contextmenu", "pointerenter", "pointerleave", "pointermove", "pointerdown", "pointerup"],
4896
+ emits: ["click", "contextmenu", "singleclick", "dblclick", "pointermove", "pointerdown", "pointerup", "wheel"],
4614
4897
  setup(__props, { expose: __expose, emit: __emit }) {
4898
+ let events = ["click", "contextmenu", "singleclick", "dblclick", "pointermove", "pointerdown", "pointerup", "wheel"];
4615
4899
  const emit = __emit;
4616
4900
  const vBind = computed(() => ({
4617
4901
  width: __props.layout.fullWidth * (1 + __props.extendX * 2),
@@ -4668,20 +4952,20 @@ const _sfc_main$I = {
4668
4952
  } else if (textLength != null) {
4669
4953
  width = textLength;
4670
4954
  }
4671
- if (anchorX != null || anchorY != null) {
4672
- let alnX = { left: 0, center: 0.5, right: 1 }[anchorX] ?? +(anchorX ?? 0.5), alnY = { bottom: 0, center: 0.5, top: 1 }[anchorY] ?? +(anchorY ?? 0.5);
4673
- if (isNaN(alnX)) alnX = 0.5;
4674
- if (isNaN(alnY)) alnY = 0.5;
4675
- let w2 = width, h = height;
4676
- ctx.rotate(angle * Math.PI / 180);
4677
- ctx.translate(w2 * (0.5 - alnX), h * (alnY - 0.5));
4678
- } else if (dockX != null || dockY != null) {
4955
+ if (dockX != null || dockY != null) {
4679
4956
  let alnX = { left: 0, center: 0.5, right: 1 }[dockX] ?? +(dockX ?? 0.5), alnY = { bottom: 0, center: 0.5, top: 1 }[dockY] ?? +(dockY ?? 0.5);
4680
4957
  if (isNaN(alnX)) alnX = 0.5;
4681
4958
  if (isNaN(alnY)) alnY = 0.5;
4682
4959
  let w2 = width * Math.abs(Math.cos(angle * Math.PI / 180)) + height * Math.abs(Math.sin(angle * Math.PI / 180)), h = width * Math.abs(Math.sin(angle * Math.PI / 180)) + height * Math.abs(Math.cos(angle * Math.PI / 180));
4683
4960
  ctx.translate(w2 * (0.5 - alnX), h * (alnY - 0.5));
4684
4961
  ctx.rotate(angle * Math.PI / 180);
4962
+ } else {
4963
+ let alnX = { left: 0, center: 0.5, right: 1 }[anchorX] ?? +(anchorX ?? 0.5), alnY = { bottom: 0, center: 0.5, top: 1 }[anchorY] ?? +(anchorY ?? 0.5);
4964
+ if (isNaN(alnX)) alnX = 0.5;
4965
+ if (isNaN(alnY)) alnY = 0.5;
4966
+ let w2 = width, h = height;
4967
+ ctx.rotate(angle * Math.PI / 180);
4968
+ ctx.translate(w2 * (0.5 - alnX), h * (alnY - 0.5));
4685
4969
  }
4686
4970
  if (width != w) ctx.scale(width / w, 1);
4687
4971
  if (color !== "none") {
@@ -4695,17 +4979,21 @@ const _sfc_main$I = {
4695
4979
  ctx.restore();
4696
4980
  }
4697
4981
  }
4698
- canvas2.onclick = function(e) {
4699
- const rect = canvas2.getBoundingClientRect();
4700
- const x2 = e.clientX - rect.left;
4701
- const y2 = e.clientY - rect.top;
4702
- for (const [path, data] of path_data) {
4703
- if (ctx.isPointInPath(path, x2, y2)) {
4704
- emit("click", e, data);
4705
- break;
4982
+ for (let evt of events) {
4983
+ canvas2.addEventListener(evt, function(e) {
4984
+ if (e._vhandled) return;
4985
+ const rect = canvas2.getBoundingClientRect();
4986
+ const x2 = e.clientX - rect.left;
4987
+ const y2 = e.clientY - rect.top;
4988
+ for (const [path, data] of path_data) {
4989
+ if (ctx.isPointInPath(path, x2, y2)) {
4990
+ emit(evt, e, data);
4991
+ e._vhandled = true;
4992
+ break;
4993
+ }
4706
4994
  }
4707
- }
4708
- };
4995
+ });
4996
+ }
4709
4997
  return canvas2;
4710
4998
  });
4711
4999
  watch(layerCanvas, (node) => containerRef.value.replaceChildren(node));
@@ -4729,7 +5017,7 @@ const _sfc_main$I = {
4729
5017
  };
4730
5018
  }
4731
5019
  };
4732
- const _sfc_main$H = {
5020
+ const _sfc_main$J = {
4733
5021
  __name: "CoreCanvasTextsegment",
4734
5022
  props: {
4735
5023
  extendX: { type: Number, default: 0 },
@@ -4738,8 +5026,9 @@ const _sfc_main$H = {
4738
5026
  coord2pos: Function,
4739
5027
  layout: Object
4740
5028
  },
4741
- emits: ["click", "contextmenu", "pointerenter", "pointerleave", "pointermove", "pointerdown", "pointerup"],
5029
+ emits: ["click", "contextmenu", "singleclick", "dblclick", "pointermove", "pointerdown", "pointerup", "wheel"],
4742
5030
  setup(__props, { expose: __expose, emit: __emit }) {
5031
+ let events = ["click", "contextmenu", "singleclick", "dblclick", "pointermove", "pointerdown", "pointerup", "wheel"];
4743
5032
  const emit = __emit;
4744
5033
  const vBind = computed(() => ({
4745
5034
  width: __props.layout.fullWidth * (1 + __props.extendX * 2),
@@ -4815,17 +5104,21 @@ const _sfc_main$H = {
4815
5104
  ctx.restore();
4816
5105
  }
4817
5106
  }
4818
- canvas2.onclick = function(e) {
4819
- const rect = canvas2.getBoundingClientRect();
4820
- const x2 = e.clientX - rect.left;
4821
- const y2 = e.clientY - rect.top;
4822
- for (const [path, data] of path_data) {
4823
- if (ctx.isPointInPath(path, x2, y2)) {
4824
- emit("click", e, data);
4825
- break;
5107
+ for (let evt of events) {
5108
+ canvas2.addEventListener(evt, function(e) {
5109
+ if (e._vhandled) return;
5110
+ const rect = canvas2.getBoundingClientRect();
5111
+ const x2 = e.clientX - rect.left;
5112
+ const y2 = e.clientY - rect.top;
5113
+ for (const [path, data] of path_data) {
5114
+ if (ctx.isPointInPath(path, x2, y2)) {
5115
+ emit(evt, e, data);
5116
+ e._vhandled = true;
5117
+ break;
5118
+ }
4826
5119
  }
4827
- }
4828
- };
5120
+ });
5121
+ }
4829
5122
  return canvas2;
4830
5123
  });
4831
5124
  watch(layerCanvas, (node) => containerRef.value.replaceChildren(node));
@@ -4853,17 +5146,18 @@ const _sfc_main$H = {
4853
5146
  };
4854
5147
  const canvas = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4855
5148
  __proto__: null,
4856
- curve: _sfc_main$N,
4857
- line: _sfc_main$M,
4858
- point: _sfc_main$L,
4859
- polygon: _sfc_main$K,
4860
- rect: _sfc_main$J,
4861
- stick: _sfc_main$M,
4862
- text: _sfc_main$I,
4863
- textsegment: _sfc_main$H,
4864
- tile: _sfc_main$J
5149
+ boxplot: _sfc_main$P,
5150
+ curve: _sfc_main$Q,
5151
+ line: _sfc_main$O,
5152
+ point: _sfc_main$N,
5153
+ polygon: _sfc_main$M,
5154
+ rect: _sfc_main$L,
5155
+ stick: _sfc_main$O,
5156
+ text: _sfc_main$K,
5157
+ textsegment: _sfc_main$J,
5158
+ tile: _sfc_main$L
4865
5159
  }, Symbol.toStringTag, { value: "Module" }));
4866
- const _sfc_main$G = {
5160
+ const _sfc_main$I = {
4867
5161
  __name: "CoreSvgBlank",
4868
5162
  props: {
4869
5163
  extendX: { type: Number, default: 0 },
@@ -4879,12 +5173,121 @@ const _sfc_main$G = {
4879
5173
  };
4880
5174
  }
4881
5175
  };
5176
+ const _sfc_main$H = {
5177
+ __name: "CoreTile",
5178
+ props: {
5179
+ x: { type: Number, default: 0 },
5180
+ y: { type: Number, default: 0 },
5181
+ width: { type: Number, default: 0 },
5182
+ height: { type: Number, default: 0 },
5183
+ fill: String,
5184
+ color: String,
5185
+ linewidth: Number,
5186
+ linetype: String,
5187
+ alpha: { type: Number, default: 1 },
5188
+ translateX: { type: Number, default: 0 },
5189
+ translateY: { type: Number, default: 0 }
5190
+ },
5191
+ setup(__props) {
5192
+ const binds = computed(() => {
5193
+ return {
5194
+ x: __props.x - __props.width / 2,
5195
+ y: __props.y - __props.height / 2,
5196
+ width: __props.width,
5197
+ height: __props.height,
5198
+ fill: __props.fill || null,
5199
+ "fill-opacity": __props.alpha == 1 ? null : __props.alpha,
5200
+ stroke: __props.color || null,
5201
+ "stroke-width": __props.linewidth,
5202
+ "stroke-opacity": __props.alpha == 1 ? null : __props.alpha,
5203
+ "stroke-dasharray": parseLineType(__props.linetype),
5204
+ transform: __props.translateX || __props.translateY ? `translate(${__props.translateX}, ${__props.translateY})` : null
5205
+ };
5206
+ });
5207
+ function parseLineType(linetype) {
5208
+ if (linetype == null) return null;
5209
+ if (Array.isArray(linetype)) return linetype.join(" ");
5210
+ if (linetype === "solid") return null;
5211
+ if (linetype === "dashed") return "4 4";
5212
+ if (linetype === "dotted") return "1 3";
5213
+ if (linetype === "dotdash") return "1 3 4 3";
5214
+ if (linetype === "longdash") return "8 4";
5215
+ if (linetype === "twodash") return "2 2 6 2";
5216
+ if (linetype.includes(" ")) return linetype;
5217
+ return linetype.split("").map((v) => +("0x" + v)).join(" ");
5218
+ }
5219
+ return (_ctx, _cache) => {
5220
+ return openBlock(), createElementBlock("rect", normalizeProps(guardReactiveProps(binds.value)), null, 16);
5221
+ };
5222
+ }
5223
+ };
5224
+ const _sfc_main$G = {
5225
+ __name: "CorePoint",
5226
+ props: {
5227
+ x: { type: Number, default: 0 },
5228
+ y: { type: Number, default: 0 },
5229
+ shape: String,
5230
+ size: { type: Number, default: 6 },
5231
+ color: String,
5232
+ stroke: String,
5233
+ linewidth: Number,
5234
+ linetype: String,
5235
+ alpha: { type: Number, default: 1 },
5236
+ angle: { type: Number, default: 0 },
5237
+ translateX: { type: Number, default: 0 },
5238
+ translateY: { type: Number, default: 0 }
5239
+ },
5240
+ setup(__props) {
5241
+ const paths = {
5242
+ square: "M-0.5-0.5H0.5V0.5H-0.5Z",
5243
+ triangle: "M0-0.667L0.577,0.333L-0.577,0.333Z",
5244
+ diamond: "M0-0.707L0.707,0L0,0.707L-0.707,0Z",
5245
+ plus: "M-0.1-0.5V-0.1H-0.5V0.1H-0.1V0.5H0.1V0.1H0.5V-0.1H0.1V-0.5H-0.1Z",
5246
+ cross: "M-0.283-0.424L-0.424-0.283L-0.141,0L-0.424,0.283L-0.283,0.424L0,0.141L0.283,0.424L0.424,0.283L0.141,0L0.424,-0.283L0.283,-0.424L0,-0.141Z"
5247
+ };
5248
+ const binds = computed(() => {
5249
+ let d = __props.shape?.startsWith?.("path:") ? __props.shape?.slice?.(5) : paths[__props.shape];
5250
+ let result = {
5251
+ fill: __props.color || null,
5252
+ "fill-opacity": __props.alpha == 1 ? null : __props.alpha,
5253
+ stroke: __props.stroke || null,
5254
+ "stroke-width": __props.linewidth,
5255
+ "stroke-opacity": __props.alpha == 1 ? null : __props.alpha,
5256
+ "stroke-dasharray": parseLineType(__props.linetype)
5257
+ };
5258
+ if (d != null) {
5259
+ let transform = `translate(${__props.x + __props.translateX},${__props.y + __props.translateY}) scale(${__props.size}) rotate(${__props.angle})`;
5260
+ Object.assign(result, { d, transform });
5261
+ } else {
5262
+ let transform = __props.translateX || __props.translateY ? `translate(${__props.translateX}, ${__props.translateY})` : null;
5263
+ Object.assign(result, { cx: __props.x, cy: __props.y, r: __props.size / 2, transform });
5264
+ }
5265
+ return result;
5266
+ });
5267
+ function parseLineType(linetype) {
5268
+ if (linetype == null) return null;
5269
+ if (Array.isArray(linetype)) return linetype.join(" ");
5270
+ if (linetype === "solid") return null;
5271
+ if (linetype === "dashed") return "4 4";
5272
+ if (linetype === "dotted") return "1 3";
5273
+ if (linetype === "dotdash") return "1 3 4 3";
5274
+ if (linetype === "longdash") return "8 4";
5275
+ if (linetype === "twodash") return "2 2 6 2";
5276
+ if (linetype.includes(" ")) return linetype;
5277
+ return linetype.split("").map((v) => +("0x" + v)).join(" ");
5278
+ }
5279
+ return (_ctx, _cache) => {
5280
+ return binds.value.d ? (openBlock(), createElementBlock("path", normalizeProps(mergeProps({ key: 0 }, binds.value)), null, 16)) : (openBlock(), createElementBlock("circle", normalizeProps(mergeProps({ key: 1 }, binds.value)), null, 16));
5281
+ };
5282
+ }
5283
+ };
4882
5284
  const _sfc_main$F = {
4883
- __name: "CoreCurve",
5285
+ __name: "CoreLine",
4884
5286
  props: {
4885
- points: { type: Array, default: () => [] },
4886
- interpolate: { default: "natural" },
4887
- fill: { type: String, default: "none" },
5287
+ x1: { type: Number, default: 0 },
5288
+ y1: { type: Number, default: 0 },
5289
+ x2: { type: Number, default: 0 },
5290
+ y2: { type: Number, default: 0 },
4888
5291
  color: String,
4889
5292
  stroke: String,
4890
5293
  linewidth: Number,
@@ -4895,23 +5298,18 @@ const _sfc_main$F = {
4895
5298
  },
4896
5299
  setup(__props) {
4897
5300
  const binds = computed(() => {
4898
- let interpolatorFn = interpolators[__props.interpolate] ?? natural;
4899
5301
  return {
4900
- d: line().curve(interpolatorFn)(__props.points.map((p) => [p.x, p.y])),
4901
- fill: __props.fill,
4902
- stroke: __props.color,
5302
+ x1: __props.x1,
5303
+ x2: __props.x2,
5304
+ y1: __props.y1,
5305
+ y2: __props.y2,
5306
+ stroke: __props.color || null,
4903
5307
  "stroke-width": __props.linewidth,
4904
- "stroke-opacity": __props.alpha,
5308
+ "stroke-opacity": __props.alpha == 1 ? null : __props.alpha,
4905
5309
  "stroke-dasharray": parseLineType(__props.linetype),
4906
5310
  transform: __props.translateX || __props.translateY ? `translate(${__props.translateX}, ${__props.translateY})` : null
4907
5311
  };
4908
5312
  });
4909
- const interpolators = {
4910
- cardinal,
4911
- catmullRom,
4912
- linear: curveLinear,
4913
- natural
4914
- };
4915
5313
  function parseLineType(linetype) {
4916
5314
  if (linetype == null) return null;
4917
5315
  if (Array.isArray(linetype)) return linetype.join(" ");
@@ -4925,12 +5323,12 @@ const _sfc_main$F = {
4925
5323
  return linetype.split("").map((v) => +("0x" + v)).join(" ");
4926
5324
  }
4927
5325
  return (_ctx, _cache) => {
4928
- return openBlock(), createElementBlock("path", normalizeProps(guardReactiveProps(binds.value)), null, 16);
5326
+ return openBlock(), createElementBlock("line", normalizeProps(guardReactiveProps(binds.value)), null, 16);
4929
5327
  };
4930
5328
  }
4931
5329
  };
4932
5330
  const _sfc_main$E = {
4933
- __name: "CoreSvgCurve",
5331
+ __name: "CoreSvgBoxplot",
4934
5332
  props: {
4935
5333
  extendX: { type: Number, default: 0 },
4936
5334
  extendY: { type: Number, default: 0 },
@@ -4938,14 +5336,30 @@ const _sfc_main$E = {
4938
5336
  coord2pos: Function,
4939
5337
  layout: Object
4940
5338
  },
4941
- emits: ["click", "contextmenu", "pointerover", "pointerout", "pointerenter", "pointerleave", "pointermove", "pointerdown", "pointerup", "wheel"],
5339
+ emits: ["click", "contextmenu", "singleclick", "pointerover", "pointerout", "pointerenter", "pointerleave", "pointermove", "pointerdown", "pointerup", "wheel"],
4942
5340
  setup(__props, { emit: __emit }) {
5341
+ let events = ["click", "contextmenu", "singleclick", "pointerover", "pointerout", "pointerenter", "pointerleave", "pointermove", "pointerdown", "pointerup", "wheel"];
4943
5342
  const emit = __emit;
4944
5343
  const binds = computed(() => {
4945
5344
  let xlim_min = -__props.layout.fullWidth * __props.extendX - __props.layout.l, xlim_max = __props.layout.fullWidth * (1 + __props.extendX) - __props.layout.l, ylim_min = -__props.layout.fullHeight * __props.extendY - __props.layout.t, ylim_max = __props.layout.fullHeight * (1 + __props.extendY) - __props.layout.t;
4946
5345
  return __props.data.map((group) => group.map(({
4947
- points,
4948
- fill = "none",
5346
+ x: x2,
5347
+ xmin,
5348
+ xmax,
5349
+ y: y2,
5350
+ ymin,
5351
+ ymax,
5352
+ lwisker,
5353
+ Q1,
5354
+ median,
5355
+ Q3,
5356
+ uwisker,
5357
+ outliers,
5358
+ $xmin,
5359
+ $xmax,
5360
+ $ymin,
5361
+ $ymax,
5362
+ fill = "white",
4949
5363
  color = "black",
4950
5364
  linewidth,
4951
5365
  linetype,
@@ -4954,37 +5368,123 @@ const _sfc_main$E = {
4954
5368
  "translate-y": translateY = 0,
4955
5369
  $raw
4956
5370
  }) => {
4957
- points = points.map((p) => (({ h: x2, v: y2 }) => ({ x: x2, y: y2 }))(__props.coord2pos(p)));
4958
- if (points.every((p) => p.x < xlim_min) || points.every((p) => p.x > xlim_max) || points.every((p) => p.y < ylim_min) || points.every((p) => p.y > ylim_max)) return null;
4959
- let result = {
4960
- points,
4961
- fill,
4962
- color,
4963
- linetype,
4964
- linewidth,
4965
- alpha,
4966
- translateX,
4967
- translateY,
4968
- onClick: (e) => emit("click", e, $raw),
4969
- onContextmenu: (e) => emit("contextmenu", e, $raw),
4970
- onPointerover: (e) => emit("pointerover", e, $raw),
4971
- onPointerout: (e) => emit("pointerout", e, $raw),
4972
- onPointerenter: (e) => emit("pointerenter", e, $raw),
4973
- onPointerleave: (e) => emit("pointerleave", e, $raw),
4974
- onPointerdown: (e) => emit("pointerdown", e, $raw),
4975
- onPointerup: (e) => emit("pointerup", e, $raw),
4976
- onPointermove: (e) => emit("pointermove", e, $raw),
4977
- onWheel: (e) => emit("wheel", e, $raw)
5371
+ const { hmin: x1, hmax: x22, vmin: y1, vmax: y22 } = __props.coord2pos({ xmin: $xmin, xmax: $xmax, ymin: $ymin, ymax: $ymax });
5372
+ if (x1 < xlim_min && x22 < xlim_min || x1 > xlim_max && x22 > xlim_max || y1 < ylim_min && y22 < ylim_min || y1 > ylim_max && y22 > ylim_max) return null;
5373
+ const { hmin: rx1, hmax: rx2, vmin: ry1, vmax: ry2 } = __props.coord2pos(x2 == null ? { ymin, ymax, xmin: Q1, xmax: Q3 } : { xmin, xmax, ymin: Q1, ymax: Q3 });
5374
+ const { h: lx1, v: ly1 } = __props.coord2pos(x2 == null ? { y: y2, x: lwisker } : { x: x2, y: lwisker });
5375
+ const { h: lx2, v: ly2 } = __props.coord2pos(x2 == null ? { y: y2, x: uwisker } : { x: x2, y: uwisker });
5376
+ const { h: mx1, v: my1 } = __props.coord2pos(x2 == null ? { y: ymin, x: median } : { x: xmin, y: median });
5377
+ const { h: mx2, v: my2 } = __props.coord2pos(x2 == null ? { y: ymax, x: median } : { x: xmax, y: median });
5378
+ const { h: uwx1, v: uwy1 } = __props.coord2pos(x2 == null ? { y: ymin * 0.25 + ymax * 0.75, x: uwisker } : { x: xmin * 0.25 + xmax * 0.75, y: uwisker });
5379
+ const { h: uwx2, v: uwy2 } = __props.coord2pos(x2 == null ? { y: ymin * 0.75 + ymax * 0.25, x: uwisker } : { x: xmin * 0.75 + xmax * 0.25, y: uwisker });
5380
+ const { h: lwx1, v: lwy1 } = __props.coord2pos(x2 == null ? { y: ymin * 0.25 + ymax * 0.75, x: lwisker } : { x: xmin * 0.25 + xmax * 0.75, y: lwisker });
5381
+ const { h: lwx2, v: lwy2 } = __props.coord2pos(x2 == null ? { y: ymin * 0.75 + ymax * 0.25, x: lwisker } : { x: xmin * 0.75 + xmax * 0.25, y: lwisker });
5382
+ let vbinds = {
5383
+ rect: {
5384
+ x: (rx1 + rx2) / 2,
5385
+ width: rx2 - rx1,
5386
+ y: (ry1 + ry2) / 2,
5387
+ height: ry2 - ry1,
5388
+ fill,
5389
+ color,
5390
+ linetype,
5391
+ linewidth,
5392
+ alpha,
5393
+ translateX,
5394
+ translateY
5395
+ },
5396
+ line: {
5397
+ x1: lx1,
5398
+ y1: ly1,
5399
+ x2: lx2,
5400
+ y2: ly2,
5401
+ color,
5402
+ linetype,
5403
+ linewidth,
5404
+ alpha,
5405
+ translateX,
5406
+ translateY
5407
+ },
5408
+ midline: {
5409
+ x1: mx1,
5410
+ y1: my1,
5411
+ x2: mx2,
5412
+ y2: my2,
5413
+ color,
5414
+ linetype,
5415
+ linewidth: (linewidth ?? 1) * 2,
5416
+ alpha,
5417
+ translateX,
5418
+ translateY
5419
+ },
5420
+ uwisker: {
5421
+ x1: uwx1,
5422
+ y1: uwy1,
5423
+ x2: uwx2,
5424
+ y2: uwy2,
5425
+ color,
5426
+ linetype,
5427
+ linewidth,
5428
+ alpha,
5429
+ translateX,
5430
+ translateY
5431
+ },
5432
+ lwisker: {
5433
+ x1: lwx1,
5434
+ y1: lwy1,
5435
+ x2: lwx2,
5436
+ y2: lwy2,
5437
+ color,
5438
+ linetype,
5439
+ linewidth,
5440
+ alpha,
5441
+ translateX,
5442
+ translateY
5443
+ },
5444
+ outliers: outliers?.map(({ x: x3, y: y3, $raw: $raw2 }) => {
5445
+ const { h: cx, v: cy } = __props.coord2pos({ x: x3, y: y3 });
5446
+ let vbind = {
5447
+ x: cx,
5448
+ y: cy,
5449
+ shape: "circle",
5450
+ size: 4,
5451
+ color,
5452
+ alpha,
5453
+ translateX,
5454
+ translateY
5455
+ };
5456
+ let von2 = Object.fromEntries(
5457
+ events.map((evt) => [evt, (e) => emit(evt, e, $raw2)])
5458
+ );
5459
+ return [vbind, von2];
5460
+ })
4978
5461
  };
4979
- return result;
5462
+ let von = Object.fromEntries(
5463
+ events.map((evt) => [evt, (e) => emit(evt, Object.assign(e, { _vhandled: true }), $raw)])
5464
+ );
5465
+ return [vbinds, von];
4980
5466
  }).filter((x2) => x2 != null));
4981
5467
  });
4982
5468
  return (_ctx, _cache) => {
4983
5469
  return openBlock(), createElementBlock("g", null, [
4984
5470
  (openBlock(true), createElementBlock(Fragment, null, renderList(binds.value, (group) => {
4985
5471
  return openBlock(), createElementBlock("g", null, [
4986
- (openBlock(true), createElementBlock(Fragment, null, renderList(group, (item) => {
4987
- return openBlock(), createBlock(_sfc_main$F, mergeProps({ ref_for: true }, item), null, 16);
5472
+ (openBlock(true), createElementBlock(Fragment, null, renderList(group, ([vbinds, von]) => {
5473
+ return openBlock(), createElementBlock("g", null, [
5474
+ createVNode(_sfc_main$F, mergeProps({ ref_for: true }, vbinds.line), null, 16),
5475
+ _cache[0] || (_cache[0] = createTextVNode()),
5476
+ createVNode(_sfc_main$H, mergeProps({ ref_for: true }, vbinds.rect, toHandlers(von)), null, 16),
5477
+ _cache[1] || (_cache[1] = createTextVNode()),
5478
+ createVNode(_sfc_main$F, mergeProps({ ref_for: true }, vbinds.midline), null, 16),
5479
+ _cache[2] || (_cache[2] = createTextVNode()),
5480
+ createVNode(_sfc_main$F, mergeProps({ ref_for: true }, vbinds.uwisker), null, 16),
5481
+ _cache[3] || (_cache[3] = createTextVNode()),
5482
+ createVNode(_sfc_main$F, mergeProps({ ref_for: true }, vbinds.lwisker), null, 16),
5483
+ _cache[4] || (_cache[4] = createTextVNode()),
5484
+ (openBlock(true), createElementBlock(Fragment, null, renderList(vbinds.outliers, ([vbind, von2]) => {
5485
+ return openBlock(), createBlock(_sfc_main$G, mergeProps({ ref_for: true }, vbind, toHandlers(von2)), null, 16);
5486
+ }), 256))
5487
+ ]);
4988
5488
  }), 256))
4989
5489
  ]);
4990
5490
  }), 256))
@@ -4993,12 +5493,11 @@ const _sfc_main$E = {
4993
5493
  }
4994
5494
  };
4995
5495
  const _sfc_main$D = {
4996
- __name: "CoreLine",
5496
+ __name: "CoreCurve",
4997
5497
  props: {
4998
- x1: { type: Number, default: 0 },
4999
- y1: { type: Number, default: 0 },
5000
- x2: { type: Number, default: 0 },
5001
- y2: { type: Number, default: 0 },
5498
+ points: { type: Array, default: () => [] },
5499
+ interpolate: { default: "natural" },
5500
+ fill: { type: String, default: "none" },
5002
5501
  color: String,
5003
5502
  stroke: String,
5004
5503
  linewidth: Number,
@@ -5009,18 +5508,23 @@ const _sfc_main$D = {
5009
5508
  },
5010
5509
  setup(__props) {
5011
5510
  const binds = computed(() => {
5511
+ let interpolatorFn = interpolators[__props.interpolate] ?? natural;
5012
5512
  return {
5013
- x1: __props.x1,
5014
- x2: __props.x2,
5015
- y1: __props.y1,
5016
- y2: __props.y2,
5017
- stroke: __props.color,
5513
+ d: line().curve(interpolatorFn)(__props.points.map((p) => [p.x, p.y])),
5514
+ fill: __props.fill || null,
5515
+ stroke: __props.color || null,
5018
5516
  "stroke-width": __props.linewidth,
5019
- "stroke-opacity": __props.alpha,
5517
+ "stroke-opacity": __props.alpha == 1 ? null : __props.alpha,
5020
5518
  "stroke-dasharray": parseLineType(__props.linetype),
5021
5519
  transform: __props.translateX || __props.translateY ? `translate(${__props.translateX}, ${__props.translateY})` : null
5022
5520
  };
5023
5521
  });
5522
+ const interpolators = {
5523
+ cardinal,
5524
+ catmullRom,
5525
+ linear: curveLinear,
5526
+ natural
5527
+ };
5024
5528
  function parseLineType(linetype) {
5025
5529
  if (linetype == null) return null;
5026
5530
  if (Array.isArray(linetype)) return linetype.join(" ");
@@ -5034,11 +5538,70 @@ const _sfc_main$D = {
5034
5538
  return linetype.split("").map((v) => +("0x" + v)).join(" ");
5035
5539
  }
5036
5540
  return (_ctx, _cache) => {
5037
- return openBlock(), createElementBlock("line", normalizeProps(guardReactiveProps(binds.value)), null, 16);
5541
+ return openBlock(), createElementBlock("path", normalizeProps(guardReactiveProps(binds.value)), null, 16);
5038
5542
  };
5039
5543
  }
5040
5544
  };
5041
5545
  const _sfc_main$C = {
5546
+ __name: "CoreSvgCurve",
5547
+ props: {
5548
+ extendX: { type: Number, default: 0 },
5549
+ extendY: { type: Number, default: 0 },
5550
+ data: Object,
5551
+ coord2pos: Function,
5552
+ layout: Object
5553
+ },
5554
+ emits: ["click", "contextmenu", "singleclick", "pointerover", "pointerout", "pointerenter", "pointerleave", "pointermove", "pointerdown", "pointerup", "wheel"],
5555
+ setup(__props, { emit: __emit }) {
5556
+ let events = ["click", "contextmenu", "singleclick", "pointerover", "pointerout", "pointerenter", "pointerleave", "pointermove", "pointerdown", "pointerup", "wheel"];
5557
+ const emit = __emit;
5558
+ const binds = computed(() => {
5559
+ let xlim_min = -__props.layout.fullWidth * __props.extendX - __props.layout.l, xlim_max = __props.layout.fullWidth * (1 + __props.extendX) - __props.layout.l, ylim_min = -__props.layout.fullHeight * __props.extendY - __props.layout.t, ylim_max = __props.layout.fullHeight * (1 + __props.extendY) - __props.layout.t;
5560
+ return __props.data.map((group) => group.map(({
5561
+ points,
5562
+ fill = "none",
5563
+ color = "black",
5564
+ linewidth,
5565
+ linetype,
5566
+ alpha,
5567
+ "translate-x": translateX = 0,
5568
+ "translate-y": translateY = 0,
5569
+ $raw,
5570
+ interpolate
5571
+ }) => {
5572
+ points = points.map((p) => (({ h: x2, v: y2 }) => ({ x: x2, y: y2 }))(__props.coord2pos(p)));
5573
+ if (points.every((p) => p.x < xlim_min) || points.every((p) => p.x > xlim_max) || points.every((p) => p.y < ylim_min) || points.every((p) => p.y > ylim_max)) return null;
5574
+ let vbind = {
5575
+ points,
5576
+ fill,
5577
+ color,
5578
+ linetype,
5579
+ linewidth,
5580
+ alpha,
5581
+ translateX,
5582
+ translateY,
5583
+ interpolate
5584
+ };
5585
+ let von = Object.fromEntries(
5586
+ events.map((evt) => [evt, (e) => emit(evt, Object.assign(e, { _vhandled: true }), $raw)])
5587
+ );
5588
+ return [vbind, von];
5589
+ }).filter((x2) => x2 != null));
5590
+ });
5591
+ return (_ctx, _cache) => {
5592
+ return openBlock(), createElementBlock("g", null, [
5593
+ (openBlock(true), createElementBlock(Fragment, null, renderList(binds.value, (group) => {
5594
+ return openBlock(), createElementBlock("g", null, [
5595
+ (openBlock(true), createElementBlock(Fragment, null, renderList(group, ([vbind, von]) => {
5596
+ return openBlock(), createBlock(_sfc_main$D, mergeProps({ ref_for: true }, vbind, toHandlers(von)), null, 16);
5597
+ }), 256))
5598
+ ]);
5599
+ }), 256))
5600
+ ]);
5601
+ };
5602
+ }
5603
+ };
5604
+ const _sfc_main$B = {
5042
5605
  __name: "CoreSvgLine",
5043
5606
  props: {
5044
5607
  extendX: { type: Number, default: 0 },
@@ -5047,8 +5610,9 @@ const _sfc_main$C = {
5047
5610
  coord2pos: Function,
5048
5611
  layout: Object
5049
5612
  },
5050
- emits: ["click", "contextmenu", "pointerover", "pointerout", "pointerenter", "pointerleave", "pointermove", "pointerdown", "pointerup", "wheel"],
5613
+ emits: ["click", "contextmenu", "singleclick", "pointerover", "pointerout", "pointerenter", "pointerleave", "pointermove", "pointerdown", "pointerup", "wheel"],
5051
5614
  setup(__props, { emit: __emit }) {
5615
+ let events = ["click", "contextmenu", "singleclick", "pointerover", "pointerout", "pointerenter", "pointerleave", "pointermove", "pointerdown", "pointerup", "wheel"];
5052
5616
  const emit = __emit;
5053
5617
  const binds = computed(() => {
5054
5618
  let xlim_min = -__props.layout.fullWidth * __props.extendX - __props.layout.l, xlim_max = __props.layout.fullWidth * (1 + __props.extendX) - __props.layout.l, ylim_min = -__props.layout.fullHeight * __props.extendY - __props.layout.t, ylim_max = __props.layout.fullHeight * (1 + __props.extendY) - __props.layout.t;
@@ -5068,7 +5632,7 @@ const _sfc_main$C = {
5068
5632
  const { h: x1, v: y1 } = __props.coord2pos({ x: x2, y: y2 });
5069
5633
  const { h: x22, v: y22 } = __props.coord2pos({ x: xend, y: yend });
5070
5634
  if (x1 < xlim_min && x22 < xlim_min || x1 > xlim_max && x22 > xlim_max || y1 < ylim_min && y22 < ylim_min || y1 > ylim_max && y22 > ylim_max) return null;
5071
- let result = {
5635
+ let vbind = {
5072
5636
  x1,
5073
5637
  x2: x22,
5074
5638
  y1,
@@ -5078,27 +5642,20 @@ const _sfc_main$C = {
5078
5642
  linewidth,
5079
5643
  alpha,
5080
5644
  translateX,
5081
- translateY,
5082
- onClick: (e) => emit("click", e, $raw),
5083
- onContextmenu: (e) => emit("contextmenu", e, $raw),
5084
- onPointerover: (e) => emit("pointerover", e, $raw),
5085
- onPointerout: (e) => emit("pointerout", e, $raw),
5086
- onPointerenter: (e) => emit("pointerenter", e, $raw),
5087
- onPointerleave: (e) => emit("pointerleave", e, $raw),
5088
- onPointerdown: (e) => emit("pointerdown", e, $raw),
5089
- onPointerup: (e) => emit("pointerup", e, $raw),
5090
- onPointermove: (e) => emit("pointermove", e, $raw),
5091
- onWheel: (e) => emit("wheel", e, $raw)
5645
+ translateY
5092
5646
  };
5093
- return result;
5647
+ let von = Object.fromEntries(
5648
+ events.map((evt) => [evt, (e) => emit(evt, Object.assign(e, { _vhandled: true }), $raw)])
5649
+ );
5650
+ return [vbind, von];
5094
5651
  }).filter((x2) => x2 != null));
5095
5652
  });
5096
5653
  return (_ctx, _cache) => {
5097
5654
  return openBlock(), createElementBlock("g", null, [
5098
5655
  (openBlock(true), createElementBlock(Fragment, null, renderList(binds.value, (group) => {
5099
5656
  return openBlock(), createElementBlock("g", null, [
5100
- (openBlock(true), createElementBlock(Fragment, null, renderList(group, (item) => {
5101
- return openBlock(), createBlock(_sfc_main$D, mergeProps({ ref_for: true }, item), null, 16);
5657
+ (openBlock(true), createElementBlock(Fragment, null, renderList(group, ([vbind, von]) => {
5658
+ return openBlock(), createBlock(_sfc_main$F, mergeProps({ ref_for: true }, vbind, toHandlers(von)), null, 16);
5102
5659
  }), 256))
5103
5660
  ]);
5104
5661
  }), 256))
@@ -5106,66 +5663,6 @@ const _sfc_main$C = {
5106
5663
  };
5107
5664
  }
5108
5665
  };
5109
- const _sfc_main$B = {
5110
- __name: "CorePoint",
5111
- props: {
5112
- x: { type: Number, default: 0 },
5113
- y: { type: Number, default: 0 },
5114
- shape: String,
5115
- size: { type: Number, default: 6 },
5116
- color: String,
5117
- stroke: String,
5118
- linewidth: Number,
5119
- linetype: String,
5120
- alpha: { type: Number, default: 1 },
5121
- angle: { type: Number, default: 0 },
5122
- translateX: { type: Number, default: 0 },
5123
- translateY: { type: Number, default: 0 }
5124
- },
5125
- setup(__props) {
5126
- const paths = {
5127
- square: "M-0.5-0.5H0.5V0.5H-0.5Z",
5128
- triangle: "M0-0.667L0.577,0.333L-0.577,0.333Z",
5129
- diamond: "M0-0.707L0.707,0L0,0.707L-0.707,0Z",
5130
- plus: "M-0.1-0.5V-0.1H-0.5V0.1H-0.1V0.5H0.1V0.1H0.5V-0.1H0.1V-0.5H-0.1Z",
5131
- cross: "M-0.283-0.424L-0.424-0.283L-0.141,0L-0.424,0.283L-0.283,0.424L0,0.141L0.283,0.424L0.424,0.283L0.141,0L0.424,-0.283L0.283,-0.424L0,-0.141Z"
5132
- };
5133
- const binds = computed(() => {
5134
- let d = __props.shape?.startsWith?.("path:") ? __props.shape?.slice?.(5) : paths[__props.shape];
5135
- let result = {
5136
- fill: __props.color,
5137
- "fill-opacity": __props.alpha,
5138
- stroke: __props.stroke,
5139
- "stroke-width": __props.linewidth,
5140
- "stroke-opacity": __props.alpha,
5141
- "stroke-dasharray": parseLineType(__props.linetype)
5142
- };
5143
- if (d != null) {
5144
- let transform = `translate(${__props.x + __props.translateX},${__props.y + __props.translateY}) scale(${__props.size}) rotate(${__props.angle})`;
5145
- Object.assign(result, { d, transform });
5146
- } else {
5147
- let transform = __props.translateX || __props.translateY ? `translate(${__props.translateX}, ${__props.translateY})` : null;
5148
- Object.assign(result, { cx: __props.x, cy: __props.y, r: __props.size / 2, transform });
5149
- }
5150
- return result;
5151
- });
5152
- function parseLineType(linetype) {
5153
- if (linetype == null) return null;
5154
- if (Array.isArray(linetype)) return linetype.join(" ");
5155
- if (linetype === "solid") return null;
5156
- if (linetype === "dashed") return "4 4";
5157
- if (linetype === "dotted") return "1 3";
5158
- if (linetype === "dotdash") return "1 3 4 3";
5159
- if (linetype === "longdash") return "8 4";
5160
- if (linetype === "twodash") return "2 2 6 2";
5161
- if (linetype.includes(" ")) return linetype;
5162
- return linetype.split("").map((v) => +("0x" + v)).join(" ");
5163
- }
5164
- return (_ctx, _cache) => {
5165
- return binds.value.d ? (openBlock(), createElementBlock("path", normalizeProps(mergeProps({ key: 0 }, binds.value)), null, 16)) : (openBlock(), createElementBlock("circle", normalizeProps(mergeProps({ key: 1 }, binds.value)), null, 16));
5166
- };
5167
- }
5168
- };
5169
5666
  const _sfc_main$A = {
5170
5667
  __name: "CoreSvgPoint",
5171
5668
  props: {
@@ -5175,8 +5672,9 @@ const _sfc_main$A = {
5175
5672
  coord2pos: Function,
5176
5673
  layout: Object
5177
5674
  },
5178
- emits: ["click", "contextmenu", "pointerover", "pointerout", "pointerenter", "pointerleave", "pointermove", "pointerdown", "pointerup", "wheel"],
5675
+ emits: ["click", "contextmenu", "singleclick", "pointerover", "pointerout", "pointerenter", "pointerleave", "pointermove", "pointerdown", "pointerup", "wheel"],
5179
5676
  setup(__props, { emit: __emit }) {
5677
+ let events = ["click", "contextmenu", "singleclick", "pointerover", "pointerout", "pointerenter", "pointerleave", "pointermove", "pointerdown", "pointerup", "wheel"];
5180
5678
  const emit = __emit;
5181
5679
  const binds = computed(() => {
5182
5680
  let xlim_min = -__props.layout.fullWidth * __props.extendX - __props.layout.l, xlim_max = __props.layout.fullWidth * (1 + __props.extendX) - __props.layout.l, ylim_min = -__props.layout.fullHeight * __props.extendY - __props.layout.t, ylim_max = __props.layout.fullHeight * (1 + __props.extendY) - __props.layout.t;
@@ -5197,7 +5695,7 @@ const _sfc_main$A = {
5197
5695
  }) => {
5198
5696
  const { h: cx, v: cy } = __props.coord2pos({ x: x2, y: y2 });
5199
5697
  if (cx < xlim_min || cx > xlim_max || cy < ylim_min || cy > ylim_max) return null;
5200
- let result = {
5698
+ let vbind = {
5201
5699
  x: cx,
5202
5700
  y: cy,
5203
5701
  shape,
@@ -5209,27 +5707,20 @@ const _sfc_main$A = {
5209
5707
  alpha,
5210
5708
  angle,
5211
5709
  translateX,
5212
- translateY,
5213
- onClick: (e) => emit("click", e, $raw),
5214
- onContextmenu: (e) => emit("contextmenu", e, $raw),
5215
- onPointerover: (e) => emit("pointerover", e, $raw),
5216
- onPointerout: (e) => emit("pointerout", e, $raw),
5217
- onPointerenter: (e) => emit("pointerenter", e, $raw),
5218
- onPointerleave: (e) => emit("pointerleave", e, $raw),
5219
- onPointerdown: (e) => emit("pointerdown", e, $raw),
5220
- onPointerup: (e) => emit("pointerup", e, $raw),
5221
- onPointermove: (e) => emit("pointermove", e, $raw),
5222
- onWheel: (e) => emit("wheel", e, $raw)
5710
+ translateY
5223
5711
  };
5224
- return result;
5712
+ let von = Object.fromEntries(
5713
+ events.map((evt) => [evt, (e) => emit(evt, Object.assign(e, { _vhandled: true }), $raw)])
5714
+ );
5715
+ return [vbind, von];
5225
5716
  }).filter((x2) => x2 != null));
5226
5717
  });
5227
5718
  return (_ctx, _cache) => {
5228
5719
  return openBlock(), createElementBlock("g", null, [
5229
5720
  (openBlock(true), createElementBlock(Fragment, null, renderList(binds.value, (group) => {
5230
5721
  return openBlock(), createElementBlock("g", null, [
5231
- (openBlock(true), createElementBlock(Fragment, null, renderList(group, (item) => {
5232
- return openBlock(), createBlock(_sfc_main$B, mergeProps({ ref_for: true }, item), null, 16);
5722
+ (openBlock(true), createElementBlock(Fragment, null, renderList(group, ([vbind, von]) => {
5723
+ return openBlock(), createBlock(_sfc_main$G, mergeProps({ ref_for: true }, vbind, toHandlers(von)), null, 16);
5233
5724
  }), 256))
5234
5725
  ]);
5235
5726
  }), 256))
@@ -5253,11 +5744,11 @@ const _sfc_main$z = {
5253
5744
  const binds = computed(() => {
5254
5745
  return {
5255
5746
  points: __props.points.map((p) => `${p.x},${p.y}`).join(" "),
5256
- fill: __props.fill,
5257
- "fill-opacity": __props.alpha,
5258
- stroke: __props.color,
5747
+ fill: __props.fill || null,
5748
+ "fill-opacity": __props.alpha == 1 ? null : __props.alpha,
5749
+ stroke: __props.color || null,
5259
5750
  "stroke-width": __props.linewidth,
5260
- "stroke-opacity": __props.alpha,
5751
+ "stroke-opacity": __props.alpha == 1 ? null : __props.alpha,
5261
5752
  "stroke-dasharray": parseLineType(__props.linetype),
5262
5753
  transform: __props.translateX || __props.translateY ? `translate(${__props.translateX}, ${__props.translateY})` : null
5263
5754
  };
@@ -5288,8 +5779,9 @@ const _sfc_main$y = {
5288
5779
  coord2pos: Function,
5289
5780
  layout: Object
5290
5781
  },
5291
- emits: ["click", "contextmenu", "pointerover", "pointerout", "pointerenter", "pointerleave", "pointermove", "pointerdown", "pointerup", "wheel"],
5782
+ emits: ["click", "contextmenu", "singleclick", "pointerover", "pointerout", "pointerenter", "pointerleave", "pointermove", "pointerdown", "pointerup", "wheel"],
5292
5783
  setup(__props, { emit: __emit }) {
5784
+ let events = ["click", "contextmenu", "singleclick", "pointerover", "pointerout", "pointerenter", "pointerleave", "pointermove", "pointerdown", "pointerup", "wheel"];
5293
5785
  const emit = __emit;
5294
5786
  const binds = computed(() => {
5295
5787
  let xlim_min = -__props.layout.fullWidth * __props.extendX - __props.layout.l, xlim_max = __props.layout.fullWidth * (1 + __props.extendX) - __props.layout.l, ylim_min = -__props.layout.fullHeight * __props.extendY - __props.layout.t, ylim_max = __props.layout.fullHeight * (1 + __props.extendY) - __props.layout.t;
@@ -5306,7 +5798,7 @@ const _sfc_main$y = {
5306
5798
  }) => {
5307
5799
  points = points.map((p) => (({ h: x2, v: y2 }) => ({ x: x2, y: y2 }))(__props.coord2pos(p)));
5308
5800
  if (points.every((p) => p.x < xlim_min) || points.every((p) => p.x > xlim_max) || points.every((p) => p.y < ylim_min) || points.every((p) => p.y > ylim_max)) return null;
5309
- let result = {
5801
+ let vbind = {
5310
5802
  points,
5311
5803
  fill,
5312
5804
  color,
@@ -5314,27 +5806,20 @@ const _sfc_main$y = {
5314
5806
  linetype,
5315
5807
  alpha,
5316
5808
  translateX,
5317
- translateY,
5318
- onClick: (e) => emit("click", e, $raw),
5319
- onContextmenu: (e) => emit("contextmenu", e, $raw),
5320
- onPointerover: (e) => emit("pointerover", e, $raw),
5321
- onPointerout: (e) => emit("pointerout", e, $raw),
5322
- onPointerenter: (e) => emit("pointerenter", e, $raw),
5323
- onPointerleave: (e) => emit("pointerleave", e, $raw),
5324
- onPointerdown: (e) => emit("pointerdown", e, $raw),
5325
- onPointerup: (e) => emit("pointerup", e, $raw),
5326
- onPointermove: (e) => emit("pointermove", e, $raw),
5327
- onWheel: (e) => emit("wheel", e, $raw)
5809
+ translateY
5328
5810
  };
5329
- return result;
5811
+ let von = Object.fromEntries(
5812
+ events.map((evt) => [evt, (e) => emit(evt, Object.assign(e, { _vhandled: true }), $raw)])
5813
+ );
5814
+ return [vbind, von];
5330
5815
  }).filter((x2) => x2 != null));
5331
5816
  });
5332
5817
  return (_ctx, _cache) => {
5333
5818
  return openBlock(), createElementBlock("g", null, [
5334
5819
  (openBlock(true), createElementBlock(Fragment, null, renderList(binds.value, (group) => {
5335
5820
  return openBlock(), createElementBlock("g", null, [
5336
- (openBlock(true), createElementBlock(Fragment, null, renderList(group, (item) => {
5337
- return openBlock(), createBlock(_sfc_main$z, mergeProps({ ref_for: true }, item), null, 16);
5821
+ (openBlock(true), createElementBlock(Fragment, null, renderList(group, ([vbind, von]) => {
5822
+ return openBlock(), createBlock(_sfc_main$z, mergeProps({ ref_for: true }, vbind, toHandlers(von)), null, 16);
5338
5823
  }), 256))
5339
5824
  ]);
5340
5825
  }), 256))
@@ -5343,54 +5828,6 @@ const _sfc_main$y = {
5343
5828
  }
5344
5829
  };
5345
5830
  const _sfc_main$x = {
5346
- __name: "CoreTile",
5347
- props: {
5348
- x: { type: Number, default: 0 },
5349
- y: { type: Number, default: 0 },
5350
- width: { type: Number, default: 0 },
5351
- height: { type: Number, default: 0 },
5352
- fill: String,
5353
- color: String,
5354
- linewidth: Number,
5355
- linetype: String,
5356
- alpha: { type: Number, default: 1 },
5357
- translateX: { type: Number, default: 0 },
5358
- translateY: { type: Number, default: 0 }
5359
- },
5360
- setup(__props) {
5361
- const binds = computed(() => {
5362
- return {
5363
- x: __props.x - __props.width / 2,
5364
- y: __props.y - __props.height / 2,
5365
- width: __props.width,
5366
- height: __props.height,
5367
- fill: __props.fill,
5368
- "fill-opacity": __props.alpha,
5369
- stroke: __props.color,
5370
- "stroke-width": __props.linewidth,
5371
- "stroke-opacity": __props.alpha,
5372
- "stroke-dasharray": parseLineType(__props.linetype),
5373
- transform: __props.translateX || __props.translateY ? `translate(${__props.translateX}, ${__props.translateY})` : null
5374
- };
5375
- });
5376
- function parseLineType(linetype) {
5377
- if (linetype == null) return null;
5378
- if (Array.isArray(linetype)) return linetype.join(" ");
5379
- if (linetype === "solid") return null;
5380
- if (linetype === "dashed") return "4 4";
5381
- if (linetype === "dotted") return "1 3";
5382
- if (linetype === "dotdash") return "1 3 4 3";
5383
- if (linetype === "longdash") return "8 4";
5384
- if (linetype === "twodash") return "2 2 6 2";
5385
- if (linetype.includes(" ")) return linetype;
5386
- return linetype.split("").map((v) => +("0x" + v)).join(" ");
5387
- }
5388
- return (_ctx, _cache) => {
5389
- return openBlock(), createElementBlock("rect", normalizeProps(guardReactiveProps(binds.value)), null, 16);
5390
- };
5391
- }
5392
- };
5393
- const _sfc_main$w = {
5394
5831
  __name: "CoreSvgRect",
5395
5832
  props: {
5396
5833
  extendX: { type: Number, default: 0 },
@@ -5399,8 +5836,9 @@ const _sfc_main$w = {
5399
5836
  coord2pos: Function,
5400
5837
  layout: Object
5401
5838
  },
5402
- emits: ["click", "contextmenu", "pointerover", "pointerout", "pointerenter", "pointerleave", "pointermove", "pointerdown", "pointerup", "wheel"],
5839
+ emits: ["click", "contextmenu", "singleclick", "pointerover", "pointerout", "pointerenter", "pointerleave", "pointermove", "pointerdown", "pointerup", "wheel"],
5403
5840
  setup(__props, { emit: __emit }) {
5841
+ let events = ["click", "contextmenu", "singleclick", "pointerover", "pointerout", "pointerenter", "pointerleave", "pointermove", "pointerdown", "pointerup", "wheel"];
5404
5842
  const emit = __emit;
5405
5843
  const binds = computed(() => {
5406
5844
  let xlim_min = -__props.layout.fullWidth * __props.extendX - __props.layout.l, xlim_max = __props.layout.fullWidth * (1 + __props.extendX) - __props.layout.l, ylim_min = -__props.layout.fullHeight * __props.extendY - __props.layout.t, ylim_max = __props.layout.fullHeight * (1 + __props.extendY) - __props.layout.t;
@@ -5420,7 +5858,7 @@ const _sfc_main$w = {
5420
5858
  }) => {
5421
5859
  const { hmin: x1, hmax: x2, vmin: y1, vmax: y2 } = __props.coord2pos({ xmin, xmax, ymin, ymax });
5422
5860
  if (x1 < xlim_min && x2 < xlim_min || x1 > xlim_max && x2 > xlim_max || y1 < ylim_min && y2 < ylim_min || y1 > ylim_max && y2 > ylim_max) return null;
5423
- let result = {
5861
+ let vbind = {
5424
5862
  x: (x1 + x2) / 2,
5425
5863
  width: x2 - x1,
5426
5864
  y: (y1 + y2) / 2,
@@ -5431,27 +5869,20 @@ const _sfc_main$w = {
5431
5869
  linewidth,
5432
5870
  alpha,
5433
5871
  translateX,
5434
- translateY,
5435
- onClick: (e) => emit("click", e, $raw),
5436
- onContextmenu: (e) => emit("contextmenu", e, $raw),
5437
- onPointerover: (e) => emit("pointerover", e, $raw),
5438
- onPointerout: (e) => emit("pointerout", e, $raw),
5439
- onPointerenter: (e) => emit("pointerenter", e, $raw),
5440
- onPointerleave: (e) => emit("pointerleave", e, $raw),
5441
- onPointerdown: (e) => emit("pointerdown", e, $raw),
5442
- onPointerup: (e) => emit("pointerup", e, $raw),
5443
- onPointermove: (e) => emit("pointermove", e, $raw),
5444
- onWheel: (e) => emit("wheel", e, $raw)
5872
+ translateY
5445
5873
  };
5446
- return result;
5874
+ let von = Object.fromEntries(
5875
+ events.map((evt) => [evt, (e) => emit(evt, Object.assign(e, { _vhandled: true }), $raw)])
5876
+ );
5877
+ return [vbind, von];
5447
5878
  }).filter((x2) => x2 != null));
5448
5879
  });
5449
5880
  return (_ctx, _cache) => {
5450
5881
  return openBlock(), createElementBlock("g", null, [
5451
5882
  (openBlock(true), createElementBlock(Fragment, null, renderList(binds.value, (group) => {
5452
5883
  return openBlock(), createElementBlock("g", null, [
5453
- (openBlock(true), createElementBlock(Fragment, null, renderList(group, (item) => {
5454
- return openBlock(), createBlock(_sfc_main$x, mergeProps({ ref_for: true }, item), null, 16);
5884
+ (openBlock(true), createElementBlock(Fragment, null, renderList(group, ([vbind, von]) => {
5885
+ return openBlock(), createBlock(_sfc_main$H, mergeProps({ ref_for: true }, vbind, toHandlers(von)), null, 16);
5455
5886
  }), 256))
5456
5887
  ]);
5457
5888
  }), 256))
@@ -5459,7 +5890,7 @@ const _sfc_main$w = {
5459
5890
  };
5460
5891
  }
5461
5892
  };
5462
- const _sfc_main$v = {
5893
+ const _sfc_main$w = {
5463
5894
  __name: "CoreSvgText",
5464
5895
  props: {
5465
5896
  extendX: { type: Number, default: 0 },
@@ -5468,8 +5899,9 @@ const _sfc_main$v = {
5468
5899
  coord2pos: Function,
5469
5900
  layout: Object
5470
5901
  },
5471
- emits: ["click", "contextmenu", "pointerover", "pointerout", "pointerenter", "pointerleave", "pointermove", "pointerdown", "pointerup", "wheel"],
5902
+ emits: ["click", "contextmenu", "singleclick", "pointerover", "pointerout", "pointerenter", "pointerleave", "pointermove", "pointerdown", "pointerup", "wheel"],
5472
5903
  setup(__props, { emit: __emit }) {
5904
+ let events = ["click", "contextmenu", "singleclick", "pointerover", "pointerout", "pointerenter", "pointerleave", "pointermove", "pointerdown", "pointerup", "wheel"];
5473
5905
  const emit = __emit;
5474
5906
  const binds = computed(() => {
5475
5907
  let xlim_min = -__props.layout.fullWidth * __props.extendX - __props.layout.l, xlim_max = __props.layout.fullWidth * (1 + __props.extendX) - __props.layout.l, ylim_min = -__props.layout.fullHeight * __props.extendY - __props.layout.t, ylim_max = __props.layout.fullHeight * (1 + __props.extendY) - __props.layout.t;
@@ -5477,7 +5909,7 @@ const _sfc_main$v = {
5477
5909
  x: x2,
5478
5910
  y: y2,
5479
5911
  size = 4,
5480
- label = "",
5912
+ label,
5481
5913
  title,
5482
5914
  color,
5483
5915
  stroke,
@@ -5494,6 +5926,7 @@ const _sfc_main$v = {
5494
5926
  "text-length": textLength,
5495
5927
  $raw
5496
5928
  }) => {
5929
+ if (label == null) return null;
5497
5930
  const { h: tx, v: ty } = __props.coord2pos({ x: x2, y: y2 });
5498
5931
  if (tx < xlim_min || tx > xlim_max || ty < ylim_min || ty > ylim_max) return null;
5499
5932
  if (typeof textLength == "object") {
@@ -5501,7 +5934,7 @@ const _sfc_main$v = {
5501
5934
  let { h: h1, v: v1 } = __props.coord2pos({ x: x2 + lx / 2, y: y2 + ly / 2 }), { h: h2, v: v2 } = __props.coord2pos({ x: x2 - lx / 2, y: y2 - ly / 2 });
5502
5935
  textLength = Math.hypot(h1 - h2 || 0, v1 - v2 || 0);
5503
5936
  }
5504
- let result = {
5937
+ let vbind = {
5505
5938
  x: tx,
5506
5939
  y: ty,
5507
5940
  text: String(label),
@@ -5519,27 +5952,20 @@ const _sfc_main$v = {
5519
5952
  anchorY,
5520
5953
  dockX,
5521
5954
  dockY,
5522
- textLength,
5523
- onClick: (e) => emit("click", e, $raw),
5524
- onContextmenu: (e) => emit("contextmenu", e, $raw),
5525
- onPointerover: (e) => emit("pointerover", e, $raw),
5526
- onPointerout: (e) => emit("pointerout", e, $raw),
5527
- onPointerenter: (e) => emit("pointerenter", e, $raw),
5528
- onPointerleave: (e) => emit("pointerleave", e, $raw),
5529
- onPointerdown: (e) => emit("pointerdown", e, $raw),
5530
- onPointerup: (e) => emit("pointerup", e, $raw),
5531
- onPointermove: (e) => emit("pointermove", e, $raw),
5532
- onWheel: (e) => emit("wheel", e, $raw)
5955
+ textLength
5533
5956
  };
5534
- return result;
5535
- }).filter((x2) => x2?.text != null));
5957
+ let von = Object.fromEntries(
5958
+ events.map((evt) => [evt, (e) => emit(evt, Object.assign(e, { _vhandled: true }), $raw)])
5959
+ );
5960
+ return [vbind, von];
5961
+ }).filter((x2) => x2 != null));
5536
5962
  });
5537
5963
  return (_ctx, _cache) => {
5538
5964
  return openBlock(), createElementBlock("g", null, [
5539
5965
  (openBlock(true), createElementBlock(Fragment, null, renderList(binds.value, (group) => {
5540
5966
  return openBlock(), createElementBlock("g", null, [
5541
- (openBlock(true), createElementBlock(Fragment, null, renderList(group, (item) => {
5542
- return openBlock(), createBlock(_sfc_main$T, mergeProps({ ref_for: true }, item), null, 16);
5967
+ (openBlock(true), createElementBlock(Fragment, null, renderList(group, ([vbind, von]) => {
5968
+ return openBlock(), createBlock(_sfc_main$W, mergeProps({ ref_for: true }, vbind, toHandlers(von)), null, 16);
5543
5969
  }), 256))
5544
5970
  ]);
5545
5971
  }), 256))
@@ -5547,7 +5973,7 @@ const _sfc_main$v = {
5547
5973
  };
5548
5974
  }
5549
5975
  };
5550
- const _sfc_main$u = {
5976
+ const _sfc_main$v = {
5551
5977
  __name: "CoreSvgTextsegment",
5552
5978
  props: {
5553
5979
  extendX: { type: Number, default: 0 },
@@ -5556,8 +5982,9 @@ const _sfc_main$u = {
5556
5982
  coord2pos: Function,
5557
5983
  layout: Object
5558
5984
  },
5559
- emits: ["click", "contextmenu", "pointerover", "pointerout", "pointerenter", "pointerleave", "pointermove", "pointerdown", "pointerup", "wheel"],
5985
+ emits: ["click", "contextmenu", "singleclick", "pointerover", "pointerout", "pointerenter", "pointerleave", "pointermove", "pointerdown", "pointerup", "wheel"],
5560
5986
  setup(__props, { emit: __emit }) {
5987
+ let events = ["click", "contextmenu", "singleclick", "pointerover", "pointerout", "pointerenter", "pointerleave", "pointermove", "pointerdown", "pointerup", "wheel"];
5561
5988
  const emit = __emit;
5562
5989
  const binds = computed(() => {
5563
5990
  let xlim_min = -__props.layout.fullWidth * __props.extendX - __props.layout.l, xlim_max = __props.layout.fullWidth * (1 + __props.extendX) - __props.layout.l, ylim_min = -__props.layout.fullHeight * __props.extendY - __props.layout.t, ylim_max = __props.layout.fullHeight * (1 + __props.extendY) - __props.layout.t;
@@ -5567,7 +5994,7 @@ const _sfc_main$u = {
5567
5994
  y: y2,
5568
5995
  yend,
5569
5996
  size = 4,
5570
- label = "",
5997
+ label,
5571
5998
  title,
5572
5999
  color,
5573
6000
  stroke,
@@ -5579,12 +6006,13 @@ const _sfc_main$u = {
5579
6006
  "text-length": textLength,
5580
6007
  $raw
5581
6008
  }) => {
6009
+ if (label == null) return null;
5582
6010
  const { h: x1, v: y1 } = __props.coord2pos({ x: x2, y: y2 });
5583
6011
  const { h: x22, v: y22 } = __props.coord2pos({ x: xend, y: yend });
5584
6012
  if (x1 < xlim_min && x22 < xlim_min || x1 > xlim_max && x22 > xlim_max || y1 < ylim_min && y22 < ylim_min || y1 > ylim_max && y22 > ylim_max) return null;
5585
6013
  let parts = splitLabel(String(label));
5586
6014
  let dx = (xend - x2) / (parts.length - 1 || 1), dy = (yend - y2) / (parts.length - 1 || 1);
5587
- let content = parts.map((v, i) => {
6015
+ let content = parts.map((label2, i) => {
5588
6016
  let $x = x2 + i * dx, $y = y2 + i * dy;
5589
6017
  const { h: tx, v: ty } = __props.coord2pos({ x: $x, y: $y });
5590
6018
  if (typeof textLength == "object") {
@@ -5592,21 +6020,17 @@ const _sfc_main$u = {
5592
6020
  let { h: h1, v: v1 } = __props.coord2pos({ x: $x + lx / 2, y: $y + ly / 2 }), { h: h2, v: v2 } = __props.coord2pos({ x: $x - lx / 2, y: $y - ly / 2 });
5593
6021
  textLength = Math.hypot(h1 - h2 || 0, v1 - v2 || 0);
5594
6022
  }
5595
- return {
5596
- bind: {
5597
- x: tx,
5598
- y: ty,
5599
- "text-anchor": "middle",
5600
- "alignment-baseline": "central",
5601
- textLength,
5602
- lengthAdjust: textLength ? "spacingAndGlyphs" : null
5603
- },
5604
- label: v
6023
+ let vbind2 = {
6024
+ x: tx,
6025
+ y: ty,
6026
+ "text-anchor": "middle",
6027
+ "alignment-baseline": "central",
6028
+ textLength,
6029
+ lengthAdjust: textLength ? "spacingAndGlyphs" : null
5605
6030
  };
6031
+ return [vbind2, label2];
5606
6032
  });
5607
- let result = {
5608
- content,
5609
- title: String(title ?? label),
6033
+ let vbind = {
5610
6034
  fill: color,
5611
6035
  "font-size": size * 4,
5612
6036
  stroke,
@@ -5614,19 +6038,12 @@ const _sfc_main$u = {
5614
6038
  "stroke-dasharray": linetype,
5615
6039
  "fill-opacity": alpha,
5616
6040
  "stroke-opacity": alpha,
5617
- transform: translateX || translateY ? `translate(${translateX}, ${translateY})` : null,
5618
- onClick: (e) => emit("click", e, $raw),
5619
- onContextmenu: (e) => emit("contextmenu", e, $raw),
5620
- onPointerover: (e) => emit("pointerover", e, $raw),
5621
- onPointerout: (e) => emit("pointerout", e, $raw),
5622
- onPointerenter: (e) => emit("pointerenter", e, $raw),
5623
- onPointerleave: (e) => emit("pointerleave", e, $raw),
5624
- onPointerdown: (e) => emit("pointerdown", e, $raw),
5625
- onPointerup: (e) => emit("pointerup", e, $raw),
5626
- onPointermove: (e) => emit("pointermove", e, $raw),
5627
- onWheel: (e) => emit("wheel", e, $raw)
6041
+ transform: translateX || translateY ? `translate(${translateX}, ${translateY})` : null
5628
6042
  };
5629
- return result;
6043
+ let von = Object.fromEntries(
6044
+ events.map((evt) => [evt, (e) => emit(evt, Object.assign(e, { _vhandled: true }), $raw)])
6045
+ );
6046
+ return [vbind, von, content, String(title ?? label)];
5630
6047
  }).filter((x2) => x2 != null));
5631
6048
  });
5632
6049
  function splitLabel(label) {
@@ -5647,15 +6064,16 @@ const _sfc_main$u = {
5647
6064
  return openBlock(), createElementBlock("g", null, [
5648
6065
  (openBlock(true), createElementBlock(Fragment, null, renderList(binds.value, (group) => {
5649
6066
  return openBlock(), createElementBlock("g", null, [
5650
- (openBlock(true), createElementBlock(Fragment, null, renderList(group, (item) => {
5651
- return openBlock(), createElementBlock("text", mergeProps({ ref_for: true }, { ...item, content: null, title: null }), [
5652
- createElementVNode("title", null, toDisplayString(item.title), 1),
5653
- (openBlock(true), createElementBlock(Fragment, null, renderList(item.content, (span) => {
6067
+ (openBlock(true), createElementBlock(Fragment, null, renderList(group, ([vbind, von, content, title]) => {
6068
+ return openBlock(), createElementBlock("text", mergeProps({ ref_for: true }, vbind, toHandlers(von, true)), [
6069
+ createElementVNode("title", null, toDisplayString(title), 1),
6070
+ _cache[0] || (_cache[0] = createTextVNode()),
6071
+ (openBlock(true), createElementBlock(Fragment, null, renderList(content, ([vbind2, label]) => {
5654
6072
  return openBlock(), createElementBlock(Fragment, null, [
5655
- span.label ? (openBlock(), createElementBlock("tspan", mergeProps({
6073
+ label ? (openBlock(), createElementBlock("tspan", mergeProps({
5656
6074
  key: 0,
5657
6075
  ref_for: true
5658
- }, span.bind), toDisplayString(span.label), 17)) : createCommentVNode("", true)
6076
+ }, vbind2), toDisplayString(label), 17)) : createCommentVNode("", true)
5659
6077
  ], 64);
5660
6078
  }), 256))
5661
6079
  ], 16);
@@ -5668,37 +6086,41 @@ const _sfc_main$u = {
5668
6086
  };
5669
6087
  const svg = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5670
6088
  __proto__: null,
5671
- blank: _sfc_main$G,
5672
- curve: _sfc_main$E,
5673
- line: _sfc_main$C,
6089
+ blank: _sfc_main$I,
6090
+ boxplot: _sfc_main$E,
6091
+ curve: _sfc_main$C,
6092
+ line: _sfc_main$B,
5674
6093
  point: _sfc_main$A,
5675
6094
  polygon: _sfc_main$y,
5676
- rect: _sfc_main$w,
5677
- stick: _sfc_main$C,
5678
- text: _sfc_main$v,
5679
- textsegment: _sfc_main$u,
5680
- tile: _sfc_main$w
6095
+ rect: _sfc_main$x,
6096
+ stick: _sfc_main$B,
6097
+ text: _sfc_main$w,
6098
+ textsegment: _sfc_main$v,
6099
+ tile: _sfc_main$x
5681
6100
  }, Symbol.toStringTag, { value: "Module" }));
5682
- const _sfc_main$t = {
6101
+ const _sfc_main$u = {
5683
6102
  __name: "CoreLayer",
5684
6103
  props: {
5685
6104
  data: Object,
5686
6105
  geom: String,
5687
- render: { type: String, default: "auto" }
6106
+ render: String,
6107
+ defaultRender: { type: String, default: "auto" }
5688
6108
  },
5689
6109
  setup(__props, { expose: __expose }) {
5690
6110
  const geoms = { svg, canvas };
5691
6111
  const rend = computed(() => {
5692
- if (__props.render == "auto") {
6112
+ let render = __props.render ?? __props.defaultRender;
6113
+ if (render == "auto") {
5693
6114
  let n_data = __props.data.map((d) => d.length).reduce((a, b) => a + b, 0);
5694
6115
  return n_data > 1e3 ? "canvas" : "svg";
5695
6116
  }
5696
- if (geoms[__props.render][__props.geom] != null) return __props.render;
6117
+ if (geoms[render][__props.geom] != null) return render;
5697
6118
  return "svg";
5698
6119
  });
5699
6120
  const layer = useTemplateRef("layer");
5700
- const style = computed(() => rend.value == "canvas" ? "pointer-events:none;" : "");
6121
+ const style = computed(() => rend.value == "canvas" ? "pointer-events: none;" : "");
5701
6122
  __expose({
6123
+ render: rend,
5702
6124
  dispatchEvent: (e) => layer.value?.dispatchEvent?.(e)
5703
6125
  });
5704
6126
  return (_ctx, _cache) => {
@@ -5716,7 +6138,7 @@ const _hoisted_1$4 = {
5716
6138
  class: "vvplot-interactive"
5717
6139
  };
5718
6140
  const _hoisted_2$3 = ["onPointerdown"];
5719
- const _sfc_main$s = {
6141
+ const _sfc_main$t = {
5720
6142
  __name: "CoreSelection",
5721
6143
  props: /* @__PURE__ */ mergeModels({
5722
6144
  coord2pos: Function,
@@ -5762,12 +6184,12 @@ const _sfc_main$s = {
5762
6184
  y: vmin,
5763
6185
  width,
5764
6186
  height,
5765
- fill: __props.theme?.background ?? "#00000020",
6187
+ fill: __props.theme?.background ?? "transparent",
5766
6188
  "fill-opacity": __props.theme?.opacity,
5767
- stroke: __props.theme?.line_color ?? "transparent",
6189
+ stroke: __props.theme?.line_color ?? "none",
5768
6190
  "stroke-width": __props.theme?.line_width,
5769
6191
  "stroke-opacity": __props.theme?.opacity,
5770
- style: config.move ? "cursor:move;" : "pointer:events-none;"
6192
+ style: config.move ? "cursor:move;" : "pointer-events:none;"
5771
6193
  };
5772
6194
  if (config.resize) {
5773
6195
  if (pos.hmin != null)
@@ -5887,7 +6309,7 @@ const _sfc_main$s = {
5887
6309
  const _hoisted_1$3 = ["height", "width"];
5888
6310
  const _hoisted_2$2 = ["y1", "y2"];
5889
6311
  const _hoisted_3$2 = ["y"];
5890
- const _sfc_main$r = {
6312
+ const _sfc_main$s = {
5891
6313
  __name: "CoreGuideGradientbar",
5892
6314
  props: {
5893
6315
  scales: Array,
@@ -5927,7 +6349,7 @@ const _sfc_main$r = {
5927
6349
  ref: "svg"
5928
6350
  }, [
5929
6351
  (openBlock(true), createElementBlock(Fragment, null, renderList(gradient_values.value, (v, i) => {
5930
- return openBlock(), createBlock(_sfc_main$x, mergeProps({
6352
+ return openBlock(), createBlock(_sfc_main$H, mergeProps({
5931
6353
  width: 10,
5932
6354
  height: 3.1,
5933
6355
  x: 10,
@@ -5935,6 +6357,7 @@ const _sfc_main$r = {
5935
6357
  alpha: __props.appearance.alpha
5936
6358
  }, { ref_for: true }, v), null, 16, ["y", "alpha"]);
5937
6359
  }), 256)),
6360
+ _cache[1] || (_cache[1] = createTextVNode()),
5938
6361
  (openBlock(true), createElementBlock(Fragment, null, renderList(guide_breaks.value, (v, i) => {
5939
6362
  return openBlock(), createElementBlock("g", null, [
5940
6363
  createElementVNode("line", {
@@ -5944,6 +6367,7 @@ const _sfc_main$r = {
5944
6367
  y2: 10 + (1 - v.position) * 90,
5945
6368
  stroke: "black"
5946
6369
  }, null, 8, _hoisted_2$2),
6370
+ _cache[0] || (_cache[0] = createTextVNode()),
5947
6371
  createElementVNode("text", {
5948
6372
  x: "20",
5949
6373
  y: 10 + (1 - v.position) * 90,
@@ -5957,12 +6381,12 @@ const _sfc_main$r = {
5957
6381
  };
5958
6382
  const element = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5959
6383
  __proto__: null,
5960
- curve: _sfc_main$F,
5961
- line: _sfc_main$D,
5962
- point: _sfc_main$B,
6384
+ curve: _sfc_main$D,
6385
+ line: _sfc_main$F,
6386
+ point: _sfc_main$G,
5963
6387
  polygon: _sfc_main$z,
5964
- text: _sfc_main$T,
5965
- tile: _sfc_main$x
6388
+ text: _sfc_main$W,
6389
+ tile: _sfc_main$H
5966
6390
  }, Symbol.toStringTag, { value: "Module" }));
5967
6391
  const _hoisted_1$2 = ["height", "width"];
5968
6392
  const _hoisted_2$1 = ["transform"];
@@ -5972,7 +6396,7 @@ const _hoisted_4$1 = {
5972
6396
  y: "10",
5973
6397
  "alignment-baseline": "central"
5974
6398
  };
5975
- const _sfc_main$q = {
6399
+ const _sfc_main$r = {
5976
6400
  __name: "CoreGuideLegendkey",
5977
6401
  props: {
5978
6402
  scales: Array,
@@ -6026,6 +6450,7 @@ const _sfc_main$q = {
6026
6450
  return openBlock(), createBlock(resolveDynamicComponent(element[geom]), mergeProps({ ref_for: true }, { ...bind, ...v.bind }), null, 16);
6027
6451
  }), 256))
6028
6452
  ]),
6453
+ _cache[0] || (_cache[0] = createTextVNode()),
6029
6454
  createElementVNode("text", _hoisted_4$1, toDisplayString(v.label), 1)
6030
6455
  ], 8, _hoisted_2$1);
6031
6456
  }), 256))
@@ -6033,7 +6458,7 @@ const _sfc_main$q = {
6033
6458
  };
6034
6459
  }
6035
6460
  };
6036
- const _sfc_main$p = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
6461
+ const _sfc_main$q = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
6037
6462
  __name: "CoreGuide",
6038
6463
  props: {
6039
6464
  scales: Array,
@@ -6041,8 +6466,8 @@ const _sfc_main$p = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
6041
6466
  },
6042
6467
  setup(__props) {
6043
6468
  const guide = {
6044
- legendkey: _sfc_main$q,
6045
- gradientbar: _sfc_main$r
6469
+ legendkey: _sfc_main$r,
6470
+ gradientbar: _sfc_main$s
6046
6471
  };
6047
6472
  const title = computed(() => {
6048
6473
  return __props.scales.map(([s]) => s.title).find((v) => v != null);
@@ -6064,28 +6489,29 @@ const _sfc_main$p = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
6064
6489
  let result = { scales: __props.scales.map(([s]) => s) };
6065
6490
  if (__props.type == "legendkey") {
6066
6491
  result.appearances = {
6067
- text: obj_merge(__props.scales.flatMap(([s, a]) => [a.text])),
6068
- line: obj_merge(__props.scales.flatMap(([s, a]) => [a.line, a.linerange, a.curve])),
6069
- point: obj_merge(__props.scales.flatMap(([s, a]) => [a.point])),
6070
- tile: obj_merge(__props.scales.flatMap(([s, a]) => [a.rect, a.tile, a.polygon]))
6492
+ text: obj_merge(...__props.scales.flatMap(([s, a]) => [a.text])),
6493
+ line: obj_merge(...__props.scales.flatMap(([s, a]) => [a.line, a.linerange, a.curve])),
6494
+ point: obj_merge(...__props.scales.flatMap(([s, a]) => [a.point])),
6495
+ tile: obj_merge(...__props.scales.flatMap(([s, a]) => [a.rect, a.tile, a.polygon]))
6071
6496
  };
6072
6497
  } else if (__props.type == "gradientbar") {
6073
6498
  let max = __props.scales.map(([s]) => s.limits?.max).filter((v) => v != null).reduce((a, b) => Math.min(a, b), Infinity);
6074
6499
  let min = __props.scales.map(([s]) => s.limits?.min).filter((v) => v != null).reduce((a, b) => Math.max(a, b), -Infinity);
6075
6500
  result.limits = { min, max };
6076
- result.appearance = obj_merge(__props.scales.flatMap(([s, a]) => Object.values(a)));
6501
+ result.appearance = obj_merge(...__props.scales.flatMap(([s, a]) => Object.values(a)));
6077
6502
  }
6078
6503
  return result;
6079
6504
  });
6080
6505
  return (_ctx, _cache) => {
6081
6506
  return openBlock(), createElementBlock(Fragment, null, [
6082
6507
  createElementVNode("span", null, toDisplayString(title.value), 1),
6508
+ _cache[0] || (_cache[0] = createTextVNode()),
6083
6509
  (openBlock(), createBlock(resolveDynamicComponent(guide[__props.type]), mergeProps(binds.value, { breaks: breaks.value }), null, 16, ["breaks"]))
6084
6510
  ], 64);
6085
6511
  };
6086
6512
  }
6087
6513
  });
6088
- const _sfc_main$o = {
6514
+ const _sfc_main$p = {
6089
6515
  __name: "CoreLegend",
6090
6516
  props: {
6091
6517
  theme: { type: Object, default: () => ({}) },
@@ -6093,7 +6519,10 @@ const _sfc_main$o = {
6093
6519
  },
6094
6520
  setup(__props) {
6095
6521
  const guides = computed(() => {
6096
- let scale_fns = Array.from(__props.scales.keys());
6522
+ let guide_scales = new Map(
6523
+ Array.from(__props.scales).filter(([fn]) => fn.legend !== false)
6524
+ );
6525
+ let scale_fns = Array.from(guide_scales.keys());
6097
6526
  let keys = scale_fns.map((s) => s.key);
6098
6527
  let j = 1;
6099
6528
  for (let i in keys) {
@@ -6102,7 +6531,7 @@ const _sfc_main$o = {
6102
6531
  }
6103
6532
  let types = scale_fns.map((s) => getGuideType(s));
6104
6533
  let groups = interaction(keys, types);
6105
- return Map.groupBy(__props.scales, (s, i) => groups.categories[groups[i]]);
6534
+ return Map.groupBy(guide_scales, (s, i) => groups.categories[groups[i]]);
6106
6535
  });
6107
6536
  function getGuideType(scale) {
6108
6537
  if (scale == null) return null;
@@ -6118,7 +6547,7 @@ const _sfc_main$o = {
6118
6547
  style: normalizeStyle({ gap: __props.theme.spacing + "px" })
6119
6548
  }, [
6120
6549
  (openBlock(true), createElementBlock(Fragment, null, renderList(guides.value, ([[key, type], scales]) => {
6121
- return openBlock(), createBlock(_sfc_main$p, {
6550
+ return openBlock(), createBlock(_sfc_main$q, {
6122
6551
  key,
6123
6552
  type,
6124
6553
  scales
@@ -6136,12 +6565,11 @@ const _hoisted_5 = ["transform", "clip-path"];
6136
6565
  const _hoisted_6 = ["transform"];
6137
6566
  const _hoisted_7 = ["clip-path"];
6138
6567
  const _hoisted_8 = { key: 1 };
6139
- const _sfc_main$n = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
6568
+ const _sfc_main$o = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
6140
6569
  __name: "CorePlot",
6141
6570
  props: /* @__PURE__ */ mergeModels({
6142
6571
  schema: Object,
6143
6572
  layers: Array,
6144
- range: Object,
6145
6573
  minRange: Object,
6146
6574
  expandAdd: Object,
6147
6575
  flip: Boolean,
@@ -6153,6 +6581,7 @@ const _sfc_main$n = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
6153
6581
  scales: Object,
6154
6582
  axes: { type: Array, default: () => [] },
6155
6583
  theme: Object,
6584
+ render: String,
6156
6585
  clip: Boolean,
6157
6586
  action: { type: Array, default: () => [] },
6158
6587
  selections: { type: Array, default: () => [] },
@@ -6196,24 +6625,26 @@ const _sfc_main$n = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
6196
6625
  selectionPreview.value = modelValue;
6197
6626
  selectionPreviewTheme.value = theme;
6198
6627
  }
6628
+ const _selectionPreviewTheme = computed(() => Object.assign({}, __props.theme?.selection, selectionPreviewTheme.value));
6199
6629
  function onselectend() {
6200
6630
  selectionPreview.value = {};
6201
6631
  }
6202
6632
  const transition = useModel(__props, "transition");
6203
6633
  const svgRef = useTemplateRef("svg");
6204
6634
  const layers = useTemplateRef("layers");
6205
- const { width, height } = useElementSize(svgRef);
6635
+ const width = ref(0), height = ref(0);
6636
+ useResizeObserver(svgRef, (entries) => {
6637
+ let { width: w, height: h } = entries[0].contentRect;
6638
+ width.value = w;
6639
+ height.value = h;
6640
+ });
6206
6641
  const gplot = computed(() => new GPlot(__props.schema, props.layers));
6207
6642
  const vplot = computed(() => {
6208
- return gplot.value.useScales(__props.scales, __props.levels).useCoordLevels(__props.coordLevels).render(
6209
- range,
6210
- __props.expandAdd,
6211
- props.minRange
6212
- );
6643
+ return gplot.value.useScales(__props.scales, __props.levels).useCoordLevels(__props.coordLevels).render(range, __props.expandAdd, props.minRange);
6213
6644
  });
6214
6645
  const panel = reactiveComputed(() => {
6215
- let padding = Object.fromEntries(["left", "right", "top", "bottom"].map((p) => [p, __props.paddings[p] ? __props.theme.plot.padding[p] || 0 : 0]));
6216
- let l = __props.theme.plot.margin.left + padding.left, r = __props.theme.plot.margin.right + padding.right, t = __props.theme.plot.margin.top + padding.top, b = __props.theme.plot.margin.bottom + padding.bottom;
6646
+ let padding = Object.fromEntries(["left", "right", "top", "bottom"].map((p) => [p, __props.paddings[p] && __props.theme.plot.padding[p] || 0]));
6647
+ let l = +__props.theme.plot.margin.left + padding.left, r = +__props.theme.plot.margin.right + padding.right, t = +__props.theme.plot.margin.top + padding.top, b = +__props.theme.plot.margin.bottom + padding.bottom;
6217
6648
  if (t + b > height.value) {
6218
6649
  t = height.value * (t / (t + b));
6219
6650
  b = height.value - t;
@@ -6324,15 +6755,15 @@ const _sfc_main$n = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
6324
6755
  function _coord2pos({ value, min, max } = {}, { oob = oob_squish_infinite } = {}, scale, rev, length, boundary) {
6325
6756
  let result = {};
6326
6757
  if (value != null) {
6327
- result.value = oob(length * (rev ? 1 - scale(value) : scale(value)), boundary);
6758
+ result.value = length ? oob(length * (rev ? 1 - scale(value) : scale(value)), boundary) : 0;
6328
6759
  }
6329
6760
  if (min == null && max == null) return result;
6330
6761
  if (rev) {
6331
- if (max != null) result.min = oob(length * (1 - scale(max)), boundary);
6332
- if (min != null) result.max = oob(length * (1 - scale(min)), boundary);
6762
+ if (max != null) result.min = length ? oob(length * (1 - scale(max)), boundary) : 0;
6763
+ if (min != null) result.max = length ? oob(length * (1 - scale(min)), boundary) : 0;
6333
6764
  } else {
6334
- if (min != null) result.min = oob(length * scale(min), boundary);
6335
- if (max != null) result.max = oob(length * scale(max), boundary);
6765
+ if (min != null) result.min = length ? oob(length * scale(min), boundary) : 0;
6766
+ if (max != null) result.max = length ? oob(length * scale(max), boundary) : 0;
6336
6767
  }
6337
6768
  return result;
6338
6769
  }
@@ -6400,7 +6831,7 @@ const _sfc_main$n = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
6400
6831
  }
6401
6832
  function getPadding({ min: $min, max: $max } = {}, { min: mmin = 0, max: mmax = 0 } = {}) {
6402
6833
  let $interval = $max - $min;
6403
- let min = $min - mmin * $interval, max = $max + mmax * $interval, interval = max - min;
6834
+ let min = +$min - mmin * $interval, max = +$max + mmax * $interval, interval = max - min;
6404
6835
  return {
6405
6836
  min: interval == 0 ? 0 : ($min - min) / interval,
6406
6837
  max: interval == 0 ? 0 : (max - $max) / interval
@@ -6416,10 +6847,34 @@ const _sfc_main$n = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
6416
6847
  let rect = svgRef.value.getBoundingClientRect();
6417
6848
  return event.clientX > rect.left + panel.l && event.clientX < rect.right - panel.r && event.clientY > rect.top + panel.t && event.clientY < rect.bottom - panel.b;
6418
6849
  }
6850
+ function dispatchPointerEvent(e) {
6851
+ if (!layers.value || e._vhandled || !isInPlot(e)) return e;
6852
+ let canvasLayers = Array.from(layers.value).filter((l) => l.render == "canvas");
6853
+ if (!canvasLayers.length) return e;
6854
+ let options = {};
6855
+ for (let key in e) options[key] = e[key];
6856
+ options.bubbles = false;
6857
+ let event = new PointerEvent(e.type, options);
6858
+ for (let key of Object.keys(e)) {
6859
+ let prop = Object.getOwnPropertyDescriptor(event, key);
6860
+ if (prop && !prop.writable && !prop.set) continue;
6861
+ event[key] = e[key];
6862
+ }
6863
+ for (let i = layers.value.length - 1; i >= 0; i--)
6864
+ if (layers.value[i].dispatchEvent(event) === false) e.preventDefault();
6865
+ for (let key of Object.keys(event)) {
6866
+ let prop = Object.getOwnPropertyDescriptor(event, key);
6867
+ if (prop && !prop.writable && !prop.set) continue;
6868
+ e[key] = event[key];
6869
+ }
6870
+ return event._vhandled ? event : e;
6871
+ }
6419
6872
  let moveTimer, movementX = 0, movementY = 0;
6420
6873
  function svgPointerdown(e) {
6421
- let coord = getCoord(e);
6422
- emit("pointerdown", e, coord);
6874
+ let evt = dispatchPointerEvent(e), coord = getCoord(e);
6875
+ emit("pointerdown", evt, coord);
6876
+ if (evt.defaultPrevented) e.preventDefault();
6877
+ if (props.clip && !isInPlot(e)) return;
6423
6878
  let svg2 = e.currentTarget;
6424
6879
  let pointerMoved = false;
6425
6880
  function detectMove(ev) {
@@ -6432,16 +6887,10 @@ const _sfc_main$n = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
6432
6887
  e.target.addEventListener("pointerup", function(ev) {
6433
6888
  e.target.removeEventListener("pointermove", detectMove);
6434
6889
  if (!pointerMoved) {
6435
- let coord2 = getCoord(ev);
6436
- emit("singleclick", new PointerEvent("singleclick", ev), coord2);
6437
- if (isInPlot(e) && layers.value) {
6438
- if (ev.button == 0) {
6439
- layers.value.forEach((layer) => layer.dispatchEvent(new PointerEvent("click", ev)));
6440
- }
6441
- }
6890
+ let event = new PointerEvent("singleclick", ev);
6891
+ ev.target.dispatchEvent(event);
6442
6892
  }
6443
6893
  }, { once: true });
6444
- if (props.clip && !isInPlot(e)) return;
6445
6894
  let sel = props.selections.find((s) => ["buttons", "ctrlKey", "shiftKey", "altKey", "metaKey"].every((k) => s[k] == e[k]));
6446
6895
  if (sel) {
6447
6896
  let { x: x2 = false, y: y2 = false, "min-range-x": mrx = 0, "min-range-y": mry = 0 } = sel;
@@ -6449,8 +6898,8 @@ const _sfc_main$n = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
6449
6898
  svg2.style.userSelect = "none";
6450
6899
  let xboundary = (({ xmin: min, xmax: max }) => ({ min, max }))(sel), yboundary = (({ ymin: min, ymax: max }) => ({ min, max }))(sel);
6451
6900
  e.target.onpointermove = (ev) => {
6901
+ if (!x2 && !y2 || !pointerMoved) return;
6452
6902
  let coordMove = getCoord(ev);
6453
- if (!x2 && !y2) return;
6454
6903
  let res = {};
6455
6904
  if (x2) {
6456
6905
  let xstart = oob_squish_any(coord.x, xboundary), xend = oob_squish_any(oob_squish_any(coordMove.x, coordMove.x > xstart ? { min: plus(xstart, mrx) } : { max: plus(xstart, -mrx) }), xboundary);
@@ -6506,12 +6955,12 @@ const _sfc_main$n = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
6506
6955
  }
6507
6956
  }
6508
6957
  if (!pointerMoved && sel.dismissible !== false) {
6509
- if (ev.defaultPrevented || ev.handled) return;
6958
+ if (ev.defaultPrevented) return;
6510
6959
  let model = sel.modelValue;
6511
6960
  if (sel.dismissible !== true && ["xmin", "xmax", "ymin", "ymax"].every((k) => model?.[k] == null)) return;
6512
6961
  let res = {}, event = new PointerEvent("select", e);
6513
6962
  sel["onUpdate:modelValue"]?.(res);
6514
- if (!emitEvent(sel["onCancel"], dropNull(res), event)) {
6963
+ if (!emitEvent(sel["onDismiss"], dropNull(res), event)) {
6515
6964
  emit("select", dropNull(res), event);
6516
6965
  }
6517
6966
  }
@@ -6557,8 +7006,9 @@ const _sfc_main$n = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
6557
7006
  }
6558
7007
  let wheelDelta = 0, wheelTimer;
6559
7008
  function svgWheel(e) {
6560
- let coord = getCoord(e);
6561
- emit("wheel", e, coord);
7009
+ let evt = dispatchPointerEvent(e), coord = getCoord(e);
7010
+ emit("wheel", evt, coord);
7011
+ if (evt.defaultPrevented) e.preventDefault();
6562
7012
  if (props.clip && !isInPlot(e)) return;
6563
7013
  let act = props.action.find((a) => ["zoom", "nudge"].includes(a.action) && ["ctrlKey", "shiftKey", "altKey", "metaKey"].every((k) => a[k] == e[k]));
6564
7014
  if (!act || !act.x && !act.y) return;
@@ -6634,18 +7084,22 @@ const _sfc_main$n = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
6634
7084
  if (!dh && !dv && sh == 1 && sv == 1) transition.value = null;
6635
7085
  }, { deep: true });
6636
7086
  function applyTransform(act, event) {
6637
- if (!Object.keys(dropNull(rangePreview) ?? {}).length) return;
6638
- if (!emitEvent(act.emit, rangePreview, event)) {
6639
- emit(act.action, rangePreview, event);
7087
+ let coord = dropNull(rangePreview) ?? {};
7088
+ if (!Object.keys(coord).length) return;
7089
+ let e = new PointerEvent(event.type, event);
7090
+ if (!emitEvent(act.emit, coord, e)) {
7091
+ emit(act.action, coord, e);
6640
7092
  }
6641
- changerange(rangePreview);
7093
+ changerange(coord);
6642
7094
  let xmin, xmax, ymin, ymax;
6643
7095
  Object.assign(rangePreview, { xmin, xmax, ymin, ymax });
6644
7096
  }
6645
7097
  const svgVOn = {
6646
7098
  pointerdown: svgPointerdown,
6647
7099
  pointerup(e) {
6648
- emit("pointerup", e, getCoord(e));
7100
+ let evt = dispatchPointerEvent(e), coord = getCoord(e);
7101
+ emit("pointerup", evt, coord);
7102
+ if (evt.defaultPrevented) e.preventDefault();
6649
7103
  },
6650
7104
  pointerover(e) {
6651
7105
  emit("pointerover", e, getCoord(e));
@@ -6659,31 +7113,40 @@ const _sfc_main$n = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
6659
7113
  pointerleave(e) {
6660
7114
  emit("pointerleave", e, getCoord(e));
6661
7115
  },
6662
- dblclick(e) {
6663
- emit("dblclick", e, getCoord(e));
6664
- },
6665
7116
  click(e) {
6666
- emit("click", e, getCoord(e));
7117
+ emit("click", dispatchPointerEvent(e), getCoord(e));
6667
7118
  },
6668
7119
  contextmenu(e) {
6669
- emit("contextmenu", e, getCoord(e));
7120
+ let evt = dispatchPointerEvent(e), coord = getCoord(e);
7121
+ emit("contextmenu", evt, coord);
7122
+ if (evt.defaultPrevented) e.preventDefault();
7123
+ },
7124
+ singleclick(e) {
7125
+ emit("singleclick", dispatchPointerEvent(e), getCoord(e));
7126
+ },
7127
+ dblclick(e) {
7128
+ let evt = dispatchPointerEvent(e), coord = getCoord(e);
7129
+ emit("dblclick", evt, coord);
7130
+ if (evt.defaultPrevented) e.preventDefault();
6670
7131
  },
6671
7132
  pointermove(e) {
6672
- emit("pointermove", e, getCoord(e));
7133
+ let evt = dispatchPointerEvent(e), coord = getCoord(e);
7134
+ emit("pointermove", evt, coord);
7135
+ if (evt.defaultPrevented) e.preventDefault();
6673
7136
  },
6674
7137
  wheel: svgWheel
6675
7138
  };
6676
7139
  function changerange(coord) {
6677
7140
  let { xmin, xmax, ymin, ymax } = coord;
6678
7141
  let { xmin: $xmin, xmax: $xmax, ymin: $ymin, ymax: $ymax } = range;
6679
- xmin = xmin != null ? plus(xmin, __props.expandAdd.x.min) : $xmin;
7142
+ xmin = xmin != null ? plus(xmin, +__props.expandAdd.x.min) : $xmin;
6680
7143
  xmax = xmax != null ? plus(xmax, -__props.expandAdd.x.max) : $xmax;
6681
- ymin = ymin != null ? plus(ymin, __props.expandAdd.y.min) : $ymin;
7144
+ ymin = ymin != null ? plus(ymin, +__props.expandAdd.y.min) : $ymin;
6682
7145
  ymax = ymax != null ? plus(ymax, -__props.expandAdd.y.max) : $ymax;
6683
7146
  if (xmin == $xmin && xmax == $xmax && ymin == $ymin && ymax == $ymax) return;
6684
7147
  Object.assign(range, { xmin, xmax, ymin, ymax });
6685
7148
  }
6686
- const axisLimits = reactiveComputed(() => {
7149
+ const axisRange = reactiveComputed(() => {
6687
7150
  let xmin = rangePreview?.xmin ?? range?.xmin, xmax = rangePreview?.xmax ?? range?.xmax, ymin = rangePreview?.ymin ?? range?.ymin, ymax = rangePreview?.ymax ?? range?.ymax;
6688
7151
  return {
6689
7152
  x: xmin || xmax ? { min: xmin, max: xmax } : void 0,
@@ -6692,24 +7155,27 @@ const _sfc_main$n = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
6692
7155
  });
6693
7156
  const gaxes = computed(() => {
6694
7157
  let coordScales = {
6695
- x: vplot.value.coordScales.x.expand(__props.expandMult?.x),
6696
- y: vplot.value.coordScales.y.expand(__props.expandMult?.y)
7158
+ x: vplot.value.coordScales.x,
7159
+ y: vplot.value.coordScales.y
6697
7160
  };
6698
7161
  return props.axes.filter((a) => a.coord in coordScales).filter((a) => ["h", "v"].includes(a.orientation)).map(({
6699
7162
  coord,
6700
7163
  breaks,
6701
- extend: extend2,
6702
7164
  labels,
7165
+ titles,
6703
7166
  minorBreaks,
6704
7167
  ...etc
6705
7168
  }) => ({
6706
7169
  coord,
6707
- axis: new GAxis(coordScales[coord], { breaks, extend: extend2, labels, minorBreaks }),
7170
+ axis: new GAxis(coordScales[coord], { breaks, labels, titles, minorBreaks }),
6708
7171
  etc
6709
7172
  }));
6710
7173
  });
6711
7174
  const vaxes = computed(() => gaxes.value.map(({ coord, axis, etc }) => {
6712
- let { majorBreaks, minorBreaks, ticks } = axis.getBindings({ limits: axisLimits[coord] });
7175
+ let { majorBreaks, minorBreaks, ticks } = axis.getBindings({
7176
+ range: axisRange[coord],
7177
+ expandMult: __props.expandMult[coord]
7178
+ });
6713
7179
  let { showGrid, orientation, ...bind } = etc;
6714
7180
  return {
6715
7181
  majorBreaks,
@@ -6725,12 +7191,12 @@ const _sfc_main$n = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
6725
7191
  let hAxes = vaxes.value.filter((a) => a.showGrid && a.orientation == "v"), vAxes = vaxes.value.filter((a) => a.showGrid && a.orientation == "h");
6726
7192
  return {
6727
7193
  h: {
6728
- majorBreaks: unique(hAxes.flatMap((a) => a.majorBreaks)),
6729
- minorBreaks: unique(hAxes.flatMap((a) => a.minorBreaks))
7194
+ majorBreaks: unique(hAxes.flatMap((a) => a.majorBreaks), (x2) => x2.position),
7195
+ minorBreaks: unique(hAxes.flatMap((a) => a.minorBreaks), (x2) => x2.position)
6730
7196
  },
6731
7197
  v: {
6732
- majorBreaks: unique(vAxes.flatMap((a) => a.majorBreaks)),
6733
- minorBreaks: unique(vAxes.flatMap((a) => a.minorBreaks))
7198
+ majorBreaks: unique(vAxes.flatMap((a) => a.majorBreaks), (x2) => x2.position),
7199
+ minorBreaks: unique(vAxes.flatMap((a) => a.minorBreaks), (x2) => x2.position)
6734
7200
  }
6735
7201
  };
6736
7202
  });
@@ -6776,6 +7242,7 @@ const _sfc_main$n = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
6776
7242
  }, null, 8, _hoisted_2)
6777
7243
  ], 8, _hoisted_1$1)
6778
7244
  ]),
7245
+ _cache[6] || (_cache[6] = createTextVNode()),
6779
7246
  __props.theme.plot.background ? (openBlock(), createElementBlock("rect", {
6780
7247
  key: 0,
6781
7248
  transform: `translate(${unref(panel).left}, ${unref(panel).top})`,
@@ -6783,17 +7250,20 @@ const _sfc_main$n = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
6783
7250
  height: unref(panel).height,
6784
7251
  fill: __props.theme.plot.background
6785
7252
  }, null, 8, _hoisted_3)) : createCommentVNode("", true),
7253
+ _cache[7] || (_cache[7] = createTextVNode()),
6786
7254
  createElementVNode("g", {
6787
- transform: `translate(${unref(panel).left}, ${unref(panel).top})`
7255
+ transform: `translate(${unref(panel).left}, ${unref(panel).top})`,
7256
+ style: { "pointer-events": "none" }
6788
7257
  }, [
6789
- __props.theme.grid.h ? (openBlock(), createBlock(_sfc_main$P, mergeProps({ key: 0 }, gridBreaks.value.h, {
7258
+ __props.theme.grid.h ? (openBlock(), createBlock(_sfc_main$S, mergeProps({ key: 0 }, gridBreaks.value.h, {
6790
7259
  layout: unref(innerRect),
6791
7260
  theme: __props.theme.grid.h,
6792
7261
  activeTransform: activeTransform.value,
6793
7262
  coord2pos,
6794
7263
  transition: transition.value
6795
7264
  }), null, 16, ["layout", "theme", "activeTransform", "transition"])) : createCommentVNode("", true),
6796
- __props.theme.grid.v ? (openBlock(), createBlock(_sfc_main$O, mergeProps({ key: 1 }, gridBreaks.value.v, {
7265
+ _cache[2] || (_cache[2] = createTextVNode()),
7266
+ __props.theme.grid.v ? (openBlock(), createBlock(_sfc_main$R, mergeProps({ key: 1 }, gridBreaks.value.v, {
6797
7267
  layout: unref(innerRect),
6798
7268
  theme: __props.theme.grid.v,
6799
7269
  activeTransform: activeTransform.value,
@@ -6801,6 +7271,7 @@ const _sfc_main$n = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
6801
7271
  transition: transition.value
6802
7272
  }), null, 16, ["layout", "theme", "activeTransform", "transition"])) : createCommentVNode("", true)
6803
7273
  ], 8, _hoisted_4),
7274
+ _cache[8] || (_cache[8] = createTextVNode()),
6804
7275
  createElementVNode("g", {
6805
7276
  transform: `translate(${unref(panel).left}, ${unref(panel).top})`,
6806
7277
  "clip-path": props.clip ? `url(#${unref(vid)}-plot-clip)` : null
@@ -6809,7 +7280,7 @@ const _sfc_main$n = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
6809
7280
  style: { transition: transition.value }
6810
7281
  }), [
6811
7282
  (openBlock(true), createElementBlock(Fragment, null, renderList(vplot.value.layers, (layer) => {
6812
- return openBlock(), createBlock(_sfc_main$t, mergeProps({
7283
+ return openBlock(), createBlock(_sfc_main$u, mergeProps({
6813
7284
  ref_for: true,
6814
7285
  ref_key: "layers",
6815
7286
  ref: layers,
@@ -6817,11 +7288,13 @@ const _sfc_main$n = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
6817
7288
  }, { ref_for: true }, layer.vBind, {
6818
7289
  layout: unref(innerRect),
6819
7290
  geom: layer.geom,
6820
- coord2pos
6821
- }), null, 16, ["data", "layout", "geom"]);
7291
+ coord2pos,
7292
+ "default-render": props.render
7293
+ }), null, 16, ["data", "layout", "geom", "default-render"]);
6822
7294
  }), 256)),
7295
+ _cache[3] || (_cache[3] = createTextVNode()),
6823
7296
  (openBlock(true), createElementBlock(Fragment, null, renderList(props.selections, (sel) => {
6824
- return openBlock(), createBlock(_sfc_main$s, mergeProps({
7297
+ return openBlock(), createBlock(_sfc_main$t, mergeProps({
6825
7298
  coord2pos,
6826
7299
  pos2coord,
6827
7300
  layout: unref(innerRect),
@@ -6829,31 +7302,34 @@ const _sfc_main$n = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
6829
7302
  onSelectend: onselectend
6830
7303
  }, { ref_for: true }, sel, { flip: __props.flip }), null, 16, ["layout", "flip"]);
6831
7304
  }), 256)),
6832
- createVNode(_sfc_main$s, {
7305
+ _cache[4] || (_cache[4] = createTextVNode()),
7306
+ createVNode(_sfc_main$t, {
6833
7307
  coord2pos,
6834
7308
  pos2coord,
6835
7309
  layout: unref(innerRect),
6836
7310
  modelValue: selectionPreview.value,
6837
- theme: selectionPreviewTheme.value,
7311
+ theme: _selectionPreviewTheme.value,
6838
7312
  flip: __props.flip
6839
7313
  }, null, 8, ["layout", "modelValue", "theme", "flip"])
6840
7314
  ], 16)
6841
7315
  ], 8, _hoisted_5),
7316
+ _cache[9] || (_cache[9] = createTextVNode()),
6842
7317
  createElementVNode("g", {
6843
7318
  transform: `translate(${unref(panel).left}, ${unref(panel).top})`
6844
7319
  }, [
6845
7320
  (openBlock(true), createElementBlock(Fragment, null, renderList(axes.value.filter((a) => typeof a.bind.position !== "number"), (axis) => {
6846
- return openBlock(), createBlock(_sfc_main$Q, mergeProps({ ref_for: true }, axis.bind, toHandlers(axis.on), {
7321
+ return openBlock(), createBlock(_sfc_main$T, mergeProps({ ref_for: true }, axis.bind, toHandlers(axis.on), {
6847
7322
  transition: transition.value,
6848
7323
  "onUpdate:transition": _cache[0] || (_cache[0] = ($event) => transition.value = $event),
6849
7324
  activeTransform: activeTransform.value
6850
7325
  }), null, 16, ["transition", "activeTransform"]);
6851
7326
  }), 256)),
7327
+ _cache[5] || (_cache[5] = createTextVNode()),
6852
7328
  createElementVNode("g", {
6853
7329
  "clip-path": props.clip ? `url(#${unref(vid)}-plot-clip)` : null
6854
7330
  }, [
6855
7331
  (openBlock(true), createElementBlock(Fragment, null, renderList(axes.value.filter((a) => typeof a.bind.position === "number"), (axis) => {
6856
- return openBlock(), createBlock(_sfc_main$Q, mergeProps({ ref_for: true }, axis.bind, toHandlers(axis.on), {
7332
+ return openBlock(), createBlock(_sfc_main$T, mergeProps({ ref_for: true }, axis.bind, toHandlers(axis.on), {
6857
7333
  transition: transition.value,
6858
7334
  "onUpdate:transition": _cache[1] || (_cache[1] = ($event) => transition.value = $event),
6859
7335
  activeTransform: activeTransform.value
@@ -6861,12 +7337,13 @@ const _sfc_main$n = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
6861
7337
  }), 256))
6862
7338
  ], 8, _hoisted_7)
6863
7339
  ], 8, _hoisted_6),
7340
+ _cache[10] || (_cache[10] = createTextVNode()),
6864
7341
  props.legendTeleport ? (openBlock(), createElementBlock("foreignObject", _hoisted_8, [
6865
7342
  (openBlock(), createBlock(Teleport, {
6866
7343
  defer: "",
6867
7344
  to: props.legendTeleport
6868
7345
  }, [
6869
- createVNode(_sfc_main$o, {
7346
+ createVNode(_sfc_main$p, {
6870
7347
  scales: vplot.value?.scales,
6871
7348
  theme: __props.theme.legend
6872
7349
  }, null, 8, ["scales", "theme"])
@@ -6876,24 +7353,31 @@ const _sfc_main$n = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
6876
7353
  };
6877
7354
  }
6878
7355
  });
6879
- const _sfc_main$m = {
7356
+ const _sfc_main$n = {
6880
7357
  $_type: "action",
6881
7358
  $_props: {}
6882
7359
  };
6883
- const _sfc_main$l = {
7360
+ const _sfc_main$m = {
6884
7361
  $_type: "layer"
6885
7362
  };
6886
- const _sfc_main$k = {
7363
+ const _sfc_main$l = {
6887
7364
  $_props: {
6888
7365
  geom: "tile",
6889
7366
  stat: "bar"
6890
7367
  },
6891
7368
  $_type: "layer"
6892
7369
  };
6893
- const _sfc_main$j = {
7370
+ const _sfc_main$k = {
6894
7371
  $_props: {
6895
7372
  geom: "blank",
6896
- stat: "blank"
7373
+ stat: "identity"
7374
+ },
7375
+ $_type: "layer"
7376
+ };
7377
+ const _sfc_main$j = {
7378
+ $_props: {
7379
+ geom: "boxplot",
7380
+ stat: "boxplot"
6897
7381
  },
6898
7382
  $_type: "layer"
6899
7383
  };
@@ -7000,9 +7484,10 @@ const _sfc_main$5 = {
7000
7484
  };
7001
7485
  const geom_components = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7002
7486
  __proto__: null,
7003
- VVGeom: _sfc_main$l,
7004
- VVGeomBar: _sfc_main$k,
7005
- VVGeomBlank: _sfc_main$j,
7487
+ VVGeom: _sfc_main$m,
7488
+ VVGeomBar: _sfc_main$l,
7489
+ VVGeomBlank: _sfc_main$k,
7490
+ VVGeomBoxplot: _sfc_main$j,
7006
7491
  VVGeomCurve: _sfc_main$i,
7007
7492
  VVGeomDensity: _sfc_main$h,
7008
7493
  VVGeomHistogram: _sfc_main$g,
@@ -7036,7 +7521,10 @@ const axis_components = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.def
7036
7521
  VVAxisX: _sfc_main$3,
7037
7522
  VVAxisY: _sfc_main$2
7038
7523
  }, Symbol.toStringTag, { value: "Module" }));
7039
- const _hoisted_1 = { class: "vvplot-panel" };
7524
+ const _hoisted_1 = {
7525
+ key: 0,
7526
+ class: "vvplot-panel"
7527
+ };
7040
7528
  const _sfc_main$1 = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
7041
7529
  __name: "Plot",
7042
7530
  props: /* @__PURE__ */ mergeModels({
@@ -7054,6 +7542,7 @@ const _sfc_main$1 = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
7054
7542
  theme: [Object, Array],
7055
7543
  action: [Object, Array],
7056
7544
  reverse: Object,
7545
+ render: String,
7057
7546
  flip: Boolean,
7058
7547
  clip: { type: Boolean, default: true },
7059
7548
  resize: null,
@@ -7075,8 +7564,18 @@ const _sfc_main$1 = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
7075
7564
  const components = {
7076
7565
  ...geom_components,
7077
7566
  ...axis_components,
7078
- VVAction: _sfc_main$m,
7079
- VVSelection: _sfc_main$m
7567
+ VVAction: _sfc_main$n,
7568
+ VVSelection: _sfc_main$n
7569
+ };
7570
+ const opponents = {
7571
+ x: "y",
7572
+ y: "x",
7573
+ h: "v",
7574
+ v: "h",
7575
+ top: "bottom",
7576
+ bottom: "top",
7577
+ left: "right",
7578
+ right: "left"
7080
7579
  };
7081
7580
  function _isPropTruthy(v) {
7082
7581
  if (v == null) return v;
@@ -7264,11 +7763,6 @@ const _sfc_main$1 = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
7264
7763
  let max = primaryAxisConfig.max[ori] ?? __props.range?.[ori + "max"];
7265
7764
  result[ori + "min"] = isFinite(min) && !Number.isNaN(min) ? min : null;
7266
7765
  result[ori + "max"] = isFinite(max) && !Number.isNaN(max) ? max : null;
7267
- let level = coordLevels.value[ori];
7268
- if (level != null) {
7269
- result[ori + "min"] = (result[ori + "min"] ?? 0) - 0.5;
7270
- result[ori + "max"] = (result[ori + "max"] ?? level.length ?? Math.max(Object.values(level))) - 0.5;
7271
- }
7272
7766
  }
7273
7767
  return result;
7274
7768
  });
@@ -7319,7 +7813,7 @@ const _sfc_main$1 = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
7319
7813
  if (newRange?.ymax !== oldRange?.ymax)
7320
7814
  rangePreview.ymax = newRange.ymax;
7321
7815
  }, { immediate: true });
7322
- watch(() => range, (newRange, oldRange) => {
7816
+ watch(() => ({ ...range }), (newRange, oldRange) => {
7323
7817
  for (let key in rangeUpdate) {
7324
7818
  rangeUpdate[key]?.(newRange[key]);
7325
7819
  }
@@ -7354,14 +7848,13 @@ const _sfc_main$1 = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
7354
7848
  else if (typeof y2 == "number") y2 = { min: y2, max: y2 };
7355
7849
  return { x: x2, y: y2 };
7356
7850
  });
7357
- const reverse = computed(() => ({
7851
+ const reverse = reactiveComputed(() => ({
7358
7852
  x: _isPropTruthy(primaryAxisConfig.reverse.x) ?? __props.reverse?.x ?? false,
7359
7853
  y: _isPropTruthy(primaryAxisConfig.reverse.y) ?? __props.reverse?.y ?? false
7360
7854
  }));
7361
7855
  const buttonsMap = { left: 1, right: 2, middle: 4, X1: 8, X2: 16 };
7362
7856
  const axes = computed(() => {
7363
7857
  let ori = __props.flip ? { x: "v", y: "h" } : { x: "h", y: "v" };
7364
- let defaultPos = __props.flip ? { x: "left", y: "bottom" } : { x: "bottom", y: "left" };
7365
7858
  let allAxes = vaxis.value.map((c) => ({ ...c.type.$_props, ...c.props, $_children: c.children })).concat(__props.axes ?? []);
7366
7859
  if (allAxes.every((ax) => ax?.coord != "x")) allAxes.push({ coord: "x" });
7367
7860
  if (allAxes.every((ax) => ax?.coord != "y")) allAxes.push({ coord: "y" });
@@ -7371,6 +7864,7 @@ const _sfc_main$1 = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
7371
7864
  title,
7372
7865
  breaks,
7373
7866
  labels,
7867
+ titles,
7374
7868
  "minor-breaks": minorBreaks,
7375
7869
  "show-grid": showGrid,
7376
7870
  theme: $$theme = [],
@@ -7392,7 +7886,14 @@ const _sfc_main$1 = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
7392
7886
  ...etc
7393
7887
  }) => {
7394
7888
  let orientation = ori[coord];
7395
- position = position ?? defaultPos[coord];
7889
+ position = position ?? "start";
7890
+ if (position == "start") {
7891
+ position = { h: "bottom", v: "left" }[orientation];
7892
+ if (reverse[opponents[coord]]) position = opponents[position];
7893
+ } else if (position == "end") {
7894
+ position = { h: "top", v: "right" }[orientation];
7895
+ if (reverse[opponents[coord]]) position = opponents[position];
7896
+ }
7396
7897
  let action2 = Object.values($_children ?? {}).filter((s) => typeof s == "function").flatMap((s) => expandFragment(s())).map((c) => ({ ...c.type.$_props, ...c.props })).concat($$action ?? []).flatMap((props) => {
7397
7898
  let res = [];
7398
7899
  for (let a of ["move", "nudge", "zoom", "rescale"]) {
@@ -7421,6 +7922,7 @@ const _sfc_main$1 = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
7421
7922
  title,
7422
7923
  breaks,
7423
7924
  labels,
7925
+ titles,
7424
7926
  minorBreaks,
7425
7927
  showGrid: _isPropTruthy(showGrid) ?? position !== "none",
7426
7928
  extend: extend2 ?? primaryAxisConfig.extend[coord],
@@ -7502,13 +8004,13 @@ const _sfc_main$1 = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
7502
8004
  return {
7503
8005
  move: Boolean(_isPropTruthy(move)),
7504
8006
  dismissible: dismissible == void 0 ? void 0 : dismissible !== false,
7505
- resize: resize !== false,
8007
+ resize: Boolean(_isPropTruthy(resize)),
7506
8008
  x: xy || Boolean(_isPropTruthy(x2)),
7507
8009
  y: xy || Boolean(_isPropTruthy(y2)),
7508
- xmin,
7509
- xmax,
7510
- ymin,
7511
- ymax,
8010
+ xmin: xmin ?? actionBoundary?.x?.min,
8011
+ xmax: xmax ?? actionBoundary?.x?.max,
8012
+ ymin: ymin ?? actionBoundary?.y?.min,
8013
+ ymax: ymax ?? actionBoundary?.y?.max,
7512
8014
  ctrlKey: Boolean(_isPropTruthy(ctrl)),
7513
8015
  shiftKey: Boolean(_isPropTruthy(shift)),
7514
8016
  altKey: Boolean(_isPropTruthy(alt)),
@@ -7528,21 +8030,24 @@ const _sfc_main$1 = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
7528
8030
  const height = useModel(__props, "height");
7529
8031
  onMounted(() => {
7530
8032
  watch(width, (v) => {
7531
- wrapperRef.value.style.width = str_c(v, "px");
8033
+ wrapperRef.value.style.width = str_c(v, "px") ?? null;
7532
8034
  }, { immediate: true });
7533
8035
  watch(height, (v) => {
7534
- wrapperRef.value.style.height = str_c(v, "px");
8036
+ wrapperRef.value.style.height = str_c(v, "px") ?? null;
7535
8037
  }, { immediate: true });
7536
8038
  });
7537
- const { width: w, height: h } = useElementSize(plotRef);
7538
- watch([w, h], ([w2, h2], [ow, oh]) => {
7539
- if (wrapperRef.value.style.width) width.value = w2;
7540
- if (wrapperRef.value.style.height) height.value = h2;
7541
- if ((w2 > 0 || h2 > 0) && (ow > 0 || oh > 0))
7542
- emit("resize", { width: w2, height: h2 }, { width: ow, height: oh });
8039
+ let oldSize = { width: 0, height: 0 };
8040
+ useResizeObserver(plotRef, (e) => {
8041
+ let { width: w, height: h } = e[0].contentRect;
8042
+ if (wrapperRef.value.style.width) width.value = w;
8043
+ if (wrapperRef.value.style.height) height.value = h;
8044
+ if ((w > 0 || h > 0) && (oldSize.width > 0 || oldSize.height > 0))
8045
+ emit("resize", { width: w, height: h }, oldSize);
8046
+ oldSize = { width: w, height: h };
7543
8047
  });
7544
8048
  const panelStyle = computed(() => {
7545
8049
  return {
8050
+ position: "absolute",
7546
8051
  left: str_c(plotRef.value?.panel?.left, "px"),
7547
8052
  top: str_c(plotRef.value?.panel?.top, "px"),
7548
8053
  width: str_c(plotRef.value?.panel?.width, "px"),
@@ -7561,6 +8066,9 @@ const _sfc_main$1 = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
7561
8066
  return style;
7562
8067
  });
7563
8068
  __expose({
8069
+ get svg() {
8070
+ return plotRef.value.svg;
8071
+ },
7564
8072
  serialize() {
7565
8073
  return serializeSVG(plotRef.value.svg);
7566
8074
  }
@@ -7571,7 +8079,7 @@ const _sfc_main$1 = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
7571
8079
  class: "vvplot",
7572
8080
  style: wrapperStyle.value
7573
8081
  }, vBind.value.wrapper), [
7574
- createVNode(_sfc_main$n, mergeProps({
8082
+ createVNode(_sfc_main$o, mergeProps({
7575
8083
  ref: "plot",
7576
8084
  paddings,
7577
8085
  schema: schema.value,
@@ -7579,7 +8087,7 @@ const _sfc_main$1 = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
7579
8087
  "min-range": minRange.value,
7580
8088
  "expand-add": expandAdd.value,
7581
8089
  "expand-mult": expandMult.value,
7582
- reverse: reverse.value,
8090
+ reverse: unref(reverse),
7583
8091
  flip: __props.flip,
7584
8092
  "coord-levels": coordLevels.value,
7585
8093
  levels: levels.value,
@@ -7590,26 +8098,28 @@ const _sfc_main$1 = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
7590
8098
  transition: transition.value,
7591
8099
  "onUpdate:transition": _cache[0] || (_cache[0] = ($event) => transition.value = $event)
7592
8100
  }, vBind.value.plot, {
7593
- selectionPreview: selectionPreview.value,
8101
+ "selection-preview": selectionPreview.value,
7594
8102
  "onUpdate:selectionPreview": _cache[1] || (_cache[1] = ($event) => selectionPreview.value = $event),
7595
- selectionPreviewTheme: selectionPreviewTheme.value,
8103
+ "selection-preview-theme": selectionPreviewTheme.value,
7596
8104
  "onUpdate:selectionPreviewTheme": _cache[2] || (_cache[2] = ($event) => selectionPreviewTheme.value = $event),
7597
8105
  action: action.value,
7598
8106
  clip: __props.clip,
8107
+ render: __props.render,
7599
8108
  legendTeleport: __props.legendTeleport,
7600
8109
  onSelect: _cache[3] || (_cache[3] = (d, e) => emit("select", d, e))
7601
- }), null, 16, ["paddings", "schema", "layers", "min-range", "expand-add", "expand-mult", "reverse", "flip", "coord-levels", "levels", "scales", "axes", "theme", "selections", "transition", "selectionPreview", "selectionPreviewTheme", "action", "clip", "legendTeleport"]),
7602
- vnodes.dom.panel?.length ? (openBlock(), createElementBlock("div", {
7603
- key: 0,
8110
+ }), null, 16, ["paddings", "schema", "layers", "min-range", "expand-add", "expand-mult", "reverse", "flip", "coord-levels", "levels", "scales", "axes", "theme", "selections", "transition", "selection-preview", "selection-preview-theme", "action", "clip", "render", "legendTeleport"]),
8111
+ _cache[4] || (_cache[4] = createTextVNode()),
8112
+ createElementVNode("div", {
7604
8113
  class: "vvplot-panel-container",
7605
8114
  style: normalizeStyle(panelStyle.value)
7606
8115
  }, [
7607
- createElementVNode("div", _hoisted_1, [
8116
+ vnodes.dom.panel?.length ? (openBlock(), createElementBlock("div", _hoisted_1, [
7608
8117
  (openBlock(true), createElementBlock(Fragment, null, renderList(vnodes.dom.panel, (c) => {
7609
8118
  return openBlock(), createBlock(resolveDynamicComponent(c));
7610
8119
  }), 256))
7611
- ])
7612
- ], 4)) : createCommentVNode("", true),
8120
+ ])) : createCommentVNode("", true)
8121
+ ], 4),
8122
+ _cache[5] || (_cache[5] = createTextVNode()),
7613
8123
  (openBlock(true), createElementBlock(Fragment, null, renderList(vdom.value, (c) => {
7614
8124
  return openBlock(), createBlock(resolveDynamicComponent(c));
7615
8125
  }), 256))
@@ -7623,26 +8133,27 @@ const _sfc_main = {
7623
8133
  };
7624
8134
  export {
7625
8135
  _sfc_main$1 as _sfc_main,
7626
- _sfc_main$m as _sfc_main$1,
7627
- _sfc_main$h as _sfc_main$10,
7628
- _sfc_main$g as _sfc_main$11,
7629
- _sfc_main$f as _sfc_main$12,
7630
- _sfc_main$e as _sfc_main$13,
7631
- _sfc_main$d as _sfc_main$14,
7632
- _sfc_main$c as _sfc_main$15,
7633
- _sfc_main$b as _sfc_main$16,
7634
- _sfc_main$a as _sfc_main$17,
7635
- _sfc_main$9 as _sfc_main$18,
7636
- _sfc_main$8 as _sfc_main$19,
8136
+ _sfc_main$n as _sfc_main$1,
8137
+ _sfc_main$i as _sfc_main$10,
8138
+ _sfc_main$h as _sfc_main$11,
8139
+ _sfc_main$g as _sfc_main$12,
8140
+ _sfc_main$f as _sfc_main$13,
8141
+ _sfc_main$e as _sfc_main$14,
8142
+ _sfc_main$d as _sfc_main$15,
8143
+ _sfc_main$c as _sfc_main$16,
8144
+ _sfc_main$b as _sfc_main$17,
8145
+ _sfc_main$a as _sfc_main$18,
8146
+ _sfc_main$9 as _sfc_main$19,
7637
8147
  _sfc_main as _sfc_main$2,
7638
- _sfc_main$7 as _sfc_main$20,
7639
- _sfc_main$6 as _sfc_main$21,
7640
- _sfc_main$5 as _sfc_main$22,
8148
+ _sfc_main$8 as _sfc_main$20,
8149
+ _sfc_main$7 as _sfc_main$21,
8150
+ _sfc_main$6 as _sfc_main$22,
8151
+ _sfc_main$5 as _sfc_main$23,
7641
8152
  _sfc_main$4 as _sfc_main$3,
7642
8153
  _sfc_main$3 as _sfc_main$4,
7643
8154
  _sfc_main$2 as _sfc_main$5,
7644
- _sfc_main$l as _sfc_main$6,
7645
- _sfc_main$k as _sfc_main$7,
7646
- _sfc_main$j as _sfc_main$8,
7647
- _sfc_main$i as _sfc_main$9
8155
+ _sfc_main$m as _sfc_main$6,
8156
+ _sfc_main$l as _sfc_main$7,
8157
+ _sfc_main$k as _sfc_main$8,
8158
+ _sfc_main$j as _sfc_main$9
7648
8159
  };