vvplot 0.4.4 → 0.4.5

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.
@@ -1819,7 +1819,7 @@ var VVPlot = (function(exports, vue) {
1819
1819
  AsisNumber.#cache.set(n, this);
1820
1820
  }
1821
1821
  }
1822
- class Asis extends String {
1822
+ class Asis {
1823
1823
  static #cache = /* @__PURE__ */ new Map();
1824
1824
  constructor(value) {
1825
1825
  if (typeof value === "string" || value instanceof String) {
@@ -1863,7 +1863,7 @@ var VVPlot = (function(exports, vue) {
1863
1863
  static from(x2) {
1864
1864
  if (x2 instanceof this) return x2;
1865
1865
  if (x2[Symbol.iterator]) {
1866
- let lvl = unique(Array.from(x2).filter((x3) => !(x3 instanceof Asis)).map((x3) => String(x3))).sort((a, b) => compare(a, b, { numeric: true }));
1866
+ let lvl = unique(Array.from(x2).filter((x3) => !(x3 instanceof Asis) && x3 != null).map((x3) => String(x3))).sort((a, b) => compare(a, b, { numeric: true }));
1867
1867
  return new this(...lvl);
1868
1868
  } else if (typeof x2 === "object") {
1869
1869
  let lvl = Object.keys(x2).map((x3) => String(x3)).sort((a, b) => compare(x2[a], x2[b]));
@@ -1917,6 +1917,9 @@ var VVPlot = (function(exports, vue) {
1917
1917
  function is_continuous(x2) {
1918
1918
  return typeof x2 === "number" || x2 instanceof Number || x2 instanceof Date;
1919
1919
  }
1920
+ function is_categorical(v) {
1921
+ return typeof v === "string" || typeof v === "boolean" || typeof v === "symbol" || typeof v === "object" && v !== null && typeof v.valueOf() !== "number" && typeof v.valueOf() !== "bigint";
1922
+ }
1920
1923
  function plus$1(a, b = 0) {
1921
1924
  if (b == 0 || a == null) return a;
1922
1925
  if (a instanceof Date) return new a.constructor(+a + b);
@@ -2508,7 +2511,7 @@ var VVPlot = (function(exports, vue) {
2508
2511
  y2,
2509
2512
  ds.outliers ?? [],
2510
2513
  xnudge
2511
- ), $xmin = psum$a(ds.xmin, xnudge), $xmax = psum$a(ds.xmax, xnudge);
2514
+ ), $xmin = psum$a(ds.min, xnudge), $xmax = psum$a(ds.max, xnudge);
2512
2515
  return {
2513
2516
  y: y2,
2514
2517
  ymin,
@@ -2808,8 +2811,8 @@ var VVPlot = (function(exports, vue) {
2808
2811
  let missingAes = ["x", "y"].filter((a) => data[a] == null);
2809
2812
  if (missingAes.length > 0)
2810
2813
  throw new Error(`Missing aesthetics for "StatBoxplot": "${missingAes.join('", "')}"`);
2811
- let isXdiscrete = data.x.some((x2) => typeof x2 !== "number");
2812
- let isYdiscrete = data.y.some((y2) => typeof y2 !== "number");
2814
+ let isXdiscrete = data.x.some(is_categorical);
2815
+ let isYdiscrete = data.y.some(is_categorical);
2813
2816
  if (isXdiscrete && isYdiscrete)
2814
2817
  throw new Error(`Both "x" and "y" are discrete, "StatBoxplot" requires one continuous and one discrete aesthetic`);
2815
2818
  if (!isXdiscrete && !isYdiscrete)
@@ -6793,9 +6796,6 @@ var VVPlot = (function(exports, vue) {
6793
6796
  if (obj == null) return {};
6794
6797
  return Object.fromEntries(Object.entries(obj).map(([k, v]) => [k, expr(k, v)]));
6795
6798
  }
6796
- function is_categorical(v) {
6797
- return typeof v === "string" || typeof v === "boolean" || typeof v === "symbol" || typeof v === "object" && v !== null && typeof v.valueOf() !== "number" && typeof v.valueOf() !== "bigint";
6798
- }
6799
6799
  class GLayer {
6800
6800
  /**
6801
6801
  * Create a graphic layer from schema
@@ -14978,7 +14978,6 @@ var VVPlot = (function(exports, vue) {
14978
14978
  pointermove(e) {
14979
14979
  emit("pointermove", e, getPosition(e));
14980
14980
  },
14981
- pointerdown: axisMovePointerdown,
14982
14981
  wheel: axisWheel
14983
14982
  };
14984
14983
  return (_ctx, _cache) => {
@@ -15016,27 +15015,26 @@ var VVPlot = (function(exports, vue) {
15016
15015
  height: 10,
15017
15016
  y: -5
15018
15017
  }, vue.toHandlers(axisVOn, true), {
15018
+ onPointerdown: axisMovePointerdown,
15019
15019
  cursor: __props.action.some?.((a) => a.action == "move") ? "grab" : null
15020
15020
  }), null, 16, _hoisted_4$3)
15021
15021
  ]),
15022
15022
  _cache[4] || (_cache[4] = vue.createTextVNode()),
15023
15023
  __props.action.some?.((a) => a.action == "rescale") ? (vue.openBlock(), vue.createElementBlock("g", _hoisted_5$2, [
15024
- vue.createElementVNode("rect", {
15024
+ vue.createElementVNode("rect", vue.mergeProps({
15025
15025
  width: 20,
15026
15026
  height: 10,
15027
15027
  y: -5,
15028
- style: { "cursor": "ew-resize" },
15029
- onPointerdown: axisRescaleLeftPointerdown
15030
- }, null, 32),
15028
+ style: { "cursor": "ew-resize" }
15029
+ }, vue.toHandlers(axisVOn, true), { onPointerdown: axisRescaleLeftPointerdown }), null, 16),
15031
15030
  _cache[0] || (_cache[0] = vue.createTextVNode()),
15032
- vue.createElementVNode("rect", {
15031
+ vue.createElementVNode("rect", vue.mergeProps({
15033
15032
  width: 20,
15034
15033
  height: 10,
15035
15034
  y: -5,
15036
15035
  x: width.value - 20,
15037
- style: { "cursor": "ew-resize" },
15038
- onPointerdown: axisRescaleRightPointerdown
15039
- }, null, 40, _hoisted_6$2)
15036
+ style: { "cursor": "ew-resize" }
15037
+ }, vue.toHandlers(axisVOn, true), { onPointerdown: axisRescaleRightPointerdown }), null, 16, _hoisted_6$2)
15040
15038
  ])) : vue.createCommentVNode("", true),
15041
15039
  _cache[5] || (_cache[5] = vue.createTextVNode()),
15042
15040
  axisTitle.value.text ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 1 }, [
@@ -15405,7 +15403,6 @@ var VVPlot = (function(exports, vue) {
15405
15403
  pointermove(e) {
15406
15404
  emit("pointermove", e, getPosition(e));
15407
15405
  },
15408
- pointerdown: axisMovePointerdown,
15409
15406
  wheel: axisWheel
15410
15407
  };
15411
15408
  return (_ctx, _cache) => {
@@ -15443,27 +15440,26 @@ var VVPlot = (function(exports, vue) {
15443
15440
  height: height.value,
15444
15441
  x: -5
15445
15442
  }, vue.toHandlers(axisVOn, true), {
15443
+ onPointerdown: axisMovePointerdown,
15446
15444
  cursor: __props.action.some?.((a) => a.action == "move") ? "grab" : null
15447
15445
  }), null, 16, _hoisted_4$2)
15448
15446
  ]),
15449
15447
  _cache[4] || (_cache[4] = vue.createTextVNode()),
15450
15448
  __props.action.some?.((a) => a.action == "rescale") ? (vue.openBlock(), vue.createElementBlock("g", _hoisted_5$1, [
15451
- vue.createElementVNode("rect", {
15449
+ vue.createElementVNode("rect", vue.mergeProps({
15452
15450
  width: 10,
15453
15451
  height: 20,
15454
15452
  x: -5,
15455
- style: { "cursor": "ns-resize" },
15456
- onPointerdown: axisRescaleTopPointerdown
15457
- }, null, 32),
15453
+ style: { "cursor": "ns-resize" }
15454
+ }, vue.toHandlers(axisVOn, true), { onPointerdown: axisRescaleTopPointerdown }), null, 16),
15458
15455
  _cache[0] || (_cache[0] = vue.createTextVNode()),
15459
- vue.createElementVNode("rect", {
15456
+ vue.createElementVNode("rect", vue.mergeProps({
15460
15457
  width: 10,
15461
15458
  height: 20,
15462
15459
  x: -5,
15463
15460
  y: height.value - 20,
15464
- style: { "cursor": "ns-resize" },
15465
- onPointerdown: axisRescaleBottomPointerdown
15466
- }, null, 40, _hoisted_6$1)
15461
+ style: { "cursor": "ns-resize" }
15462
+ }, vue.toHandlers(axisVOn, true), { onPointerdown: axisRescaleBottomPointerdown }), null, 16, _hoisted_6$1)
15467
15463
  ])) : vue.createCommentVNode("", true),
15468
15464
  _cache[5] || (_cache[5] = vue.createTextVNode()),
15469
15465
  axisTitle.value.text ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 1 }, [
@@ -15945,14 +15941,14 @@ var VVPlot = (function(exports, vue) {
15945
15941
  } of group) {
15946
15942
  let dx = Math.sqrt(C / (A * C - B * B)), dy = Math.sqrt(A / (A * C - B * B));
15947
15943
  const { h: ch, v: cv } = __props.coord2pos({ x: cx, y: cy });
15948
- let { hmin, hmax, vmin, vmax } = __props.coord2pos({ xmin: cx - dx, xmax: cx + dx, ymin: cy - dy, ymax: cy + dy });
15949
- let scaleX = (hmax - hmin) / (2 * dx), scaleY = (vmax - vmin) / (2 * dy);
15944
+ let { h: h1, v: v1 } = __props.coord2pos({ x: cx - dx, y: cy - dy }), { h: h2, v: v2 } = __props.coord2pos({ x: cx + dx, y: cy + dy });
15945
+ let scaleX = (h2 - h1) / (2 * dx), scaleY = (v2 - v1) / (2 * dy);
15950
15946
  A /= scaleX * scaleX;
15951
15947
  B /= scaleX * scaleY;
15952
15948
  C /= scaleY * scaleY;
15953
15949
  const tr = A + C, det = A * C - B * B;
15954
15950
  const disc = Math.sqrt(Math.max(0, tr * tr / 4 - det));
15955
- let rx2 = 1 / Math.sqrt(tr / 2 + disc), ry = 1 / Math.sqrt(tr / 2 - disc), angle2 = -Math.atan2(2 * B, A - C) / 2;
15951
+ let rx2 = 1 / Math.sqrt(tr / 2 + disc), ry = 1 / Math.sqrt(tr / 2 - disc), angle2 = Math.atan2(2 * B, A - C) / 2;
15956
15952
  const path2d = new Path2D();
15957
15953
  path2d.ellipse(ch + translateX, cv + translateY, rx2, ry, angle2, 0, 2 * Math.PI);
15958
15954
  _path_data.set(path2d, $raw);
@@ -17253,9 +17249,9 @@ var VVPlot = (function(exports, vue) {
17253
17249
  }) => {
17254
17250
  let dx = Math.sqrt(C / (A * C - B * B)), dy = Math.sqrt(A / (A * C - B * B));
17255
17251
  const { h: ch, v: cv } = __props.coord2pos({ x: cx, y: cy });
17256
- let { hmin, hmax, vmin, vmax } = __props.coord2pos({ xmin: cx - dx, xmax: cx + dx, ymin: cy - dy, ymax: cy + dy });
17257
- if (hmax < xlim_min || hmin > xlim_max || vmax < ylim_min || vmin > ylim_max) return null;
17258
- let scaleX = (hmax - hmin) / (2 * dx), scaleY = (vmax - vmin) / (2 * dy);
17252
+ let { h: h1, v: v1 } = __props.coord2pos({ x: cx - dx, y: cy - dy }), { h: h2, v: v2 } = __props.coord2pos({ x: cx + dx, y: cy + dy });
17253
+ if (h1 < xlim_min && h2 < xlim_min || h2 > xlim_max && h1 > xlim_max || v1 < ylim_min && v2 < ylim_min || v2 > ylim_max && v1 > ylim_max) return null;
17254
+ let scaleX = (h2 - h1) / (2 * dx), scaleY = (v2 - v1) / (2 * dy);
17259
17255
  A /= scaleX * scaleX;
17260
17256
  B /= scaleX * scaleY;
17261
17257
  C /= scaleY * scaleY;
@@ -17266,7 +17262,7 @@ var VVPlot = (function(exports, vue) {
17266
17262
  cy: cv,
17267
17263
  rx: 1 / Math.sqrt(tr / 2 + disc) || 0,
17268
17264
  ry: 1 / Math.sqrt(tr / 2 - disc) || 0,
17269
- angle: -Math.atan2(2 * B, A - C) / 2 * 180 / Math.PI || 0,
17265
+ angle: Math.atan2(2 * B, A - C) / 2 * 180 / Math.PI || 0,
17270
17266
  fill,
17271
17267
  color: color2,
17272
17268
  linetype,
@@ -17495,6 +17491,8 @@ var VVPlot = (function(exports, vue) {
17495
17491
  alpha: alpha2,
17496
17492
  "translate-x": translateX = 0,
17497
17493
  "translate-y": translateY = 0,
17494
+ "anchor-x": anchorX,
17495
+ "anchor-y": anchorY = 0.5,
17498
17496
  "font-family": fontFamily = "sans-serif",
17499
17497
  "text-align": textAlign = "start",
17500
17498
  inset = 0,
@@ -17508,140 +17506,72 @@ var VVPlot = (function(exports, vue) {
17508
17506
  if (x1 < xlim_min && x22 < xlim_min || x1 > xlim_max && x22 > xlim_max || y1 < ylim_min && y22 < ylim_min || y1 > ylim_max && y22 > ylim_max) return null;
17509
17507
  let radian = Math.atan2(y22 - y1, x22 - x1);
17510
17508
  let vbind = {
17511
- color: color2 || null,
17512
- fill: color2 || null,
17513
- "fill-opacity": alpha2 == 1 ? null : alpha2,
17514
- "font-size": size * 4,
17515
- stroke: stroke || null,
17516
- "stroke-width": linewidth,
17517
- "stroke-dasharray": parseLinetype(linetype).join(" ") || null,
17518
- "stroke-opacity": alpha2 == 1 ? null : alpha2,
17519
- "font-family": fontFamily,
17509
+ text: String(label),
17510
+ title: String(title ?? label),
17511
+ color: color2,
17512
+ alpha: alpha2,
17513
+ size,
17514
+ stroke,
17515
+ linewidth,
17516
+ linetype,
17517
+ fontFamily,
17520
17518
  class: className,
17521
17519
  style
17522
17520
  };
17523
17521
  let von = Object.fromEntries(
17524
17522
  events.map((evt) => [evt, (e) => emit(evt, Object.assign(e, { _vhandled: true }), __props.getCoord(e), $raw)])
17525
17523
  );
17526
- let tx, ty, content = parseMarkdownInline(String(label));
17524
+ let tx, ty;
17527
17525
  switch (textAlign) {
17528
17526
  case "stretch":
17529
17527
  tx = (x1 + x22) / 2;
17530
17528
  ty = (y1 + y22) / 2;
17531
- vbind["text-anchor"] = "middle";
17529
+ anchorX = 0.5;
17532
17530
  vbind.textLength = Math.hypot(x22 - x1 || 0, y22 - y1 || 0);
17533
- vbind.lengthAdjust = "spacingAndGlyphs";
17534
17531
  break;
17535
17532
  case "center":
17536
17533
  tx = (x1 + x22) / 2;
17537
17534
  ty = (y1 + y22) / 2;
17538
- vbind["text-anchor"] = "middle";
17535
+ anchorX ??= 0.5;
17539
17536
  break;
17540
17537
  case "pre":
17541
17538
  tx = x1;
17542
17539
  ty = y1;
17543
17540
  translateX -= Math.cos(radian) * inset;
17544
17541
  translateY -= Math.sin(radian) * inset;
17545
- vbind["text-anchor"] = "end";
17542
+ anchorX ??= 1;
17546
17543
  break;
17547
17544
  case "end":
17548
17545
  tx = x22;
17549
17546
  ty = y22;
17550
17547
  translateX -= Math.cos(radian) * inset;
17551
17548
  translateY -= Math.sin(radian) * inset;
17552
- vbind["text-anchor"] = "end";
17549
+ anchorX ??= 1;
17553
17550
  break;
17554
17551
  case "post":
17555
17552
  tx = x22;
17556
17553
  ty = y22;
17557
17554
  translateX += Math.cos(radian) * inset;
17558
17555
  translateY += Math.sin(radian) * inset;
17559
- vbind["text-anchor"] = "start";
17556
+ anchorX ??= 0;
17560
17557
  break;
17561
17558
  default:
17562
17559
  tx = x1;
17563
17560
  ty = y1;
17564
17561
  translateX += Math.cos(radian) * inset;
17565
17562
  translateY += Math.sin(radian) * inset;
17566
- vbind["text-anchor"] = "start";
17563
+ anchorX ??= 0;
17567
17564
  }
17568
- let transform = [];
17569
- if (translateX || translateY) transform.push(`translate(${translateX}, ${translateY})`);
17570
- if (radian) transform.push(`rotate(${radian * 180 / Math.PI})`);
17571
- Object.assign(vbind, {
17572
- x: tx,
17573
- y: ty,
17574
- "dominant-baseline": "central",
17575
- "transform-origin": `${tx} ${ty}`,
17576
- transform: transform.join(" ") || null
17577
- });
17578
- return [vbind, von, content, String(title ?? String(label).replace(/\x01|\x02/g, ""))];
17565
+ Object.assign(vbind, { x: tx, y: ty, translateX, translateY, anchorX, anchorY, angle: radian * 180 / Math.PI });
17566
+ return [vbind, von];
17579
17567
  }).filter((x2) => x2 != null));
17580
17568
  });
17581
- const parser = new Parser();
17582
- function parseMarkdownInline(markdown2) {
17583
- const walker = parser.parse(markdown2).walker();
17584
- const fragments = [];
17585
- let stack2 = [], scales = [1], offset = 0;
17586
- let ev;
17587
- while (ev = walker.next()) {
17588
- let { node: { type, literal }, entering } = ev;
17589
- let scale = scales.at(-1);
17590
- if (entering) {
17591
- if (type === "text" || type === "code") {
17592
- const vbind = Object.assign({
17593
- dy: str_c(offset || null, "em")
17594
- }, ...stack2, {
17595
- "font-family": type === "code" ? "monospace" : null,
17596
- "font-size": scale === 1 ? null : `${scale}em`
17597
- });
17598
- offset = 0;
17599
- fragments.push({ text: literal, vbind });
17600
- } else if (type === "strong") {
17601
- stack2.push({ "font-weight": "bold" });
17602
- } else if (type === "emph") {
17603
- stack2.push({ "font-style": "italic" });
17604
- } else if (type === "softbreak" || type === "paragraph") {
17605
- fragments.push({ text: " " });
17606
- } else if (type === "html_inline") {
17607
- const tag2 = literal;
17608
- if (tag2.includes("color=")) {
17609
- const fill = tag2.match(/color=(['"])(.*?)\1/i)?.[2] ?? tag2.match(/color=(\S*)/)?.[1];
17610
- if (fill) stack2.push({ fill });
17611
- } else if (tag2.includes("</font>")) {
17612
- stack2.pop();
17613
- } else if (tag2.includes("<sup>")) {
17614
- offset -= 0.4 * scale;
17615
- scales.push(scale * 0.7);
17616
- } else if (tag2.includes("</sup>")) {
17617
- offset += 0.4 * scales.at(-1);
17618
- scales.pop();
17619
- } else if (tag2.includes("<sub>")) {
17620
- offset += 0.25 * scale;
17621
- scales.push(scale * 0.7);
17622
- } else if (tag2.includes("</sub>")) {
17623
- offset -= 0.25 * scales.at(-1);
17624
- scales.pop();
17625
- }
17626
- }
17627
- } else {
17628
- if (["strong", "emph"].includes(type)) stack2.pop();
17629
- }
17630
- }
17631
- return fragments;
17632
- }
17633
17569
  return (_ctx, _cache) => {
17634
17570
  return vue.openBlock(), vue.createElementBlock("g", null, [
17635
17571
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(binds.value, (group) => {
17636
17572
  return vue.openBlock(), vue.createElementBlock("g", vue.mergeProps({ ref_for: true }, { class: __props.groupClass, style: __props.groupStyle }), [
17637
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(group, ([vbind, von, textFragments, title]) => {
17638
- return vue.openBlock(), vue.createElementBlock("text", vue.mergeProps({ ref_for: true }, vbind, vue.toHandlers(von, true)), [
17639
- vue.createElementVNode("title", null, vue.toDisplayString(title), 1),
17640
- _cache[0] || (_cache[0] = vue.createTextVNode()),
17641
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(textFragments, (tspan) => {
17642
- return vue.openBlock(), vue.createElementBlock("tspan", vue.mergeProps({ ref_for: true }, tspan.vbind), vue.toDisplayString(tspan.text), 17);
17643
- }), 256))
17644
- ], 16);
17573
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(group, ([vbind, von]) => {
17574
+ return vue.openBlock(), vue.createBlock(_sfc_main$12, vue.mergeProps({ ref_for: true }, vbind, vue.toHandlers(von)), null, 16);
17645
17575
  }), 256))
17646
17576
  ], 16);
17647
17577
  }), 256))