vvplot 0.7.1 → 0.7.2

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.
@@ -16,22 +16,24 @@ var VVPlot = (function(exports, vue) {
16
16
  }
17
17
  };
18
18
  var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod, mod.exports), cb = null), mod.exports);
19
- var __exportAll = (all, no_symbols) => {
20
- let target = {};
19
+ var __exportAll = (all, flags) => {
20
+ let target = Object.setPrototypeOf({}, null);
21
21
  for (var name in all) __defProp(target, name, {
22
22
  get: all[name],
23
23
  enumerable: true
24
24
  });
25
- if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
26
- return target;
25
+ if (!(flags & 1)) __defProp(target, Symbol.toStringTag, { value: "Module" });
26
+ return flags & 2 ? target : Object.preventExtensions(target);
27
27
  };
28
28
  var __copyProps = (to, from, except, desc) => {
29
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
30
- key = keys[i];
31
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
32
- get: ((k) => from[k]).bind(null, key),
33
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
34
- });
29
+ if (from && typeof from === "object" || typeof from === "function") {
30
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
31
+ desc = __getOwnPropDesc(from, key);
32
+ __defProp(to, key, {
33
+ get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
34
+ enumerable: !desc || desc.enumerable
35
+ });
36
+ }
35
37
  }
36
38
  return to;
37
39
  };
