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.
@@ -1,7 +1,7 @@
1
+ import { Fragment, Teleport, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createPropsRestProxy, createSlots, createTextVNode, createVNode, getCurrentInstance, getCurrentScope, guardReactiveProps, hasInjectionContext, inject, isRef, mergeModels, mergeProps, normalizeProps, normalizeStyle, onMounted, onScopeDispose, openBlock, provide, reactive, ref, renderList, renderSlot, resolveDynamicComponent, shallowReactive, shallowReadonly, shallowRef, toDisplayString, toHandlers, toValue, unref, useAttrs, useId, useModel, useSlots, useTemplateRef, watch, watchEffect, withCtx } from "vue";
1
2
  import { Asis, EnumElement, EnumLevel, __exportAll, categorize, deepEqual, is_categorical, numutils, obj_merge, oob_censor, oob_squish_any, oob_squish_infinite, plus, str_c, unique } from "./chunk-utils.js";
2
3
  import { dropNull, emitEvent, expandFragment, exportSVG, parseLinetype, pointerEvents, serializeSVG, useEventClone } from "./chunk-utils2.js";
3
- import { _sfc_main as _sfc_main$54, _sfc_main$1 as _sfc_main$53, _sfc_main$10 as _sfc_main$44, _sfc_main$11 as _sfc_main$43, _sfc_main$12 as _sfc_main$42, _sfc_main$13 as _sfc_main$41, _sfc_main$14 as _sfc_main$40, _sfc_main$15 as _sfc_main$39, _sfc_main$16 as _sfc_main$38, _sfc_main$17 as _sfc_main$37, _sfc_main$18 as _sfc_main$36, _sfc_main$19 as _sfc_main$35, _sfc_main$2 as _sfc_main$52, _sfc_main$20 as _sfc_main$34, _sfc_main$21 as _sfc_main$33, _sfc_main$22 as _sfc_main$32, _sfc_main$23 as _sfc_main$31, _sfc_main$24 as _sfc_main$30, _sfc_main$25 as _sfc_main$27, _sfc_main$26 as _sfc_main$28, _sfc_main$27 as _sfc_main$29, _sfc_main$3 as _sfc_main$51, _sfc_main$4 as _sfc_main$50, _sfc_main$5 as _sfc_main$49, _sfc_main$6 as _sfc_main$48, _sfc_main$7 as _sfc_main$47, _sfc_main$8 as _sfc_main$46, _sfc_main$9 as _sfc_main$45, getComponent, resolveElement, resolveGeom, resolveRenderer, resolveStat } from "./chunk-GeomViolin.js";
4
- import { Fragment, Teleport, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createPropsRestProxy, createSlots, createTextVNode, createVNode, getCurrentInstance, getCurrentScope, guardReactiveProps, hasInjectionContext, inject, isRef, mergeModels, mergeProps, normalizeProps, normalizeStyle, onMounted, onScopeDispose, openBlock, provide, reactive, ref, renderList, renderSlot, resolveDynamicComponent, shallowReactive, shallowReadonly, shallowRef, toDisplayString, toHandlers, toValue, unref, useAttrs, useId, useModel, useSlots, useTemplateRef, watch, watchEffect, withCtx } from "vue";
4
+ import { _sfc_main as _sfc_main$56, _sfc_main$1 as _sfc_main$55, _sfc_main$10 as _sfc_main$46, _sfc_main$11 as _sfc_main$45, _sfc_main$12 as _sfc_main$44, _sfc_main$13 as _sfc_main$43, _sfc_main$14 as _sfc_main$42, _sfc_main$15 as _sfc_main$41, _sfc_main$16 as _sfc_main$40, _sfc_main$17 as _sfc_main$39, _sfc_main$18 as _sfc_main$38, _sfc_main$19 as _sfc_main$37, _sfc_main$2 as _sfc_main$54, _sfc_main$20 as _sfc_main$36, _sfc_main$21 as _sfc_main$35, _sfc_main$22 as _sfc_main$34, _sfc_main$23 as _sfc_main$33, _sfc_main$24 as _sfc_main$32, _sfc_main$25 as _sfc_main$29, _sfc_main$26 as _sfc_main$30, _sfc_main$27 as _sfc_main$31, _sfc_main$3 as _sfc_main$53, _sfc_main$4 as _sfc_main$52, _sfc_main$5 as _sfc_main$51, _sfc_main$6 as _sfc_main$50, _sfc_main$7 as _sfc_main$49, _sfc_main$8 as _sfc_main$48, _sfc_main$9 as _sfc_main$47, getComponent, resolveElement, resolveGeom, resolveRenderer, resolveStat } from "./chunk-GeomViolin.js";
5
5
  // node_modules/@vueuse/shared/dist/index.js
6
6
  /**
7
7
  * Call onScopeDispose() if it's inside an effect scope lifecycle, if not, do nothing
@@ -272,7 +272,7 @@ function useResizeObserver(target, callback, options = {}) {
272
272
  }
273
273
  // node_modules/@vue/shared/dist/shared.esm-bundler.js
274
274
  /**
275
- * @vue/shared v3.5.45
275
+ * @vue/shared v3.5.46
276
276
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
277
277
  * @license MIT
278
278
  **/
@@ -286,10 +286,18 @@ var NO = () => false;
286
286
  var extend$1 = Object.assign;
287
287
  var isArray = Array.isArray;
288
288
  var isString = (val) => typeof val === "string";
289
+ var STRING_CACHE_MAX_SIZE = 1e4;
289
290
  var cacheStringFunction = (fn) => {
290
- const cache = /* @__PURE__ */ Object.create(null);
291
+ let cache = /* @__PURE__ */ Object.create(null);
292
+ let size = 0;
291
293
  return ((str) => {
292
- return cache[str] || (cache[str] = fn(str));
294
+ const hit = cache[str];
295
+ if (hit !== void 0) return hit;
296
+ if (++size > STRING_CACHE_MAX_SIZE) {
297
+ cache = /* @__PURE__ */ Object.create(null);
298
+ size = 1;
299
+ }
300
+ return cache[str] = fn(str);
293
301
  });
294
302
  };
295
303
  var camelizeRE = /-\w/g;