@@ -310,7 +312,7 @@ var VVPlot = (function(exports, vue) {
310
312
  }
311
313
  // node_modules/@vue/shared/dist/shared.esm-bundler.js
312
314
  /**
313
- * @vue/shared v3.5.45
315
+ * @vue/shared v3.5.46
314
316
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
315
317
  * @license MIT
316
318
  **/
@@ -324,10 +326,18 @@ var VVPlot = (function(exports, vue) {
324
326
  var extend$1 = Object.assign;
325
327
  var isArray = Array.isArray;
326
328
  var isString = (val) => typeof val === "string";
329
+ var STRING_CACHE_MAX_SIZE = 1e4;
327
330
  var cacheStringFunction = (fn) => {
328
- const cache = /* @__PURE__ */ Object.create(null);
331
+ let cache = /* @__PURE__ */ Object.create(null);
332
+ let size = 0;
329
333
  return ((str) => {
330
- return cache[str] || (cache[str] = fn(str));
334
+ const hit = cache[str];
335
+ if (hit !== void 0) return hit;
336
+ if (++size > STRING_CACHE_MAX_SIZE) {
337
+ cache = /* @__PURE__ */ Object.create(null);
338
+ size = 1;
339
+ }
340
+ return cache[str] = fn(str);
331
341
  });
332
342
  };
333
343
  var camelizeRE = /-\w/g;
@@ -340,7 +350,7 @@ var VVPlot = (function(exports, vue) {
340
350
  var isSVGTag = /* @__PURE__ */ makeMap("svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,feDistantLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,text,textPath,title,tspan,unknown,use,view");
341
351
  // node_modules/@vue/compiler-core/dist/compiler-core.esm-bundler.js
342
352
  /**
343
- * @vue/compiler-core v3.5.45
353
+ * @vue/compiler-core v3.5.46
344
354
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
345
355
  * @license MIT
346
356
  **/
@@ -2112,6 +2122,199 @@ var VVPlot = (function(exports, vue) {
2112
2122
  while (i--) if (args[i]) break;
2113
2123
  return args.slice(0, i + 1).map((arg, i2) => arg || createSimpleExpression(`_`.repeat(i2 + 1), false));
2114
2124
  }
2125
+ // src/core/utils.js
2126
+ function expandFragment(componentList) {
2127
+ if (componentList == null) return [];
2128
+ return componentList.flatMap((layer) => {
2129
+ if (layer.type == vue.Fragment) return expandFragment(layer.children);
2130
+ else if (layer.type == "template") return expandFragment(layer.children).map((c) => {
2131
+ c.props = {
2132
+ ...c.props,
2133
+ ...layer.props
2134
+ };
2135
+ return c;
2136
+ });
2137
+ return layer;
2138
+ });
2139
+ }
2140
+ var pointerEventClones = /* @__PURE__ */ new WeakMap();
2141
+ /**
2142
+ * Lazily clone a pointer event through a Vue ref. Reading `.value` (normally
2143
+ * with `unref`) creates the clone; never reading it avoids the allocation.
2144
+ * @param {PointerEvent} event
2145
+ */
2146
+ function useEventClone(event) {
2147
+ return (0, vue.computed)(() => {
2148
+ let cached = pointerEventClones.get(event);
2149
+ if (cached) return cached;
2150
+ let options = {};
2151
+ for (let key in event) options[key] = event[key];
2152
+ options.bubbles = false;
2153
+ let clone = new PointerEvent(event.type, options);
2154
+ for (let key of Object.keys(event)) {
2155
+ let prop = Object.getOwnPropertyDescriptor(clone, key);
2156
+ if (prop && !prop.writable && !prop.set) continue;
2157
+ clone[key] = event[key];
2158
+ }
2159
+ pointerEventClones.set(event, clone);
2160
+ return clone;
2161
+ });
2162
+ }
2163
+ var pointerEvents = [
2164
+ "click",
2165
+ "contextmenu",
2166
+ "singleclick",
2167
+ "dblclick",
2168
+ "pointerover",
2169
+ "pointerout",
2170
+ "pointerenter",
2171
+ "pointerleave",
2172
+ "pointermove",
2173
+ "pointerdown",
2174
+ "pointerup",
2175
+ "wheel"
2176
+ ];
2177
+ function emitEvent(handlers, ...args) {
2178
+ if (Array.isArray(handlers)) {
2179
+ handlers = handlers.filter((h) => typeof h === "function");
2180
+ if (handlers.length === 0) return false;
2181
+ handlers.forEach((h) => h(...args));
2182
+ return true;
2183
+ }
2184
+ if (typeof handlers !== "function") return false;
2185
+ handlers(...args);
2186
+ return true;
2187
+ }
2188
+ function parseLinetype(linetype) {
2189
+ if (linetype == null) return [];
2190
+ if (Array.isArray(linetype)) return linetype;
2191
+ if (linetype === "solid") return [];
2192
+ if (linetype === "dashed") return [4, 4];
2193
+ if (linetype === "dotted") return [1, 3];
2194
+ if (linetype === "dotdash") return [
2195
+ 1,
2196
+ 3,
2197
+ 4,
2198
+ 3
2199
+ ];
2200
+ if (linetype === "longdash") return [8, 4];
2201
+ if (linetype === "twodash") return [
2202
+ 2,
2203
+ 2,
2204
+ 6,
2205
+ 2
2206
+ ];
2207
+ if (linetype.includes(" ")) return linetype.split(" ").map((v) => +v);
2208
+ return linetype.split("").map((v) => +("0x" + v));
2209
+ }
2210
+ /**
2211
+ * drop null/undefined values from an object
2212
+ * @param {Object} obj
2213
+ * @returns {Object}
2214
+ */
2215
+ function dropNull(obj) {
2216
+ if (typeof obj !== "object" || obj == null) return obj;
2217
+ return Object.fromEntries(Object.entries(obj).filter(([k, v]) => v != null));
2218
+ }
2219
+ var unitInPx = {
2220
+ "": 1,
2221
+ "px": 1,
2222
+ "in": 96,
2223
+ "cm": 96 / 2.54,
2224
+ "mm": 96 / 25.4,
2225
+ "pt": 96 / 72,
2226
+ "pc": 16
2227
+ };
2228
+ /**
2229
+ * Normalize an SVG element by embedding canvas images and removing comments.
2230
+ * @param {SVGElement} svgElement
2231
+ * @returns {SVGElement}
2232
+ */
2233
+ function normalizeSVG(svgElement) {
2234
+ if (!(svgElement instanceof SVGElement)) return null;
2235
+ function removeComments(node) {
2236
+ let i = node.childNodes.length;
2237
+ while (i--) {
2238
+ const child = node.childNodes[i];
2239
+ if (child.nodeType === Node.COMMENT_NODE) node.removeChild(child);
2240
+ else if (child.nodeType === Node.ELEMENT_NODE) {
2241
+ removeComments(child);
2242
+ if (child.getAttribute("style") == "") child.removeAttribute("style");
2243
+ if (child.getAttribute("class") == "") child.removeAttribute("class");
2244
+ }
2245
+ }
2246
+ }
2247
+ let svgClone = svgElement.cloneNode(true);
2248
+ let foreignElements = Array.from(svgElement.querySelectorAll("foreignObject")), foreignClones = Array.from(svgClone.querySelectorAll("foreignObject"));
2249
+ for (let i = 0; i < foreignElements.length; i++) {
2250
+ let foreignElement = foreignElements[i], foreignClone = foreignClones[i];
2251
+ let canvas = foreignElements[i].querySelector("canvas");
2252
+ if (!canvas) continue;
2253
+ let img = svgClone.ownerDocument.createElementNS("http://www.w3.org/2000/svg", "image");
2254
+ img.setAttribute("href", canvas.toDataURL());
2255
+ img.setAttribute("x", foreignElement.getAttribute("x"));
2256
+ img.setAttribute("y", foreignElement.getAttribute("y"));
2257
+ img.setAttribute("width", foreignElement.getAttribute("width"));
2258
+ img.setAttribute("height", foreignElement.getAttribute("height"));
2259
+ foreignClone.parentNode.replaceChild(img, foreignClone);
2260
+ }
2261
+ for (let node of svgClone.querySelectorAll(".vvplot-interactive,foreignObject")) node.remove();
2262
+ let bbox = svgElement.getBoundingClientRect();
2263
+ removeComments(svgClone);
2264
+ svgClone.setAttribute("xmlns", "http://www.w3.org/2000/svg");
2265
+ svgClone.setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
2266
+ svgClone.setAttribute("version", "1.1");
2267
+ svgClone.removeAttribute("width");
2268
+ svgClone.removeAttribute("height");
2269
+ svgClone.removeAttribute("x");
2270
+ svgClone.removeAttribute("y");
2271
+ svgClone.removeAttribute("transform");
2272
+ svgClone.setAttribute("viewBox", `0 0 ${svgElement.scrollWidth || bbox.width} ${svgElement.scrollHeight || bbox.height}`);
2273
+ return svgClone;
2274
+ }
2275
+ /**
2276
+ * Serialize an SVG element to a string.
2277
+ * @param {SVGElement} svgElement
2278
+ * @param {Object} options
2279
+ * @param {string} options.unit - The unit for width and height (default: 'mm').
2280
+ * @returns {string}
2281
+ */
2282
+ function serializeSVG(svgElement, { unit = "mm" } = {}) {
2283
+ if (!(svgElement instanceof SVGElement)) return null;
2284
+ let svg = normalizeSVG(svgElement);
2285
+ if (!unitInPx[unit]) unit = "";
2286
+ svg.setAttribute("width", svg.viewBox.baseVal.width / unitInPx[unit] + unit);
2287
+ svg.setAttribute("height", svg.viewBox.baseVal.height / unitInPx[unit] + unit);
2288
+ return new XMLSerializer().serializeToString(svg);
2289
+ }
2290
+ /**
2291
+ * Export an SVG element to a string, inlining images as data URLs.
2292
+ * @param {SVGElement} svgElement
2293
+ * @param {Object} options
2294
+ * @param {string} options.unit - The unit for width and height (default: 'mm').
2295
+ * @returns {string}
2296
+ */
2297
+ async function exportSVG(svgElement, { unit = "mm" } = {}) {
2298
+ if (!(svgElement instanceof SVGElement)) return null;
2299
+ let svg = normalizeSVG(svgElement);
2300
+ if (!unitInPx[unit]) unit = "";
2301
+ svg.setAttribute("width", svg.viewBox.baseVal.width / unitInPx[unit] + unit);
2302
+ svg.setAttribute("height", svg.viewBox.baseVal.height / unitInPx[unit] + unit);
2303
+ const cache = /* @__PURE__ */ new Map();
2304
+ for (let el of svg.querySelectorAll("image")) {
2305
+ let href = el.getAttribute("href") ?? el.getAttribute("xlink:href");
2306
+ if (href.startsWith("data:")) continue;
2307
+ try {
2308
+ let response = await fetch(href);
2309
+ if (!response.ok) throw new Error(`Failed to fetch image: ${response.status}`);
2310
+ cache.set(href, await blobToDataURL(await response.blob()));
2311
+ } catch (e) {
2312
+ console.warn(`Failed to inline image ${href}: ${e.message}`);
2313
+ }
2314
+ if (cache.has(href)) el.setAttribute("href", cache.get(href));
2315
+ }
2316
+ return new XMLSerializer().serializeToString(svg);
2317
+ }
2115
2318
  // src/js/utils.js
2116
2319
  var utils_exports$1 = /* @__PURE__ */ __exportAll({
2117
2320
  Asis: () => Asis,
@@ -2119,6 +2322,7 @@ var VVPlot = (function(exports, vue) {
2119
2322
  EnumLevel: () => EnumLevel,
2120
2323
  categorize: () => categorize,
2121
2324
  deepEqual: () => deepEqual,
2325
+ exportSVG: () => exportSVG,
2122
2326
  interaction: () => interaction,
2123
2327
  intraaction: () => intraaction,
2124
2328
  intrazip: () => intrazip,
@@ -2130,6 +2334,7 @@ var VVPlot = (function(exports, vue) {
2130
2334
  oob_squish_any: () => oob_squish_any,
2131
2335
  oob_squish_infinite: () => oob_squish_infinite,
2132
2336
  plus: () => plus$1,
2337
+ serializeSVG: () => serializeSVG,
2133
2338
  str_c: () => str_c,
2134
2339
  unique: () => unique,
2135
2340
  vecutils: () => vecutils
@@ -2262,12 +2467,12 @@ var VVPlot = (function(exports, vue) {
2262
2467
  min(arr, { na_rm = true, infinity_rm = true } = {}) {
2263
2468
  if (na_rm) arr = arr.filter(is_continuous);
2264
2469
  if (infinity_rm) arr = arr.filter((x) => isFinite(x));
2265
- return Array.from(arr).reduce((a, b) => a < b ? a : b, Infinity);
2470
+ return Array.from(arr).reduce((a, b) => a < b ? a : b, 1e400);
2266
2471
  },
2267
2472
  max(arr, { na_rm = true, infinity_rm = true } = {}) {
2268
2473
  if (na_rm) arr = arr.filter(is_continuous);
2269
2474
  if (infinity_rm) arr = arr.filter((x) => isFinite(x));
2270
- return Array.from(arr).reduce((a, b) => a > b ? a : b, -Infinity);
2475
+ return Array.from(arr).reduce((a, b) => a > b ? a : b, -1e400);
2271
2476
  },
2272
2477
  sum(arr, { na_rm = true, infinity_rm = true } = {}) {
2273
2478
  if (na_rm) arr = arr.filter(is_continuous);
@@ -2305,7 +2510,7 @@ var VVPlot = (function(exports, vue) {
2305
2510
  if (na_rm) arr = arr.filter(is_continuous);
2306
2511
  if (infinity_rm) arr = arr.filter((x) => isFinite(x));
2307
2512
  if (arr.length == 0) return new Array(2);
2308
- let min = Array.from(arr).reduce((a, b) => a < b ? a : b, Infinity), max = Array.from(arr).reduce((a, b) => a > b ? a : b, -Infinity);
2513
+ let min = Array.from(arr).reduce((a, b) => a < b ? a : b, 1e400), max = Array.from(arr).reduce((a, b) => a > b ? a : b, -1e400);
2309
2514
  return Object.assign([min, max], {
2310
2515
  min,
2311
2516
  max
@@ -2446,8 +2651,8 @@ var VVPlot = (function(exports, vue) {
2446
2651
  * @returns {number}
2447
2652
  */
2448
2653
  function oob_squish_infinite(value, { min, max }) {
2449
- if (value == -Infinity) return min;
2450
- if (value == Infinity) return max;
2654
+ if (value == -1e400) return min;
2655
+ if (value == 1e400) return max;
2451
2656
  return value;
2452
2657
  }
2453
2658
  /**
@@ -2606,11 +2811,12 @@ var VVPlot = (function(exports, vue) {
2606
2811
  padding_h: 50,
2607
2812
  padding_v: 30
2608
2813
  },
2609
- legend: {
2610
- spacing: 4,
2814
+ legend: { spacing: 4 },
2815
+ guide: {
2611
2816
  title_size: 18,
2612
2817
  label_size: 16,
2613
2818
  key_size: 10,
2819
+ bin_size: 3,
2614
2820
  key_spacing: 10
2615
2821
  },
2616
2822
  selection: { background: "#00000020" }
@@ -2769,7 +2975,8 @@ var VVPlot = (function(exports, vue) {
2769
2975
  background: theme?.plot?.background
2770
2976
  },
2771
2977
  selection: theme?.selection ?? {},
2772
- legend: theme?.legend ?? {}
2978
+ legend: theme?.legend ?? {},
2979
+ guide: theme?.guide ?? {}
2773
2980
  };
2774
2981
  }
2775
2982
  var theme_default = {
@@ -2782,195 +2989,6 @@ var VVPlot = (function(exports, vue) {
2782
2989
  linedraw: theme_linedraw,
2783
2990
  void: theme_void
2784
2991
  };
2785
- // src/core/utils.js
2786
- function expandFragment(componentList) {
2787
- if (componentList == null) return [];
2788
- return componentList.flatMap((layer) => {
2789
- if (layer.type == vue.Fragment) return expandFragment(layer.children);
2790
- else if (layer.type == "template") return expandFragment(layer.children).map((c) => {
2791
- c.props = {
2792
- ...c.props,
2793
- ...layer.props
2794
- };
2795
- return c;
2796
- });
2797
- return layer;
2798
- });
2799
- }
2800
- var pointerEventClones = /* @__PURE__ */ new WeakMap();
2801
- /**
2802
- * Lazily clone a pointer event through a Vue ref. Reading `.value` (normally
2803
- * with `unref`) creates the clone; never reading it avoids the allocation.
2804
- * @param {PointerEvent} event
2805
- */
2806
- function useEventClone(event) {
2807
- return (0, vue.computed)(() => {
2808
- let cached = pointerEventClones.get(event);
2809
- if (cached) return cached;
2810
- let options = {};
2811
- for (let key in event) options[key] = event[key];
2812
- options.bubbles = false;
2813
- let clone = new PointerEvent(event.type, options);
2814
- for (let key of Object.keys(event)) {
2815
- let prop = Object.getOwnPropertyDescriptor(clone, key);
2816
- if (prop && !prop.writable && !prop.set) continue;
2817
- clone[key] = event[key];
2818
- }
2819
- pointerEventClones.set(event, clone);
2820
- return clone;
2821
- });
2822
- }
2823
- var pointerEvents = [
2824
- "click",
2825
- "contextmenu",
2826
- "singleclick",
2827
- "dblclick",
2828
- "pointerover",
2829
- "pointerout",
2830
- "pointerenter",
2831
- "pointerleave",
2832
- "pointermove",
2833
- "pointerdown",
2834
- "pointerup",
2835
- "wheel"
2836
- ];
2837
- function emitEvent(handlers, ...args) {
2838
- if (Array.isArray(handlers)) {
2839
- handlers = handlers.filter((h) => typeof h === "function");
2840
- if (handlers.length === 0) return false;
2841
- handlers.forEach((h) => h(...args));
2842
- return true;
2843
- }
2844
- if (typeof handlers !== "function") return false;
2845
- handlers(...args);
2846
- return true;
2847
- }
2848
- function parseLinetype(linetype) {
2849
- if (linetype == null) return [];
2850
- if (Array.isArray(linetype)) return linetype;
2851
- if (linetype === "solid") return [];
2852
- if (linetype === "dashed") return [4, 4];
2853
- if (linetype === "dotted") return [1, 3];
2854
- if (linetype === "dotdash") return [
2855
- 1,
2856
- 3,
2857
- 4,
2858
- 3
2859
- ];
2860
- if (linetype === "longdash") return [8, 4];
2861
- if (linetype === "twodash") return [
2862
- 2,
2863
- 2,
2864
- 6,
2865
- 2
2866
- ];
2867
- if (linetype.includes(" ")) return linetype.split(" ").map((v) => +v);
2868
- return linetype.split("").map((v) => +("0x" + v));
2869
- }
2870
- /**
2871
- * drop null/undefined values from an object
2872
- * @param {Object} obj
2873
- * @returns {Object}
2874
- */
2875
- function dropNull(obj) {
2876
- if (typeof obj !== "object" || obj == null) return obj;
2877
- return Object.fromEntries(Object.entries(obj).filter(([k, v]) => v != null));
2878
- }
2879
- var unitInPx = {
2880
- "": 1,
2881
- "px": 1,
2882
- "in": 96,
2883
- "cm": 96 / 2.54,
2884
- "mm": 96 / 25.4,
2885
- "pt": 96 / 72,
2886
- "pc": 16
2887
- };
2888
- /**
2889
- * Normalize an SVG element by embedding canvas images and removing comments.
2890
- * @param {SVGElement} svgElement
2891
- * @returns {SVGElement}
2892
- */
2893
- function normalizeSVG(svgElement) {
2894
- if (!(svgElement instanceof SVGElement)) return null;
2895
- function removeComments(node) {
2896
- let i = node.childNodes.length;
2897
- while (i--) {
2898
- const child = node.childNodes[i];
2899
- if (child.nodeType === Node.COMMENT_NODE) node.removeChild(child);
2900
- else if (child.nodeType === Node.ELEMENT_NODE) {
2901
- removeComments(child);
2902
- if (child.getAttribute("style") == "") child.removeAttribute("style");
2903
- if (child.getAttribute("class") == "") child.removeAttribute("class");
2904
- }
2905
- }
2906
- }
2907
- let svgClone = svgElement.cloneNode(true);
2908
- let foreignElements = Array.from(svgElement.querySelectorAll("foreignObject")), foreignClones = Array.from(svgClone.querySelectorAll("foreignObject"));
2909
- for (let i = 0; i < foreignElements.length; i++) {
2910
- let foreignElement = foreignElements[i], foreignClone = foreignClones[i];
2911
- let canvas = foreignElements[i].querySelector("canvas");
2912
- if (!canvas) continue;
2913
- let img = svgClone.ownerDocument.createElementNS("http://www.w3.org/2000/svg", "image");
2914
- img.setAttribute("href", canvas.toDataURL());
2915
- img.setAttribute("x", foreignElement.getAttribute("x"));
2916
- img.setAttribute("y", foreignElement.getAttribute("y"));
2917
- img.setAttribute("width", foreignElement.getAttribute("width"));
2918
- img.setAttribute("height", foreignElement.getAttribute("height"));
2919
- foreignClone.parentNode.replaceChild(img, foreignClone);
2920
- }
2921
- for (let node of svgClone.querySelectorAll(".vvplot-interactive,foreignObject")) node.remove();
2922
- removeComments(svgClone);
2923
- svgClone.setAttribute("xmlns", "http://www.w3.org/2000/svg");
2924
- svgClone.setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
2925
- svgClone.setAttribute("version", "1.1");
2926
- svgClone.removeAttribute("width");
2927
- svgClone.removeAttribute("height");
2928
- svgClone.setAttribute("viewBox", `0 0 ${svgElement.scrollWidth} ${svgElement.scrollHeight}`);
2929
- return svgClone;
2930
- }
2931
- /**
2932
- * Serialize an SVG element to a string.
2933
- * @param {SVGElement} svgElement
2934
- * @param {Object} options
2935
- * @param {string} options.unit - The unit for width and height (default: 'mm').
2936
- * @returns {string}
2937
- */
2938
- function serializeSVG(svgElement, { unit = "mm" } = {}) {
2939
- if (!(svgElement instanceof SVGElement)) return null;
2940
- let svg = normalizeSVG(svgElement);
2941
- if (!unitInPx[unit]) unit = "";
2942
- svg.setAttribute("width", svgElement.scrollWidth / unitInPx[unit] + unit);
2943
- svg.setAttribute("height", svgElement.scrollHeight / unitInPx[unit] + unit);
2944
- return new XMLSerializer().serializeToString(svg);
2945
- }
2946
- /**
2947
- * Export an SVG element to a string, inlining images as data URLs.
2948
- * @param {SVGElement} svgElement
2949
- * @param {Object} options
2950
- * @param {string} options.unit - The unit for width and height (default: 'mm').
2951
- * @returns {string}
2952
- */
2953
- async function exportSVG(svgElement, { unit = "mm" } = {}) {
2954
- if (!(svgElement instanceof SVGElement)) return null;
2955
- let svg = normalizeSVG(svgElement);
2956
- if (!unitInPx[unit]) unit = "";
2957
- svg.setAttribute("width", svgElement.scrollWidth / unitInPx[unit] + unit);
2958
- svg.setAttribute("height", svgElement.scrollHeight / unitInPx[unit] + unit);
2959
- const cache = /* @__PURE__ */ new Map();
2960
- for (let el of svg.querySelectorAll("image")) {
2961
- let href = el.getAttribute("href") ?? el.getAttribute("xlink:href");
2962
- if (href.startsWith("data:")) continue;
2963
- try {
2964
- let response = await fetch(href);
2965
- if (!response.ok) throw new Error(`Failed to fetch image: ${response.status}`);
2966
- cache.set(href, await blobToDataURL(await response.blob()));
2967
- } catch (e) {
2968
- console.warn(`Failed to inline image ${href}: ${e.message}`);
2969
- }
2970
- if (cache.has(href)) el.setAttribute("href", cache.get(href));
2971
- }
2972
- return new XMLSerializer().serializeToString(svg);
2973
- }
2974
2992
  // src/core/registry/component.js
2975
2993
  /**
2976
2994
  * Runtime registry for layer declaration components.
@@ -3084,37 +3102,62 @@ var VVPlot = (function(exports, vue) {
3084
3102
  };
3085
3103
  }
3086
3104
  // src/components/Axis.vue
3087
- var _sfc_main$90 = {
3105
+ var _sfc_main$92 = {
3088
3106
  $_type: "axis",
3089
3107
  $_props: {}
3090
3108
  };
3091
3109
  // src/components/AxisX.vue
3092
- var _sfc_main$89 = {
3110
+ var _sfc_main$91 = {
3093
3111
  $_type: "axis",
3094
3112
  $_props: { coord: "x" }
3095
3113
  };
3096
3114
  // src/components/AxisY.vue
3097
- var _sfc_main$88 = {
3115
+ var _sfc_main$90 = {
3098
3116
  $_type: "axis",
3099
3117
  $_props: { coord: "y" }
3100
3118
  };
3101
3119
  // src/components/AxisBreak.vue
3102
- var _sfc_main$87 = {
3120
+ var _sfc_main$89 = {
3103
3121
  $_type: "axis-break",
3104
3122
  $_props: { type: "major" }
3105
3123
  };
3106
3124
  // src/components/Action.vue
3107
- var _sfc_main$86 = {
3125
+ var _sfc_main$88 = {
3108
3126
  $_type: "action",
3109
3127
  $_props: {}
3110
3128
  };
3111
3129
  // src/components/Selection.vue
3112
- var _sfc_main$85 = {
3130
+ var _sfc_main$87 = {
3113
3131
  $_type: "selection",
3114
3132
  $_props: {}
3115
3133
  };
3116
3134
  // src/components/Geom.vue
3117
- var _sfc_main$84 = { $_type: "layer" };
3135
+ var _sfc_main$86 = {
3136
+ $_type: "layer",
3137
+ $_props: {}
3138
+ };
3139
+ // src/components/Legend.vue
3140
+ var _sfc_main$85 = {
3141
+ $_type: "legend",
3142
+ $_props: {}
3143
+ };
3144
+ // src/components/Guide.vue
3145
+ var _sfc_main$84 = {
3146
+ $_type: "guide",
3147
+ $_props: {}
3148
+ };
3149
+ // src/components/index.ts
3150
+ var components_exports$2 = /* @__PURE__ */ __exportAll({
3151
+ VVAction: () => _sfc_main$88,
3152
+ VVAxis: () => _sfc_main$92,
3153
+ VVAxisBreak: () => _sfc_main$89,
3154
+ VVAxisX: () => _sfc_main$91,
3155
+ VVAxisY: () => _sfc_main$90,
3156
+ VVGeom: () => _sfc_main$86,
3157
+ VVGuide: () => _sfc_main$84,
3158
+ VVLegend: () => _sfc_main$85,
3159
+ VVSelection: () => _sfc_main$87
3160
+ });
3118
3161
  // src/core/registry/geom.js
3119
3162
  /**
3120
3163
  * Runtime registry for geometry definitions.
@@ -3324,154 +3367,154 @@ var VVPlot = (function(exports, vue) {
3324
3367
  var reHslPercent = new RegExp(`^hsl\\(${reN},${reP},${reP}\\)$`);
3325
3368
  var reHslaPercent = new RegExp(`^hsla\\(${reN},${reP},${reP},${reN}\\)$`);
3326
3369
  var named = {
3327
- aliceblue: 15792383,
3328
- antiquewhite: 16444375,
3370
+ aliceblue: 0xf0f8ff,
3371
+ antiquewhite: 0xfaebd7,
3329
3372
  aqua: 65535,
3330
3373
  aquamarine: 8388564,
3331
- azure: 15794175,
3332
- beige: 16119260,
3333
- bisque: 16770244,
3374
+ azure: 0xf0ffff,
3375
+ beige: 0xf5f5dc,
3376
+ bisque: 0xffe4c4,
3334
3377
  black: 0,
3335
- blanchedalmond: 16772045,
3378
+ blanchedalmond: 0xffebcd,
3336
3379
  blue: 255,
3337
3380
  blueviolet: 9055202,
3338
- brown: 10824234,
3339
- burlywood: 14596231,
3381
+ brown: 0xa52a2a,
3382
+ burlywood: 0xdeb887,
3340
3383
  cadetblue: 6266528,
3341
3384
  chartreuse: 8388352,
3342
- chocolate: 13789470,
3343
- coral: 16744272,
3385
+ chocolate: 0xd2691e,
3386
+ coral: 0xff7f50,
3344
3387
  cornflowerblue: 6591981,
3345
- cornsilk: 16775388,
3346
- crimson: 14423100,
3388
+ cornsilk: 0xfff8dc,
3389
+ crimson: 0xdc143c,
3347
3390
  cyan: 65535,
3348
3391
  darkblue: 139,
3349
3392
  darkcyan: 35723,
3350
- darkgoldenrod: 12092939,
3351
- darkgray: 11119017,
3393
+ darkgoldenrod: 0xb8860b,
3394
+ darkgray: 0xa9a9a9,
3352
3395
  darkgreen: 25600,
3353
- darkgrey: 11119017,
3354
- darkkhaki: 12433259,
3396
+ darkgrey: 0xa9a9a9,
3397
+ darkkhaki: 0xbdb76b,
3355
3398
  darkmagenta: 9109643,
3356
3399
  darkolivegreen: 5597999,
3357
- darkorange: 16747520,
3358
- darkorchid: 10040012,
3400
+ darkorange: 0xff8c00,
3401
+ darkorchid: 0x9932cc,
3359
3402
  darkred: 9109504,
3360
- darksalmon: 15308410,
3403
+ darksalmon: 0xe9967a,
3361
3404
  darkseagreen: 9419919,
3362
3405
  darkslateblue: 4734347,
3363
3406
  darkslategray: 3100495,
3364
3407
  darkslategrey: 3100495,
3365
3408
  darkturquoise: 52945,
3366
3409
  darkviolet: 9699539,
3367
- deeppink: 16716947,
3410
+ deeppink: 0xff1493,
3368
3411
  deepskyblue: 49151,
3369
3412
  dimgray: 6908265,
3370
3413
  dimgrey: 6908265,
3371
3414
  dodgerblue: 2003199,
3372
- firebrick: 11674146,
3373
- floralwhite: 16775920,
3415
+ firebrick: 0xb22222,
3416
+ floralwhite: 0xfffaf0,
3374
3417
  forestgreen: 2263842,
3375
- fuchsia: 16711935,
3376
- gainsboro: 14474460,
3377
- ghostwhite: 16316671,
3378
- gold: 16766720,
3379
- goldenrod: 14329120,
3418
+ fuchsia: 0xff00ff,
3419
+ gainsboro: 0xdcdcdc,
3420
+ ghostwhite: 0xf8f8ff,
3421
+ gold: 0xffd700,
3422
+ goldenrod: 0xdaa520,
3380
3423
  gray: 8421504,
3381
3424
  green: 32768,
3382
- greenyellow: 11403055,
3425
+ greenyellow: 0xadff2f,
3383
3426
  grey: 8421504,
3384
- honeydew: 15794160,
3385
- hotpink: 16738740,
3386
- indianred: 13458524,
3427
+ honeydew: 0xf0fff0,
3428
+ hotpink: 0xff69b4,
3429
+ indianred: 0xcd5c5c,
3387
3430
  indigo: 4915330,
3388
- ivory: 16777200,
3389
- khaki: 15787660,
3390
- lavender: 15132410,
3391
- lavenderblush: 16773365,
3431
+ ivory: 0xfffff0,
3432
+ khaki: 0xf0e68c,
3433
+ lavender: 0xe6e6fa,
3434
+ lavenderblush: 0xfff0f5,
3392
3435
  lawngreen: 8190976,
3393
- lemonchiffon: 16775885,
3394
- lightblue: 11393254,
3395
- lightcoral: 15761536,
3396
- lightcyan: 14745599,
3397
- lightgoldenrodyellow: 16448210,
3398
- lightgray: 13882323,
3436
+ lemonchiffon: 0xfffacd,
3437
+ lightblue: 0xadd8e6,
3438
+ lightcoral: 0xf08080,
3439
+ lightcyan: 0xe0ffff,
3440
+ lightgoldenrodyellow: 0xfafad2,
3441
+ lightgray: 0xd3d3d3,
3399
3442
  lightgreen: 9498256,
3400
- lightgrey: 13882323,
3401
- lightpink: 16758465,
3402
- lightsalmon: 16752762,
3443
+ lightgrey: 0xd3d3d3,
3444
+ lightpink: 0xffb6c1,
3445
+ lightsalmon: 0xffa07a,
3403
3446
  lightseagreen: 2142890,
3404
3447
  lightskyblue: 8900346,
3405
3448
  lightslategray: 7833753,
3406
3449
  lightslategrey: 7833753,
3407
- lightsteelblue: 11584734,
3408
- lightyellow: 16777184,
3450
+ lightsteelblue: 0xb0c4de,
3451
+ lightyellow: 0xffffe0,
3409
3452
  lime: 65280,
3410
3453
  limegreen: 3329330,
3411
- linen: 16445670,
3412
- magenta: 16711935,
3454
+ linen: 0xfaf0e6,
3455
+ magenta: 0xff00ff,
3413
3456
  maroon: 8388608,
3414
3457
  mediumaquamarine: 6737322,
3415
3458
  mediumblue: 205,
3416
- mediumorchid: 12211667,
3459
+ mediumorchid: 0xba55d3,
3417
3460
  mediumpurple: 9662683,
3418
3461
  mediumseagreen: 3978097,
3419
3462
  mediumslateblue: 8087790,
3420
3463
  mediumspringgreen: 64154,
3421
3464
  mediumturquoise: 4772300,
3422
- mediumvioletred: 13047173,
3465
+ mediumvioletred: 0xc71585,
3423
3466
  midnightblue: 1644912,
3424
- mintcream: 16121850,
3425
- mistyrose: 16770273,
3426
- moccasin: 16770229,
3427
- navajowhite: 16768685,
3467
+ mintcream: 0xf5fffa,
3468
+ mistyrose: 0xffe4e1,
3469
+ moccasin: 0xffe4b5,
3470
+ navajowhite: 0xffdead,
3428
3471
  navy: 128,
3429
- oldlace: 16643558,
3472
+ oldlace: 0xfdf5e6,
3430
3473
  olive: 8421376,
3431
3474
  olivedrab: 7048739,
3432
- orange: 16753920,
3433
- orangered: 16729344,
3434
- orchid: 14315734,
3435
- palegoldenrod: 15657130,
3436
- palegreen: 10025880,
3437
- paleturquoise: 11529966,
3438
- palevioletred: 14381203,
3439
- papayawhip: 16773077,
3440
- peachpuff: 16767673,
3441
- peru: 13468991,
3442
- pink: 16761035,
3443
- plum: 14524637,
3444
- powderblue: 11591910,
3475
+ orange: 0xffa500,
3476
+ orangered: 0xff4500,
3477
+ orchid: 0xda70d6,
3478
+ palegoldenrod: 0xeee8aa,
3479
+ palegreen: 0x98fb98,
3480
+ paleturquoise: 0xafeeee,
3481
+ palevioletred: 0xdb7093,
3482
+ papayawhip: 0xffefd5,
3483
+ peachpuff: 0xffdab9,
3484
+ peru: 0xcd853f,
3485
+ pink: 0xffc0cb,
3486
+ plum: 0xdda0dd,
3487
+ powderblue: 0xb0e0e6,
3445
3488
  purple: 8388736,
3446
3489
  rebeccapurple: 6697881,
3447
- red: 16711680,
3448
- rosybrown: 12357519,
3490
+ red: 0xff0000,
3491
+ rosybrown: 0xbc8f8f,
3449
3492
  royalblue: 4286945,
3450
3493
  saddlebrown: 9127187,
3451
- salmon: 16416882,
3452
- sandybrown: 16032864,
3494
+ salmon: 0xfa8072,
3495
+ sandybrown: 0xf4a460,
3453
3496
  seagreen: 3050327,
3454
- seashell: 16774638,
3455
- sienna: 10506797,
3456
- silver: 12632256,
3497
+ seashell: 0xfff5ee,
3498
+ sienna: 0xa0522d,
3499
+ silver: 0xc0c0c0,
3457
3500
  skyblue: 8900331,
3458
3501
  slateblue: 6970061,
3459
3502
  slategray: 7372944,
3460
3503
  slategrey: 7372944,
3461
- snow: 16775930,
3504
+ snow: 0xfffafa,
3462
3505
  springgreen: 65407,
3463
3506
  steelblue: 4620980,
3464
- tan: 13808780,
3507
+ tan: 0xd2b48c,
3465
3508
  teal: 32896,
3466
- thistle: 14204888,
3467
- tomato: 16737095,
3509
+ thistle: 0xd8bfd8,
3510
+ tomato: 0xff6347,
3468
3511
  turquoise: 4251856,
3469
- violet: 15631086,
3470
- wheat: 16113331,
3471
- white: 16777215,
3472
- whitesmoke: 16119285,
3473
- yellow: 16776960,
3474
- yellowgreen: 10145074
3512
+ violet: 0xee82ee,
3513
+ wheat: 0xf5deb3,
3514
+ white: 0xffffff,
3515
+ whitesmoke: 0xf5f5f5,
3516
+ yellow: 0xffff00,
3517
+ yellowgreen: 0x9acd32
3475
3518
  };
3476
3519
  define(Color, color, {
3477
3520
  copy(channels) {
@@ -4130,9 +4173,9 @@ var VVPlot = (function(exports, vue) {
4130
4173
  }
4131
4174
  }
4132
4175
  }
4133
- if (comma && !zero) value = group(value, Infinity);
4176
+ if (comma && !zero) value = group(value, 1e400);
4134
4177
  var length = valuePrefix.length + value.length + valueSuffix.length, padding = length < width ? new Array(width - length + 1).join(fill) : "";
4135
- if (comma && zero) value = group(padding + value, padding.length ? width - valueSuffix.length : Infinity), padding = "";
4178
+ if (comma && zero) value = group(padding + value, padding.length ? width - valueSuffix.length : 1e400), padding = "";
4136
4179
  switch (align) {
4137
4180
  case "<":
4138
4181
  value = valuePrefix + value + valueSuffix + padding;
@@ -4796,9 +4839,9 @@ var VVPlot = (function(exports, vue) {
4796
4839
  "k": 1e3,
4797
4840
  "M": 1e6,
4798
4841
  "G": 1e9,
4799
- "T": 0xe8d4a51000,
4800
- "P": 0x38d7ea4c68000,
4801
- "E": 0xde0b6b3a7640000,
4842
+ "T": 1e12,
4843
+ "P": 1e15,
4844
+ "E": 1e18,
4802
4845
  "Z": 1e21,
4803
4846
  "Y": 1e24
4804
4847
  },
@@ -4815,9 +4858,9 @@ var VVPlot = (function(exports, vue) {
4815
4858
  "k": 1e3,
4816
4859
  "M": 1e6,
4817
4860
  "G": 1e9,
4818
- "T": 0xe8d4a51000,
4819
- "P": 0x38d7ea4c68000,
4820
- "E": 0xde0b6b3a7640000,
4861
+ "T": 1e12,
4862
+ "P": 1e15,
4863
+ "E": 1e18,
4821
4864
  "Z": 1e21,
4822
4865
  "Y": 1e24
4823
4866
  },
@@ -5544,9 +5587,9 @@ var VVPlot = (function(exports, vue) {
5544
5587
  }
5545
5588
  };
5546
5589
  // src/core/axis/CoreAxisH.vue
5547
- var _hoisted_1$28 = ["transform"];
5590
+ var _hoisted_1$29 = ["transform"];
5548
5591
  var _hoisted_2$8 = ["x2"];
5549
- var _hoisted_3$3 = {
5592
+ var _hoisted_3$2 = {
5550
5593
  class: "vvplot-interactive",
5551
5594
  fill: "transparent"
5552
5595
  };
@@ -5729,14 +5772,24 @@ var VVPlot = (function(exports, vue) {
5729
5772
  return result.filter((t) => t.text.fill != null).sort((a, b) => a.text.x - b.text.x);
5730
5773
  });
5731
5774
  const iRef = (0, vue.useTemplateRef)("i");
5775
+ function clientToOffset({ clientX, clientY }) {
5776
+ let ctm = iRef.value?.getScreenCTM?.();
5777
+ if (!ctm) return {
5778
+ offsetX: clientX,
5779
+ offsetY: clientY
5780
+ };
5781
+ let { x: offsetX, y: offsetY } = new DOMPoint(clientX, clientY).matrixTransform(ctm.inverse());
5782
+ return {
5783
+ offsetX,
5784
+ offsetY
5785
+ };
5786
+ }
5732
5787
  function getPosition(event) {
5733
- let rect = iRef.value.getBoundingClientRect();
5734
- let scaleX = rect.width / iRef.value.getBBox().width;
5735
- let offsetX = event.clientX - rect.left;
5736
- let l = offsetX / scaleX - __props.layout.left;
5788
+ let { offsetX: h } = clientToOffset(event);
5789
+ let l = h - __props.layout.left;
5737
5790
  let result = {
5738
5791
  l,
5739
- r: __props.layout.left + __props.layout.width - offsetX / scaleX
5792
+ r: __props.layout.left + __props.layout.width - h
5740
5793
  };
5741
5794
  let { x, y } = __props.mapping.pos2coord({ h: l });
5742
5795
  if (x) result.x = x;
@@ -5744,7 +5797,7 @@ var VVPlot = (function(exports, vue) {
5744
5797
  return result;
5745
5798
  }
5746
5799
  const emit = __emit;
5747
- let moveTimer, movementX = 0;
5800
+ let moveTimer;
5748
5801
  function axisMovePointerdown(e) {
5749
5802
  let position = getPosition(e);
5750
5803
  emit("pointerdown", e, position);
@@ -5764,12 +5817,13 @@ var VVPlot = (function(exports, vue) {
5764
5817
  moveTimer = clearTimeout(moveTimer);
5765
5818
  let hmin0 = 0, hmax0 = __props.layout.width;
5766
5819
  let boundary = __props.mapping.coord2pos(act);
5767
- let scaleX = iRef.value.getBoundingClientRect().width / iRef.value.getBBox().width;
5820
+ let { offsetX: h0 } = clientToOffset(e);
5768
5821
  e.target.setPointerCapture(e.pointerId);
5769
5822
  e.target.onpointermove = (ev) => {
5770
- movementX += ev.movementX;
5823
+ let { offsetX: h } = clientToOffset(ev);
5824
+ let movementH = h - h0;
5771
5825
  if (!pointerMoved) return;
5772
- let dh = oob_squish_any(-movementX / scaleX, {
5826
+ let dh = oob_squish_any(-movementH, {
5773
5827
  min: boundary.hmin - hmin0,
5774
5828
  max: boundary.hmax - hmax0
5775
5829
  });
@@ -5790,7 +5844,6 @@ var VVPlot = (function(exports, vue) {
5790
5844
  if (!pointerMoved) return;
5791
5845
  moveTimer = setTimeout(() => {
5792
5846
  applyTransform(act, ev);
5793
- movementX = 0;
5794
5847
  }, 300);
5795
5848
  }, { once: true });
5796
5849
  }
@@ -5812,13 +5865,13 @@ var VVPlot = (function(exports, vue) {
5812
5865
  hmax: coord0.hmin + mrh
5813
5866
  }).hmin
5814
5867
  };
5815
- let scaleX = iRef.value.getBoundingClientRect().width / iRef.value.getBBox().width;
5816
- let movementX = 0;
5868
+ let { offsetX: h0 } = clientToOffset(e);
5817
5869
  e.target.setPointerCapture(e.pointerId);
5818
5870
  e.target.onpointermove = (ev) => {
5819
- movementX += ev.movementX;
5871
+ let { offsetX: h } = clientToOffset(ev);
5872
+ let movementH = h - h0;
5820
5873
  let { xmin, xmax, ymin, ymax } = __props.mapping.pos2coord({
5821
- hmin: oob_squish_any(hmax - (hmax - hmin) * position.r / Math.max(position.r - movementX / scaleX, 1), boundary),
5874
+ hmin: oob_squish_any(hmax - (hmax - hmin) * position.r / Math.max(position.r - movementH, 1), boundary),
5822
5875
  hmax
5823
5876
  });
5824
5877
  rangeStore.updatePreview({
@@ -5851,14 +5904,14 @@ var VVPlot = (function(exports, vue) {
5851
5904
  }).hmax,
5852
5905
  max: __props.mapping.coord2pos(act).hmax
5853
5906
  };
5854
- iRef.value.getBoundingClientRect().width / iRef.value.getBBox().width;
5855
- let movementX = 0;
5907
+ let { offsetX: h0 } = clientToOffset(e);
5856
5908
  e.target.setPointerCapture(e.pointerId);
5857
5909
  e.target.onpointermove = (ev) => {
5858
- movementX += ev.movementX;
5910
+ let { offsetX: h } = clientToOffset(ev);
5911
+ let movementH = h - h0;
5859
5912
  let { xmin, xmax, ymin, ymax } = __props.mapping.pos2coord({
5860
5913
  hmin,
5861
- hmax: oob_squish_any(hmin + (hmax - hmin) * position.l / Math.max(position.l + movementX, 1), boundary)
5914
+ hmax: oob_squish_any(hmin + (hmax - hmin) * position.l / Math.max(position.l + movementH, 1), boundary)
5862
5915
  });
5863
5916
  rangeStore.updatePreview({
5864
5917
  xmin,
@@ -5899,7 +5952,7 @@ var VVPlot = (function(exports, vue) {
5899
5952
  let { "min-range-h": mrh = 0, sensitivity = 1.25 } = act;
5900
5953
  let lvl = sensitivity ** (delta / 100);
5901
5954
  let boundary = __props.mapping.coord2pos(act);
5902
- let hmin = Math.max(pos.l - Math.max(pos.l, 0) * lvl, boundary.hmin ?? -Infinity), hmax = Math.min(pos.l + Math.max(pos.r, 0) * lvl, boundary.hmax ?? Infinity);
5955
+ let hmin = Math.max(pos.l - Math.max(pos.l, 0) * lvl, boundary.hmin ?? -1e400), hmax = Math.min(pos.l + Math.max(pos.r, 0) * lvl, boundary.hmax ?? 1e400);
5903
5956
  let { [__props.coord + "min"]: min, [__props.coord + "max"]: max } = __props.mapping.pos2coord({
5904
5957
  hmin,
5905
5958
  hmax
@@ -5996,7 +6049,7 @@ var VVPlot = (function(exports, vue) {
5996
6049
  return (0, vue.openBlock)(), (0, vue.createElementBlock)("g", (0, vue.mergeProps)({ ref_for: true }, tick.wrapper), [(0, vue.createVNode)(_sfc_main$83, (0, vue.mergeProps)({ ref_for: true }, tick.text, { getPosition }), null, 16)], 16);
5997
6050
  }), 256)),
5998
6051
  _cache[3] || (_cache[3] = (0, vue.createTextVNode)()),
5999
- (0, vue.createElementVNode)("g", _hoisted_3$3, [(0, vue.createElementVNode)("rect", (0, vue.mergeProps)({
6052
+ (0, vue.createElementVNode)("g", _hoisted_3$2, [(0, vue.createElementVNode)("rect", (0, vue.mergeProps)({
6000
6053
  ref: "i",
6001
6054
  width: width.value,
6002
6055
  height: 10,
@@ -6024,14 +6077,14 @@ var VVPlot = (function(exports, vue) {
6024
6077
  ])) : (0, vue.createCommentVNode)("", true),
6025
6078
  _cache[5] || (_cache[5] = (0, vue.createTextVNode)()),
6026
6079
  axisTitle.value.text ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.resolveDynamicComponent)(TitleElement.value), (0, vue.normalizeProps)((0, vue.mergeProps)({ key: 2 }, axisTitle.value)), null, 16)) : (0, vue.createCommentVNode)("", true)
6027
- ], 12, _hoisted_1$28);
6080
+ ], 12, _hoisted_1$29);
6028
6081
  };
6029
6082
  }
6030
6083
  };
6031
6084
  // src/core/axis/CoreAxisV.vue
6032
- var _hoisted_1$27 = ["transform"];
6085
+ var _hoisted_1$28 = ["transform"];
6033
6086
  var _hoisted_2$7 = ["y2"];
6034
- var _hoisted_3$2 = {
6087
+ var _hoisted_3$1 = {
6035
6088
  class: "vvplot-interactive",
6036
6089
  fill: "transparent"
6037
6090
  };
@@ -6214,14 +6267,24 @@ var VVPlot = (function(exports, vue) {
6214
6267
  return result.filter((t) => t.text.fill != null).sort((a, b) => a.text.y - b.text.y);
6215
6268
  });
6216
6269
  const iRef = (0, vue.useTemplateRef)("i");
6270
+ function clientToOffset({ clientX, clientY }) {
6271
+ let ctm = iRef.value?.getScreenCTM?.();
6272
+ if (!ctm) return {
6273
+ offsetX: clientX,
6274
+ offsetY: clientY
6275
+ };
6276
+ let { x: offsetX, y: offsetY } = new DOMPoint(clientX, clientY).matrixTransform(ctm.inverse());
6277
+ return {
6278
+ offsetX,
6279
+ offsetY
6280
+ };
6281
+ }
6217
6282
  function getPosition(event) {
6218
- let rect = iRef.value.getBoundingClientRect();
6219
- let scaleY = rect.height / iRef.value.getBBox().height;
6220
- let offsetY = event.clientY - rect.top;
6221
- let t = offsetY / scaleY - __props.layout.top;
6283
+ let { offsetY: v } = clientToOffset(event);
6284
+ let t = v - __props.layout.top;
6222
6285
  let result = {
6223
6286
  t,
6224
- b: __props.layout.top + __props.layout.height - offsetY / scaleY
6287
+ b: __props.layout.top + __props.layout.height - v
6225
6288
  };
6226
6289
  let { x, y } = __props.mapping.pos2coord({ v: t });
6227
6290
  if (x) result.x = x;
@@ -6229,7 +6292,7 @@ var VVPlot = (function(exports, vue) {
6229
6292
  return result;
6230
6293
  }
6231
6294
  const emit = __emit;
6232
- let moveTimer, movementY = 0;
6295
+ let moveTimer;
6233
6296
  function axisMovePointerdown(e) {
6234
6297
  let position = getPosition(e);
6235
6298
  emit("pointerdown", e, position);
@@ -6249,12 +6312,13 @@ var VVPlot = (function(exports, vue) {
6249
6312
  moveTimer = clearTimeout(moveTimer);
6250
6313
  let vmin0 = 0, vmax0 = __props.layout.height;
6251
6314
  let boundary = __props.mapping.coord2pos(act);
6252
- let scaleY = iRef.value.getBoundingClientRect().height / iRef.value.getBBox().height;
6315
+ let { offsetY: v0 } = clientToOffset(e);
6253
6316
  e.target.setPointerCapture(e.pointerId);
6254
6317
  e.target.onpointermove = (ev) => {
6255
- movementY += ev.movementY;
6318
+ let { offsetY: v } = clientToOffset(ev);
6319
+ let movementV = v - v0;
6256
6320
  if (!pointerMoved) return;
6257
- let dv = oob_squish_any(-movementY / scaleY, {
6321
+ let dv = oob_squish_any(-movementV, {
6258
6322
  min: boundary.vmin - vmin0,
6259
6323
  max: boundary.vmax - vmax0
6260
6324
  });
@@ -6275,7 +6339,6 @@ var VVPlot = (function(exports, vue) {
6275
6339
  if (!pointerMoved) return;
6276
6340
  moveTimer = setTimeout(() => {
6277
6341
  applyTransform(act, ev);
6278
- movementY = 0;
6279
6342
  }, 300);
6280
6343
  }, { once: true });
6281
6344
  }
@@ -6297,13 +6360,13 @@ var VVPlot = (function(exports, vue) {
6297
6360
  vmax: coord0.vmin + mrv
6298
6361
  }).vmin
6299
6362
  };
6300
- let scaleY = iRef.value.getBoundingClientRect().height / iRef.value.getBBox().height;
6301
- let movementY = 0;
6363
+ let { offsetY: v0 } = clientToOffset(e);
6302
6364
  e.target.setPointerCapture(e.pointerId);
6303
6365
  e.target.onpointermove = (ev) => {
6304
- movementY += ev.movementY;
6366
+ let { offsetY: v } = clientToOffset(ev);
6367
+ let movementV = v - v0;
6305
6368
  let { xmin, xmax, ymin, ymax } = __props.mapping.pos2coord({
6306
- vmin: oob_squish_any(vmax - (vmax - vmin) * position.b / Math.max(position.b - movementY / scaleY, 1), boundary),
6369
+ vmin: oob_squish_any(vmax - (vmax - vmin) * position.b / Math.max(position.b - movementV, 1), boundary),
6307
6370
  vmax
6308
6371
  });
6309
6372
  rangeStore.updatePreview({
@@ -6336,14 +6399,14 @@ var VVPlot = (function(exports, vue) {
6336
6399
  }).vmax,
6337
6400
  max: __props.mapping.coord2pos(act).vmax
6338
6401
  };
6339
- let scaleY = iRef.value.getBoundingClientRect().height / iRef.value.getBBox().height;
6340
- let movementY = 0;
6402
+ let { offsetY: v0 } = clientToOffset(e);
6341
6403
  e.target.setPointerCapture(e.pointerId);
6342
6404
  e.target.onpointermove = (ev) => {
6343
- movementY += ev.movementY;
6405
+ let { offsetY: v } = clientToOffset(ev);
6406
+ let movementV = v - v0;
6344
6407
  let { xmin, xmax, ymin, ymax } = __props.mapping.pos2coord({
6345
6408
  vmin,
6346
- vmax: oob_squish_any(vmin + (vmax - vmin) * position.t / Math.max(position.t + movementY / scaleY, 1), boundary)
6409
+ vmax: oob_squish_any(vmin + (vmax - vmin) * position.t / Math.max(position.t + movementV, 1), boundary)
6347
6410
  });
6348
6411
  rangeStore.updatePreview({
6349
6412
  xmin,
@@ -6384,7 +6447,7 @@ var VVPlot = (function(exports, vue) {
6384
6447
  let { "min-range-v": mrv = 0, sensitivity = 1.25 } = act;
6385
6448
  let lvl = sensitivity ** (delta / 100);
6386
6449
  let boundary = __props.mapping.coord2pos(act);
6387
- let vmin = Math.max(pos.t - Math.max(pos.t, 0) * lvl, boundary.vmin ?? -Infinity), vmax = Math.min(pos.t + Math.max(pos.b, 0) * lvl, boundary.vmax ?? Infinity);
6450
+ let vmin = Math.max(pos.t - Math.max(pos.t, 0) * lvl, boundary.vmin ?? -1e400), vmax = Math.min(pos.t + Math.max(pos.b, 0) * lvl, boundary.vmax ?? 1e400);
6388
6451
  let { [__props.coord + "min"]: min, [__props.coord + "max"]: max } = __props.mapping.pos2coord({
6389
6452
  vmin,
6390
6453
  vmax
@@ -6481,7 +6544,7 @@ var VVPlot = (function(exports, vue) {
6481
6544
  return (0, vue.openBlock)(), (0, vue.createElementBlock)("g", (0, vue.mergeProps)({ ref_for: true }, tick.wrapper), [(0, vue.createVNode)(_sfc_main$83, (0, vue.mergeProps)({ ref_for: true }, tick.text, { getPosition }), null, 16)], 16);
6482
6545
  }), 256)),
6483
6546
  _cache[3] || (_cache[3] = (0, vue.createTextVNode)()),
6484
- (0, vue.createElementVNode)("g", _hoisted_3$2, [(0, vue.createElementVNode)("rect", (0, vue.mergeProps)({
6547
+ (0, vue.createElementVNode)("g", _hoisted_3$1, [(0, vue.createElementVNode)("rect", (0, vue.mergeProps)({
6485
6548
  ref: "i",
6486
6549
  width: 10,
6487
6550
  height: height.value,
@@ -6509,7 +6572,7 @@ var VVPlot = (function(exports, vue) {
6509
6572
  ])) : (0, vue.createCommentVNode)("", true),
6510
6573
  _cache[5] || (_cache[5] = (0, vue.createTextVNode)()),
6511
6574
  axisTitle.value.text ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.resolveDynamicComponent)(TitleElement.value), (0, vue.normalizeProps)((0, vue.mergeProps)({ key: 2 }, axisTitle.value)), null, 16)) : (0, vue.createCommentVNode)("", true)
6512
- ], 12, _hoisted_1$27);
6575
+ ], 12, _hoisted_1$28);
6513
6576
  };
6514
6577
  }
6515
6578
  };
@@ -6856,7 +6919,7 @@ var VVPlot = (function(exports, vue) {
6856
6919
  }
6857
6920
  };
6858
6921
  // src/core/CoreSelection.vue
6859
- var _hoisted_1$26 = { key: 0 };
6922
+ var _hoisted_1$27 = { key: 0 };
6860
6923
  var _hoisted_2$6 = ["onPointerdown"];
6861
6924
  var _sfc_main$76 = {
6862
6925
  __name: "CoreSelection",
@@ -7095,6 +7158,7 @@ var VVPlot = (function(exports, vue) {
7095
7158
  e.preventDefault();
7096
7159
  e.target.setPointerCapture(e.pointerId);
7097
7160
  let { xreverse: $xreverse, yreverse: $yreverse, ...coord0 } = normalize(model.value);
7161
+ let { l: h0, t: v0 } = __props.mapping.getCoord?.(e) ?? {};
7098
7162
  let pos0 = __props.mapping.coord2pos(coord0);
7099
7163
  let { h: coordL, v: coordT } = __props.mapping.pos2coord({
7100
7164
  h: pos0.hmin,
@@ -7113,14 +7177,13 @@ var VVPlot = (function(exports, vue) {
7113
7177
  max: config.ymax
7114
7178
  }, [mrh = 0, mry = 0] = __props.flip ? [config.minRangeY, config.minRangeX] : [config.minRangeX, config.minRangeY];
7115
7179
  let boundary = __props.mapping.coord2pos(config);
7116
- let movementX = 0, movementY = 0;
7117
7180
  let xmin, xmax, ymin, ymax, xreverse = false, yreverse = false;
7118
7181
  e.target.onpointermove = (ev) => {
7119
7182
  pointerMoved = true;
7120
- movementX += ev.movementX;
7121
- movementY += ev.movementY;
7183
+ let { l: h, t: v } = __props.mapping.getCoord?.(ev) ?? {};
7184
+ let movementH = h - h0 || 0, movementV = v - v0 || 0;
7122
7185
  if (dir.includes("l") && dir.includes("r")) {
7123
- let dh = oob_squish_any(movementX, {
7186
+ let dh = oob_squish_any(movementH, {
7124
7187
  min: boundary.hmin - hmin0,
7125
7188
  max: boundary.hmax - hmax0
7126
7189
  });
@@ -7131,16 +7194,16 @@ var VVPlot = (function(exports, vue) {
7131
7194
  coordL = coord.hmin;
7132
7195
  coordR = coord.hmax;
7133
7196
  } else if (dir.includes("l")) {
7134
- coordL = __props.mapping.pos2coord({ h: hmin0 + movementX }).h;
7197
+ coordL = __props.mapping.pos2coord({ h: hmin0 + movementH }).h;
7135
7198
  coordL = oob_squish_any(coordL, coordL > coordR ? { min: plus$1(coordR, mrh) } : { max: plus$1(coordR, -mrh) });
7136
- xreverse = hmin0 + movementX > hmax0;
7199
+ xreverse = hmin0 + movementH > hmax0;
7137
7200
  } else if (dir.includes("r")) {
7138
- coordR = __props.mapping.pos2coord({ h: hmax0 + movementX }).h;
7201
+ coordR = __props.mapping.pos2coord({ h: hmax0 + movementH }).h;
7139
7202
  coordR = oob_squish_any(coordR, coordR > coordL ? { min: plus$1(coordL, mrh) } : { max: plus$1(coordL, -mrh) });
7140
- xreverse = hmax0 + movementX < hmin0;
7203
+ xreverse = hmax0 + movementH < hmin0;
7141
7204
  }
7142
7205
  if (dir.includes("t") && dir.includes("b")) {
7143
- let dv = oob_squish_any(movementY, {
7206
+ let dv = oob_squish_any(movementV, {
7144
7207
  min: boundary.vmin - vmin0,
7145
7208
  max: boundary.vmax - vmax0
7146
7209
  });
@@ -7151,13 +7214,13 @@ var VVPlot = (function(exports, vue) {
7151
7214
  coordT = coord.vmin;
7152
7215
  coordB = coord.vmax;
7153
7216
  } else if (dir.includes("t")) {
7154
- coordT = __props.mapping.pos2coord({ v: vmin0 + movementY }).v;
7217
+ coordT = __props.mapping.pos2coord({ v: vmin0 + movementV }).v;
7155
7218
  coordT = oob_squish_any(coordT, coordT > coordB ? { min: plus$1(coordB, mry) } : { max: plus$1(coordB, -mry) });
7156
- yreverse = vmin0 + movementY > vmax0;
7219
+ yreverse = vmin0 + movementV > vmax0;
7157
7220
  } else if (dir.includes("b")) {
7158
- coordB = __props.mapping.pos2coord({ v: vmax0 + movementY }).v;
7221
+ coordB = __props.mapping.pos2coord({ v: vmax0 + movementV }).v;
7159
7222
  coordB = oob_squish_any(coordB, coordB > coordT ? { min: plus$1(coordT, mry) } : { max: plus$1(coordT, -mry) });
7160
- yreverse = vmax0 + movementY < vmin0;
7223
+ yreverse = vmax0 + movementV < vmin0;
7161
7224
  }
7162
7225
  xmin = oob_squish_any(__props.flip ? coordT : coordL, xboundary);
7163
7226
  xmax = oob_squish_any(__props.flip ? coordB : coordR, xboundary);
@@ -7197,7 +7260,7 @@ var VVPlot = (function(exports, vue) {
7197
7260
  }, { once: true });
7198
7261
  }
7199
7262
  return (_ctx, _cache) => {
7200
- return rectBind.value ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("g", _hoisted_1$26, [
7263
+ return rectBind.value ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("g", _hoisted_1$27, [
7201
7264
  (0, vue.createElementVNode)("rect", (0, vue.normalizeProps)((0, vue.guardReactiveProps)(rectBind.value)), null, 16),
7202
7265
  _cache[0] || (_cache[0] = (0, vue.createTextVNode)()),
7203
7266
  ((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)(interactiveBind.value, (bind, k) => {
@@ -7211,7 +7274,7 @@ var VVPlot = (function(exports, vue) {
7211
7274
  }
7212
7275
  };
7213
7276
  // src/elements/ElementText.vue
7214
- var _hoisted_1$25 = ["font-size"];
7277
+ var _hoisted_1$26 = ["font-size"];
7215
7278
  var _hoisted_2$5 = { key: 0 };
7216
7279
  var _sfc_main$75 = {
7217
7280
  __name: "ElementText",
@@ -7343,7 +7406,7 @@ var VVPlot = (function(exports, vue) {
7343
7406
  return (0, vue.openBlock)(), (0, vue.createElementBlock)("text", (0, vue.mergeProps)({
7344
7407
  ref_key: "ele",
7345
7408
  ref: ele
7346
- }, binds.value, { "font-size": (__props.fontSize ?? __props.size * 4) || null }), [(0, vue.renderSlot)(_ctx.$slots, "default", {}, () => [__props.title ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("title", _hoisted_2$5, (0, vue.toDisplayString)(__props.title), 1)) : (0, vue.createCommentVNode)("", true), (0, vue.createTextVNode)(" " + (0, vue.toDisplayString)(__props.text?.replace(/ /g, "\xA0")), 1)])], 16, _hoisted_1$25);
7409
+ }, binds.value, { "font-size": (__props.fontSize ?? __props.size * 4) || null }), [(0, vue.renderSlot)(_ctx.$slots, "default", {}, () => [__props.title ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("title", _hoisted_2$5, (0, vue.toDisplayString)(__props.title), 1)) : (0, vue.createCommentVNode)("", true), (0, vue.createTextVNode)(" " + (0, vue.toDisplayString)(__props.text?.replace(/ /g, "\xA0")), 1)])], 16, _hoisted_1$26);
7347
7410
  };
7348
7411
  }
7349
7412
  };
@@ -32656,7 +32719,7 @@ var VVPlot = (function(exports, vue) {
32656
32719
  XmlRenderer.prototype.tag = tag;
32657
32720
  XmlRenderer.prototype.esc = escapeXml;
32658
32721
  // src/elements/ElementMarkdown.vue
32659
- var _hoisted_1$24 = ["text-anchor", "font-size"];
32722
+ var _hoisted_1$25 = ["text-anchor", "font-size"];
32660
32723
  var _hoisted_2$4 = { key: 0 };
32661
32724
  var _sfc_main$74 = {
32662
32725
  __name: "ElementMarkdown",
@@ -32848,12 +32911,12 @@ var VVPlot = (function(exports, vue) {
32848
32911
  ((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)(textFragments.value, (span) => {
32849
32912
  return (0, vue.openBlock)(), (0, vue.createElementBlock)("tspan", (0, vue.mergeProps)({ ref_for: true }, span.vbind), (0, vue.toDisplayString)(span.text), 17);
32850
32913
  }), 256))
32851
- ], 16, _hoisted_1$24);
32914
+ ], 16, _hoisted_1$25);
32852
32915
  };
32853
32916
  }
32854
32917
  };
32855
32918
  // src/elements/ElementTile.vue
32856
- var _hoisted_1$23 = { key: 0 };
32919
+ var _hoisted_1$24 = { key: 0 };
32857
32920
  var _sfc_main$73 = {
32858
32921
  __name: "ElementTile",
32859
32922
  props: {
@@ -32909,51 +32972,92 @@ var VVPlot = (function(exports, vue) {
32909
32972
  };
32910
32973
  });
32911
32974
  return (_ctx, _cache) => {
32912
- return (0, vue.openBlock)(), (0, vue.createElementBlock)("rect", (0, vue.normalizeProps)((0, vue.guardReactiveProps)(binds.value)), [__props.title ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("title", _hoisted_1$23, (0, vue.toDisplayString)(__props.title), 1)) : (0, vue.createCommentVNode)("", true)], 16);
32975
+ return (0, vue.openBlock)(), (0, vue.createElementBlock)("rect", (0, vue.normalizeProps)((0, vue.guardReactiveProps)(binds.value)), [__props.title ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("title", _hoisted_1$24, (0, vue.toDisplayString)(__props.title), 1)) : (0, vue.createCommentVNode)("", true)], 16);
32913
32976
  };
32914
32977
  }
32915
32978
  };
32916
32979
  // src/core/guide/CoreGuideGradientbar.vue
32917
- var _hoisted_1$22 = [
32980
+ var _hoisted_1$23 = [
32918
32981
  "x1",
32919
32982
  "x2",
32920
32983
  "y1",
32921
32984
  "y2"
32922
32985
  ];
32923
- var nBins = 30;
32924
32986
  var padding = 5;
32925
32987
  var _sfc_main$72 = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
32926
32988
  __name: "CoreGuideGradientbar",
32927
32989
  props: {
32928
- scales: Array,
32929
- appearance: {
32930
- type: Object,
32931
- default: () => ({})
32990
+ sources: {
32991
+ type: Array,
32992
+ default: () => []
32932
32993
  },
32933
32994
  theme: {
32934
32995
  type: Object,
32935
32996
  default: () => ({})
32936
32997
  },
32937
- breaks: Array,
32938
- limits: Object
32998
+ bins: {
32999
+ type: Number,
33000
+ default: 30
33001
+ },
33002
+ breaks: [Array, Function],
33003
+ labels: [Array, Function],
33004
+ titles: [Array, Function]
32939
33005
  },
32940
33006
  setup(__props) {
33007
+ const props = (0, vue.createPropsRestProxy)(__props, [
33008
+ "sources",
33009
+ "theme",
33010
+ "bins"
33011
+ ]);
33012
+ const scales = (0, vue.computed)(() => __props.sources.map((source) => source.scale));
33013
+ const appearance = (0, vue.computed)(() => obj_merge(...__props.sources.flatMap((source) => Object.values(source.appearance ?? {}))));
33014
+ const limits = (0, vue.computed)(() => {
33015
+ let max = scales.value.map((s) => s.limits?.max).filter((v) => v != null).reduce((a, b) => Math.min(a, b), 1e400);
33016
+ return {
33017
+ min: scales.value.map((s) => s.limits?.min).filter((v) => v != null).reduce((a, b) => Math.max(a, b), -1e400),
33018
+ max
33019
+ };
33020
+ });
32941
33021
  const guide_breaks = (0, vue.computed)(() => {
32942
- let { min, max } = __props.limits;
32943
- return __props.breaks.map((v) => ({
32944
- position: (v - min) / (max - min),
32945
- label: String(v)
32946
- }));
33022
+ let { breaks, labels, titles } = props;
33023
+ if (typeof breaks === "function") breaks = breaks({
33024
+ ...limits.value,
33025
+ scales: scales.value,
33026
+ sources: __props.sources
33027
+ });
33028
+ if (!Array.isArray(breaks)) breaks = [];
33029
+ if (typeof labels === "function") labels = breaks.map(labels);
33030
+ if (!Array.isArray(labels)) labels = [];
33031
+ else if (labels.length !== breaks.length) {
33032
+ console.warn("[vvplot] Length of labels must be the same as breaks.");
33033
+ labels = [];
33034
+ }
33035
+ if (typeof titles === "function") titles = breaks.map(titles);
33036
+ if (!Array.isArray(titles)) titles = [];
33037
+ else if (titles.length !== breaks.length) {
33038
+ console.warn("[vvplot] Length of titles must be the same as breaks.");
33039
+ titles = [];
33040
+ }
33041
+ let { min, max } = limits.value;
33042
+ return breaks.map((value, i) => {
33043
+ let label = labels[i] ?? String(value);
33044
+ let title = titles[i] ?? label;
33045
+ return {
33046
+ position: (value - min) / (max - min),
33047
+ label,
33048
+ title
33049
+ };
33050
+ });
32947
33051
  });
32948
33052
  const gradient_values = (0, vue.computed)(() => {
32949
- let { min, max } = __props.limits;
32950
- let step = (max - min) / 29;
32951
- let cuts = Array.from({ length: nBins }, (_, i) => min + i * step);
32952
- let scaled = __props.scales.map((s) => s(cuts));
32953
- return cuts.map((v, i) => Object.fromEntries(__props.scales.map((s, j) => [{ "color": "fill" }[s.aesthetics] ?? s.aesthetics, scaled[j][i]])));
33053
+ let { min, max } = limits.value;
33054
+ let step = (max - min) / (__props.bins - 1);
33055
+ let cuts = Array.from({ length: __props.bins }, (_, i) => min + i * step);
33056
+ let scaled = scales.value.map((s) => s(cuts));
33057
+ return cuts.map((v, i) => Object.fromEntries(scales.value.map((s, j) => [{ "color": "fill" }[s.aesthetics] ?? s.aesthetics, scaled[j][i]])));
32954
33058
  });
32955
33059
  const w = (0, vue.computed)(() => __props.theme.key_size + 10);
32956
- const h = (0, vue.computed)(() => __props.theme.key_spacing * 3 / 10);
33060
+ const h = (0, vue.computed)(() => __props.theme.bin_size);
32957
33061
  const text_bind = (0, vue.computed)(() => {
32958
33062
  return {
32959
33063
  "font-size": __props.theme.label_size || 0,
@@ -32968,8 +33072,8 @@ var VVPlot = (function(exports, vue) {
32968
33072
  width: __props.theme.key_size,
32969
33073
  height: h.value * 1.05,
32970
33074
  x: w.value / 2,
32971
- y: 10 + (29 - i + .5) * h.value,
32972
- alpha: __props.appearance.alpha
33075
+ y: 10 + (__props.bins - i - .5) * h.value,
33076
+ alpha: appearance.value.alpha
32973
33077
  }, { ref_for: true }, v), null, 16, [
32974
33078
  "width",
32975
33079
  "height",
@@ -32979,32 +33083,40 @@ var VVPlot = (function(exports, vue) {
32979
33083
  ]);
32980
33084
  }), 256)),
32981
33085
  _cache[1] || (_cache[1] = (0, vue.createTextVNode)()),
32982
- ((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)(guide_breaks.value, ({ position, label }, i) => {
33086
+ ((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)(guide_breaks.value, ({ position, label, title }, i) => {
32983
33087
  return (0, vue.openBlock)(), (0, vue.createElementBlock)("g", null, [
32984
33088
  (0, vue.createElementVNode)("line", {
32985
33089
  x1: w.value - padding,
32986
33090
  x2: w.value - padding + 3,
32987
- y1: 10 + (1 - position) * h.value * nBins,
32988
- y2: 10 + (1 - position) * h.value * nBins,
33091
+ y1: 10 + (1 - position) * h.value * __props.bins,
33092
+ y2: 10 + (1 - position) * h.value * __props.bins,
32989
33093
  stroke: "black"
32990
- }, null, 8, _hoisted_1$22),
33094
+ }, null, 8, _hoisted_1$23),
32991
33095
  _cache[0] || (_cache[0] = (0, vue.createTextVNode)()),
32992
33096
  __props.theme.label_type == "markdown" ? ((0, vue.openBlock)(), (0, vue.createBlock)(_sfc_main$74, (0, vue.mergeProps)({
32993
33097
  key: 0,
32994
33098
  x: w.value,
32995
- y: 10 + (1 - position) * h.value * nBins
32996
- }, { ref_for: true }, text_bind.value, { text: label }), null, 16, [
33099
+ y: 10 + (1 - position) * h.value * __props.bins
33100
+ }, { ref_for: true }, text_bind.value, {
33101
+ text: label,
33102
+ title
33103
+ }), null, 16, [
32997
33104
  "x",
32998
33105
  "y",
32999
- "text"
33106
+ "text",
33107
+ "title"
33000
33108
  ])) : ((0, vue.openBlock)(), (0, vue.createBlock)(_sfc_main$75, (0, vue.mergeProps)({
33001
33109
  key: 1,
33002
33110
  x: w.value,
33003
- y: 10 + (1 - position) * h.value * nBins
33004
- }, { ref_for: true }, text_bind.value, { text: label }), null, 16, [
33111
+ y: 10 + (1 - position) * h.value * __props.bins
33112
+ }, { ref_for: true }, text_bind.value, {
33113
+ text: label,
33114
+ title
33115
+ }), null, 16, [
33005
33116
  "x",
33006
33117
  "y",
33007
- "text"
33118
+ "text",
33119
+ "title"
33008
33120
  ]))
33009
33121
  ]);
33010
33122
  }), 256))
@@ -33965,7 +34077,7 @@ var VVPlot = (function(exports, vue) {
33965
34077
  }
33966
34078
  };
33967
34079
  // src/elements/ElementPath.vue
33968
- var _hoisted_1$21 = { key: 0 };
34080
+ var _hoisted_1$22 = { key: 0 };
33969
34081
  var _sfc_main$71 = {
33970
34082
  __name: "ElementPath",
33971
34083
  props: {
@@ -34003,7 +34115,7 @@ var VVPlot = (function(exports, vue) {
34003
34115
  };
34004
34116
  });
34005
34117
  return (_ctx, _cache) => {
34006
- return (0, vue.openBlock)(), (0, vue.createElementBlock)("path", (0, vue.normalizeProps)((0, vue.guardReactiveProps)(binds.value)), [__props.title ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("title", _hoisted_1$21, (0, vue.toDisplayString)(__props.title), 1)) : (0, vue.createCommentVNode)("", true)], 16);
34118
+ return (0, vue.openBlock)(), (0, vue.createElementBlock)("path", (0, vue.normalizeProps)((0, vue.guardReactiveProps)(binds.value)), [__props.title ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("title", _hoisted_1$22, (0, vue.toDisplayString)(__props.title), 1)) : (0, vue.createCommentVNode)("", true)], 16);
34007
34119
  };
34008
34120
  }
34009
34121
  };
@@ -34028,7 +34140,7 @@ var VVPlot = (function(exports, vue) {
34028
34140
  }
34029
34141
  };
34030
34142
  // src/elements/ElementLine.vue
34031
- var _hoisted_1$20 = { key: 0 };
34143
+ var _hoisted_1$21 = { key: 0 };
34032
34144
  var _sfc_main$69 = {
34033
34145
  __name: "ElementLine",
34034
34146
  props: {
@@ -34082,7 +34194,7 @@ var VVPlot = (function(exports, vue) {
34082
34194
  };
34083
34195
  });
34084
34196
  return (_ctx, _cache) => {
34085
- return (0, vue.openBlock)(), (0, vue.createElementBlock)("line", (0, vue.normalizeProps)((0, vue.guardReactiveProps)(binds.value)), [__props.title ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("title", _hoisted_1$20, (0, vue.toDisplayString)(__props.title), 1)) : (0, vue.createCommentVNode)("", true)], 16);
34197
+ return (0, vue.openBlock)(), (0, vue.createElementBlock)("line", (0, vue.normalizeProps)((0, vue.guardReactiveProps)(binds.value)), [__props.title ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("title", _hoisted_1$21, (0, vue.toDisplayString)(__props.title), 1)) : (0, vue.createCommentVNode)("", true)], 16);
34086
34198
  };
34087
34199
  }
34088
34200
  };
@@ -34104,7 +34216,7 @@ var VVPlot = (function(exports, vue) {
34104
34216
  }
34105
34217
  };
34106
34218
  // src/elements/ElementPoint.vue
34107
- var _hoisted_1$19 = { key: 0 };
34219
+ var _hoisted_1$20 = { key: 0 };
34108
34220
  var _hoisted_2$3 = { key: 0 };
34109
34221
  var _sfc_main$67 = {
34110
34222
  __name: "ElementPoint",
@@ -34190,7 +34302,7 @@ var VVPlot = (function(exports, vue) {
34190
34302
  return result;
34191
34303
  });
34192
34304
  return (_ctx, _cache) => {
34193
- return binds.value.d ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("path", (0, vue.normalizeProps)((0, vue.mergeProps)({ key: 0 }, binds.value)), [__props.title ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("title", _hoisted_1$19, (0, vue.toDisplayString)(__props.title), 1)) : (0, vue.createCommentVNode)("", true)], 16)) : ((0, vue.openBlock)(), (0, vue.createElementBlock)("circle", (0, vue.normalizeProps)((0, vue.mergeProps)({ key: 1 }, binds.value)), [__props.title ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("title", _hoisted_2$3, (0, vue.toDisplayString)(__props.title), 1)) : (0, vue.createCommentVNode)("", true)], 16));
34305
+ return binds.value.d ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("path", (0, vue.normalizeProps)((0, vue.mergeProps)({ key: 0 }, binds.value)), [__props.title ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("title", _hoisted_1$20, (0, vue.toDisplayString)(__props.title), 1)) : (0, vue.createCommentVNode)("", true)], 16)) : ((0, vue.openBlock)(), (0, vue.createElementBlock)("circle", (0, vue.normalizeProps)((0, vue.mergeProps)({ key: 1 }, binds.value)), [__props.title ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("title", _hoisted_2$3, (0, vue.toDisplayString)(__props.title), 1)) : (0, vue.createCommentVNode)("", true)], 16));
34194
34306
  };
34195
34307
  }
34196
34308
  };
@@ -34248,19 +34360,26 @@ var VVPlot = (function(exports, vue) {
34248
34360
  tile: () => _sfc_main$64
34249
34361
  });
34250
34362
  // src/core/guide/CoreGuideLegendkey.vue
34251
- var _hoisted_1$18 = ["transform"];
34363
+ var _hoisted_1$19 = ["transform"];
34252
34364
  var _hoisted_2$2 = ["transform"];
34253
34365
  var _sfc_main$63 = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
34254
34366
  __name: "CoreGuideLegendkey",
34255
34367
  props: {
34256
- sources: Array,
34368
+ sources: {
34369
+ type: Array,
34370
+ default: () => []
34371
+ },
34257
34372
  theme: {
34258
34373
  type: Object,
34259
34374
  default: () => ({})
34260
34375
  },
34261
- breaks: Array
34376
+ bins: Number,
34377
+ breaks: [Array, Function],
34378
+ labels: [Array, Function],
34379
+ titles: [Array, Function]
34262
34380
  },
34263
34381
  setup(__props) {
34382
+ const props = (0, vue.createPropsRestProxy)(__props, ["sources", "theme"]);
34264
34383
  const scales = (0, vue.computed)(() => new Map(__props.sources.map(({ scale, appearance }) => [scale, appearance ?? {}])));
34265
34384
  const appearances = (0, vue.computed)(() => {
34266
34385
  let glyphs = Array.from(scales.value.values().flatMap((v) => Object.keys(v)));
@@ -34268,19 +34387,48 @@ var VVPlot = (function(exports, vue) {
34268
34387
  for (let geom in result) result[geom] = obj_merge(...result[geom]);
34269
34388
  return result;
34270
34389
  });
34390
+ const limits = (0, vue.computed)(() => {
34391
+ let max = Array.from(scales.value.keys()).map((s) => s.limits?.max).filter((v) => v != null).reduce((a, b) => Math.min(a, b), 1e400);
34392
+ return {
34393
+ min: Array.from(scales.value.keys()).map((s) => s.limits?.min).filter((v) => v != null).reduce((a, b) => Math.max(a, b), -1e400),
34394
+ max
34395
+ };
34396
+ });
34271
34397
  const guide_breaks = (0, vue.computed)(() => {
34272
- let res = __props.breaks.map(() => ({}));
34398
+ let { breaks, labels, titles } = props;
34399
+ if (typeof breaks === "function") breaks = breaks({
34400
+ ...limits.value,
34401
+ scales: scales.value,
34402
+ sources: __props.sources
34403
+ });
34404
+ if (!Array.isArray(breaks)) breaks = [];
34405
+ if (typeof labels === "function") labels = breaks.map(labels);
34406
+ if (!Array.isArray(labels)) labels = [];
34407
+ else if (labels.length !== breaks.length) {
34408
+ console.warn("[vvplot] Length of labels must be the same as breaks.");
34409
+ labels = [];
34410
+ }
34411
+ if (typeof titles === "function") titles = breaks.map(titles);
34412
+ if (!Array.isArray(titles)) titles = [];
34413
+ else if (titles.length !== breaks.length) {
34414
+ console.warn("[vvplot] Length of titles must be the same as breaks.");
34415
+ titles = [];
34416
+ }
34417
+ let res = breaks.map(() => ({}));
34273
34418
  for (let [scale, glyphs] of scales.value) {
34274
- let scaled = scale(__props.breaks);
34419
+ let scaled = scale(breaks);
34275
34420
  for (let glyph in glyphs) {
34276
34421
  res.forEach((v) => v[glyph] ??= {});
34277
34422
  for (let i = 0; i < scaled.length; i++) res[i][glyph][scale.aesthetics] = scaled[i];
34278
34423
  }
34279
34424
  }
34280
34425
  let cates = categorize(res);
34281
- return Array.from(Map.groupBy(__props.breaks.map((x) => String(x)), (_, i) => cates.categories[cates[i]])).map(([bind, labels]) => ({
34282
- label: labels.join("; "),
34283
- bind
34426
+ let labelTexts = breaks.map((value, i) => labels[i] ?? String(value));
34427
+ let titleTexts = breaks.map((value, i) => titles[i] ?? labelTexts[i]);
34428
+ return Array.from(Map.groupBy(breaks.map((_, i) => i), (_, i) => cates.categories[cates[i]]), ([bind, indices]) => ({
34429
+ bind,
34430
+ label: indices.map((i) => labelTexts[i]).join("; "),
34431
+ title: indices.map((i) => titleTexts[i]).join("; ")
34284
34432
  }));
34285
34433
  });
34286
34434
  const h = (0, vue.computed)(() => __props.theme.key_size + __props.theme.key_spacing);
@@ -34293,7 +34441,7 @@ var VVPlot = (function(exports, vue) {
34293
34441
  };
34294
34442
  });
34295
34443
  return (_ctx, _cache) => {
34296
- return (0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)(guide_breaks.value, ({ bind, label }, i) => {
34444
+ return (0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)(guide_breaks.value, ({ bind, label, title }, i) => {
34297
34445
  return (0, vue.openBlock)(), (0, vue.createElementBlock)("g", { transform: `translate(0, ${i * h.value})` }, [
34298
34446
  (0, vue.createElementVNode)("g", { transform: `translate(${w.value / 2}, ${h.value / 2})` }, [((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)(appearances.value, (appearance, glyph) => {
34299
34447
  return (0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, { key: glyph }, [glyph_exports[glyph] ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.resolveDynamicComponent)(glyph_exports[glyph]), (0, vue.mergeProps)({
@@ -34309,50 +34457,61 @@ var VVPlot = (function(exports, vue) {
34309
34457
  key: 0,
34310
34458
  x: w.value,
34311
34459
  y: h.value / 2
34312
- }, { ref_for: true }, text_bind.value, { text: label }), null, 16, [
34460
+ }, { ref_for: true }, text_bind.value, {
34461
+ text: label,
34462
+ title
34463
+ }), null, 16, [
34313
34464
  "x",
34314
34465
  "y",
34315
- "text"
34466
+ "text",
34467
+ "title"
34316
34468
  ])) : ((0, vue.openBlock)(), (0, vue.createBlock)(_sfc_main$75, (0, vue.mergeProps)({
34317
34469
  key: 1,
34318
34470
  x: w.value,
34319
34471
  y: h.value / 2
34320
- }, { ref_for: true }, text_bind.value, { text: label }), null, 16, [
34472
+ }, { ref_for: true }, text_bind.value, {
34473
+ text: label,
34474
+ title
34475
+ }), null, 16, [
34321
34476
  "x",
34322
34477
  "y",
34323
- "text"
34478
+ "text",
34479
+ "title"
34324
34480
  ]))
34325
- ], 8, _hoisted_1$18);
34481
+ ], 8, _hoisted_1$19);
34326
34482
  }), 256);
34327
34483
  };
34328
34484
  }
34329
34485
  });
34330
34486
  // src/core/guide/CoreGuide.vue
34331
- var _hoisted_1$17 = ["width", "height"];
34332
- var _hoisted_2$1 = { ref: "g" };
34333
- var _hoisted_3$1 = ["transform"];
34334
- var _sfc_main$62 = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
34487
+ var _hoisted_1$18 = { ref: "g" };
34488
+ var _hoisted_2$1 = ["transform"];
34489
+ var _sfc_main$62 = {
34335
34490
  __name: "CoreGuide",
34336
34491
  props: {
34337
- breaks: Array,
34338
- sources: Array,
34339
34492
  type: {
34340
34493
  type: String,
34341
34494
  default: "legendkey"
34342
34495
  },
34343
- theme: Object
34496
+ sources: Array,
34497
+ theme: Object,
34498
+ title: null,
34499
+ breaks: [Array, Function],
34500
+ labels: [Array, Function],
34501
+ titles: [Array, Function],
34502
+ bins: Number
34344
34503
  },
34345
34504
  setup(__props, { expose: __expose }) {
34505
+ const props = (0, vue.createPropsRestProxy)(__props, [
34506
+ "type",
34507
+ "sources",
34508
+ "theme",
34509
+ "title"
34510
+ ]);
34346
34511
  const guide = {
34347
34512
  legendkey: _sfc_main$63,
34348
34513
  gradientbar: _sfc_main$72
34349
34514
  };
34350
- const scales = (0, vue.computed)(() => __props.sources.map((source) => source.scale));
34351
- const title = (0, vue.computed)(() => {
34352
- let scales = __props.sources.map((source) => source.scale);
34353
- for (let { title } of scales) if (title !== void 0) return title;
34354
- for (let { _title } of scales) if (_title !== void 0) return _title;
34355
- });
34356
34515
  const title_bind = (0, vue.computed)(() => {
34357
34516
  let size = __props.theme.title_size || 0;
34358
34517
  return {
@@ -34360,146 +34519,126 @@ var VVPlot = (function(exports, vue) {
34360
34519
  color: __props.theme.title_color,
34361
34520
  y: size * 1.2 / 2,
34362
34521
  "anchor-x": 0,
34363
- text: title.value
34522
+ text: __props.title
34364
34523
  };
34365
34524
  });
34366
- const binds = (0, vue.computed)(() => {
34367
- if (__props.type == "legendkey") return { sources: __props.sources };
34368
- else if (__props.type == "gradientbar") {
34369
- let max = scales.value.map((s) => s.limits?.max).filter((v) => v != null).reduce((a, b) => Math.min(a, b), Infinity);
34370
- let min = scales.value.map((s) => s.limits?.min).filter((v) => v != null).reduce((a, b) => Math.max(a, b), -Infinity);
34371
- return {
34372
- scales: scales.value,
34373
- limits: {
34374
- min,
34375
- max
34376
- },
34377
- appearance: obj_merge(...__props.sources.flatMap((source) => Object.values(source.appearance)))
34378
- };
34379
- }
34525
+ const size = (0, vue.reactive)({
34526
+ width: 0,
34527
+ height: 0
34380
34528
  });
34381
- const width = (0, vue.ref)(0), height = (0, vue.ref)(0);
34382
- const svgRef = (0, vue.useTemplateRef)("svg");
34383
- useResizeObserver((0, vue.useTemplateRef)("g"), ([entry]) => {
34384
- let bbox = svgRef.value?.getBBox?.();
34529
+ const gRef = (0, vue.useTemplateRef)("g");
34530
+ useResizeObserver(gRef, () => {
34531
+ let bbox = gRef.value?.getBBox?.();
34385
34532
  if (!bbox) return;
34386
- width.value = bbox.width + bbox.x;
34387
- height.value = bbox.height + bbox.y;
34533
+ let { width, height } = bbox;
34534
+ if (size.width !== width) size.width = width;
34535
+ if (size.height !== height) size.height = height;
34388
34536
  });
34389
- __expose({ serialize(options) {
34390
- return serializeSVG(svgRef.value, options);
34391
- } });
34537
+ __expose({ size });
34392
34538
  return (_ctx, _cache) => {
34393
- return (0, vue.openBlock)(), (0, vue.createElementBlock)("svg", {
34394
- ref: "svg",
34395
- width: width.value,
34396
- height: height.value
34397
- }, [(0, vue.createElementVNode)("g", _hoisted_2$1, [
34398
- title.value && __props.theme.title_type == "markdown" ? ((0, vue.openBlock)(), (0, vue.createBlock)(_sfc_main$74, (0, vue.normalizeProps)((0, vue.mergeProps)({ key: 0 }, title_bind.value)), null, 16)) : title.value ? ((0, vue.openBlock)(), (0, vue.createBlock)(_sfc_main$75, (0, vue.normalizeProps)((0, vue.mergeProps)({ key: 1 }, title_bind.value)), null, 16)) : (0, vue.createCommentVNode)("", true),
34539
+ return (0, vue.openBlock)(), (0, vue.createElementBlock)("g", _hoisted_1$18, [
34540
+ __props.title && __props.theme.title_type == "markdown" ? ((0, vue.openBlock)(), (0, vue.createBlock)(_sfc_main$74, (0, vue.normalizeProps)((0, vue.mergeProps)({ key: 0 }, title_bind.value)), null, 16)) : __props.title ? ((0, vue.openBlock)(), (0, vue.createBlock)(_sfc_main$75, (0, vue.normalizeProps)((0, vue.mergeProps)({ key: 1 }, title_bind.value)), null, 16)) : (0, vue.createCommentVNode)("", true),
34399
34541
  _cache[0] || (_cache[0] = (0, vue.createTextVNode)()),
34400
- (0, vue.createElementVNode)("g", { transform: title.value ? `translate(0, ${title_bind.value.y * 2})` : null }, [((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.resolveDynamicComponent)(guide[__props.type]), (0, vue.mergeProps)(binds.value, {
34401
- theme: __props.theme,
34402
- breaks: __props.breaks
34403
- }), null, 16, ["theme", "breaks"]))], 8, _hoisted_3$1)
34404
- ], 512)], 8, _hoisted_1$17);
34542
+ (0, vue.createElementVNode)("g", { transform: __props.title ? `translate(0, ${title_bind.value.y * 2})` : null }, [((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.resolveDynamicComponent)(guide[__props.type]), (0, vue.mergeProps)({
34543
+ sources: __props.sources,
34544
+ theme: __props.theme
34545
+ }, props), null, 16, ["sources", "theme"]))], 8, _hoisted_2$1)
34546
+ ], 512);
34405
34547
  };
34406
34548
  }
34407
- });
34549
+ };
34408
34550
  // src/core/CoreLegend.vue
34551
+ var _hoisted_1$17 = [
34552
+ "width",
34553
+ "height",
34554
+ "transform"
34555
+ ];
34409
34556
  var _sfc_main$61 = {
34410
34557
  __name: "CoreLegend",
34411
34558
  props: {
34559
+ guideGroups: {
34560
+ type: Array,
34561
+ default: () => []
34562
+ },
34412
34563
  theme: {
34413
34564
  type: Object,
34414
34565
  default: () => ({})
34415
34566
  },
34416
- scales: Map
34567
+ guides: Object,
34568
+ direction: String,
34569
+ anchorX: [Number, String],
34570
+ anchorY: [Number, String]
34417
34571
  },
34418
34572
  setup(__props, { expose: __expose }) {
34419
- const guides = (0, vue.computed)(() => {
34420
- let entries = Array.from(__props.scales).filter(([fn]) => fn.legend !== false && fn.limits?.min != fn.limits?.max).map(([scale, appearance]) => {
34421
- let breaks = scale.breaks;
34422
- if (typeof breaks === "function") breaks = breaks(scale.limits);
34423
- if (scale.level != null) breaks ??= scale.level.apply(scale.level);
34424
- breaks ??= break_default.number({ minor: true })(scale.limits);
34425
- breaks = Array.isArray(breaks) ? Array.from(breaks) : [];
34426
- let guide = scale.guide;
34427
- if (!scale.level && [
34428
- "color",
34429
- "fill",
34430
- "alpha"
34431
- ].includes(scale.aesthetics)) guide ??= "gradientbar";
34432
- guide ??= "legendkey";
34573
+ const groups = (0, vue.computed)(() => {
34574
+ if (!__props.guides?.length) return __props.guideGroups;
34575
+ let gmap = new Map(__props.guideGroups.map((group) => [group.key, group]));
34576
+ return __props.guides.filter(({ key }) => key != null && gmap.has(key)).map(({ key, theme: $$theme, title: $$title, ...guide }) => {
34577
+ let { theme: $theme, title: $title, ...etc } = gmap.get(key);
34433
34578
  return {
34434
- guide,
34435
- breaks,
34436
- scale,
34437
- appearance
34438
- };
34439
- });
34440
- let cate = categorize(entries.map(({ guide, breaks, scale }) => ({
34441
- guide,
34442
- breaks,
34443
- key: scale.key
34444
- })), (a, b, lvl) => {
34445
- if (a instanceof EnumElement && b instanceof EnumElement) return a.label === b.label && a.value === b.value;
34446
- if (a instanceof EnumElement || b instanceof EnumElement) return false;
34447
- });
34448
- return Array.from(Map.groupBy(entries.map(({ scale, appearance }) => ({
34449
- scale,
34450
- appearance
34451
- })), (_, i) => cate.categories[cate[i]])).map(([{ guide, breaks, key }, sources], i) => {
34452
- key ??= "_guide_" + (i + 1);
34453
- return {
34454
- sources,
34455
- guide,
34456
- breaks,
34457
- key
34579
+ theme: $$theme ?? $theme,
34580
+ title: $$title ?? $title,
34581
+ ...etc,
34582
+ ...guide
34458
34583
  };
34459
34584
  });
34460
34585
  });
34461
- const guidesRef = (0, vue.useTemplateRef)("legend-guides");
34462
- function serialize() {
34463
- const parser = new DOMParser();
34464
- let svgs = guidesRef.value.map((p) => p?.serialize?.()).filter((x) => x != null).map((xml) => parser.parseFromString(xml, "image/svg+xml").documentElement);
34465
- if (svgs.length == 0) return;
34466
- let width = svgs.reduce((acc, svg) => acc > svg.viewBox.baseVal.width ? acc : svg.viewBox.baseVal.width, 0);
34467
- let height = svgs.reduce((acc, svg) => acc + svg.viewBox.baseVal.height, 0) + (__props.theme.spacing || 0) * (svgs.length - 1);
34468
- let result = document.createElementNS("http://www.w3.org/2000/svg", "svg");
34469
- result.setAttribute("xmlns", "http://www.w3.org/2000/svg");
34470
- result.setAttribute("width", width);
34471
- result.setAttribute("height", height);
34472
- let offset = 0;
34473
- for (let svg of svgs) {
34474
- let g = svg.childNodes[0];
34475
- g.setAttribute("transform", `translate(0, ${offset})`);
34476
- offset += svg.viewBox.baseVal.height + (__props.theme.spacing || 0);
34477
- result.appendChild(g);
34586
+ const spacing = (0, vue.computed)(() => isFinite(__props.theme.spacing) ? +__props.theme.spacing : 0);
34587
+ const guideRefs = (0, vue.shallowReactive)([]);
34588
+ const layout = (0, vue.computed)(() => {
34589
+ let x = 0, y = 0, width = 0, height = 0;
34590
+ let transforms = [];
34591
+ for (let guide of guideRefs ?? []) {
34592
+ let size = guide?.size ?? {
34593
+ width: 0,
34594
+ height: 0
34595
+ };
34596
+ transforms.push(`translate(${x}, ${y})`);
34597
+ if (__props.direction === "horizontal") {
34598
+ x += size.width + spacing.value;
34599
+ width = x - spacing.value;
34600
+ height = Math.max(height, size.height);
34601
+ } else {
34602
+ y += size.height + spacing.value;
34603
+ height = y - spacing.value;
34604
+ width = Math.max(width, size.width);
34605
+ }
34478
34606
  }
34479
- return new XMLSerializer().serializeToString(result);
34480
- }
34481
- __expose({ serialize });
34607
+ return {
34608
+ width,
34609
+ height,
34610
+ transforms
34611
+ };
34612
+ });
34613
+ const transform = (0, vue.computed)(() => {
34614
+ if (__props.anchorX == null && __props.anchorY == null) return null;
34615
+ let alnX = {
34616
+ left: 0,
34617
+ center: .5,
34618
+ right: 1
34619
+ }[__props.anchorX] ?? +(__props.anchorX ?? .5), alnY = {
34620
+ bottom: 0,
34621
+ center: .5,
34622
+ top: 1
34623
+ }[__props.anchorY] ?? +(__props.anchorY ?? .5);
34624
+ return `translate(${layout.value.width * -alnX}, ${layout.value.height * (alnY - 1)})`;
34625
+ });
34626
+ __expose({ svg: (0, vue.useTemplateRef)("svg") });
34482
34627
  return (_ctx, _cache) => {
34483
- return __props.scales ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", {
34628
+ return groups.value.length ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("svg", {
34484
34629
  key: 0,
34485
- class: "vvplot-legend",
34486
- style: (0, vue.normalizeStyle)({ gap: `${__props.theme.spacing || 0}px` })
34487
- }, [((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)(guides.value, ({ sources, guide, breaks, key }) => {
34488
- return (0, vue.openBlock)(), (0, vue.createBlock)(_sfc_main$62, {
34630
+ ref: "svg",
34631
+ width: layout.value.width,
34632
+ height: layout.value.height,
34633
+ overflow: "visible",
34634
+ transform: transform.value
34635
+ }, [((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)(groups.value, (guide, i) => {
34636
+ return (0, vue.openBlock)(), (0, vue.createBlock)(_sfc_main$62, (0, vue.mergeProps)({
34489
34637
  ref_for: true,
34490
- ref: "legend-guides",
34491
- key,
34492
- sources,
34493
- type: guide,
34494
- breaks,
34495
- theme: __props.theme
34496
- }, null, 8, [
34497
- "sources",
34498
- "type",
34499
- "breaks",
34500
- "theme"
34501
- ]);
34502
- }), 128))], 4)) : (0, vue.createCommentVNode)("", true);
34638
+ ref: (el) => (0, vue.unref)(guideRefs)[i] = el,
34639
+ transform: layout.value.transforms[i]
34640
+ }, { ref_for: true }, guide), null, 16, ["transform"]);
34641
+ }), 256))], 8, _hoisted_1$17)) : (0, vue.createCommentVNode)("", true);
34503
34642
  };
34504
34643
  }
34505
34644
  };
@@ -34516,8 +34655,9 @@ var VVPlot = (function(exports, vue) {
34516
34655
  var _hoisted_5 = ["transform"];
34517
34656
  var _hoisted_6 = ["clip-path"];
34518
34657
  var _hoisted_7 = ["transform", "clip-path"];
34519
- var _hoisted_8 = { key: 1 };
34520
- var _sfc_main$60 = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
34658
+ var _hoisted_8 = ["transform"];
34659
+ var _hoisted_9 = { key: 0 };
34660
+ var _sfc_main$60 = {
34521
34661
  __name: "CorePlot",
34522
34662
  props: /*@__PURE__*/ (0, vue.mergeModels)({
34523
34663
  schema: Object,
@@ -34535,6 +34675,10 @@ var VVPlot = (function(exports, vue) {
34535
34675
  type: Array,
34536
34676
  default: () => []
34537
34677
  },
34678
+ legends: {
34679
+ type: Array,
34680
+ default: () => []
34681
+ },
34538
34682
  theme: Object,
34539
34683
  render: String,
34540
34684
  clip: Boolean,
@@ -34546,8 +34690,7 @@ var VVPlot = (function(exports, vue) {
34546
34690
  selections: {
34547
34691
  type: Array,
34548
34692
  default: () => []
34549
- },
34550
- legendTeleport: null
34693
+ }
34551
34694
  }, {
34552
34695
  "selectionPreview": {},
34553
34696
  "selectionPreviewModifiers": {},
@@ -34611,7 +34754,7 @@ var VVPlot = (function(exports, vue) {
34611
34754
  const transition = (0, vue.useModel)(__props, "transition");
34612
34755
  const svgRef = (0, vue.useTemplateRef)("svg");
34613
34756
  const layers = (0, vue.useTemplateRef)("layers");
34614
- const legendRef = (0, vue.useTemplateRef)("legend");
34757
+ const legendRef = (0, vue.shallowReactive)(/* @__PURE__ */ new Map());
34615
34758
  const width = (0, vue.ref)(0), height = (0, vue.ref)(0);
34616
34759
  useResizeObserver(svgRef, (entries) => {
34617
34760
  let { width: w, height: h } = entries[0].contentRect;
@@ -34718,10 +34861,52 @@ var VVPlot = (function(exports, vue) {
34718
34861
  fullHeight: h
34719
34862
  };
34720
34863
  });
34864
+ const legends = (0, vue.computed)(() => props.legends.map(({ teleport, positionX: x, positionY: y, anchorX, anchorY, key, ...etc } = {}, i) => {
34865
+ if (teleport) return {
34866
+ teleport,
34867
+ vBind: etc
34868
+ };
34869
+ anchorX ??= {
34870
+ left: "left",
34871
+ right: "right"
34872
+ }[x] ?? "center";
34873
+ anchorY ??= {
34874
+ bottom: "bottom",
34875
+ top: "top"
34876
+ }[y] ?? "center";
34877
+ if (typeof x == "string") {
34878
+ x = {
34879
+ left: "0%",
34880
+ center: "50%",
34881
+ right: "100%"
34882
+ }[x] ?? x;
34883
+ if (x.endsWith("%")) x = panel.width * x.slice(0, -1) / 100;
34884
+ }
34885
+ if (typeof y == "string") {
34886
+ y = {
34887
+ bottom: "0%",
34888
+ center: "50%",
34889
+ top: "100%"
34890
+ }[y] ?? y;
34891
+ if (y.endsWith("%")) y = panel.height * (1 - y.slice(0, -1) / 100);
34892
+ } else y = panel.height - y;
34893
+ return {
34894
+ key: key ?? i,
34895
+ x: x || void 0,
34896
+ y: y || void 0,
34897
+ vBind: {
34898
+ anchorX,
34899
+ anchorY,
34900
+ ...etc
34901
+ }
34902
+ };
34903
+ }));
34721
34904
  __expose({
34722
34905
  panel,
34723
34906
  svg: svgRef,
34724
- legend: legendRef
34907
+ getLegendSvg(key) {
34908
+ return (key == null ? legendRef.values().next().value : legendRef.get(key)).svg;
34909
+ }
34725
34910
  });
34726
34911
  const transformBind = (0, vue.computed)(() => {
34727
34912
  let tslH = activeTransform.value.translateH + innerRect.left, tslV = activeTransform.value.translateV + innerRect.top, sclH = activeTransform.value.scaleH, sclV = activeTransform.value.scaleV, transform = [];
@@ -34897,11 +35082,21 @@ var VVPlot = (function(exports, vue) {
34897
35082
  max: interval == 0 ? 0 : (max - $max) / interval
34898
35083
  };
34899
35084
  }
35085
+ function clientToOffset({ clientX, clientY }) {
35086
+ let ctm = svgRef.value?.getScreenCTM?.();
35087
+ if (!ctm) return {
35088
+ offsetX: clientX,
35089
+ offsetY: clientY
35090
+ };
35091
+ let { x: offsetX, y: offsetY } = new DOMPoint(clientX, clientY).matrixTransform(ctm.inverse());
35092
+ return {
35093
+ offsetX,
35094
+ offsetY
35095
+ };
35096
+ }
34900
35097
  function getCoord(event) {
34901
- let rect = svgRef.value.getBoundingClientRect();
34902
- let scaleX = rect.width / svgRef.value.clientWidth, scaleY = rect.height / svgRef.value.clientHeight;
34903
- let offsetX = event.clientX - rect.left, offsetY = event.clientY - rect.top;
34904
- let l = offsetX / scaleX - (panel.left + innerRect.left), t = offsetY / scaleY - (panel.top + innerRect.top), r = panel.left + innerRect.right - offsetX / scaleX, b = panel.top + innerRect.bottom - offsetY / scaleY;
35098
+ let { offsetX, offsetY } = clientToOffset(event);
35099
+ let l = offsetX - (panel.left + innerRect.left), t = offsetY - (panel.top + innerRect.top), r = panel.left + innerRect.right - offsetX, b = panel.top + innerRect.bottom - offsetY;
34905
35100
  let { x, y } = pos2coord({
34906
35101
  h: l,
34907
35102
  v: t
@@ -34921,9 +35116,8 @@ var VVPlot = (function(exports, vue) {
34921
35116
  getCoord
34922
35117
  };
34923
35118
  function isInPlot(event) {
34924
- let rect = svgRef.value.getBoundingClientRect();
34925
- let scaleX = rect.width / svgRef.value.clientWidth, scaleY = rect.height / svgRef.value.clientHeight;
34926
- return event.clientX - rect.left > panel.l * scaleX && rect.right - event.clientX > panel.r * scaleX && event.clientY - rect.top > panel.t * scaleY && rect.bottom - event.clientY > panel.b * scaleY;
35119
+ let { offsetX, offsetY } = clientToOffset(event);
35120
+ return offsetX > panel.left && offsetX < panel.right && offsetY > panel.top && offsetY < panel.bottom;
34927
35121
  }
34928
35122
  function dispatchPointerEvent(e) {
34929
35123
  if (!layers.value || e._vhandled || !isInPlot(e)) return e;
@@ -34933,7 +35127,7 @@ var VVPlot = (function(exports, vue) {
34933
35127
  }
34934
35128
  return e;
34935
35129
  }
34936
- let moveTimer, movementX = 0, movementY = 0;
35130
+ let moveTimer;
34937
35131
  function svgPointerdown(e) {
34938
35132
  let evt = dispatchPointerEvent(e), coord = getCoord(e);
34939
35133
  emit("pointerdown", evt, coord);
@@ -35048,8 +35242,7 @@ var VVPlot = (function(exports, vue) {
35048
35242
  "metaKey"
35049
35243
  ].every((k) => a[k] == e[k]));
35050
35244
  if (act) {
35051
- let rect = svgRef.value.getBoundingClientRect();
35052
- let scaleX = rect.width / svgRef.value.clientWidth, scaleY = rect.height / svgRef.value.clientHeight;
35245
+ let { offsetX: h0, offsetY: v0 } = clientToOffset(e);
35053
35246
  e.target.setPointerCapture(e.pointerId);
35054
35247
  svg.style.userSelect = "none";
35055
35248
  moveTimer = clearTimeout(moveTimer);
@@ -35057,19 +35250,18 @@ var VVPlot = (function(exports, vue) {
35057
35250
  let boundary = coord2pos(act);
35058
35251
  e.target.onpointermove = (ev) => {
35059
35252
  let { x = false, y = false } = act;
35060
- let [h, v] = __props.flip ? [y, x] : [x, y];
35061
- if (h) {
35062
- movementX += ev.movementX;
35063
- let dh = oob_squish_any(-movementX / scaleX, {
35253
+ let { offsetX: h, offsetY: v } = clientToOffset(ev);
35254
+ let movementH = h - h0, movementV = v - v0;
35255
+ if (__props.flip ? y : x) {
35256
+ let dh = oob_squish_any(-movementH, {
35064
35257
  min: boundary.hmin - hmin0,
35065
35258
  max: boundary.hmax - hmax0
35066
35259
  });
35067
35260
  h1 = hmin0 + dh;
35068
35261
  h2 = hmax0 + dh;
35069
35262
  }
35070
- if (v) {
35071
- movementY += ev.movementY;
35072
- let dv = oob_squish_any(-movementY / scaleY, {
35263
+ if (__props.flip ? x : y) {
35264
+ let dv = oob_squish_any(-movementV, {
35073
35265
  min: boundary.vmin - vmin0,
35074
35266
  max: boundary.vmax - vmax0
35075
35267
  });
@@ -35094,7 +35286,6 @@ var VVPlot = (function(exports, vue) {
35094
35286
  svg.style.userSelect = null;
35095
35287
  moveTimer = setTimeout(() => {
35096
35288
  applyTransform(act, ev);
35097
- movementX = movementY = 0;
35098
35289
  }, 300);
35099
35290
  }, { once: true });
35100
35291
  return;
@@ -35131,12 +35322,12 @@ var VVPlot = (function(exports, vue) {
35131
35322
  let boundary = coord2pos(act);
35132
35323
  let hmin, hmax, vmin, vmax;
35133
35324
  if (h) {
35134
- hmin = Math.max(pos.l - Math.max(pos.l, 0) * lvl, boundary.hmin ?? -Infinity);
35135
- hmax = Math.min(pos.l + Math.max(pos.r, 0) * lvl, boundary.hmax ?? Infinity);
35325
+ hmin = Math.max(pos.l - Math.max(pos.l, 0) * lvl, boundary.hmin ?? -1e400);
35326
+ hmax = Math.min(pos.l + Math.max(pos.r, 0) * lvl, boundary.hmax ?? 1e400);
35136
35327
  }
35137
35328
  if (v) {
35138
- vmin = Math.max(pos.t - Math.max(pos.t, 0) * lvl, boundary.vmin ?? -Infinity);
35139
- vmax = Math.min(pos.t + Math.max(pos.b, 0) * lvl, boundary.vmax ?? Infinity);
35329
+ vmin = Math.max(pos.t - Math.max(pos.t, 0) * lvl, boundary.vmin ?? -1e400);
35330
+ vmax = Math.min(pos.t + Math.max(pos.b, 0) * lvl, boundary.vmax ?? 1e400);
35140
35331
  }
35141
35332
  let { xmin, xmax, ymin, ymax } = pos2coord({
35142
35333
  hmin,
@@ -35358,12 +35549,71 @@ var VVPlot = (function(exports, vue) {
35358
35549
  };
35359
35550
  });
35360
35551
  });
35552
+ const guideGroups = (0, vue.computed)(() => {
35553
+ let entries = [];
35554
+ for (let [scale, appearance] of gplot.value.scales) {
35555
+ if (scale.legend === false) continue;
35556
+ if (scale.limits?.min == scale.limits?.max) continue;
35557
+ let type = scale.guide;
35558
+ if (!scale.level && [
35559
+ "color",
35560
+ "fill",
35561
+ "alpha"
35562
+ ].includes(scale.aesthetics)) type ??= "gradientbar";
35563
+ type ??= "legendkey";
35564
+ if (type === "none" || typeof type !== "string") continue;
35565
+ let breaks = scale.breaks;
35566
+ if (typeof breaks === "function") breaks = breaks(scale.limits);
35567
+ if (scale.level != null) breaks ??= scale.level.apply(scale.level);
35568
+ breaks ??= break_default.number({ minor: true })(scale.limits);
35569
+ breaks = Array.isArray(breaks) ? Array.from(breaks) : [];
35570
+ entries.push({
35571
+ key: scale.key,
35572
+ type,
35573
+ breaks,
35574
+ scale,
35575
+ appearance
35576
+ });
35577
+ }
35578
+ let cate = categorize(entries.map(({ type, breaks, key }) => ({
35579
+ type,
35580
+ breaks,
35581
+ key
35582
+ })), (a, b) => {
35583
+ if (a instanceof EnumElement && b instanceof EnumElement) return a.label === b.label && a.value === b.value;
35584
+ if (a instanceof EnumElement || b instanceof EnumElement) return false;
35585
+ });
35586
+ let usedKeys = /* @__PURE__ */ new Set(), suffix = 0;
35587
+ return Array.from(Map.groupBy(entries, (_, i) => cate[i]), ([idx, sources]) => {
35588
+ let { key, type, breaks } = cate.categories[idx];
35589
+ let title = sources.find((s) => s.scale.title != null)?.scale.title ?? sources.find((s) => s.scale._title != null)?.scale._title;
35590
+ if (key != null) {
35591
+ let $key = key, suffix = 1;
35592
+ while (usedKeys.has(key)) key = `${$key}#${++suffix}`;
35593
+ if (key !== $key) console.warn(`[vvplot] Guide key "${$key}" is used by incompatible guides; split "${key}" instead.`);
35594
+ } else do
35595
+ key = `_guide_${++suffix}`;
35596
+ while (usedKeys.has(key));
35597
+ usedKeys.add(key);
35598
+ return {
35599
+ key,
35600
+ type,
35601
+ title,
35602
+ breaks,
35603
+ theme: __props.theme.guide,
35604
+ sources: sources.map(({ scale, appearance }) => ({
35605
+ scale,
35606
+ appearance
35607
+ }))
35608
+ };
35609
+ });
35610
+ });
35361
35611
  return (_ctx, _cache) => {
35362
35612
  return (0, vue.openBlock)(), (0, vue.createElementBlock)("svg", (0, vue.mergeProps)({
35363
35613
  ref: "svg",
35364
35614
  width: "100%",
35365
35615
  height: "100%"
35366
- }, (0, vue.toHandlers)(svgVOn, true), _ctx.$attrs, { style: { "touch-action": "none" } }), [
35616
+ }, (0, vue.toHandlers)(svgVOn, true), { style: { "touch-action": "none" } }), [
35367
35617
  (0, vue.createElementVNode)("defs", null, [(0, vue.createElementVNode)("clipPath", { id: `${(0, vue.unref)(vid)}-plot-clip` }, [(0, vue.createElementVNode)("rect", {
35368
35618
  x: "0",
35369
35619
  y: "0",
@@ -35502,28 +35752,44 @@ var VVPlot = (function(exports, vue) {
35502
35752
  })
35503
35753
  ], 8, _hoisted_7),
35504
35754
  _cache[12] || (_cache[12] = (0, vue.createTextVNode)()),
35505
- (0, vue.renderSlot)(_ctx.$slots, "default"),
35755
+ legends.value.length ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("g", {
35756
+ key: 1,
35757
+ transform: `translate(${(0, vue.unref)(panel).left}, ${(0, vue.unref)(panel).top})`
35758
+ }, [((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)(legends.value, (legend, i) => {
35759
+ return (0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, null, [legend.teleport ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("foreignObject", _hoisted_9, [((0, vue.openBlock)(), (0, vue.createBlock)(vue.Teleport, {
35760
+ defer: "",
35761
+ to: legend.teleport
35762
+ }, [(0, vue.createVNode)(_sfc_main$61, (0, vue.mergeProps)({
35763
+ ref_for: true,
35764
+ ref: (el) => (0, vue.unref)(legendRef).set(legend.key, el)
35765
+ }, { ref_for: true }, legend.vBind, { "guide-groups": guideGroups.value }), null, 16, ["guide-groups"])], 8, ["to"]))])) : ((0, vue.openBlock)(), (0, vue.createBlock)(_sfc_main$61, (0, vue.mergeProps)({
35766
+ key: 1,
35767
+ ref_for: true,
35768
+ ref: (el) => (0, vue.unref)(legendRef).set(legend.key, el)
35769
+ }, { ref_for: true }, legend.vBind, {
35770
+ "guide-groups": guideGroups.value,
35771
+ x: legend.x,
35772
+ y: legend.y
35773
+ }), null, 16, [
35774
+ "guide-groups",
35775
+ "x",
35776
+ "y"
35777
+ ]))], 64);
35778
+ }), 256))], 8, _hoisted_8)) : (0, vue.createCommentVNode)("", true),
35506
35779
  _cache[13] || (_cache[13] = (0, vue.createTextVNode)()),
35780
+ (0, vue.renderSlot)(_ctx.$slots, "default"),
35781
+ _cache[14] || (_cache[14] = (0, vue.createTextVNode)()),
35507
35782
  (0, vue.renderSlot)(_ctx.$slots, "overlay-plot", {
35508
35783
  mapping,
35509
35784
  layout: (0, vue.unref)(innerRect),
35510
35785
  panel: (0, vue.unref)(panel),
35511
35786
  activeTransform: activeTransform.value
35512
- }),
35513
- _cache[14] || (_cache[14] = (0, vue.createTextVNode)()),
35514
- props.legendTeleport ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("foreignObject", _hoisted_8, [((0, vue.openBlock)(), (0, vue.createBlock)(vue.Teleport, {
35515
- defer: "",
35516
- to: props.legendTeleport
35517
- }, [(0, vue.createVNode)(_sfc_main$61, {
35518
- ref: "legend",
35519
- scales: gplot.value?.scales,
35520
- theme: __props.theme.legend
35521
- }, null, 8, ["scales", "theme"])], 8, ["to"]))])) : (0, vue.createCommentVNode)("", true)
35787
+ })
35522
35788
  ], 16);
35523
35789
  };
35524
35790
  }
35525
- });
35526
- // src/components/Plot.vue
35791
+ };
35792
+ // src/core/Plot.vue
35527
35793
  var _hoisted_1$15 = {
35528
35794
  key: 0,
35529
35795
  class: "vvplot-panel",
@@ -35556,8 +35822,11 @@ var VVPlot = (function(exports, vue) {
35556
35822
  default: true
35557
35823
  },
35558
35824
  resize: null,
35559
- legendTeleport: null,
35560
- dpi: Number
35825
+ dpi: Number,
35826
+ overflow: {
35827
+ type: String,
35828
+ default: "hidden"
35829
+ }
35561
35830
  }, {
35562
35831
  "selectionPreview": { default: () => ({}) },
35563
35832
  "selectionPreviewModifiers": {},
@@ -35584,15 +35853,6 @@ var VVPlot = (function(exports, vue) {
35584
35853
  "update:height"
35585
35854
  ]),
35586
35855
  setup(__props, { expose: __expose, emit: __emit }) {
35587
- const components = {
35588
- VVAxis: _sfc_main$90,
35589
- VVAxisX: _sfc_main$89,
35590
- VVAxisY: _sfc_main$88,
35591
- VVAxisBreak: _sfc_main$87,
35592
- VVAction: _sfc_main$86,
35593
- VVSelection: _sfc_main$85,
35594
- VVGeom: _sfc_main$84
35595
- };
35596
35856
  const opponents = {
35597
35857
  x: "y",
35598
35858
  y: "x",
@@ -35619,7 +35879,7 @@ var VVPlot = (function(exports, vue) {
35619
35879
  capitalize(camelize(tag))
35620
35880
  ];
35621
35881
  for (let name of names) {
35622
- let type = components[name] ?? getComponent(name) ?? globalComponents[name];
35882
+ let type = components_exports$2[name] ?? getComponent(name) ?? globalComponents[name];
35623
35883
  if (type != null) return type;
35624
35884
  }
35625
35885
  }
@@ -35647,6 +35907,7 @@ var VVPlot = (function(exports, vue) {
35647
35907
  layer: {},
35648
35908
  action: {},
35649
35909
  selection: {},
35910
+ legend: {},
35650
35911
  dom: {}
35651
35912
  });
35652
35913
  for (let key in $slots) {
@@ -35666,11 +35927,12 @@ var VVPlot = (function(exports, vue) {
35666
35927
  const vaxis = (0, vue.computed)(() => Object.values(vnodes.axis).flat());
35667
35928
  const vaction = (0, vue.computed)(() => Object.values(vnodes.action).flat());
35668
35929
  const vselection = (0, vue.computed)(() => Object.values(vnodes.selection).flat());
35930
+ const vlegend = (0, vue.computed)(() => Object.values(vnodes.legend).flat());
35669
35931
  const vdom = (0, vue.computed)(() => Object.keys(vnodes.dom).flatMap((k) => k == "panel" ? [] : vnodes.dom[k]));
35670
35932
  const vdom_svg = (0, vue.computed)(() => vdom.value.filter((v) => isSVGTag(v.type)));
35671
35933
  const vdom_etc = (0, vue.computed)(() => vdom.value.filter((v) => !isSVGTag(v.type)));
35672
35934
  const vBind = (0, vue.computed)(() => {
35673
- let plot = {};
35935
+ let plot = { overflow: __props.overflow };
35674
35936
  let wrapper = {};
35675
35937
  for (let key in $attrs) if (key.startsWith("on")) {
35676
35938
  let arr = Array.isArray($attrs[key]) ? $attrs[key] : [$attrs[key]];
@@ -35686,6 +35948,43 @@ var VVPlot = (function(exports, vue) {
35686
35948
  const theme = (0, vue.computed)(() => {
35687
35949
  return themeBuild(themePreprocess(themeMerge(...[theme_base, theme_default$1].concat(__props.theme ?? [])), __props.flip));
35688
35950
  }, { deep: true });
35951
+ const legends = (0, vue.computed)(() => {
35952
+ return vlegend.value.map((c) => {
35953
+ let { theme: $$theme = [], teleport, key, ...etc } = {
35954
+ key: c.key,
35955
+ ...c.type.$_props,
35956
+ ...c.props
35957
+ };
35958
+ let config = {
35959
+ positionX: "right",
35960
+ positionY: "top",
35961
+ anchorX: void 0,
35962
+ anchorY: void 0
35963
+ };
35964
+ let guides = Object.values(c.children ?? {}).filter((s) => s instanceof Function).flatMap((s) => s()).filter((c) => c.type?.$_type === "guide").map((c) => ({
35965
+ key: c.key,
35966
+ ...c.type.$_props,
35967
+ ...c.props
35968
+ })).map(({ theme: $$theme = [], ...$etc }) => ({
35969
+ theme: Object.assign({}, ...[theme.value?.guide].concat($$theme)),
35970
+ ...$etc
35971
+ }));
35972
+ for (let key in etc) {
35973
+ let k = camelize(key);
35974
+ if (k in config) {
35975
+ config[k] = etc[key];
35976
+ continue;
35977
+ }
35978
+ }
35979
+ return {
35980
+ key,
35981
+ guides,
35982
+ teleport,
35983
+ theme: Object.assign({}, ...[theme.value?.legend].concat($$theme)),
35984
+ ...config
35985
+ };
35986
+ });
35987
+ });
35689
35988
  const primaryAxis = reactiveComputed(() => {
35690
35989
  let allAxes = vaxis.value.map((c) => ({
35691
35990
  ...c.type.$_props,
@@ -35718,14 +36017,14 @@ var VVPlot = (function(exports, vue) {
35718
36017
  };
35719
36018
  });
35720
36019
  const layers = (0, vue.computed)(() => {
35721
- return vlayer.value.map((layer) => {
36020
+ return vlayer.value.map((c) => {
35722
36021
  let { geom, stat, renderer, aes, scales, data, key, ...etc } = {
35723
- ...layer.type.$_props,
35724
- ...layer.props
36022
+ ...c.type.$_props,
36023
+ ...c.props
35725
36024
  };
35726
36025
  if (typeof geom === "string") renderer ??= geom;
35727
- let argnames = layer.type.$_argnames || [];
35728
- let optnames = layer.type.$_optnames || [];
36026
+ let argnames = c.type.$_argnames || [];
36027
+ let optnames = c.type.$_optnames || [];
35729
36028
  let $$aes = {}, args = {}, attrs = {}, opts = {}, vBind = {};
35730
36029
  let config = {
35731
36030
  extendX: 0,
@@ -36153,7 +36452,7 @@ var VVPlot = (function(exports, vue) {
36153
36452
  const wrapperStyle = (0, vue.computed)(() => {
36154
36453
  let style = {
36155
36454
  position: "relative",
36156
- overflow: "hidden",
36455
+ overflow: __props.overflow,
36157
36456
  boxSizing: "border-box"
36158
36457
  };
36159
36458
  if (__props.resize === "both" || __props.resize === true || __props.resize === "") Object.assign(style, { resize: "both" });
@@ -36171,8 +36470,11 @@ var VVPlot = (function(exports, vue) {
36171
36470
  async export(options) {
36172
36471
  return exportSVG(plotRef.value.svg, options);
36173
36472
  },
36174
- serializeLegend(options) {
36175
- return plotRef.value.legend.serialize(options);
36473
+ serializeLegend(key, options) {
36474
+ return serializeSVG(plotRef.value.getLegendSvg(key), options);
36475
+ },
36476
+ async exportLegend(key, options) {
36477
+ return exportSVG(plotRef.value.getLegendSvg(key), options);
36176
36478
  },
36177
36479
  ...$vvplot
36178
36480
  });
@@ -36209,7 +36511,7 @@ var VVPlot = (function(exports, vue) {
36209
36511
  clip: __props.clip,
36210
36512
  render: __props.render,
36211
36513
  dpi: __props.dpi ?? 96 * (0, vue.unref)(pixelRatio),
36212
- legendTeleport: __props.legendTeleport,
36514
+ legends: legends.value,
36213
36515
  onSelect: _cache[3] || (_cache[3] = (d, e) => emit("select", d, e))
36214
36516
  }), (0, vue.createSlots)({
36215
36517
  default: (0, vue.withCtx)(() => [((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)(vdom_svg.value, (c) => {
@@ -36243,7 +36545,7 @@ var VVPlot = (function(exports, vue) {
36243
36545
  "clip",
36244
36546
  "render",
36245
36547
  "dpi",
36246
- "legendTeleport"
36548
+ "legends"
36247
36549
  ]),
36248
36550
  _cache[5] || (_cache[5] = (0, vue.createTextVNode)()),
36249
36551
  (0, vue.createElementVNode)("div", {
@@ -36515,12 +36817,12 @@ var VVPlot = (function(exports, vue) {
36515
36817
  });
36516
36818
  // src/components.ts
36517
36819
  var components_exports = /* @__PURE__ */ __exportAll({
36518
- VVAction: () => _sfc_main$86,
36519
- VVAxis: () => _sfc_main$90,
36520
- VVAxisBreak: () => _sfc_main$87,
36521
- VVAxisX: () => _sfc_main$89,
36522
- VVAxisY: () => _sfc_main$88,
36523
- VVGeom: () => _sfc_main$84,
36820
+ VVAction: () => _sfc_main$88,
36821
+ VVAxis: () => _sfc_main$92,
36822
+ VVAxisBreak: () => _sfc_main$89,
36823
+ VVAxisX: () => _sfc_main$91,
36824
+ VVAxisY: () => _sfc_main$90,
36825
+ VVGeom: () => _sfc_main$86,
36524
36826
  VVGeomBar: () => _sfc_main$58,
36525
36827
  VVGeomBlank: () => _sfc_main$57,
36526
36828
  VVGeomBoxplot: () => _sfc_main$56,
@@ -36544,8 +36846,10 @@ var VVPlot = (function(exports, vue) {
36544
36846
  VVGeomTextsegment: () => _sfc_main$38,
36545
36847
  VVGeomTile: () => _sfc_main$37,
36546
36848
  VVGeomViolin: () => _sfc_main$36,
36849
+ VVGuide: () => _sfc_main$84,
36850
+ VVLegend: () => _sfc_main$85,
36547
36851
  VVPlot: () => _sfc_main$59,
36548
- VVSelection: () => _sfc_main$85
36852
+ VVSelection: () => _sfc_main$87
36549
36853
  });
36550
36854
  // src/elements/ElementCurve.vue
36551
36855
  var _hoisted_1$14 = { key: 0 };
@@ -37544,7 +37848,7 @@ var VVPlot = (function(exports, vue) {
37544
37848
  uniform: (x) => Math.abs(x) <= 1 ? .5 : 0,
37545
37849
  triangular: (x) => Math.abs(x) <= 1 ? 1 - Math.abs(x) : 0,
37546
37850
  epanechnikov: (x) => Math.abs(x) <= 1 ? .75 * (1 - x ** 2) : 0,
37547
- biweight: (x) => Math.abs(x) <= 1 ? 15 / 16 * (1 - x ** 2) ** 2 : 0,
37851
+ biweight: (x) => Math.abs(x) <= 1 ? .9375 * (1 - x ** 2) ** 2 : 0,
37548
37852
  triweight: (x) => Math.abs(x) <= 1 ? 35 / 32 * (1 - x ** 2) ** 3 : 0,
37549
37853
  tricube: (x) => Math.abs(x) <= 1 ? 70 / 81 * (1 - Math.abs(x) ** 3) ** 3 : 0,
37550
37854
  gaussian: (x) => Math.exp(-.5 * x ** 2) / Math.sqrt(2 * Math.PI),
@@ -38066,7 +38370,7 @@ var VVPlot = (function(exports, vue) {
38066
38370
  uniform: (x) => Math.abs(x) <= 1 ? .5 : 0,
38067
38371
  triangular: (x) => Math.abs(x) <= 1 ? 1 - Math.abs(x) : 0,
38068
38372
  epanechnikov: (x) => Math.abs(x) <= 1 ? .75 * (1 - x ** 2) : 0,
38069
- biweight: (x) => Math.abs(x) <= 1 ? 15 / 16 * (1 - x ** 2) ** 2 : 0,
38373
+ biweight: (x) => Math.abs(x) <= 1 ? .9375 * (1 - x ** 2) ** 2 : 0,
38070
38374
  triweight: (x) => Math.abs(x) <= 1 ? 35 / 32 * (1 - x ** 2) ** 3 : 0,
38071
38375
  tricube: (x) => Math.abs(x) <= 1 ? 70 / 81 * (1 - Math.abs(x) ** 3) ** 3 : 0,
38072
38376
  gaussian: (x) => Math.exp(-.5 * x ** 2) / Math.sqrt(2 * Math.PI),