@@ -302,7 +310,7 @@ var capitalize = /* @__PURE__ */ cacheStringFunction((str) => {
302
310
  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");
303
311
  // node_modules/@vue/compiler-core/dist/compiler-core.esm-bundler.js
304
312
  /**
305
- * @vue/compiler-core v3.5.45
313
+ * @vue/compiler-core v3.5.46
306
314
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
307
315
  * @license MIT
308
316
  **/
@@ -2111,11 +2119,12 @@ var theme_base = {
2111
2119
  padding_h: 50,
2112
2120
  padding_v: 30
2113
2121
  },
2114
- legend: {
2115
- spacing: 4,
2122
+ legend: { spacing: 4 },
2123
+ guide: {
2116
2124
  title_size: 18,
2117
2125
  label_size: 16,
2118
2126
  key_size: 10,
2127
+ bin_size: 3,
2119
2128
  key_spacing: 10
2120
2129
  },
2121
2130
  selection: { background: "#00000020" }
@@ -2274,7 +2283,8 @@ function themeBuild(theme) {
2274
2283
  background: theme?.plot?.background
2275
2284
  },
2276
2285
  selection: theme?.selection ?? {},
2277
- legend: theme?.legend ?? {}
2286
+ legend: theme?.legend ?? {},
2287
+ guide: theme?.guide ?? {}
2278
2288
  };
2279
2289
  }
2280
2290
  var theme_default$1 = {
@@ -2364,37 +2374,62 @@ function createRangeStore({ initialRange = {}, initialPreview = {}, onRangeChang
2364
2374
  };
2365
2375
  }
2366
2376
  // src/components/Axis.vue
2367
- var _sfc_main$26 = {
2377
+ var _sfc_main$28 = {
2368
2378
  $_type: "axis",
2369
2379
  $_props: {}
2370
2380
  };
2371
2381
  // src/components/AxisX.vue
2372
- var _sfc_main$25 = {
2382
+ var _sfc_main$27 = {
2373
2383
  $_type: "axis",
2374
2384
  $_props: { coord: "x" }
2375
2385
  };
2376
2386
  // src/components/AxisY.vue
2377
- var _sfc_main$24 = {
2387
+ var _sfc_main$26 = {
2378
2388
  $_type: "axis",
2379
2389
  $_props: { coord: "y" }
2380
2390
  };
2381
2391
  // src/components/AxisBreak.vue
2382
- var _sfc_main$23 = {
2392
+ var _sfc_main$25 = {
2383
2393
  $_type: "axis-break",
2384
2394
  $_props: { type: "major" }
2385
2395
  };
2386
2396
  // src/components/Action.vue
2387
- var _sfc_main$22 = {
2397
+ var _sfc_main$24 = {
2388
2398
  $_type: "action",
2389
2399
  $_props: {}
2390
2400
  };
2391
2401
  // src/components/Selection.vue
2392
- var _sfc_main$21 = {
2402
+ var _sfc_main$23 = {
2393
2403
  $_type: "selection",
2394
2404
  $_props: {}
2395
2405
  };
2396
2406
  // src/components/Geom.vue
2397
- var _sfc_main$20 = { $_type: "layer" };
2407
+ var _sfc_main$22 = {
2408
+ $_type: "layer",
2409
+ $_props: {}
2410
+ };
2411
+ // src/components/Legend.vue
2412
+ var _sfc_main$21 = {
2413
+ $_type: "legend",
2414
+ $_props: {}
2415
+ };
2416
+ // src/components/Guide.vue
2417
+ var _sfc_main$20 = {
2418
+ $_type: "guide",
2419
+ $_props: {}
2420
+ };
2421
+ // src/components/index.ts
2422
+ var components_exports$1 = /* @__PURE__ */ __exportAll({
2423
+ VVAction: () => _sfc_main$24,
2424
+ VVAxis: () => _sfc_main$28,
2425
+ VVAxisBreak: () => _sfc_main$25,
2426
+ VVAxisX: () => _sfc_main$27,
2427
+ VVAxisY: () => _sfc_main$26,
2428
+ VVGeom: () => _sfc_main$22,
2429
+ VVGuide: () => _sfc_main$20,
2430
+ VVLegend: () => _sfc_main$21,
2431
+ VVSelection: () => _sfc_main$23
2432
+ });
2398
2433
  // node_modules/d3-array/dist/d3-array.mjs
2399
2434
  function ascending(a, b) {
2400
2435
  return a == null || b == null ? NaN : a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
@@ -2530,154 +2565,154 @@ var reRgbaPercent = new RegExp(`^rgba\\(${reP},${reP},${reP},${reN}\\)$`);
2530
2565
  var reHslPercent = new RegExp(`^hsl\\(${reN},${reP},${reP}\\)$`);
2531
2566
  var reHslaPercent = new RegExp(`^hsla\\(${reN},${reP},${reP},${reN}\\)$`);
2532
2567
  var named = {
2533
- aliceblue: 15792383,
2534
- antiquewhite: 16444375,
2568
+ aliceblue: 0xf0f8ff,
2569
+ antiquewhite: 0xfaebd7,
2535
2570
  aqua: 65535,
2536
2571
  aquamarine: 8388564,
2537
- azure: 15794175,
2538
- beige: 16119260,
2539
- bisque: 16770244,
2572
+ azure: 0xf0ffff,
2573
+ beige: 0xf5f5dc,
2574
+ bisque: 0xffe4c4,
2540
2575
  black: 0,
2541
- blanchedalmond: 16772045,
2576
+ blanchedalmond: 0xffebcd,
2542
2577
  blue: 255,
2543
2578
  blueviolet: 9055202,
2544
- brown: 10824234,
2545
- burlywood: 14596231,
2579
+ brown: 0xa52a2a,
2580
+ burlywood: 0xdeb887,
2546
2581
  cadetblue: 6266528,
2547
2582
  chartreuse: 8388352,
2548
- chocolate: 13789470,
2549
- coral: 16744272,
2583
+ chocolate: 0xd2691e,
2584
+ coral: 0xff7f50,
2550
2585
  cornflowerblue: 6591981,
2551
- cornsilk: 16775388,
2552
- crimson: 14423100,
2586
+ cornsilk: 0xfff8dc,
2587
+ crimson: 0xdc143c,
2553
2588
  cyan: 65535,
2554
2589
  darkblue: 139,
2555
2590
  darkcyan: 35723,
2556
- darkgoldenrod: 12092939,
2557
- darkgray: 11119017,
2591
+ darkgoldenrod: 0xb8860b,
2592
+ darkgray: 0xa9a9a9,
2558
2593
  darkgreen: 25600,
2559
- darkgrey: 11119017,
2560
- darkkhaki: 12433259,
2594
+ darkgrey: 0xa9a9a9,
2595
+ darkkhaki: 0xbdb76b,
2561
2596
  darkmagenta: 9109643,
2562
2597
  darkolivegreen: 5597999,
2563
- darkorange: 16747520,
2564
- darkorchid: 10040012,
2598
+ darkorange: 0xff8c00,
2599
+ darkorchid: 0x9932cc,
2565
2600
  darkred: 9109504,
2566
- darksalmon: 15308410,
2601
+ darksalmon: 0xe9967a,
2567
2602
  darkseagreen: 9419919,
2568
2603
  darkslateblue: 4734347,
2569
2604
  darkslategray: 3100495,
2570
2605
  darkslategrey: 3100495,
2571
2606
  darkturquoise: 52945,
2572
2607
  darkviolet: 9699539,
2573
- deeppink: 16716947,
2608
+ deeppink: 0xff1493,
2574
2609
  deepskyblue: 49151,
2575
2610
  dimgray: 6908265,
2576
2611
  dimgrey: 6908265,
2577
2612
  dodgerblue: 2003199,
2578
- firebrick: 11674146,
2579
- floralwhite: 16775920,
2613
+ firebrick: 0xb22222,
2614
+ floralwhite: 0xfffaf0,
2580
2615
  forestgreen: 2263842,
2581
- fuchsia: 16711935,
2582
- gainsboro: 14474460,
2583
- ghostwhite: 16316671,
2584
- gold: 16766720,
2585
- goldenrod: 14329120,
2616
+ fuchsia: 0xff00ff,
2617
+ gainsboro: 0xdcdcdc,
2618
+ ghostwhite: 0xf8f8ff,
2619
+ gold: 0xffd700,
2620
+ goldenrod: 0xdaa520,
2586
2621
  gray: 8421504,
2587
2622
  green: 32768,
2588
- greenyellow: 11403055,
2623
+ greenyellow: 0xadff2f,
2589
2624
  grey: 8421504,
2590
- honeydew: 15794160,
2591
- hotpink: 16738740,
2592
- indianred: 13458524,
2625
+ honeydew: 0xf0fff0,
2626
+ hotpink: 0xff69b4,
2627
+ indianred: 0xcd5c5c,
2593
2628
  indigo: 4915330,
2594
- ivory: 16777200,
2595
- khaki: 15787660,
2596
- lavender: 15132410,
2597
- lavenderblush: 16773365,
2629
+ ivory: 0xfffff0,
2630
+ khaki: 0xf0e68c,
2631
+ lavender: 0xe6e6fa,
2632
+ lavenderblush: 0xfff0f5,
2598
2633
  lawngreen: 8190976,
2599
- lemonchiffon: 16775885,
2600
- lightblue: 11393254,
2601
- lightcoral: 15761536,
2602
- lightcyan: 14745599,
2603
- lightgoldenrodyellow: 16448210,
2604
- lightgray: 13882323,
2634
+ lemonchiffon: 0xfffacd,
2635
+ lightblue: 0xadd8e6,
2636
+ lightcoral: 0xf08080,
2637
+ lightcyan: 0xe0ffff,
2638
+ lightgoldenrodyellow: 0xfafad2,
2639
+ lightgray: 0xd3d3d3,
2605
2640
  lightgreen: 9498256,
2606
- lightgrey: 13882323,
2607
- lightpink: 16758465,
2608
- lightsalmon: 16752762,
2641
+ lightgrey: 0xd3d3d3,
2642
+ lightpink: 0xffb6c1,
2643
+ lightsalmon: 0xffa07a,
2609
2644
  lightseagreen: 2142890,
2610
2645
  lightskyblue: 8900346,
2611
2646
  lightslategray: 7833753,
2612
2647
  lightslategrey: 7833753,
2613
- lightsteelblue: 11584734,
2614
- lightyellow: 16777184,
2648
+ lightsteelblue: 0xb0c4de,
2649
+ lightyellow: 0xffffe0,
2615
2650
  lime: 65280,
2616
2651
  limegreen: 3329330,
2617
- linen: 16445670,
2618
- magenta: 16711935,
2652
+ linen: 0xfaf0e6,
2653
+ magenta: 0xff00ff,
2619
2654
  maroon: 8388608,
2620
2655
  mediumaquamarine: 6737322,
2621
2656
  mediumblue: 205,
2622
- mediumorchid: 12211667,
2657
+ mediumorchid: 0xba55d3,
2623
2658
  mediumpurple: 9662683,
2624
2659
  mediumseagreen: 3978097,
2625
2660
  mediumslateblue: 8087790,
2626
2661
  mediumspringgreen: 64154,
2627
2662
  mediumturquoise: 4772300,
2628
- mediumvioletred: 13047173,
2663
+ mediumvioletred: 0xc71585,
2629
2664
  midnightblue: 1644912,
2630
- mintcream: 16121850,
2631
- mistyrose: 16770273,
2632
- moccasin: 16770229,
2633
- navajowhite: 16768685,
2665
+ mintcream: 0xf5fffa,
2666
+ mistyrose: 0xffe4e1,
2667
+ moccasin: 0xffe4b5,
2668
+ navajowhite: 0xffdead,
2634
2669
  navy: 128,
2635
- oldlace: 16643558,
2670
+ oldlace: 0xfdf5e6,
2636
2671
  olive: 8421376,
2637
2672
  olivedrab: 7048739,
2638
- orange: 16753920,
2639
- orangered: 16729344,
2640
- orchid: 14315734,
2641
- palegoldenrod: 15657130,
2642
- palegreen: 10025880,
2643
- paleturquoise: 11529966,
2644
- palevioletred: 14381203,
2645
- papayawhip: 16773077,
2646
- peachpuff: 16767673,
2647
- peru: 13468991,
2648
- pink: 16761035,
2649
- plum: 14524637,
2650
- powderblue: 11591910,
2673
+ orange: 0xffa500,
2674
+ orangered: 0xff4500,
2675
+ orchid: 0xda70d6,
2676
+ palegoldenrod: 0xeee8aa,
2677
+ palegreen: 0x98fb98,
2678
+ paleturquoise: 0xafeeee,
2679
+ palevioletred: 0xdb7093,
2680
+ papayawhip: 0xffefd5,
2681
+ peachpuff: 0xffdab9,
2682
+ peru: 0xcd853f,
2683
+ pink: 0xffc0cb,
2684
+ plum: 0xdda0dd,
2685
+ powderblue: 0xb0e0e6,
2651
2686
  purple: 8388736,
2652
2687
  rebeccapurple: 6697881,
2653
- red: 16711680,
2654
- rosybrown: 12357519,
2688
+ red: 0xff0000,
2689
+ rosybrown: 0xbc8f8f,
2655
2690
  royalblue: 4286945,
2656
2691
  saddlebrown: 9127187,
2657
- salmon: 16416882,
2658
- sandybrown: 16032864,
2692
+ salmon: 0xfa8072,
2693
+ sandybrown: 0xf4a460,
2659
2694
  seagreen: 3050327,
2660
- seashell: 16774638,
2661
- sienna: 10506797,
2662
- silver: 12632256,
2695
+ seashell: 0xfff5ee,
2696
+ sienna: 0xa0522d,
2697
+ silver: 0xc0c0c0,
2663
2698
  skyblue: 8900331,
2664
2699
  slateblue: 6970061,
2665
2700
  slategray: 7372944,
2666
2701
  slategrey: 7372944,
2667
- snow: 16775930,
2702
+ snow: 0xfffafa,
2668
2703
  springgreen: 65407,
2669
2704
  steelblue: 4620980,
2670
- tan: 13808780,
2705
+ tan: 0xd2b48c,
2671
2706
  teal: 32896,
2672
- thistle: 14204888,
2673
- tomato: 16737095,
2707
+ thistle: 0xd8bfd8,
2708
+ tomato: 0xff6347,
2674
2709
  turquoise: 4251856,
2675
- violet: 15631086,
2676
- wheat: 16113331,
2677
- white: 16777215,
2678
- whitesmoke: 16119285,
2679
- yellow: 16776960,
2680
- yellowgreen: 10145074
2710
+ violet: 0xee82ee,
2711
+ wheat: 0xf5deb3,
2712
+ white: 0xffffff,
2713
+ whitesmoke: 0xf5f5f5,
2714
+ yellow: 0xffff00,
2715
+ yellowgreen: 0x9acd32
2681
2716
  };
2682
2717
  define(Color, color, {
2683
2718
  copy(channels) {
@@ -3336,9 +3371,9 @@ function formatLocale(locale) {
3336
3371
  }
3337
3372
  }
3338
3373
  }
3339
- if (comma && !zero) value = group(value, Infinity);
3374
+ if (comma && !zero) value = group(value, 1e400);
3340
3375
  var length = valuePrefix.length + value.length + valueSuffix.length, padding = length < width ? new Array(width - length + 1).join(fill) : "";
3341
- if (comma && zero) value = group(padding + value, padding.length ? width - valueSuffix.length : Infinity), padding = "";
3376
+ if (comma && zero) value = group(padding + value, padding.length ? width - valueSuffix.length : 1e400), padding = "";
3342
3377
  switch (align) {
3343
3378
  case "<":
3344
3379
  value = valuePrefix + value + valueSuffix + padding;
@@ -4002,9 +4037,9 @@ var number_cut = {
4002
4037
  "k": 1e3,
4003
4038
  "M": 1e6,
4004
4039
  "G": 1e9,
4005
- "T": 0xe8d4a51000,
4006
- "P": 0x38d7ea4c68000,
4007
- "E": 0xde0b6b3a7640000,
4040
+ "T": 1e12,
4041
+ "P": 1e15,
4042
+ "E": 1e18,
4008
4043
  "Z": 1e21,
4009
4044
  "Y": 1e24
4010
4045
  },
@@ -4021,9 +4056,9 @@ var number_cut = {
4021
4056
  "k": 1e3,
4022
4057
  "M": 1e6,
4023
4058
  "G": 1e9,
4024
- "T": 0xe8d4a51000,
4025
- "P": 0x38d7ea4c68000,
4026
- "E": 0xde0b6b3a7640000,
4059
+ "T": 1e12,
4060
+ "P": 1e15,
4061
+ "E": 1e18,
4027
4062
  "Z": 1e21,
4028
4063
  "Y": 1e24
4029
4064
  },
@@ -4711,9 +4746,9 @@ var _sfc_main$19 = {
4711
4746
  }
4712
4747
  };
4713
4748
  // src/core/axis/CoreAxisH.vue
4714
- var _hoisted_1$8 = ["transform"];
4749
+ var _hoisted_1$9 = ["transform"];
4715
4750
  var _hoisted_2$5 = ["x2"];
4716
- var _hoisted_3$3 = {
4751
+ var _hoisted_3$2 = {
4717
4752
  class: "vvplot-interactive",
4718
4753
  fill: "transparent"
4719
4754
  };
@@ -4896,14 +4931,24 @@ var _sfc_main$18 = {
4896
4931
  return result.filter((t) => t.text.fill != null).sort((a, b) => a.text.x - b.text.x);
4897
4932
  });
4898
4933
  const iRef = useTemplateRef("i");
4934
+ function clientToOffset({ clientX, clientY }) {
4935
+ let ctm = iRef.value?.getScreenCTM?.();
4936
+ if (!ctm) return {
4937
+ offsetX: clientX,
4938
+ offsetY: clientY
4939
+ };
4940
+ let { x: offsetX, y: offsetY } = new DOMPoint(clientX, clientY).matrixTransform(ctm.inverse());
4941
+ return {
4942
+ offsetX,
4943
+ offsetY
4944
+ };
4945
+ }
4899
4946
  function getPosition(event) {
4900
- let rect = iRef.value.getBoundingClientRect();
4901
- let scaleX = rect.width / iRef.value.getBBox().width;
4902
- let offsetX = event.clientX - rect.left;
4903
- let l = offsetX / scaleX - __props.layout.left;
4947
+ let { offsetX: h } = clientToOffset(event);
4948
+ let l = h - __props.layout.left;
4904
4949
  let result = {
4905
4950
  l,
4906
- r: __props.layout.left + __props.layout.width - offsetX / scaleX
4951
+ r: __props.layout.left + __props.layout.width - h
4907
4952
  };
4908
4953
  let { x, y } = __props.mapping.pos2coord({ h: l });
4909
4954
  if (x) result.x = x;
@@ -4911,7 +4956,7 @@ var _sfc_main$18 = {
4911
4956
  return result;
4912
4957
  }
4913
4958
  const emit = __emit;
4914
- let moveTimer, movementX = 0;
4959
+ let moveTimer;
4915
4960
  function axisMovePointerdown(e) {
4916
4961
  let position = getPosition(e);
4917
4962
  emit("pointerdown", e, position);
@@ -4931,12 +4976,13 @@ var _sfc_main$18 = {
4931
4976
  moveTimer = clearTimeout(moveTimer);
4932
4977
  let hmin0 = 0, hmax0 = __props.layout.width;
4933
4978
  let boundary = __props.mapping.coord2pos(act);
4934
- let scaleX = iRef.value.getBoundingClientRect().width / iRef.value.getBBox().width;
4979
+ let { offsetX: h0 } = clientToOffset(e);
4935
4980
  e.target.setPointerCapture(e.pointerId);
4936
4981
  e.target.onpointermove = (ev) => {
4937
- movementX += ev.movementX;
4982
+ let { offsetX: h } = clientToOffset(ev);
4983
+ let movementH = h - h0;
4938
4984
  if (!pointerMoved) return;
4939
- let dh = oob_squish_any(-movementX / scaleX, {
4985
+ let dh = oob_squish_any(-movementH, {
4940
4986
  min: boundary.hmin - hmin0,
4941
4987
  max: boundary.hmax - hmax0
4942
4988
  });
@@ -4957,7 +5003,6 @@ var _sfc_main$18 = {
4957
5003
  if (!pointerMoved) return;
4958
5004
  moveTimer = setTimeout(() => {
4959
5005
  applyTransform(act, ev);
4960
- movementX = 0;
4961
5006
  }, 300);
4962
5007
  }, { once: true });
4963
5008
  }
@@ -4979,13 +5024,13 @@ var _sfc_main$18 = {
4979
5024
  hmax: coord0.hmin + mrh
4980
5025
  }).hmin
4981
5026
  };
4982
- let scaleX = iRef.value.getBoundingClientRect().width / iRef.value.getBBox().width;
4983
- let movementX = 0;
5027
+ let { offsetX: h0 } = clientToOffset(e);
4984
5028
  e.target.setPointerCapture(e.pointerId);
4985
5029
  e.target.onpointermove = (ev) => {
4986
- movementX += ev.movementX;
5030
+ let { offsetX: h } = clientToOffset(ev);
5031
+ let movementH = h - h0;
4987
5032
  let { xmin, xmax, ymin, ymax } = __props.mapping.pos2coord({
4988
- hmin: oob_squish_any(hmax - (hmax - hmin) * position.r / Math.max(position.r - movementX / scaleX, 1), boundary),
5033
+ hmin: oob_squish_any(hmax - (hmax - hmin) * position.r / Math.max(position.r - movementH, 1), boundary),
4989
5034
  hmax
4990
5035
  });
4991
5036
  rangeStore.updatePreview({
@@ -5018,14 +5063,14 @@ var _sfc_main$18 = {
5018
5063
  }).hmax,
5019
5064
  max: __props.mapping.coord2pos(act).hmax
5020
5065
  };
5021
- iRef.value.getBoundingClientRect().width / iRef.value.getBBox().width;
5022
- let movementX = 0;
5066
+ let { offsetX: h0 } = clientToOffset(e);
5023
5067
  e.target.setPointerCapture(e.pointerId);
5024
5068
  e.target.onpointermove = (ev) => {
5025
- movementX += ev.movementX;
5069
+ let { offsetX: h } = clientToOffset(ev);
5070
+ let movementH = h - h0;
5026
5071
  let { xmin, xmax, ymin, ymax } = __props.mapping.pos2coord({
5027
5072
  hmin,
5028
- hmax: oob_squish_any(hmin + (hmax - hmin) * position.l / Math.max(position.l + movementX, 1), boundary)
5073
+ hmax: oob_squish_any(hmin + (hmax - hmin) * position.l / Math.max(position.l + movementH, 1), boundary)
5029
5074
  });
5030
5075
  rangeStore.updatePreview({
5031
5076
  xmin,
@@ -5066,7 +5111,7 @@ var _sfc_main$18 = {
5066
5111
  let { "min-range-h": mrh = 0, sensitivity = 1.25 } = act;
5067
5112
  let lvl = sensitivity ** (delta / 100);
5068
5113
  let boundary = __props.mapping.coord2pos(act);
5069
- 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);
5114
+ 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);
5070
5115
  let { [__props.coord + "min"]: min, [__props.coord + "max"]: max } = __props.mapping.pos2coord({
5071
5116
  hmin,
5072
5117
  hmax
@@ -5164,7 +5209,7 @@ var _sfc_main$18 = {
5164
5209
  return openBlock(), createElementBlock("g", mergeProps({ ref_for: true }, tick.wrapper), [createVNode(_sfc_main$19, mergeProps({ ref_for: true }, tick.text, { getPosition }), null, 16)], 16);
5165
5210
  }), 256)),
5166
5211
  _cache[3] || (_cache[3] = createTextVNode()),
5167
- createElementVNode("g", _hoisted_3$3, [createElementVNode("rect", mergeProps({
5212
+ createElementVNode("g", _hoisted_3$2, [createElementVNode("rect", mergeProps({
5168
5213
  ref: "i",
5169
5214
  width: width.value,
5170
5215
  height: 10,
@@ -5192,14 +5237,14 @@ var _sfc_main$18 = {
5192
5237
  ])) : createCommentVNode("", true),
5193
5238
  _cache[5] || (_cache[5] = createTextVNode()),
5194
5239
  axisTitle.value.text ? (openBlock(), createBlock(resolveDynamicComponent(TitleElement.value), normalizeProps(mergeProps({ key: 2 }, axisTitle.value)), null, 16)) : createCommentVNode("", true)
5195
- ], 12, _hoisted_1$8);
5240
+ ], 12, _hoisted_1$9);
5196
5241
  };
5197
5242
  }
5198
5243
  };
5199
5244
  // src/core/axis/CoreAxisV.vue
5200
- var _hoisted_1$7 = ["transform"];
5245
+ var _hoisted_1$8 = ["transform"];
5201
5246
  var _hoisted_2$4 = ["y2"];
5202
- var _hoisted_3$2 = {
5247
+ var _hoisted_3$1 = {
5203
5248
  class: "vvplot-interactive",
5204
5249
  fill: "transparent"
5205
5250
  };
@@ -5382,14 +5427,24 @@ var _sfc_main$17 = {
5382
5427
  return result.filter((t) => t.text.fill != null).sort((a, b) => a.text.y - b.text.y);
5383
5428
  });
5384
5429
  const iRef = useTemplateRef("i");
5430
+ function clientToOffset({ clientX, clientY }) {
5431
+ let ctm = iRef.value?.getScreenCTM?.();
5432
+ if (!ctm) return {
5433
+ offsetX: clientX,
5434
+ offsetY: clientY
5435
+ };
5436
+ let { x: offsetX, y: offsetY } = new DOMPoint(clientX, clientY).matrixTransform(ctm.inverse());
5437
+ return {
5438
+ offsetX,
5439
+ offsetY
5440
+ };
5441
+ }
5385
5442
  function getPosition(event) {
5386
- let rect = iRef.value.getBoundingClientRect();
5387
- let scaleY = rect.height / iRef.value.getBBox().height;
5388
- let offsetY = event.clientY - rect.top;
5389
- let t = offsetY / scaleY - __props.layout.top;
5443
+ let { offsetY: v } = clientToOffset(event);
5444
+ let t = v - __props.layout.top;
5390
5445
  let result = {
5391
5446
  t,
5392
- b: __props.layout.top + __props.layout.height - offsetY / scaleY
5447
+ b: __props.layout.top + __props.layout.height - v
5393
5448
  };
5394
5449
  let { x, y } = __props.mapping.pos2coord({ v: t });
5395
5450
  if (x) result.x = x;
@@ -5397,7 +5452,7 @@ var _sfc_main$17 = {
5397
5452
  return result;
5398
5453
  }
5399
5454
  const emit = __emit;
5400
- let moveTimer, movementY = 0;
5455
+ let moveTimer;
5401
5456
  function axisMovePointerdown(e) {
5402
5457
  let position = getPosition(e);
5403
5458
  emit("pointerdown", e, position);
@@ -5417,12 +5472,13 @@ var _sfc_main$17 = {
5417
5472
  moveTimer = clearTimeout(moveTimer);
5418
5473
  let vmin0 = 0, vmax0 = __props.layout.height;
5419
5474
  let boundary = __props.mapping.coord2pos(act);
5420
- let scaleY = iRef.value.getBoundingClientRect().height / iRef.value.getBBox().height;
5475
+ let { offsetY: v0 } = clientToOffset(e);
5421
5476
  e.target.setPointerCapture(e.pointerId);
5422
5477
  e.target.onpointermove = (ev) => {
5423
- movementY += ev.movementY;
5478
+ let { offsetY: v } = clientToOffset(ev);
5479
+ let movementV = v - v0;
5424
5480
  if (!pointerMoved) return;
5425
- let dv = oob_squish_any(-movementY / scaleY, {
5481
+ let dv = oob_squish_any(-movementV, {
5426
5482
  min: boundary.vmin - vmin0,
5427
5483
  max: boundary.vmax - vmax0
5428
5484
  });
@@ -5443,7 +5499,6 @@ var _sfc_main$17 = {
5443
5499
  if (!pointerMoved) return;
5444
5500
  moveTimer = setTimeout(() => {
5445
5501
  applyTransform(act, ev);
5446
- movementY = 0;
5447
5502
  }, 300);
5448
5503
  }, { once: true });
5449
5504
  }
@@ -5465,13 +5520,13 @@ var _sfc_main$17 = {
5465
5520
  vmax: coord0.vmin + mrv
5466
5521
  }).vmin
5467
5522
  };
5468
- let scaleY = iRef.value.getBoundingClientRect().height / iRef.value.getBBox().height;
5469
- let movementY = 0;
5523
+ let { offsetY: v0 } = clientToOffset(e);
5470
5524
  e.target.setPointerCapture(e.pointerId);
5471
5525
  e.target.onpointermove = (ev) => {
5472
- movementY += ev.movementY;
5526
+ let { offsetY: v } = clientToOffset(ev);
5527
+ let movementV = v - v0;
5473
5528
  let { xmin, xmax, ymin, ymax } = __props.mapping.pos2coord({
5474
- vmin: oob_squish_any(vmax - (vmax - vmin) * position.b / Math.max(position.b - movementY / scaleY, 1), boundary),
5529
+ vmin: oob_squish_any(vmax - (vmax - vmin) * position.b / Math.max(position.b - movementV, 1), boundary),
5475
5530
  vmax
5476
5531
  });
5477
5532
  rangeStore.updatePreview({
@@ -5504,14 +5559,14 @@ var _sfc_main$17 = {
5504
5559
  }).vmax,
5505
5560
  max: __props.mapping.coord2pos(act).vmax
5506
5561
  };
5507
- let scaleY = iRef.value.getBoundingClientRect().height / iRef.value.getBBox().height;
5508
- let movementY = 0;
5562
+ let { offsetY: v0 } = clientToOffset(e);
5509
5563
  e.target.setPointerCapture(e.pointerId);
5510
5564
  e.target.onpointermove = (ev) => {
5511
- movementY += ev.movementY;
5565
+ let { offsetY: v } = clientToOffset(ev);
5566
+ let movementV = v - v0;
5512
5567
  let { xmin, xmax, ymin, ymax } = __props.mapping.pos2coord({
5513
5568
  vmin,
5514
- vmax: oob_squish_any(vmin + (vmax - vmin) * position.t / Math.max(position.t + movementY / scaleY, 1), boundary)
5569
+ vmax: oob_squish_any(vmin + (vmax - vmin) * position.t / Math.max(position.t + movementV, 1), boundary)
5515
5570
  });
5516
5571
  rangeStore.updatePreview({
5517
5572
  xmin,
@@ -5552,7 +5607,7 @@ var _sfc_main$17 = {
5552
5607
  let { "min-range-v": mrv = 0, sensitivity = 1.25 } = act;
5553
5608
  let lvl = sensitivity ** (delta / 100);
5554
5609
  let boundary = __props.mapping.coord2pos(act);
5555
- 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);
5610
+ 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);
5556
5611
  let { [__props.coord + "min"]: min, [__props.coord + "max"]: max } = __props.mapping.pos2coord({
5557
5612
  vmin,
5558
5613
  vmax
@@ -5650,7 +5705,7 @@ var _sfc_main$17 = {
5650
5705
  return openBlock(), createElementBlock("g", mergeProps({ ref_for: true }, tick.wrapper), [createVNode(_sfc_main$19, mergeProps({ ref_for: true }, tick.text, { getPosition }), null, 16)], 16);
5651
5706
  }), 256)),
5652
5707
  _cache[3] || (_cache[3] = createTextVNode()),
5653
- createElementVNode("g", _hoisted_3$2, [createElementVNode("rect", mergeProps({
5708
+ createElementVNode("g", _hoisted_3$1, [createElementVNode("rect", mergeProps({
5654
5709
  ref: "i",
5655
5710
  width: 10,
5656
5711
  height: height.value,
@@ -5678,7 +5733,7 @@ var _sfc_main$17 = {
5678
5733
  ])) : createCommentVNode("", true),
5679
5734
  _cache[5] || (_cache[5] = createTextVNode()),
5680
5735
  axisTitle.value.text ? (openBlock(), createBlock(resolveDynamicComponent(TitleElement.value), normalizeProps(mergeProps({ key: 2 }, axisTitle.value)), null, 16)) : createCommentVNode("", true)
5681
- ], 12, _hoisted_1$7);
5736
+ ], 12, _hoisted_1$8);
5682
5737
  };
5683
5738
  }
5684
5739
  };
@@ -5899,7 +5954,7 @@ var _sfc_main$13 = {
5899
5954
  }
5900
5955
  };
5901
5956
  // src/core/CoreSelection.vue
5902
- var _hoisted_1$6 = { key: 0 };
5957
+ var _hoisted_1$7 = { key: 0 };
5903
5958
  var _hoisted_2$3 = ["onPointerdown"];
5904
5959
  var _sfc_main$12 = {
5905
5960
  __name: "CoreSelection",
@@ -6138,6 +6193,7 @@ var _sfc_main$12 = {
6138
6193
  e.preventDefault();
6139
6194
  e.target.setPointerCapture(e.pointerId);
6140
6195
  let { xreverse: $xreverse, yreverse: $yreverse, ...coord0 } = normalize(model.value);
6196
+ let { l: h0, t: v0 } = __props.mapping.getCoord?.(e) ?? {};
6141
6197
  let pos0 = __props.mapping.coord2pos(coord0);
6142
6198
  let { h: coordL, v: coordT } = __props.mapping.pos2coord({
6143
6199
  h: pos0.hmin,
@@ -6156,14 +6212,13 @@ var _sfc_main$12 = {
6156
6212
  max: config.ymax
6157
6213
  }, [mrh = 0, mry = 0] = __props.flip ? [config.minRangeY, config.minRangeX] : [config.minRangeX, config.minRangeY];
6158
6214
  let boundary = __props.mapping.coord2pos(config);
6159
- let movementX = 0, movementY = 0;
6160
6215
  let xmin, xmax, ymin, ymax, xreverse = false, yreverse = false;
6161
6216
  e.target.onpointermove = (ev) => {
6162
6217
  pointerMoved = true;
6163
- movementX += ev.movementX;
6164
- movementY += ev.movementY;
6218
+ let { l: h, t: v } = __props.mapping.getCoord?.(ev) ?? {};
6219
+ let movementH = h - h0 || 0, movementV = v - v0 || 0;
6165
6220
  if (dir.includes("l") && dir.includes("r")) {
6166
- let dh = oob_squish_any(movementX, {
6221
+ let dh = oob_squish_any(movementH, {
6167
6222
  min: boundary.hmin - hmin0,
6168
6223
  max: boundary.hmax - hmax0
6169
6224
  });
@@ -6174,16 +6229,16 @@ var _sfc_main$12 = {
6174
6229
  coordL = coord.hmin;
6175
6230
  coordR = coord.hmax;
6176
6231
  } else if (dir.includes("l")) {
6177
- coordL = __props.mapping.pos2coord({ h: hmin0 + movementX }).h;
6232
+ coordL = __props.mapping.pos2coord({ h: hmin0 + movementH }).h;
6178
6233
  coordL = oob_squish_any(coordL, coordL > coordR ? { min: plus(coordR, mrh) } : { max: plus(coordR, -mrh) });
6179
- xreverse = hmin0 + movementX > hmax0;
6234
+ xreverse = hmin0 + movementH > hmax0;
6180
6235
  } else if (dir.includes("r")) {
6181
- coordR = __props.mapping.pos2coord({ h: hmax0 + movementX }).h;
6236
+ coordR = __props.mapping.pos2coord({ h: hmax0 + movementH }).h;
6182
6237
  coordR = oob_squish_any(coordR, coordR > coordL ? { min: plus(coordL, mrh) } : { max: plus(coordL, -mrh) });
6183
- xreverse = hmax0 + movementX < hmin0;
6238
+ xreverse = hmax0 + movementH < hmin0;
6184
6239
  }
6185
6240
  if (dir.includes("t") && dir.includes("b")) {
6186
- let dv = oob_squish_any(movementY, {
6241
+ let dv = oob_squish_any(movementV, {
6187
6242
  min: boundary.vmin - vmin0,
6188
6243
  max: boundary.vmax - vmax0
6189
6244
  });
@@ -6194,13 +6249,13 @@ var _sfc_main$12 = {
6194
6249
  coordT = coord.vmin;
6195
6250
  coordB = coord.vmax;
6196
6251
  } else if (dir.includes("t")) {
6197
- coordT = __props.mapping.pos2coord({ v: vmin0 + movementY }).v;
6252
+ coordT = __props.mapping.pos2coord({ v: vmin0 + movementV }).v;
6198
6253
  coordT = oob_squish_any(coordT, coordT > coordB ? { min: plus(coordB, mry) } : { max: plus(coordB, -mry) });
6199
- yreverse = vmin0 + movementY > vmax0;
6254
+ yreverse = vmin0 + movementV > vmax0;
6200
6255
  } else if (dir.includes("b")) {
6201
- coordB = __props.mapping.pos2coord({ v: vmax0 + movementY }).v;
6256
+ coordB = __props.mapping.pos2coord({ v: vmax0 + movementV }).v;
6202
6257
  coordB = oob_squish_any(coordB, coordB > coordT ? { min: plus(coordT, mry) } : { max: plus(coordT, -mry) });
6203
- yreverse = vmax0 + movementY < vmin0;
6258
+ yreverse = vmax0 + movementV < vmin0;
6204
6259
  }
6205
6260
  xmin = oob_squish_any(__props.flip ? coordT : coordL, xboundary);
6206
6261
  xmax = oob_squish_any(__props.flip ? coordB : coordR, xboundary);
@@ -6240,7 +6295,7 @@ var _sfc_main$12 = {
6240
6295
  }, { once: true });
6241
6296
  }
6242
6297
  return (_ctx, _cache) => {
6243
- return rectBind.value ? (openBlock(), createElementBlock("g", _hoisted_1$6, [
6298
+ return rectBind.value ? (openBlock(), createElementBlock("g", _hoisted_1$7, [
6244
6299
  createElementVNode("rect", normalizeProps(guardReactiveProps(rectBind.value)), null, 16),
6245
6300
  _cache[0] || (_cache[0] = createTextVNode()),
6246
6301
  (openBlock(true), createElementBlock(Fragment, null, renderList(interactiveBind.value, (bind, k) => {
@@ -6254,46 +6309,87 @@ var _sfc_main$12 = {
6254
6309
  }
6255
6310
  };
6256
6311
  // src/core/guide/CoreGuideGradientbar.vue
6257
- var _hoisted_1$5 = [
6312
+ var _hoisted_1$6 = [
6258
6313
  "x1",
6259
6314
  "x2",
6260
6315
  "y1",
6261
6316
  "y2"
6262
6317
  ];
6263
- var nBins = 30;
6264
6318
  var padding = 5;
6265
6319
  var _sfc_main$11 = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
6266
6320
  __name: "CoreGuideGradientbar",
6267
6321
  props: {
6268
- scales: Array,
6269
- appearance: {
6270
- type: Object,
6271
- default: () => ({})
6322
+ sources: {
6323
+ type: Array,
6324
+ default: () => []
6272
6325
  },
6273
6326
  theme: {
6274
6327
  type: Object,
6275
6328
  default: () => ({})
6276
6329
  },
6277
- breaks: Array,
6278
- limits: Object
6330
+ bins: {
6331
+ type: Number,
6332
+ default: 30
6333
+ },
6334
+ breaks: [Array, Function],
6335
+ labels: [Array, Function],
6336
+ titles: [Array, Function]
6279
6337
  },
6280
6338
  setup(__props) {
6339
+ const props = createPropsRestProxy(__props, [
6340
+ "sources",
6341
+ "theme",
6342
+ "bins"
6343
+ ]);
6344
+ const scales = computed(() => __props.sources.map((source) => source.scale));
6345
+ const appearance = computed(() => obj_merge(...__props.sources.flatMap((source) => Object.values(source.appearance ?? {}))));
6346
+ const limits = computed(() => {
6347
+ let max = scales.value.map((s) => s.limits?.max).filter((v) => v != null).reduce((a, b) => Math.min(a, b), 1e400);
6348
+ return {
6349
+ min: scales.value.map((s) => s.limits?.min).filter((v) => v != null).reduce((a, b) => Math.max(a, b), -1e400),
6350
+ max
6351
+ };
6352
+ });
6281
6353
  const guide_breaks = computed(() => {
6282
- let { min, max } = __props.limits;
6283
- return __props.breaks.map((v) => ({
6284
- position: (v - min) / (max - min),
6285
- label: String(v)
6286
- }));
6354
+ let { breaks, labels, titles } = props;
6355
+ if (typeof breaks === "function") breaks = breaks({
6356
+ ...limits.value,
6357
+ scales: scales.value,
6358
+ sources: __props.sources
6359
+ });
6360
+ if (!Array.isArray(breaks)) breaks = [];
6361
+ if (typeof labels === "function") labels = breaks.map(labels);
6362
+ if (!Array.isArray(labels)) labels = [];
6363
+ else if (labels.length !== breaks.length) {
6364
+ console.warn("[vvplot] Length of labels must be the same as breaks.");
6365
+ labels = [];
6366
+ }
6367
+ if (typeof titles === "function") titles = breaks.map(titles);
6368
+ if (!Array.isArray(titles)) titles = [];
6369
+ else if (titles.length !== breaks.length) {
6370
+ console.warn("[vvplot] Length of titles must be the same as breaks.");
6371
+ titles = [];
6372
+ }
6373
+ let { min, max } = limits.value;
6374
+ return breaks.map((value, i) => {
6375
+ let label = labels[i] ?? String(value);
6376
+ let title = titles[i] ?? label;
6377
+ return {
6378
+ position: (value - min) / (max - min),
6379
+ label,
6380
+ title
6381
+ };
6382
+ });
6287
6383
  });
6288
6384
  const gradient_values = computed(() => {
6289
- let { min, max } = __props.limits;
6290
- let step = (max - min) / 29;
6291
- let cuts = Array.from({ length: nBins }, (_, i) => min + i * step);
6292
- let scaled = __props.scales.map((s) => s(cuts));
6293
- return cuts.map((v, i) => Object.fromEntries(__props.scales.map((s, j) => [{ "color": "fill" }[s.aesthetics] ?? s.aesthetics, scaled[j][i]])));
6385
+ let { min, max } = limits.value;
6386
+ let step = (max - min) / (__props.bins - 1);
6387
+ let cuts = Array.from({ length: __props.bins }, (_, i) => min + i * step);
6388
+ let scaled = scales.value.map((s) => s(cuts));
6389
+ return cuts.map((v, i) => Object.fromEntries(scales.value.map((s, j) => [{ "color": "fill" }[s.aesthetics] ?? s.aesthetics, scaled[j][i]])));
6294
6390
  });
6295
6391
  const w = computed(() => __props.theme.key_size + 10);
6296
- const h = computed(() => __props.theme.key_spacing * 3 / 10);
6392
+ const h = computed(() => __props.theme.bin_size);
6297
6393
  const text_bind = computed(() => {
6298
6394
  return {
6299
6395
  "font-size": __props.theme.label_size || 0,
@@ -6304,12 +6400,12 @@ var _sfc_main$11 = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
6304
6400
  return (_ctx, _cache) => {
6305
6401
  return openBlock(), createElementBlock(Fragment, null, [
6306
6402
  (openBlock(true), createElementBlock(Fragment, null, renderList(gradient_values.value, (v, i) => {
6307
- return openBlock(), createBlock(_sfc_main$27, mergeProps({
6403
+ return openBlock(), createBlock(_sfc_main$29, mergeProps({
6308
6404
  width: __props.theme.key_size,
6309
6405
  height: h.value * 1.05,
6310
6406
  x: w.value / 2,
6311
- y: 10 + (29 - i + .5) * h.value,
6312
- alpha: __props.appearance.alpha
6407
+ y: 10 + (__props.bins - i - .5) * h.value,
6408
+ alpha: appearance.value.alpha
6313
6409
  }, { ref_for: true }, v), null, 16, [
6314
6410
  "width",
6315
6411
  "height",
@@ -6319,32 +6415,40 @@ var _sfc_main$11 = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
6319
6415
  ]);
6320
6416
  }), 256)),
6321
6417
  _cache[1] || (_cache[1] = createTextVNode()),
6322
- (openBlock(true), createElementBlock(Fragment, null, renderList(guide_breaks.value, ({ position, label }, i) => {
6418
+ (openBlock(true), createElementBlock(Fragment, null, renderList(guide_breaks.value, ({ position, label, title }, i) => {
6323
6419
  return openBlock(), createElementBlock("g", null, [
6324
6420
  createElementVNode("line", {
6325
6421
  x1: w.value - padding,
6326
6422
  x2: w.value - padding + 3,
6327
- y1: 10 + (1 - position) * h.value * nBins,
6328
- y2: 10 + (1 - position) * h.value * nBins,
6423
+ y1: 10 + (1 - position) * h.value * __props.bins,
6424
+ y2: 10 + (1 - position) * h.value * __props.bins,
6329
6425
  stroke: "black"
6330
- }, null, 8, _hoisted_1$5),
6426
+ }, null, 8, _hoisted_1$6),
6331
6427
  _cache[0] || (_cache[0] = createTextVNode()),
6332
- __props.theme.label_type == "markdown" ? (openBlock(), createBlock(_sfc_main$28, mergeProps({
6428
+ __props.theme.label_type == "markdown" ? (openBlock(), createBlock(_sfc_main$30, mergeProps({
6333
6429
  key: 0,
6334
6430
  x: w.value,
6335
- y: 10 + (1 - position) * h.value * nBins
6336
- }, { ref_for: true }, text_bind.value, { text: label }), null, 16, [
6431
+ y: 10 + (1 - position) * h.value * __props.bins
6432
+ }, { ref_for: true }, text_bind.value, {
6433
+ text: label,
6434
+ title
6435
+ }), null, 16, [
6337
6436
  "x",
6338
6437
  "y",
6339
- "text"
6340
- ])) : (openBlock(), createBlock(_sfc_main$29, mergeProps({
6438
+ "text",
6439
+ "title"
6440
+ ])) : (openBlock(), createBlock(_sfc_main$31, mergeProps({
6341
6441
  key: 1,
6342
6442
  x: w.value,
6343
- y: 10 + (1 - position) * h.value * nBins
6344
- }, { ref_for: true }, text_bind.value, { text: label }), null, 16, [
6443
+ y: 10 + (1 - position) * h.value * __props.bins
6444
+ }, { ref_for: true }, text_bind.value, {
6445
+ text: label,
6446
+ title
6447
+ }), null, 16, [
6345
6448
  "x",
6346
6449
  "y",
6347
- "text"
6450
+ "text",
6451
+ "title"
6348
6452
  ]))
6349
6453
  ]);
6350
6454
  }), 256))
@@ -6353,7 +6457,7 @@ var _sfc_main$11 = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
6353
6457
  }
6354
6458
  });
6355
6459
  // src/elements/ElementPath.vue
6356
- var _hoisted_1$4 = { key: 0 };
6460
+ var _hoisted_1$5 = { key: 0 };
6357
6461
  var _sfc_main$10 = {
6358
6462
  __name: "ElementPath",
6359
6463
  props: {
@@ -6391,7 +6495,7 @@ var _sfc_main$10 = {
6391
6495
  };
6392
6496
  });
6393
6497
  return (_ctx, _cache) => {
6394
- return openBlock(), createElementBlock("path", normalizeProps(guardReactiveProps(binds.value)), [__props.title ? (openBlock(), createElementBlock("title", _hoisted_1$4, toDisplayString(__props.title), 1)) : createCommentVNode("", true)], 16);
6498
+ return openBlock(), createElementBlock("path", normalizeProps(guardReactiveProps(binds.value)), [__props.title ? (openBlock(), createElementBlock("title", _hoisted_1$5, toDisplayString(__props.title), 1)) : createCommentVNode("", true)], 16);
6395
6499
  };
6396
6500
  }
6397
6501
  };
@@ -6424,7 +6528,7 @@ var _sfc_main$8 = {
6424
6528
  } },
6425
6529
  setup(__props) {
6426
6530
  return (_ctx, _cache) => {
6427
- return openBlock(), createBlock(_sfc_main$30, {
6531
+ return openBlock(), createBlock(_sfc_main$32, {
6428
6532
  x1: -__props.boxSize / 2,
6429
6533
  x2: __props.boxSize / 2,
6430
6534
  color: "black"
@@ -6441,7 +6545,7 @@ var _sfc_main$7 = {
6441
6545
  } },
6442
6546
  setup(__props) {
6443
6547
  return (_ctx, _cache) => {
6444
- return openBlock(), createBlock(_sfc_main$31, { size: __props.boxSize * 6 / 10 }, null, 8, ["size"]);
6548
+ return openBlock(), createBlock(_sfc_main$33, { size: __props.boxSize * 6 / 10 }, null, 8, ["size"]);
6445
6549
  };
6446
6550
  }
6447
6551
  };
@@ -6454,7 +6558,7 @@ var _sfc_main$6 = {
6454
6558
  } },
6455
6559
  setup(__props) {
6456
6560
  return (_ctx, _cache) => {
6457
- return openBlock(), createBlock(_sfc_main$29, {
6561
+ return openBlock(), createBlock(_sfc_main$31, {
6458
6562
  size: __props.boxSize * 4 / 10,
6459
6563
  text: "a"
6460
6564
  }, null, 8, ["size"]);
@@ -6470,7 +6574,7 @@ var _sfc_main$5 = {
6470
6574
  } },
6471
6575
  setup(__props) {
6472
6576
  return (_ctx, _cache) => {
6473
- return openBlock(), createBlock(_sfc_main$27, {
6577
+ return openBlock(), createBlock(_sfc_main$29, {
6474
6578
  width: __props.boxSize,
6475
6579
  height: __props.boxSize
6476
6580
  }, null, 8, ["width", "height"]);
@@ -6486,19 +6590,26 @@ var glyph_exports = /* @__PURE__ */ __exportAll({
6486
6590
  tile: () => _sfc_main$5
6487
6591
  });
6488
6592
  // src/core/guide/CoreGuideLegendkey.vue
6489
- var _hoisted_1$3 = ["transform"];
6593
+ var _hoisted_1$4 = ["transform"];
6490
6594
  var _hoisted_2$2 = ["transform"];
6491
6595
  var _sfc_main$4 = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
6492
6596
  __name: "CoreGuideLegendkey",
6493
6597
  props: {
6494
- sources: Array,
6598
+ sources: {
6599
+ type: Array,
6600
+ default: () => []
6601
+ },
6495
6602
  theme: {
6496
6603
  type: Object,
6497
6604
  default: () => ({})
6498
6605
  },
6499
- breaks: Array
6606
+ bins: Number,
6607
+ breaks: [Array, Function],
6608
+ labels: [Array, Function],
6609
+ titles: [Array, Function]
6500
6610
  },
6501
6611
  setup(__props) {
6612
+ const props = createPropsRestProxy(__props, ["sources", "theme"]);
6502
6613
  const scales = computed(() => new Map(__props.sources.map(({ scale, appearance }) => [scale, appearance ?? {}])));
6503
6614
  const appearances = computed(() => {
6504
6615
  let glyphs = Array.from(scales.value.values().flatMap((v) => Object.keys(v)));
@@ -6506,19 +6617,48 @@ var _sfc_main$4 = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
6506
6617
  for (let geom in result) result[geom] = obj_merge(...result[geom]);
6507
6618
  return result;
6508
6619
  });
6620
+ const limits = computed(() => {
6621
+ let max = Array.from(scales.value.keys()).map((s) => s.limits?.max).filter((v) => v != null).reduce((a, b) => Math.min(a, b), 1e400);
6622
+ return {
6623
+ min: Array.from(scales.value.keys()).map((s) => s.limits?.min).filter((v) => v != null).reduce((a, b) => Math.max(a, b), -1e400),
6624
+ max
6625
+ };
6626
+ });
6509
6627
  const guide_breaks = computed(() => {
6510
- let res = __props.breaks.map(() => ({}));
6628
+ let { breaks, labels, titles } = props;
6629
+ if (typeof breaks === "function") breaks = breaks({
6630
+ ...limits.value,
6631
+ scales: scales.value,
6632
+ sources: __props.sources
6633
+ });
6634
+ if (!Array.isArray(breaks)) breaks = [];
6635
+ if (typeof labels === "function") labels = breaks.map(labels);
6636
+ if (!Array.isArray(labels)) labels = [];
6637
+ else if (labels.length !== breaks.length) {
6638
+ console.warn("[vvplot] Length of labels must be the same as breaks.");
6639
+ labels = [];
6640
+ }
6641
+ if (typeof titles === "function") titles = breaks.map(titles);
6642
+ if (!Array.isArray(titles)) titles = [];
6643
+ else if (titles.length !== breaks.length) {
6644
+ console.warn("[vvplot] Length of titles must be the same as breaks.");
6645
+ titles = [];
6646
+ }
6647
+ let res = breaks.map(() => ({}));
6511
6648
  for (let [scale, glyphs] of scales.value) {
6512
- let scaled = scale(__props.breaks);
6649
+ let scaled = scale(breaks);
6513
6650
  for (let glyph in glyphs) {
6514
6651
  res.forEach((v) => v[glyph] ??= {});
6515
6652
  for (let i = 0; i < scaled.length; i++) res[i][glyph][scale.aesthetics] = scaled[i];
6516
6653
  }
6517
6654
  }
6518
6655
  let cates = categorize(res);
6519
- return Array.from(Map.groupBy(__props.breaks.map((x) => String(x)), (_, i) => cates.categories[cates[i]])).map(([bind, labels]) => ({
6520
- label: labels.join("; "),
6521
- bind
6656
+ let labelTexts = breaks.map((value, i) => labels[i] ?? String(value));
6657
+ let titleTexts = breaks.map((value, i) => titles[i] ?? labelTexts[i]);
6658
+ return Array.from(Map.groupBy(breaks.map((_, i) => i), (_, i) => cates.categories[cates[i]]), ([bind, indices]) => ({
6659
+ bind,
6660
+ label: indices.map((i) => labelTexts[i]).join("; "),
6661
+ title: indices.map((i) => titleTexts[i]).join("; ")
6522
6662
  }));
6523
6663
  });
6524
6664
  const h = computed(() => __props.theme.key_size + __props.theme.key_spacing);
@@ -6531,7 +6671,7 @@ var _sfc_main$4 = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
6531
6671
  };
6532
6672
  });
6533
6673
  return (_ctx, _cache) => {
6534
- return openBlock(true), createElementBlock(Fragment, null, renderList(guide_breaks.value, ({ bind, label }, i) => {
6674
+ return openBlock(true), createElementBlock(Fragment, null, renderList(guide_breaks.value, ({ bind, label, title }, i) => {
6535
6675
  return openBlock(), createElementBlock("g", { transform: `translate(0, ${i * h.value})` }, [
6536
6676
  createElementVNode("g", { transform: `translate(${w.value / 2}, ${h.value / 2})` }, [(openBlock(true), createElementBlock(Fragment, null, renderList(appearances.value, (appearance, glyph) => {
6537
6677
  return openBlock(), createElementBlock(Fragment, { key: glyph }, [glyph_exports[glyph] ? (openBlock(), createBlock(resolveDynamicComponent(glyph_exports[glyph]), mergeProps({
@@ -6543,54 +6683,65 @@ var _sfc_main$4 = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
6543
6683
  }), null, 16, ["box-size"])) : createCommentVNode("", true)], 64);
6544
6684
  }), 128))], 8, _hoisted_2$2),
6545
6685
  _cache[0] || (_cache[0] = createTextVNode()),
6546
- __props.theme.label_type == "markdown" ? (openBlock(), createBlock(_sfc_main$28, mergeProps({
6686
+ __props.theme.label_type == "markdown" ? (openBlock(), createBlock(_sfc_main$30, mergeProps({
6547
6687
  key: 0,
6548
6688
  x: w.value,
6549
6689
  y: h.value / 2
6550
- }, { ref_for: true }, text_bind.value, { text: label }), null, 16, [
6690
+ }, { ref_for: true }, text_bind.value, {
6691
+ text: label,
6692
+ title
6693
+ }), null, 16, [
6551
6694
  "x",
6552
6695
  "y",
6553
- "text"
6554
- ])) : (openBlock(), createBlock(_sfc_main$29, mergeProps({
6696
+ "text",
6697
+ "title"
6698
+ ])) : (openBlock(), createBlock(_sfc_main$31, mergeProps({
6555
6699
  key: 1,
6556
6700
  x: w.value,
6557
6701
  y: h.value / 2
6558
- }, { ref_for: true }, text_bind.value, { text: label }), null, 16, [
6702
+ }, { ref_for: true }, text_bind.value, {
6703
+ text: label,
6704
+ title
6705
+ }), null, 16, [
6559
6706
  "x",
6560
6707
  "y",
6561
- "text"
6708
+ "text",
6709
+ "title"
6562
6710
  ]))
6563
- ], 8, _hoisted_1$3);
6711
+ ], 8, _hoisted_1$4);
6564
6712
  }), 256);
6565
6713
  };
6566
6714
  }
6567
6715
  });
6568
6716
  // src/core/guide/CoreGuide.vue
6569
- var _hoisted_1$2 = ["width", "height"];
6570
- var _hoisted_2$1 = { ref: "g" };
6571
- var _hoisted_3$1 = ["transform"];
6572
- var _sfc_main$3 = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
6717
+ var _hoisted_1$3 = { ref: "g" };
6718
+ var _hoisted_2$1 = ["transform"];
6719
+ var _sfc_main$3 = {
6573
6720
  __name: "CoreGuide",
6574
6721
  props: {
6575
- breaks: Array,
6576
- sources: Array,
6577
6722
  type: {
6578
6723
  type: String,
6579
6724
  default: "legendkey"
6580
6725
  },
6581
- theme: Object
6726
+ sources: Array,
6727
+ theme: Object,
6728
+ title: null,
6729
+ breaks: [Array, Function],
6730
+ labels: [Array, Function],
6731
+ titles: [Array, Function],
6732
+ bins: Number
6582
6733
  },
6583
6734
  setup(__props, { expose: __expose }) {
6735
+ const props = createPropsRestProxy(__props, [
6736
+ "type",
6737
+ "sources",
6738
+ "theme",
6739
+ "title"
6740
+ ]);
6584
6741
  const guide = {
6585
6742
  legendkey: _sfc_main$4,
6586
6743
  gradientbar: _sfc_main$11
6587
6744
  };
6588
- const scales = computed(() => __props.sources.map((source) => source.scale));
6589
- const title = computed(() => {
6590
- let scales = __props.sources.map((source) => source.scale);
6591
- for (let { title } of scales) if (title !== void 0) return title;
6592
- for (let { _title } of scales) if (_title !== void 0) return _title;
6593
- });
6594
6745
  const title_bind = computed(() => {
6595
6746
  let size = __props.theme.title_size || 0;
6596
6747
  return {
@@ -6598,146 +6749,126 @@ var _sfc_main$3 = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
6598
6749
  color: __props.theme.title_color,
6599
6750
  y: size * 1.2 / 2,
6600
6751
  "anchor-x": 0,
6601
- text: title.value
6752
+ text: __props.title
6602
6753
  };
6603
6754
  });
6604
- const binds = computed(() => {
6605
- if (__props.type == "legendkey") return { sources: __props.sources };
6606
- else if (__props.type == "gradientbar") {
6607
- let max = scales.value.map((s) => s.limits?.max).filter((v) => v != null).reduce((a, b) => Math.min(a, b), Infinity);
6608
- let min = scales.value.map((s) => s.limits?.min).filter((v) => v != null).reduce((a, b) => Math.max(a, b), -Infinity);
6609
- return {
6610
- scales: scales.value,
6611
- limits: {
6612
- min,
6613
- max
6614
- },
6615
- appearance: obj_merge(...__props.sources.flatMap((source) => Object.values(source.appearance)))
6616
- };
6617
- }
6755
+ const size = reactive({
6756
+ width: 0,
6757
+ height: 0
6618
6758
  });
6619
- const width = ref(0), height = ref(0);
6620
- const svgRef = useTemplateRef("svg");
6621
- useResizeObserver(useTemplateRef("g"), ([entry]) => {
6622
- let bbox = svgRef.value?.getBBox?.();
6759
+ const gRef = useTemplateRef("g");
6760
+ useResizeObserver(gRef, () => {
6761
+ let bbox = gRef.value?.getBBox?.();
6623
6762
  if (!bbox) return;
6624
- width.value = bbox.width + bbox.x;
6625
- height.value = bbox.height + bbox.y;
6763
+ let { width, height } = bbox;
6764
+ if (size.width !== width) size.width = width;
6765
+ if (size.height !== height) size.height = height;
6626
6766
  });
6627
- __expose({ serialize(options) {
6628
- return serializeSVG(svgRef.value, options);
6629
- } });
6767
+ __expose({ size });
6630
6768
  return (_ctx, _cache) => {
6631
- return openBlock(), createElementBlock("svg", {
6632
- ref: "svg",
6633
- width: width.value,
6634
- height: height.value
6635
- }, [createElementVNode("g", _hoisted_2$1, [
6636
- title.value && __props.theme.title_type == "markdown" ? (openBlock(), createBlock(_sfc_main$28, normalizeProps(mergeProps({ key: 0 }, title_bind.value)), null, 16)) : title.value ? (openBlock(), createBlock(_sfc_main$29, normalizeProps(mergeProps({ key: 1 }, title_bind.value)), null, 16)) : createCommentVNode("", true),
6769
+ return openBlock(), createElementBlock("g", _hoisted_1$3, [
6770
+ __props.title && __props.theme.title_type == "markdown" ? (openBlock(), createBlock(_sfc_main$30, normalizeProps(mergeProps({ key: 0 }, title_bind.value)), null, 16)) : __props.title ? (openBlock(), createBlock(_sfc_main$31, normalizeProps(mergeProps({ key: 1 }, title_bind.value)), null, 16)) : createCommentVNode("", true),
6637
6771
  _cache[0] || (_cache[0] = createTextVNode()),
6638
- createElementVNode("g", { transform: title.value ? `translate(0, ${title_bind.value.y * 2})` : null }, [(openBlock(), createBlock(resolveDynamicComponent(guide[__props.type]), mergeProps(binds.value, {
6639
- theme: __props.theme,
6640
- breaks: __props.breaks
6641
- }), null, 16, ["theme", "breaks"]))], 8, _hoisted_3$1)
6642
- ], 512)], 8, _hoisted_1$2);
6772
+ createElementVNode("g", { transform: __props.title ? `translate(0, ${title_bind.value.y * 2})` : null }, [(openBlock(), createBlock(resolveDynamicComponent(guide[__props.type]), mergeProps({
6773
+ sources: __props.sources,
6774
+ theme: __props.theme
6775
+ }, props), null, 16, ["sources", "theme"]))], 8, _hoisted_2$1)
6776
+ ], 512);
6643
6777
  };
6644
6778
  }
6645
- });
6779
+ };
6646
6780
  // src/core/CoreLegend.vue
6781
+ var _hoisted_1$2 = [
6782
+ "width",
6783
+ "height",
6784
+ "transform"
6785
+ ];
6647
6786
  var _sfc_main$2 = {
6648
6787
  __name: "CoreLegend",
6649
6788
  props: {
6789
+ guideGroups: {
6790
+ type: Array,
6791
+ default: () => []
6792
+ },
6650
6793
  theme: {
6651
6794
  type: Object,
6652
6795
  default: () => ({})
6653
6796
  },
6654
- scales: Map
6797
+ guides: Object,
6798
+ direction: String,
6799
+ anchorX: [Number, String],
6800
+ anchorY: [Number, String]
6655
6801
  },
6656
6802
  setup(__props, { expose: __expose }) {
6657
- const guides = computed(() => {
6658
- let entries = Array.from(__props.scales).filter(([fn]) => fn.legend !== false && fn.limits?.min != fn.limits?.max).map(([scale, appearance]) => {
6659
- let breaks = scale.breaks;
6660
- if (typeof breaks === "function") breaks = breaks(scale.limits);
6661
- if (scale.level != null) breaks ??= scale.level.apply(scale.level);
6662
- breaks ??= break_default.number({ minor: true })(scale.limits);
6663
- breaks = Array.isArray(breaks) ? Array.from(breaks) : [];
6664
- let guide = scale.guide;
6665
- if (!scale.level && [
6666
- "color",
6667
- "fill",
6668
- "alpha"
6669
- ].includes(scale.aesthetics)) guide ??= "gradientbar";
6670
- guide ??= "legendkey";
6671
- return {
6672
- guide,
6673
- breaks,
6674
- scale,
6675
- appearance
6676
- };
6677
- });
6678
- let cate = categorize(entries.map(({ guide, breaks, scale }) => ({
6679
- guide,
6680
- breaks,
6681
- key: scale.key
6682
- })), (a, b, lvl) => {
6683
- if (a instanceof EnumElement && b instanceof EnumElement) return a.label === b.label && a.value === b.value;
6684
- if (a instanceof EnumElement || b instanceof EnumElement) return false;
6685
- });
6686
- return Array.from(Map.groupBy(entries.map(({ scale, appearance }) => ({
6687
- scale,
6688
- appearance
6689
- })), (_, i) => cate.categories[cate[i]])).map(([{ guide, breaks, key }, sources], i) => {
6690
- key ??= "_guide_" + (i + 1);
6803
+ const groups = computed(() => {
6804
+ if (!__props.guides?.length) return __props.guideGroups;
6805
+ let gmap = new Map(__props.guideGroups.map((group) => [group.key, group]));
6806
+ return __props.guides.filter(({ key }) => key != null && gmap.has(key)).map(({ key, theme: $$theme, title: $$title, ...guide }) => {
6807
+ let { theme: $theme, title: $title, ...etc } = gmap.get(key);
6691
6808
  return {
6692
- sources,
6693
- guide,
6694
- breaks,
6695
- key
6809
+ theme: $$theme ?? $theme,
6810
+ title: $$title ?? $title,
6811
+ ...etc,
6812
+ ...guide
6696
6813
  };
6697
6814
  });
6698
6815
  });
6699
- const guidesRef = useTemplateRef("legend-guides");
6700
- function serialize() {
6701
- const parser = new DOMParser();
6702
- let svgs = guidesRef.value.map((p) => p?.serialize?.()).filter((x) => x != null).map((xml) => parser.parseFromString(xml, "image/svg+xml").documentElement);
6703
- if (svgs.length == 0) return;
6704
- let width = svgs.reduce((acc, svg) => acc > svg.viewBox.baseVal.width ? acc : svg.viewBox.baseVal.width, 0);
6705
- let height = svgs.reduce((acc, svg) => acc + svg.viewBox.baseVal.height, 0) + (__props.theme.spacing || 0) * (svgs.length - 1);
6706
- let result = document.createElementNS("http://www.w3.org/2000/svg", "svg");
6707
- result.setAttribute("xmlns", "http://www.w3.org/2000/svg");
6708
- result.setAttribute("width", width);
6709
- result.setAttribute("height", height);
6710
- let offset = 0;
6711
- for (let svg of svgs) {
6712
- let g = svg.childNodes[0];
6713
- g.setAttribute("transform", `translate(0, ${offset})`);
6714
- offset += svg.viewBox.baseVal.height + (__props.theme.spacing || 0);
6715
- result.appendChild(g);
6816
+ const spacing = computed(() => isFinite(__props.theme.spacing) ? +__props.theme.spacing : 0);
6817
+ const guideRefs = shallowReactive([]);
6818
+ const layout = computed(() => {
6819
+ let x = 0, y = 0, width = 0, height = 0;
6820
+ let transforms = [];
6821
+ for (let guide of guideRefs ?? []) {
6822
+ let size = guide?.size ?? {
6823
+ width: 0,
6824
+ height: 0
6825
+ };
6826
+ transforms.push(`translate(${x}, ${y})`);
6827
+ if (__props.direction === "horizontal") {
6828
+ x += size.width + spacing.value;
6829
+ width = x - spacing.value;
6830
+ height = Math.max(height, size.height);
6831
+ } else {
6832
+ y += size.height + spacing.value;
6833
+ height = y - spacing.value;
6834
+ width = Math.max(width, size.width);
6835
+ }
6716
6836
  }
6717
- return new XMLSerializer().serializeToString(result);
6718
- }
6719
- __expose({ serialize });
6837
+ return {
6838
+ width,
6839
+ height,
6840
+ transforms
6841
+ };
6842
+ });
6843
+ const transform = computed(() => {
6844
+ if (__props.anchorX == null && __props.anchorY == null) return null;
6845
+ let alnX = {
6846
+ left: 0,
6847
+ center: .5,
6848
+ right: 1
6849
+ }[__props.anchorX] ?? +(__props.anchorX ?? .5), alnY = {
6850
+ bottom: 0,
6851
+ center: .5,
6852
+ top: 1
6853
+ }[__props.anchorY] ?? +(__props.anchorY ?? .5);
6854
+ return `translate(${layout.value.width * -alnX}, ${layout.value.height * (alnY - 1)})`;
6855
+ });
6856
+ __expose({ svg: useTemplateRef("svg") });
6720
6857
  return (_ctx, _cache) => {
6721
- return __props.scales ? (openBlock(), createElementBlock("div", {
6858
+ return groups.value.length ? (openBlock(), createElementBlock("svg", {
6722
6859
  key: 0,
6723
- class: "vvplot-legend",
6724
- style: normalizeStyle({ gap: `${__props.theme.spacing || 0}px` })
6725
- }, [(openBlock(true), createElementBlock(Fragment, null, renderList(guides.value, ({ sources, guide, breaks, key }) => {
6726
- return openBlock(), createBlock(_sfc_main$3, {
6860
+ ref: "svg",
6861
+ width: layout.value.width,
6862
+ height: layout.value.height,
6863
+ overflow: "visible",
6864
+ transform: transform.value
6865
+ }, [(openBlock(true), createElementBlock(Fragment, null, renderList(groups.value, (guide, i) => {
6866
+ return openBlock(), createBlock(_sfc_main$3, mergeProps({
6727
6867
  ref_for: true,
6728
- ref: "legend-guides",
6729
- key,
6730
- sources,
6731
- type: guide,
6732
- breaks,
6733
- theme: __props.theme
6734
- }, null, 8, [
6735
- "sources",
6736
- "type",
6737
- "breaks",
6738
- "theme"
6739
- ]);
6740
- }), 128))], 4)) : createCommentVNode("", true);
6868
+ ref: (el) => unref(guideRefs)[i] = el,
6869
+ transform: layout.value.transforms[i]
6870
+ }, { ref_for: true }, guide), null, 16, ["transform"]);
6871
+ }), 256))], 8, _hoisted_1$2)) : createCommentVNode("", true);
6741
6872
  };
6742
6873
  }
6743
6874
  };
@@ -6754,8 +6885,9 @@ var _hoisted_4 = ["transform"];
6754
6885
  var _hoisted_5 = ["transform"];
6755
6886
  var _hoisted_6 = ["clip-path"];
6756
6887
  var _hoisted_7 = ["transform", "clip-path"];
6757
- var _hoisted_8 = { key: 1 };
6758
- var _sfc_main$1 = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
6888
+ var _hoisted_8 = ["transform"];
6889
+ var _hoisted_9 = { key: 0 };
6890
+ var _sfc_main$1 = {
6759
6891
  __name: "CorePlot",
6760
6892
  props: /*@__PURE__*/ mergeModels({
6761
6893
  schema: Object,
@@ -6773,6 +6905,10 @@ var _sfc_main$1 = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
6773
6905
  type: Array,
6774
6906
  default: () => []
6775
6907
  },
6908
+ legends: {
6909
+ type: Array,
6910
+ default: () => []
6911
+ },
6776
6912
  theme: Object,
6777
6913
  render: String,
6778
6914
  clip: Boolean,
@@ -6784,8 +6920,7 @@ var _sfc_main$1 = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
6784
6920
  selections: {
6785
6921
  type: Array,
6786
6922
  default: () => []
6787
- },
6788
- legendTeleport: null
6923
+ }
6789
6924
  }, {
6790
6925
  "selectionPreview": {},
6791
6926
  "selectionPreviewModifiers": {},
@@ -6849,7 +6984,7 @@ var _sfc_main$1 = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
6849
6984
  const transition = useModel(__props, "transition");
6850
6985
  const svgRef = useTemplateRef("svg");
6851
6986
  const layers = useTemplateRef("layers");
6852
- const legendRef = useTemplateRef("legend");
6987
+ const legendRef = shallowReactive(/* @__PURE__ */ new Map());
6853
6988
  const width = ref(0), height = ref(0);
6854
6989
  useResizeObserver(svgRef, (entries) => {
6855
6990
  let { width: w, height: h } = entries[0].contentRect;
@@ -6956,10 +7091,52 @@ var _sfc_main$1 = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
6956
7091
  fullHeight: h
6957
7092
  };
6958
7093
  });
7094
+ const legends = computed(() => props.legends.map(({ teleport, positionX: x, positionY: y, anchorX, anchorY, key, ...etc } = {}, i) => {
7095
+ if (teleport) return {
7096
+ teleport,
7097
+ vBind: etc
7098
+ };
7099
+ anchorX ??= {
7100
+ left: "left",
7101
+ right: "right"
7102
+ }[x] ?? "center";
7103
+ anchorY ??= {
7104
+ bottom: "bottom",
7105
+ top: "top"
7106
+ }[y] ?? "center";
7107
+ if (typeof x == "string") {
7108
+ x = {
7109
+ left: "0%",
7110
+ center: "50%",
7111
+ right: "100%"
7112
+ }[x] ?? x;
7113
+ if (x.endsWith("%")) x = panel.width * x.slice(0, -1) / 100;
7114
+ }
7115
+ if (typeof y == "string") {
7116
+ y = {
7117
+ bottom: "0%",
7118
+ center: "50%",
7119
+ top: "100%"
7120
+ }[y] ?? y;
7121
+ if (y.endsWith("%")) y = panel.height * (1 - y.slice(0, -1) / 100);
7122
+ } else y = panel.height - y;
7123
+ return {
7124
+ key: key ?? i,
7125
+ x: x || void 0,
7126
+ y: y || void 0,
7127
+ vBind: {
7128
+ anchorX,
7129
+ anchorY,
7130
+ ...etc
7131
+ }
7132
+ };
7133
+ }));
6959
7134
  __expose({
6960
7135
  panel,
6961
7136
  svg: svgRef,
6962
- legend: legendRef
7137
+ getLegendSvg(key) {
7138
+ return (key == null ? legendRef.values().next().value : legendRef.get(key)).svg;
7139
+ }
6963
7140
  });
6964
7141
  const transformBind = computed(() => {
6965
7142
  let tslH = activeTransform.value.translateH + innerRect.left, tslV = activeTransform.value.translateV + innerRect.top, sclH = activeTransform.value.scaleH, sclV = activeTransform.value.scaleV, transform = [];
@@ -7135,11 +7312,21 @@ var _sfc_main$1 = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
7135
7312
  max: interval == 0 ? 0 : (max - $max) / interval
7136
7313
  };
7137
7314
  }
7315
+ function clientToOffset({ clientX, clientY }) {
7316
+ let ctm = svgRef.value?.getScreenCTM?.();
7317
+ if (!ctm) return {
7318
+ offsetX: clientX,
7319
+ offsetY: clientY
7320
+ };
7321
+ let { x: offsetX, y: offsetY } = new DOMPoint(clientX, clientY).matrixTransform(ctm.inverse());
7322
+ return {
7323
+ offsetX,
7324
+ offsetY
7325
+ };
7326
+ }
7138
7327
  function getCoord(event) {
7139
- let rect = svgRef.value.getBoundingClientRect();
7140
- let scaleX = rect.width / svgRef.value.clientWidth, scaleY = rect.height / svgRef.value.clientHeight;
7141
- let offsetX = event.clientX - rect.left, offsetY = event.clientY - rect.top;
7142
- 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;
7328
+ let { offsetX, offsetY } = clientToOffset(event);
7329
+ 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;
7143
7330
  let { x, y } = pos2coord({
7144
7331
  h: l,
7145
7332
  v: t
@@ -7159,9 +7346,8 @@ var _sfc_main$1 = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
7159
7346
  getCoord
7160
7347
  };
7161
7348
  function isInPlot(event) {
7162
- let rect = svgRef.value.getBoundingClientRect();
7163
- let scaleX = rect.width / svgRef.value.clientWidth, scaleY = rect.height / svgRef.value.clientHeight;
7164
- 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;
7349
+ let { offsetX, offsetY } = clientToOffset(event);
7350
+ return offsetX > panel.left && offsetX < panel.right && offsetY > panel.top && offsetY < panel.bottom;
7165
7351
  }
7166
7352
  function dispatchPointerEvent(e) {
7167
7353
  if (!layers.value || e._vhandled || !isInPlot(e)) return e;
@@ -7171,7 +7357,7 @@ var _sfc_main$1 = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
7171
7357
  }
7172
7358
  return e;
7173
7359
  }
7174
- let moveTimer, movementX = 0, movementY = 0;
7360
+ let moveTimer;
7175
7361
  function svgPointerdown(e) {
7176
7362
  let evt = dispatchPointerEvent(e), coord = getCoord(e);
7177
7363
  emit("pointerdown", evt, coord);
@@ -7286,8 +7472,7 @@ var _sfc_main$1 = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
7286
7472
  "metaKey"
7287
7473
  ].every((k) => a[k] == e[k]));
7288
7474
  if (act) {
7289
- let rect = svgRef.value.getBoundingClientRect();
7290
- let scaleX = rect.width / svgRef.value.clientWidth, scaleY = rect.height / svgRef.value.clientHeight;
7475
+ let { offsetX: h0, offsetY: v0 } = clientToOffset(e);
7291
7476
  e.target.setPointerCapture(e.pointerId);
7292
7477
  svg.style.userSelect = "none";
7293
7478
  moveTimer = clearTimeout(moveTimer);
@@ -7295,19 +7480,18 @@ var _sfc_main$1 = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
7295
7480
  let boundary = coord2pos(act);
7296
7481
  e.target.onpointermove = (ev) => {
7297
7482
  let { x = false, y = false } = act;
7298
- let [h, v] = __props.flip ? [y, x] : [x, y];
7299
- if (h) {
7300
- movementX += ev.movementX;
7301
- let dh = oob_squish_any(-movementX / scaleX, {
7483
+ let { offsetX: h, offsetY: v } = clientToOffset(ev);
7484
+ let movementH = h - h0, movementV = v - v0;
7485
+ if (__props.flip ? y : x) {
7486
+ let dh = oob_squish_any(-movementH, {
7302
7487
  min: boundary.hmin - hmin0,
7303
7488
  max: boundary.hmax - hmax0
7304
7489
  });
7305
7490
  h1 = hmin0 + dh;
7306
7491
  h2 = hmax0 + dh;
7307
7492
  }
7308
- if (v) {
7309
- movementY += ev.movementY;
7310
- let dv = oob_squish_any(-movementY / scaleY, {
7493
+ if (__props.flip ? x : y) {
7494
+ let dv = oob_squish_any(-movementV, {
7311
7495
  min: boundary.vmin - vmin0,
7312
7496
  max: boundary.vmax - vmax0
7313
7497
  });
@@ -7332,7 +7516,6 @@ var _sfc_main$1 = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
7332
7516
  svg.style.userSelect = null;
7333
7517
  moveTimer = setTimeout(() => {
7334
7518
  applyTransform(act, ev);
7335
- movementX = movementY = 0;
7336
7519
  }, 300);
7337
7520
  }, { once: true });
7338
7521
  return;
@@ -7369,12 +7552,12 @@ var _sfc_main$1 = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
7369
7552
  let boundary = coord2pos(act);
7370
7553
  let hmin, hmax, vmin, vmax;
7371
7554
  if (h) {
7372
- hmin = Math.max(pos.l - Math.max(pos.l, 0) * lvl, boundary.hmin ?? -Infinity);
7373
- hmax = Math.min(pos.l + Math.max(pos.r, 0) * lvl, boundary.hmax ?? Infinity);
7555
+ hmin = Math.max(pos.l - Math.max(pos.l, 0) * lvl, boundary.hmin ?? -1e400);
7556
+ hmax = Math.min(pos.l + Math.max(pos.r, 0) * lvl, boundary.hmax ?? 1e400);
7374
7557
  }
7375
7558
  if (v) {
7376
- vmin = Math.max(pos.t - Math.max(pos.t, 0) * lvl, boundary.vmin ?? -Infinity);
7377
- vmax = Math.min(pos.t + Math.max(pos.b, 0) * lvl, boundary.vmax ?? Infinity);
7559
+ vmin = Math.max(pos.t - Math.max(pos.t, 0) * lvl, boundary.vmin ?? -1e400);
7560
+ vmax = Math.min(pos.t + Math.max(pos.b, 0) * lvl, boundary.vmax ?? 1e400);
7378
7561
  }
7379
7562
  let { xmin, xmax, ymin, ymax } = pos2coord({
7380
7563
  hmin,
@@ -7598,12 +7781,71 @@ var _sfc_main$1 = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
7598
7781
  };
7599
7782
  });
7600
7783
  });
7784
+ const guideGroups = computed(() => {
7785
+ let entries = [];
7786
+ for (let [scale, appearance] of gplot.value.scales) {
7787
+ if (scale.legend === false) continue;
7788
+ if (scale.limits?.min == scale.limits?.max) continue;
7789
+ let type = scale.guide;
7790
+ if (!scale.level && [
7791
+ "color",
7792
+ "fill",
7793
+ "alpha"
7794
+ ].includes(scale.aesthetics)) type ??= "gradientbar";
7795
+ type ??= "legendkey";
7796
+ if (type === "none" || typeof type !== "string") continue;
7797
+ let breaks = scale.breaks;
7798
+ if (typeof breaks === "function") breaks = breaks(scale.limits);
7799
+ if (scale.level != null) breaks ??= scale.level.apply(scale.level);
7800
+ breaks ??= break_default.number({ minor: true })(scale.limits);
7801
+ breaks = Array.isArray(breaks) ? Array.from(breaks) : [];
7802
+ entries.push({
7803
+ key: scale.key,
7804
+ type,
7805
+ breaks,
7806
+ scale,
7807
+ appearance
7808
+ });
7809
+ }
7810
+ let cate = categorize(entries.map(({ type, breaks, key }) => ({
7811
+ type,
7812
+ breaks,
7813
+ key
7814
+ })), (a, b) => {
7815
+ if (a instanceof EnumElement && b instanceof EnumElement) return a.label === b.label && a.value === b.value;
7816
+ if (a instanceof EnumElement || b instanceof EnumElement) return false;
7817
+ });
7818
+ let usedKeys = /* @__PURE__ */ new Set(), suffix = 0;
7819
+ return Array.from(Map.groupBy(entries, (_, i) => cate[i]), ([idx, sources]) => {
7820
+ let { key, type, breaks } = cate.categories[idx];
7821
+ let title = sources.find((s) => s.scale.title != null)?.scale.title ?? sources.find((s) => s.scale._title != null)?.scale._title;
7822
+ if (key != null) {
7823
+ let $key = key, suffix = 1;
7824
+ while (usedKeys.has(key)) key = `${$key}#${++suffix}`;
7825
+ if (key !== $key) console.warn(`[vvplot] Guide key "${$key}" is used by incompatible guides; split "${key}" instead.`);
7826
+ } else do
7827
+ key = `_guide_${++suffix}`;
7828
+ while (usedKeys.has(key));
7829
+ usedKeys.add(key);
7830
+ return {
7831
+ key,
7832
+ type,
7833
+ title,
7834
+ breaks,
7835
+ theme: __props.theme.guide,
7836
+ sources: sources.map(({ scale, appearance }) => ({
7837
+ scale,
7838
+ appearance
7839
+ }))
7840
+ };
7841
+ });
7842
+ });
7601
7843
  return (_ctx, _cache) => {
7602
7844
  return openBlock(), createElementBlock("svg", mergeProps({
7603
7845
  ref: "svg",
7604
7846
  width: "100%",
7605
7847
  height: "100%"
7606
- }, toHandlers(svgVOn, true), _ctx.$attrs, { style: { "touch-action": "none" } }), [
7848
+ }, toHandlers(svgVOn, true), { style: { "touch-action": "none" } }), [
7607
7849
  createElementVNode("defs", null, [createElementVNode("clipPath", { id: `${unref(vid)}-plot-clip` }, [createElementVNode("rect", {
7608
7850
  x: "0",
7609
7851
  y: "0",
@@ -7742,28 +7984,44 @@ var _sfc_main$1 = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
7742
7984
  })
7743
7985
  ], 8, _hoisted_7),
7744
7986
  _cache[12] || (_cache[12] = createTextVNode()),
7745
- renderSlot(_ctx.$slots, "default"),
7987
+ legends.value.length ? (openBlock(), createElementBlock("g", {
7988
+ key: 1,
7989
+ transform: `translate(${unref(panel).left}, ${unref(panel).top})`
7990
+ }, [(openBlock(true), createElementBlock(Fragment, null, renderList(legends.value, (legend, i) => {
7991
+ return openBlock(), createElementBlock(Fragment, null, [legend.teleport ? (openBlock(), createElementBlock("foreignObject", _hoisted_9, [(openBlock(), createBlock(Teleport, {
7992
+ defer: "",
7993
+ to: legend.teleport
7994
+ }, [createVNode(_sfc_main$2, mergeProps({
7995
+ ref_for: true,
7996
+ ref: (el) => unref(legendRef).set(legend.key, el)
7997
+ }, { ref_for: true }, legend.vBind, { "guide-groups": guideGroups.value }), null, 16, ["guide-groups"])], 8, ["to"]))])) : (openBlock(), createBlock(_sfc_main$2, mergeProps({
7998
+ key: 1,
7999
+ ref_for: true,
8000
+ ref: (el) => unref(legendRef).set(legend.key, el)
8001
+ }, { ref_for: true }, legend.vBind, {
8002
+ "guide-groups": guideGroups.value,
8003
+ x: legend.x,
8004
+ y: legend.y
8005
+ }), null, 16, [
8006
+ "guide-groups",
8007
+ "x",
8008
+ "y"
8009
+ ]))], 64);
8010
+ }), 256))], 8, _hoisted_8)) : createCommentVNode("", true),
7746
8011
  _cache[13] || (_cache[13] = createTextVNode()),
8012
+ renderSlot(_ctx.$slots, "default"),
8013
+ _cache[14] || (_cache[14] = createTextVNode()),
7747
8014
  renderSlot(_ctx.$slots, "overlay-plot", {
7748
8015
  mapping,
7749
8016
  layout: unref(innerRect),
7750
8017
  panel: unref(panel),
7751
8018
  activeTransform: activeTransform.value
7752
- }),
7753
- _cache[14] || (_cache[14] = createTextVNode()),
7754
- props.legendTeleport ? (openBlock(), createElementBlock("foreignObject", _hoisted_8, [(openBlock(), createBlock(Teleport, {
7755
- defer: "",
7756
- to: props.legendTeleport
7757
- }, [createVNode(_sfc_main$2, {
7758
- ref: "legend",
7759
- scales: gplot.value?.scales,
7760
- theme: __props.theme.legend
7761
- }, null, 8, ["scales", "theme"])], 8, ["to"]))])) : createCommentVNode("", true)
8019
+ })
7762
8020
  ], 16);
7763
8021
  };
7764
8022
  }
7765
- });
7766
- // src/components/Plot.vue
8023
+ };
8024
+ // src/core/Plot.vue
7767
8025
  var _hoisted_1 = {
7768
8026
  key: 0,
7769
8027
  class: "vvplot-panel",
@@ -7796,8 +8054,11 @@ var _sfc_main = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
7796
8054
  default: true
7797
8055
  },
7798
8056
  resize: null,
7799
- legendTeleport: null,
7800
- dpi: Number
8057
+ dpi: Number,
8058
+ overflow: {
8059
+ type: String,
8060
+ default: "hidden"
8061
+ }
7801
8062
  }, {
7802
8063
  "selectionPreview": { default: () => ({}) },
7803
8064
  "selectionPreviewModifiers": {},
@@ -7824,15 +8085,6 @@ var _sfc_main = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
7824
8085
  "update:height"
7825
8086
  ]),
7826
8087
  setup(__props, { expose: __expose, emit: __emit }) {
7827
- const components = {
7828
- VVAxis: _sfc_main$26,
7829
- VVAxisX: _sfc_main$25,
7830
- VVAxisY: _sfc_main$24,
7831
- VVAxisBreak: _sfc_main$23,
7832
- VVAction: _sfc_main$22,
7833
- VVSelection: _sfc_main$21,
7834
- VVGeom: _sfc_main$20
7835
- };
7836
8088
  const opponents = {
7837
8089
  x: "y",
7838
8090
  y: "x",
@@ -7859,7 +8111,7 @@ var _sfc_main = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
7859
8111
  capitalize(camelize(tag))
7860
8112
  ];
7861
8113
  for (let name of names) {
7862
- let type = components[name] ?? getComponent(name) ?? globalComponents[name];
8114
+ let type = components_exports$1[name] ?? getComponent(name) ?? globalComponents[name];
7863
8115
  if (type != null) return type;
7864
8116
  }
7865
8117
  }
@@ -7887,6 +8139,7 @@ var _sfc_main = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
7887
8139
  layer: {},
7888
8140
  action: {},
7889
8141
  selection: {},
8142
+ legend: {},
7890
8143
  dom: {}
7891
8144
  });
7892
8145
  for (let key in $slots) {
@@ -7906,11 +8159,12 @@ var _sfc_main = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
7906
8159
  const vaxis = computed(() => Object.values(vnodes.axis).flat());
7907
8160
  const vaction = computed(() => Object.values(vnodes.action).flat());
7908
8161
  const vselection = computed(() => Object.values(vnodes.selection).flat());
8162
+ const vlegend = computed(() => Object.values(vnodes.legend).flat());
7909
8163
  const vdom = computed(() => Object.keys(vnodes.dom).flatMap((k) => k == "panel" ? [] : vnodes.dom[k]));
7910
8164
  const vdom_svg = computed(() => vdom.value.filter((v) => isSVGTag(v.type)));
7911
8165
  const vdom_etc = computed(() => vdom.value.filter((v) => !isSVGTag(v.type)));
7912
8166
  const vBind = computed(() => {
7913
- let plot = {};
8167
+ let plot = { overflow: __props.overflow };
7914
8168
  let wrapper = {};
7915
8169
  for (let key in $attrs) if (key.startsWith("on")) {
7916
8170
  let arr = Array.isArray($attrs[key]) ? $attrs[key] : [$attrs[key]];
@@ -7926,6 +8180,43 @@ var _sfc_main = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
7926
8180
  const theme = computed(() => {
7927
8181
  return themeBuild(themePreprocess(themeMerge(...[theme_base, theme_default].concat(__props.theme ?? [])), __props.flip));
7928
8182
  }, { deep: true });
8183
+ const legends = computed(() => {
8184
+ return vlegend.value.map((c) => {
8185
+ let { theme: $$theme = [], teleport, key, ...etc } = {
8186
+ key: c.key,
8187
+ ...c.type.$_props,
8188
+ ...c.props
8189
+ };
8190
+ let config = {
8191
+ positionX: "right",
8192
+ positionY: "top",
8193
+ anchorX: void 0,
8194
+ anchorY: void 0
8195
+ };
8196
+ let guides = Object.values(c.children ?? {}).filter((s) => s instanceof Function).flatMap((s) => s()).filter((c) => c.type?.$_type === "guide").map((c) => ({
8197
+ key: c.key,
8198
+ ...c.type.$_props,
8199
+ ...c.props
8200
+ })).map(({ theme: $$theme = [], ...$etc }) => ({
8201
+ theme: Object.assign({}, ...[theme.value?.guide].concat($$theme)),
8202
+ ...$etc
8203
+ }));
8204
+ for (let key in etc) {
8205
+ let k = camelize(key);
8206
+ if (k in config) {
8207
+ config[k] = etc[key];
8208
+ continue;
8209
+ }
8210
+ }
8211
+ return {
8212
+ key,
8213
+ guides,
8214
+ teleport,
8215
+ theme: Object.assign({}, ...[theme.value?.legend].concat($$theme)),
8216
+ ...config
8217
+ };
8218
+ });
8219
+ });
7929
8220
  const primaryAxis = reactiveComputed(() => {
7930
8221
  let allAxes = vaxis.value.map((c) => ({
7931
8222
  ...c.type.$_props,
@@ -7958,14 +8249,14 @@ var _sfc_main = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
7958
8249
  };
7959
8250
  });
7960
8251
  const layers = computed(() => {
7961
- return vlayer.value.map((layer) => {
8252
+ return vlayer.value.map((c) => {
7962
8253
  let { geom, stat, renderer, aes, scales, data, key, ...etc } = {
7963
- ...layer.type.$_props,
7964
- ...layer.props
8254
+ ...c.type.$_props,
8255
+ ...c.props
7965
8256
  };
7966
8257
  if (typeof geom === "string") renderer ??= geom;
7967
- let argnames = layer.type.$_argnames || [];
7968
- let optnames = layer.type.$_optnames || [];
8258
+ let argnames = c.type.$_argnames || [];
8259
+ let optnames = c.type.$_optnames || [];
7969
8260
  let $$aes = {}, args = {}, attrs = {}, opts = {}, vBind = {};
7970
8261
  let config = {
7971
8262
  extendX: 0,
@@ -8393,7 +8684,7 @@ var _sfc_main = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
8393
8684
  const wrapperStyle = computed(() => {
8394
8685
  let style = {
8395
8686
  position: "relative",
8396
- overflow: "hidden",
8687
+ overflow: __props.overflow,
8397
8688
  boxSizing: "border-box"
8398
8689
  };
8399
8690
  if (__props.resize === "both" || __props.resize === true || __props.resize === "") Object.assign(style, { resize: "both" });
@@ -8411,8 +8702,11 @@ var _sfc_main = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
8411
8702
  async export(options) {
8412
8703
  return exportSVG(plotRef.value.svg, options);
8413
8704
  },
8414
- serializeLegend(options) {
8415
- return plotRef.value.legend.serialize(options);
8705
+ serializeLegend(key, options) {
8706
+ return serializeSVG(plotRef.value.getLegendSvg(key), options);
8707
+ },
8708
+ async exportLegend(key, options) {
8709
+ return exportSVG(plotRef.value.getLegendSvg(key), options);
8416
8710
  },
8417
8711
  ...$vvplot
8418
8712
  });
@@ -8449,7 +8743,7 @@ var _sfc_main = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
8449
8743
  clip: __props.clip,
8450
8744
  render: __props.render,
8451
8745
  dpi: __props.dpi ?? 96 * unref(pixelRatio),
8452
- legendTeleport: __props.legendTeleport,
8746
+ legends: legends.value,
8453
8747
  onSelect: _cache[3] || (_cache[3] = (d, e) => emit("select", d, e))
8454
8748
  }), createSlots({
8455
8749
  default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(vdom_svg.value, (c) => {
@@ -8483,7 +8777,7 @@ var _sfc_main = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
8483
8777
  "clip",
8484
8778
  "render",
8485
8779
  "dpi",
8486
- "legendTeleport"
8780
+ "legends"
8487
8781
  ]),
8488
8782
  _cache[5] || (_cache[5] = createTextVNode()),
8489
8783
  createElementVNode("div", {
@@ -8502,36 +8796,38 @@ var _sfc_main = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
8502
8796
  });
8503
8797
  // src/components.ts
8504
8798
  var components_exports = /* @__PURE__ */ __exportAll({
8505
- VVAction: () => _sfc_main$22,
8506
- VVAxis: () => _sfc_main$26,
8507
- VVAxisBreak: () => _sfc_main$23,
8508
- VVAxisX: () => _sfc_main$25,
8509
- VVAxisY: () => _sfc_main$24,
8510
- VVGeom: () => _sfc_main$20,
8511
- VVGeomBar: () => _sfc_main$32,
8512
- VVGeomBlank: () => _sfc_main$33,
8513
- VVGeomBoxplot: () => _sfc_main$34,
8514
- VVGeomCol: () => _sfc_main$35,
8515
- VVGeomCurve: () => _sfc_main$36,
8516
- VVGeomDensity: () => _sfc_main$37,
8517
- VVGeomEllipse: () => _sfc_main$38,
8518
- VVGeomHistogram: () => _sfc_main$39,
8519
- VVGeomLine: () => _sfc_main$40,
8520
- VVGeomLinerange: () => _sfc_main$41,
8521
- VVGeomMarkdown: () => _sfc_main$42,
8522
- VVGeomMarkdownsegment: () => _sfc_main$43,
8523
- VVGeomPath: () => _sfc_main$44,
8524
- VVGeomPoint: () => _sfc_main$45,
8525
- VVGeomPolygon: () => _sfc_main$46,
8526
- VVGeomRect: () => _sfc_main$47,
8527
- VVGeomSegment: () => _sfc_main$48,
8528
- VVGeomShape: () => _sfc_main$49,
8529
- VVGeomStick: () => _sfc_main$50,
8530
- VVGeomText: () => _sfc_main$51,
8531
- VVGeomTextsegment: () => _sfc_main$52,
8532
- VVGeomTile: () => _sfc_main$53,
8533
- VVGeomViolin: () => _sfc_main$54,
8799
+ VVAction: () => _sfc_main$24,
8800
+ VVAxis: () => _sfc_main$28,
8801
+ VVAxisBreak: () => _sfc_main$25,
8802
+ VVAxisX: () => _sfc_main$27,
8803
+ VVAxisY: () => _sfc_main$26,
8804
+ VVGeom: () => _sfc_main$22,
8805
+ VVGeomBar: () => _sfc_main$34,
8806
+ VVGeomBlank: () => _sfc_main$35,
8807
+ VVGeomBoxplot: () => _sfc_main$36,
8808
+ VVGeomCol: () => _sfc_main$37,
8809
+ VVGeomCurve: () => _sfc_main$38,
8810
+ VVGeomDensity: () => _sfc_main$39,
8811
+ VVGeomEllipse: () => _sfc_main$40,
8812
+ VVGeomHistogram: () => _sfc_main$41,
8813
+ VVGeomLine: () => _sfc_main$42,
8814
+ VVGeomLinerange: () => _sfc_main$43,
8815
+ VVGeomMarkdown: () => _sfc_main$44,
8816
+ VVGeomMarkdownsegment: () => _sfc_main$45,
8817
+ VVGeomPath: () => _sfc_main$46,
8818
+ VVGeomPoint: () => _sfc_main$47,
8819
+ VVGeomPolygon: () => _sfc_main$48,
8820
+ VVGeomRect: () => _sfc_main$49,
8821
+ VVGeomSegment: () => _sfc_main$50,
8822
+ VVGeomShape: () => _sfc_main$51,
8823
+ VVGeomStick: () => _sfc_main$52,
8824
+ VVGeomText: () => _sfc_main$53,
8825
+ VVGeomTextsegment: () => _sfc_main$54,
8826
+ VVGeomTile: () => _sfc_main$55,
8827
+ VVGeomViolin: () => _sfc_main$56,
8828
+ VVGuide: () => _sfc_main$20,
8829
+ VVLegend: () => _sfc_main$21,
8534
8830
  VVPlot: () => _sfc_main,
8535
- VVSelection: () => _sfc_main$21
8831
+ VVSelection: () => _sfc_main$23
8536
8832
  });
8537
- export { _sfc_main, _sfc_main$10 as _sfc_main$1, _sfc_main$20 as _sfc_main$2, _sfc_main$21 as _sfc_main$3, _sfc_main$22 as _sfc_main$4, _sfc_main$23 as _sfc_main$5, _sfc_main$24 as _sfc_main$6, _sfc_main$25 as _sfc_main$7, _sfc_main$26 as _sfc_main$8, break_default, components_exports, label_default, number_cut, oob, scale_default, theme_default$1 as theme_default };
8833
+ export { _sfc_main, _sfc_main$10 as _sfc_main$1, _sfc_main$28 as _sfc_main$10, _sfc_main$20 as _sfc_main$2, _sfc_main$21 as _sfc_main$3, _sfc_main$22 as _sfc_main$4, _sfc_main$23 as _sfc_main$5, _sfc_main$24 as _sfc_main$6, _sfc_main$25 as _sfc_main$7, _sfc_main$26 as _sfc_main$8, _sfc_main$27 as _sfc_main$9, break_default, components_exports, label_default, number_cut, oob, scale_default, theme_default$1 as theme_default };