expressive-charts 0.11.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +66 -1
- package/README.md +26 -25
- package/dist/{define-DeZLs1h7.js → define-ClDM4DNz.js} +13 -5
- package/dist/define-ClDM4DNz.js.map +1 -0
- package/dist/{drawing-OmQV-0BB.d.ts → drawing-qGmuUkoL.d.ts} +4 -3
- package/dist/{effect-HCWnmB72.d.ts → effect-GgFkjYSV.d.ts} +1 -1
- package/dist/expressive-charts.global.js +10 -10
- package/dist/expressive-charts.global.js.map +1 -1
- package/dist/icons/sport.cjs +12 -4
- package/dist/icons/sport.cjs.map +1 -1
- package/dist/icons/sport.d.cts +1 -1
- package/dist/icons/sport.d.ts +1 -1
- package/dist/icons/sport.js +2 -2
- package/dist/{index-CmnxlWkB.d.cts → index-DLdz-1iE.d.cts} +4 -3
- package/dist/index.cjs +209 -89
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +55 -13
- package/dist/index.d.ts +55 -13
- package/dist/index.js +192 -82
- package/dist/index.js.map +1 -1
- package/dist/{path-data-DnEckjY8.js → path-data-Cfjk04X8.js} +5 -5
- package/dist/{path-data-DnEckjY8.js.map → path-data-Cfjk04X8.js.map} +1 -1
- package/dist/runner-DZP831pq.d.cts +1 -0
- package/dist/testing.cjs +7 -7
- package/dist/testing.d.cts +2 -2
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +1 -1
- package/dist/{transition-romki_A6.js → transition-BxWp6BVX.js} +6 -6
- package/dist/{transition-romki_A6.js.map → transition-BxWp6BVX.js.map} +1 -1
- package/package.json +10 -5
- package/dist/define-DeZLs1h7.js.map +0 -1
- package/dist/runner-C87v9F_y.d.cts +0 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import { a as TAU$2, c as boundsOf, d as normalizeAngle, f as pointOn, l as extremes, n as formatNumber } from "./path-data-
|
|
3
|
-
import { t as defineIcon } from "./define-
|
|
1
|
+
import { A as tween, B as unease, C as flattenPath, D as describeArc, E as describeBar, F as motion, H as defaultClock, I as scaleDuration, L as easeInOutCubic, M as createMotion, N as defaultScaling, O as labelBoxes$1, P as mediaReducedMotion, R as easeOutCubic, S as cubicPieces, T as describeLine, U as manualClock, V as createClock, W as report, _ as formatPath, a as AVERAGE_WIDTH, b as transformPath, d as createRegistry, f as describeValue$1, g as describeShape, h as describe, j as TIMINGS, k as loopOutline, l as mergeFields, m as resolveEffects, n as playTransition, o as TEXT_SIZE, p as isMarkEffect, r as createRunner, s as boxAround, t as isTransitionEffect, u as EFFECT_SLOTS, v as parsePath, w as describePoint, x as FLAT, y as shapeOutline, z as linear } from "./transition-BxWp6BVX.js";
|
|
2
|
+
import { a as TAU$2, c as boundsOf, d as normalizeAngle, f as pointOn, l as extremes, n as formatNumber } from "./path-data-Cfjk04X8.js";
|
|
3
|
+
import { t as defineIcon } from "./define-ClDM4DNz.js";
|
|
4
4
|
// src/core/animated.ts
|
|
5
5
|
const interpolateNumber = (a, b) => (t) => a * (1 - t) + b * t;
|
|
6
6
|
const interpolatePoint = (a, b) => (t) => ({
|
|
@@ -77,7 +77,7 @@ function animated(initial, interpolate, options = {}) {
|
|
|
77
77
|
// src/core/playback.ts
|
|
78
78
|
const SEEK_MS = 350;
|
|
79
79
|
function playback(options) {
|
|
80
|
-
checkOptions$
|
|
80
|
+
checkOptions$16(options);
|
|
81
81
|
const { from, to, duration, onFrame } = options;
|
|
82
82
|
const ease = options.ease ?? linear;
|
|
83
83
|
const timing = options.timing ?? "playback";
|
|
@@ -220,7 +220,7 @@ function playback(options) {
|
|
|
220
220
|
}
|
|
221
221
|
};
|
|
222
222
|
}
|
|
223
|
-
function checkOptions$
|
|
223
|
+
function checkOptions$16(options) {
|
|
224
224
|
if (typeof options !== "object" || options === null) throw new TypeError("playback needs options: { from, to, duration, onFrame }.");
|
|
225
225
|
const { from, to, duration, ease, timing, onFrame, clock, motion } = options;
|
|
226
226
|
for (const [name, value] of [["from", from], ["to", to]]) if (!isFiniteNumber(value)) throw new RangeError(`playback: ${name} must be a finite number, got ${String(value)}.`);
|
|
@@ -440,7 +440,7 @@ function nearest$1(mark, grid, p) {
|
|
|
440
440
|
const n = grid.length;
|
|
441
441
|
if (n === 1) return 0;
|
|
442
442
|
let best = 0;
|
|
443
|
-
let bestDistance =
|
|
443
|
+
let bestDistance = 1e400;
|
|
444
444
|
grid.forEach((q, i) => {
|
|
445
445
|
const d = squared(q, p);
|
|
446
446
|
if (d < bestDistance) {
|
|
@@ -582,6 +582,7 @@ function textMeasure(svg) {
|
|
|
582
582
|
if (typeof probe.getComputedTextLength === "function" && svg.isConnected) {
|
|
583
583
|
probe.textContent = text;
|
|
584
584
|
width = probe.getComputedTextLength();
|
|
585
|
+
if (width > 0 && leavesSpacingOut(svg)) width += spacingIn(probe, text);
|
|
585
586
|
}
|
|
586
587
|
probe.remove();
|
|
587
588
|
if (!(width > 0)) return text.length * size * AVERAGE_WIDTH;
|
|
@@ -590,6 +591,34 @@ function textMeasure(svg) {
|
|
|
590
591
|
};
|
|
591
592
|
return Object.assign(measure, { clear: () => cache.clear() });
|
|
592
593
|
}
|
|
594
|
+
const unspaced = /* @__PURE__ */ new WeakMap();
|
|
595
|
+
const TEST_SPACING = 8;
|
|
596
|
+
function leavesSpacingOut(svg) {
|
|
597
|
+
const doc = svg.ownerDocument;
|
|
598
|
+
let found = unspaced.get(doc);
|
|
599
|
+
if (found !== void 0) return found;
|
|
600
|
+
const probe = svgElement("text", {
|
|
601
|
+
visibility: "hidden",
|
|
602
|
+
"aria-hidden": "true"
|
|
603
|
+
}, svg);
|
|
604
|
+
if (typeof probe.getEndPositionOfChar !== "function") found = false;
|
|
605
|
+
else {
|
|
606
|
+
probe.style.setProperty("letter-spacing", `${TEST_SPACING}px`, "important");
|
|
607
|
+
probe.textContent = "00";
|
|
608
|
+
const spacing = px(styleOf(probe)?.letterSpacing);
|
|
609
|
+
const length = probe.getComputedTextLength();
|
|
610
|
+
if (spacing > 0 && length > 0) found = probe.getEndPositionOfChar(1).x - probe.getStartPositionOfChar(0).x - length > spacing / 2;
|
|
611
|
+
}
|
|
612
|
+
probe.remove();
|
|
613
|
+
if (found !== void 0) unspaced.set(doc, found);
|
|
614
|
+
return found ?? false;
|
|
615
|
+
}
|
|
616
|
+
function spacingIn(probe, text) {
|
|
617
|
+
const style = styleOf(probe);
|
|
618
|
+
return px(style?.letterSpacing) * (Array.from(text).length - 1) + px(style?.wordSpacing) * (text.split(/[ ]/).length - 1);
|
|
619
|
+
}
|
|
620
|
+
const styleOf = (element) => element.ownerDocument.defaultView?.getComputedStyle(element);
|
|
621
|
+
const px = (value) => Number.parseFloat(value ?? "") || 0;
|
|
593
622
|
// src/charts/bar-layout.ts
|
|
594
623
|
const ROW = 34;
|
|
595
624
|
const BAR = 20;
|
|
@@ -1800,7 +1829,7 @@ function svgSurface(options) {
|
|
|
1800
1829
|
}, overlay);
|
|
1801
1830
|
setStyles(group, markColorStyles(options.colors(key)));
|
|
1802
1831
|
orders.set(group, order);
|
|
1803
|
-
const above = Array.from(overlay.children).find((child) => (orders.get(child) ?? -
|
|
1832
|
+
const above = Array.from(overlay.children).find((child) => (orders.get(child) ?? -1e400) > order);
|
|
1804
1833
|
overlay.insertBefore(group, above ?? null);
|
|
1805
1834
|
let live = groups.get(key);
|
|
1806
1835
|
if (!live) groups.set(key, live = /* @__PURE__ */ new Set());
|
|
@@ -3460,7 +3489,7 @@ function viewBox$1(svg) {
|
|
|
3460
3489
|
const STAGE$2 = 500;
|
|
3461
3490
|
function barChart$1(target, options, env) {
|
|
3462
3491
|
const container = resolveTarget$2(target, "barChart");
|
|
3463
|
-
checkOptions$
|
|
3492
|
+
checkOptions$15(options);
|
|
3464
3493
|
let current = options;
|
|
3465
3494
|
const motion = chartMotion(options.motion, env.motion);
|
|
3466
3495
|
let effects = resolveEffects(options.on, env.presets);
|
|
@@ -4056,7 +4085,7 @@ function barChart$1(target, options, env) {
|
|
|
4056
4085
|
...current,
|
|
4057
4086
|
...next
|
|
4058
4087
|
};
|
|
4059
|
-
checkOptions$
|
|
4088
|
+
checkOptions$15(merged);
|
|
4060
4089
|
const swapped = "on" in next ? nextEffects(effects, current.on, merged.on, env.presets) : effects;
|
|
4061
4090
|
const nextLayout = layout(merged, swapped);
|
|
4062
4091
|
const nextTable = tableFor(merged, nextLayout);
|
|
@@ -4148,7 +4177,7 @@ function barChart$1(target, options, env) {
|
|
|
4148
4177
|
}
|
|
4149
4178
|
});
|
|
4150
4179
|
}
|
|
4151
|
-
function checkOptions$
|
|
4180
|
+
function checkOptions$15(options) {
|
|
4152
4181
|
checkChartOptions(options, "barChart");
|
|
4153
4182
|
const { colorBy, room } = options;
|
|
4154
4183
|
if (room !== void 0 && !(typeof room === "number" && Number.isFinite(room) && room >= 0)) throw new RangeError(`barChart: room must be a number of px, 0 or more, got ${String(room)}.`);
|
|
@@ -4452,7 +4481,7 @@ const TAU = 2 * Math.PI;
|
|
|
4452
4481
|
const VISIBLE$1 = .5;
|
|
4453
4482
|
function donutChart$1(target, options, env) {
|
|
4454
4483
|
const container = resolveTarget$2(target, "donutChart");
|
|
4455
|
-
checkOptions$
|
|
4484
|
+
checkOptions$14(options);
|
|
4456
4485
|
let current = options;
|
|
4457
4486
|
const motion = chartMotion(options.motion, env.motion);
|
|
4458
4487
|
let effects = resolveEffects(options.on, env.presets);
|
|
@@ -5026,7 +5055,7 @@ function donutChart$1(target, options, env) {
|
|
|
5026
5055
|
...current,
|
|
5027
5056
|
...next
|
|
5028
5057
|
};
|
|
5029
|
-
checkOptions$
|
|
5058
|
+
checkOptions$14(merged);
|
|
5030
5059
|
const swapped = "on" in next ? nextEffects(effects, current.on, merged.on, env.presets) : effects;
|
|
5031
5060
|
const nextLayout = layout(merged, swapped);
|
|
5032
5061
|
const nextTable = tableFor(merged, nextLayout);
|
|
@@ -5114,7 +5143,7 @@ function donutChart$1(target, options, env) {
|
|
|
5114
5143
|
}
|
|
5115
5144
|
});
|
|
5116
5145
|
}
|
|
5117
|
-
function checkOptions$
|
|
5146
|
+
function checkOptions$14(options) {
|
|
5118
5147
|
checkChartOptions(options, "donutChart");
|
|
5119
5148
|
const { center, sort } = options;
|
|
5120
5149
|
if (center !== void 0 && center !== false && typeof center !== "function") throw new TypeError("donutChart: center must be false or a function that returns the text for the total.");
|
|
@@ -5252,7 +5281,7 @@ function lineCurve(xs, values, amount, scales, presence) {
|
|
|
5252
5281
|
];
|
|
5253
5282
|
};
|
|
5254
5283
|
return {
|
|
5255
|
-
between(from, to, through =
|
|
5284
|
+
between(from, to, through = 1e400) {
|
|
5256
5285
|
const p = piece(from, to);
|
|
5257
5286
|
if (!p || !tangents) return [];
|
|
5258
5287
|
const [v0, c1, c2, v1, k] = p;
|
|
@@ -5523,7 +5552,7 @@ function boundaries(lo, hi, step, zone) {
|
|
|
5523
5552
|
return out;
|
|
5524
5553
|
}
|
|
5525
5554
|
const nth = unit === "day" ? (i) => midnight(zone, start.year, start.month, start.date + i) : unit === "week" ? (i) => midnight(zone, start.year, start.month, start.date - (start.weekday + 6) % 7 + 7 * i) : unit === "month" ? (i) => midnight(zone, start.year, Math.floor(start.month / count) * count + count * i, 1) : (i) => midnight(zone, Math.floor(start.year / count) * count + count * i, 0, 1);
|
|
5526
|
-
let previous = -
|
|
5555
|
+
let previous = -1e400;
|
|
5527
5556
|
for (let i = 0;; i++) {
|
|
5528
5557
|
const t = nth(i);
|
|
5529
5558
|
if (t >= hi || t <= previous) break;
|
|
@@ -6264,7 +6293,7 @@ function lineChart$1(target, options, env) {
|
|
|
6264
6293
|
const events = chartEvents("lineChart");
|
|
6265
6294
|
let measuredWidth = containerWidth(container);
|
|
6266
6295
|
let destroyed = false;
|
|
6267
|
-
let through =
|
|
6296
|
+
let through = 1e400;
|
|
6268
6297
|
const labelFailures = /* @__PURE__ */ new WeakSet();
|
|
6269
6298
|
let laidOut;
|
|
6270
6299
|
let firstTable;
|
|
@@ -6410,7 +6439,7 @@ function lineChart$1(target, options, env) {
|
|
|
6410
6439
|
}
|
|
6411
6440
|
function drawnThrough(next) {
|
|
6412
6441
|
const last = next.rows[next.rows.length - 1];
|
|
6413
|
-
return last && through < last.x ? revealedIn(next) :
|
|
6442
|
+
return last && through < last.x ? revealedIn(next) : 1e400;
|
|
6414
6443
|
}
|
|
6415
6444
|
const revealed = (record) => !record.leaving && record.row.x <= revealedIn(laidOut);
|
|
6416
6445
|
function createRow(row, entering) {
|
|
@@ -6889,8 +6918,8 @@ function lineChart$1(target, options, env) {
|
|
|
6889
6918
|
function nearestPoint(at) {
|
|
6890
6919
|
const shown = rowOrder.filter(revealed).flatMap(livePoints);
|
|
6891
6920
|
let best;
|
|
6892
|
-
let far =
|
|
6893
|
-
let rank =
|
|
6921
|
+
let far = 1e400;
|
|
6922
|
+
let rank = 1e400;
|
|
6894
6923
|
for (const point of shown) {
|
|
6895
6924
|
const d = apart(point.shown.geometry.center, at);
|
|
6896
6925
|
const r = laidOut.series.indexOf(point.series);
|
|
@@ -6910,7 +6939,7 @@ function lineChart$1(target, options, env) {
|
|
|
6910
6939
|
}
|
|
6911
6940
|
if (on.size < 2) return best;
|
|
6912
6941
|
let pick = best;
|
|
6913
|
-
let near =
|
|
6942
|
+
let near = 1e400;
|
|
6914
6943
|
for (const series of laidOut.series) {
|
|
6915
6944
|
const point = on.get(series);
|
|
6916
6945
|
if (!point) continue;
|
|
@@ -7643,7 +7672,7 @@ function strokeNear({ geometry, data: { samples } }, x, from, at, reach) {
|
|
|
7643
7672
|
if (!next || (way > 0 ? next : samples[j]).gapBefore) break;
|
|
7644
7673
|
const to = way > 0 ? Math.min(next.t, t + span) : Math.max(next.t, t - span);
|
|
7645
7674
|
const b = geometry.path(to);
|
|
7646
|
-
near = Math.min(near ??
|
|
7675
|
+
near = Math.min(near ?? 1e400, toSegment(at, a, b));
|
|
7647
7676
|
if (to !== next.t) break;
|
|
7648
7677
|
a = b;
|
|
7649
7678
|
}
|
|
@@ -7767,7 +7796,7 @@ function describeRects(key, parts, baseline) {
|
|
|
7767
7796
|
...span(part.box)
|
|
7768
7797
|
})).sort((a, b) => a.near - b.near || a.far - b.far || a.index - b.index);
|
|
7769
7798
|
let reached = 0;
|
|
7770
|
-
let gap =
|
|
7799
|
+
let gap = 1e400;
|
|
7771
7800
|
const segments = order.map(({ index, near, far }) => {
|
|
7772
7801
|
if (reached > 0 && far > near) gap = Math.min(gap, near - reached);
|
|
7773
7802
|
const size = Math.max(0, far - reached);
|
|
@@ -8163,7 +8192,7 @@ function hostMarkHandle(parts, edits, halos) {
|
|
|
8163
8192
|
};
|
|
8164
8193
|
}
|
|
8165
8194
|
function hostColors(element, root) {
|
|
8166
|
-
const fill = paintOf$1(element, root, "fill");
|
|
8195
|
+
const fill = element.localName === "line" ? NONE : paintOf$1(element, root, "fill");
|
|
8167
8196
|
const paint = fill === NONE ? "stroke" : "fill";
|
|
8168
8197
|
const color = paint === "fill" ? fill : paintOf$1(element, root, "stroke");
|
|
8169
8198
|
if (color === void 0 || color === NONE) return void 0;
|
|
@@ -8583,6 +8612,7 @@ function watchHost(doc, clock, onChanges) {
|
|
|
8583
8612
|
}
|
|
8584
8613
|
// src/charts/adapter/expressive.ts
|
|
8585
8614
|
const SVG_NS = "http://www.w3.org/2000/svg";
|
|
8615
|
+
const GEOMETRY_ORDER = "Since 0.13.0 geometry is called with (datum, element, key), not (element, datum, key).";
|
|
8586
8616
|
const SHAPES$1 = /* @__PURE__ */ new Set([
|
|
8587
8617
|
"circle",
|
|
8588
8618
|
"ellipse",
|
|
@@ -8600,7 +8630,7 @@ const WRAPPING_ROLES = /* @__PURE__ */ new Set([
|
|
|
8600
8630
|
const insides = /* @__PURE__ */ new WeakMap();
|
|
8601
8631
|
const insidesOf = (port) => port ? insides.get(port) : void 0;
|
|
8602
8632
|
function expressive$1(target, options, env) {
|
|
8603
|
-
checkOptions$
|
|
8633
|
+
checkOptions$13(options);
|
|
8604
8634
|
const motion = chartMotion(options.motion, env.motion);
|
|
8605
8635
|
let effects = resolveEffects(options.on, env.presets);
|
|
8606
8636
|
let given = options.on;
|
|
@@ -8682,12 +8712,18 @@ function expressive$1(target, options, env) {
|
|
|
8682
8712
|
}
|
|
8683
8713
|
function givenMark(key, pieces, index, at) {
|
|
8684
8714
|
const first = pieces[0];
|
|
8685
|
-
|
|
8686
|
-
|
|
8715
|
+
let geometry;
|
|
8716
|
+
try {
|
|
8717
|
+
geometry = options.geometry(first.datum, first.element, key);
|
|
8718
|
+
} catch (error) {
|
|
8719
|
+
throw Object.assign(/* @__PURE__ */ new TypeError(`expressive: geometry for "${key}" threw. ${GEOMETRY_ORDER} Its error: ${error instanceof Error ? error.message : String(error)}`), { cause: error });
|
|
8720
|
+
}
|
|
8721
|
+
if (typeof geometry !== "object" || geometry === null || geometry.key !== key) throw new TypeError(`expressive: geometry for "${key}" must be a MarkGeometry with the key "${key}". Build it with describe and the key passed in. ${GEOMETRY_ORDER}`);
|
|
8722
|
+
const parts = pieces.map((p) => part(p, outlineOf(geometry, p.series, pieces.length), at));
|
|
8687
8723
|
return {
|
|
8688
8724
|
key,
|
|
8689
8725
|
geometry,
|
|
8690
|
-
parts
|
|
8726
|
+
parts,
|
|
8691
8727
|
index
|
|
8692
8728
|
};
|
|
8693
8729
|
}
|
|
@@ -8709,13 +8745,14 @@ function expressive$1(target, options, env) {
|
|
|
8709
8745
|
function rectMark(key, pieces, edge, index, at) {
|
|
8710
8746
|
const { geometry, order } = describeRects(key, pieces.map((p) => p.rect), edge);
|
|
8711
8747
|
const segments = geometry.segments ?? [];
|
|
8748
|
+
const parts = order.map((j, n) => {
|
|
8749
|
+
const segment = segments[n];
|
|
8750
|
+
return part(pieces[j], segment && segment.length >= .5 ? { d: segment.outline.d } : void 0, at);
|
|
8751
|
+
});
|
|
8712
8752
|
return {
|
|
8713
8753
|
key,
|
|
8714
|
-
geometry,
|
|
8715
|
-
parts
|
|
8716
|
-
const segment = segments[n];
|
|
8717
|
-
return part(pieces[j], segment && segment.length >= .5 ? { d: segment.outline.d } : void 0, at);
|
|
8718
|
-
}),
|
|
8754
|
+
geometry: labelled(geometry, parts[0]),
|
|
8755
|
+
parts,
|
|
8719
8756
|
index,
|
|
8720
8757
|
rect: {
|
|
8721
8758
|
edge,
|
|
@@ -8775,12 +8812,15 @@ function expressive$1(target, options, env) {
|
|
|
8775
8812
|
}];
|
|
8776
8813
|
return {
|
|
8777
8814
|
key,
|
|
8778
|
-
geometry,
|
|
8815
|
+
geometry: labelled(geometry, piece),
|
|
8779
8816
|
parts,
|
|
8780
8817
|
index,
|
|
8781
8818
|
...tag === "circle" ? { circle: true } : {}
|
|
8782
8819
|
};
|
|
8783
8820
|
}
|
|
8821
|
+
function labelled(geometry, first) {
|
|
8822
|
+
return options.labelBounds ? withLabels(geometry, options.labelBounds(first.datum, first.element)) : geometry;
|
|
8823
|
+
}
|
|
8784
8824
|
function widthOf(stroke, m, at) {
|
|
8785
8825
|
const width = stroke?.width ?? 1;
|
|
8786
8826
|
if (!stroke?.screen) return width * scaleOf$2(m);
|
|
@@ -9413,10 +9453,11 @@ function expressive$1(target, options, env) {
|
|
|
9413
9453
|
if (destroyed) return;
|
|
9414
9454
|
const reading = read(next ?? source);
|
|
9415
9455
|
if (next !== void 0) source = next;
|
|
9416
|
-
runner.interrupt();
|
|
9417
9456
|
const diff = apply(reading);
|
|
9418
9457
|
watchMarks();
|
|
9419
9458
|
dropGone();
|
|
9459
|
+
const again = hovered?.effects ? diff.changed.flatMap(({ record }) => hovered.keys.includes(record.key) ? [record] : []) : [];
|
|
9460
|
+
runner.leave(again.map((record) => record.key));
|
|
9420
9461
|
const exited = runner.exit(diff.exiting.map(input));
|
|
9421
9462
|
emitEach("exit", diff.exiting);
|
|
9422
9463
|
if (diff.newRow || diff.changed.length > 0 || diff.entering.length > 0 || diff.exiting.length > 0) runner.update(diff.changed.map(({ record, from }) => ({
|
|
@@ -9443,7 +9484,7 @@ function expressive$1(target, options, env) {
|
|
|
9443
9484
|
for (const record of order) if (!entering.has(record)) following.add(record);
|
|
9444
9485
|
}
|
|
9445
9486
|
for (const record of following) runner.change(record.mark.geometry, record.mark.data);
|
|
9446
|
-
runner.
|
|
9487
|
+
runner.hover(again.filter((record) => hovered?.effects && hovered.keys.includes(record.key) && records.get(record.key) === record).map(input));
|
|
9447
9488
|
keyboard?.sync();
|
|
9448
9489
|
for (const listener of refreshed) listener();
|
|
9449
9490
|
exited.then(() => {
|
|
@@ -9500,7 +9541,7 @@ function expressive$1(target, options, env) {
|
|
|
9500
9541
|
}
|
|
9501
9542
|
});
|
|
9502
9543
|
}
|
|
9503
|
-
function checkOptions$
|
|
9544
|
+
function checkOptions$13(options) {
|
|
9504
9545
|
if (typeof options !== "object" || options === null) throw new TypeError("expressive needs options, with at least a key: { key: (d) => d.name }.");
|
|
9505
9546
|
if (typeof options.key !== "function") throw new TypeError("expressive needs a key function, for example key: (d) => d.name. Marks are matched by key.");
|
|
9506
9547
|
for (const name of [
|
|
@@ -9508,6 +9549,7 @@ function checkOptions$12(options) {
|
|
|
9508
9549
|
"segment",
|
|
9509
9550
|
"value",
|
|
9510
9551
|
"geometry",
|
|
9552
|
+
"labelBounds",
|
|
9511
9553
|
"markLabel"
|
|
9512
9554
|
]) if (options[name] !== void 0 && typeof options[name] !== "function") throw new TypeError(`expressive: ${name} must be a function.`);
|
|
9513
9555
|
if (options.baseline !== void 0 && options.baseline !== "auto" && !isBaseline(options.baseline)) throw new RangeError(`expressive: baseline must be "left", "right", "top", "bottom" or "auto", got ${String(options.baseline)}.`);
|
|
@@ -9517,6 +9559,19 @@ function partOf(mark, key) {
|
|
|
9517
9559
|
const segment = mark?.geometry.segments?.find((s) => s.key === key);
|
|
9518
9560
|
return segment && mark.parts.find((p) => p.series === segment.series);
|
|
9519
9561
|
}
|
|
9562
|
+
function withLabels(geometry, boxes) {
|
|
9563
|
+
if (!Array.isArray(boxes)) throw new TypeError(`expressive: labelBounds for "${geometry.key}" must return a list of boxes { x, y, width, height }, got ${describeValue(boxes)}.`);
|
|
9564
|
+
const copies = boxes.map((box) => ({
|
|
9565
|
+
x: box?.x,
|
|
9566
|
+
y: box?.y,
|
|
9567
|
+
width: box?.width,
|
|
9568
|
+
height: box?.height
|
|
9569
|
+
}));
|
|
9570
|
+
return {
|
|
9571
|
+
...geometry,
|
|
9572
|
+
labelBounds: labelBoxes$1(`shape, for expressive's labelBounds for "${geometry.key}"`, copies)
|
|
9573
|
+
};
|
|
9574
|
+
}
|
|
9520
9575
|
function ownSeries(mark) {
|
|
9521
9576
|
const names = [...(mark.geometry.segments ?? []).map((s) => s.series), ...mark.parts.map((p) => p.series)];
|
|
9522
9577
|
return [...new Set(names.filter((name) => name !== void 0))];
|
|
@@ -9875,15 +9930,19 @@ function fromVegaView$1(view, options, env) {
|
|
|
9875
9930
|
if (options.sample !== void 0 && typeof options.sample !== "function") throw new TypeError("fromVegaView: sample must be a function.");
|
|
9876
9931
|
let current = readView();
|
|
9877
9932
|
const { mark: _mark, sample: _sample, ...rest } = options;
|
|
9933
|
+
const read = /* @__PURE__ */ new WeakMap();
|
|
9878
9934
|
const attachment = expressive$1(current.elements, {
|
|
9879
9935
|
...rest,
|
|
9880
9936
|
datum: (element) => itemOf(element).datum,
|
|
9881
|
-
geometry: (
|
|
9937
|
+
geometry: (datum, element, key) => {
|
|
9882
9938
|
const geometry = current.geometry.get(key);
|
|
9883
9939
|
if (!geometry) throw new TypeError(`fromVegaView: no geometry for "${key}". Its key must be the same for every item of a mark.`);
|
|
9884
|
-
return geometry;
|
|
9940
|
+
if (!options.labelBounds) return geometry;
|
|
9941
|
+
const labelled = withLabels(geometry, options.labelBounds(datum, element));
|
|
9942
|
+
read.set(labelled, geometry);
|
|
9943
|
+
return labelled;
|
|
9885
9944
|
},
|
|
9886
|
-
...options.samples || !options.sample ? {} : { samples: (_datum, mark) => current.samples.get(mark) ?? [] },
|
|
9945
|
+
...options.samples || !options.sample ? {} : { samples: (_datum, mark) => current.samples.get(read.get(mark) ?? mark) ?? [] },
|
|
9887
9946
|
...options.value || !options.sample ? {} : { value: (_datum, element) => current.values.get(element) }
|
|
9888
9947
|
}, env);
|
|
9889
9948
|
const clock = env.clock ?? defaultClock;
|
|
@@ -10245,7 +10304,7 @@ const OUT_BY = .4;
|
|
|
10245
10304
|
const HALF = .5;
|
|
10246
10305
|
function chartSwitch$1(target, options, env) {
|
|
10247
10306
|
const host = resolveTarget$2(target, "chartSwitch");
|
|
10248
|
-
const names = checkOptions$
|
|
10307
|
+
const names = checkOptions$12(options);
|
|
10249
10308
|
const effect = options.transition;
|
|
10250
10309
|
const colors = toColorAssignment(options.colors);
|
|
10251
10310
|
const motion = env.motion;
|
|
@@ -10297,7 +10356,7 @@ function chartSwitch$1(target, options, env) {
|
|
|
10297
10356
|
}, runsLayer);
|
|
10298
10357
|
setStyles(group, tokensOf(paints[order] ?? { color: key }));
|
|
10299
10358
|
orders.set(group, order);
|
|
10300
|
-
const above = Array.from(runsLayer.children).find((child) => (orders.get(child) ?? -
|
|
10359
|
+
const above = Array.from(runsLayer.children).find((child) => (orders.get(child) ?? -1e400) > order);
|
|
10301
10360
|
runsLayer.insertBefore(group, above ?? null);
|
|
10302
10361
|
const layer = svgLayer(group);
|
|
10303
10362
|
return {
|
|
@@ -11091,7 +11150,7 @@ function isView(value, container) {
|
|
|
11091
11150
|
"destroy"
|
|
11092
11151
|
].every((method) => typeof view[method] === "function") && element?.nodeType === 1 && container.contains(element);
|
|
11093
11152
|
}
|
|
11094
|
-
function checkOptions$
|
|
11153
|
+
function checkOptions$12(options) {
|
|
11095
11154
|
if (typeof options !== "object" || options === null) throw new TypeError("chartSwitch needs options.");
|
|
11096
11155
|
const { views, initial, transition, announce } = options;
|
|
11097
11156
|
if (typeof views !== "object" || views === null) throw new TypeError("chartSwitch needs views: by name, a function that draws each view's chart in the container it's given.");
|
|
@@ -11121,10 +11180,11 @@ const HINTS = {
|
|
|
11121
11180
|
reduced: "Your device asks for reduced motion, so motion is off. Picking a mode here overrides it."
|
|
11122
11181
|
};
|
|
11123
11182
|
let switches = 0;
|
|
11124
|
-
function motionSwitch$1(target,
|
|
11183
|
+
function motionSwitch$1(target, options) {
|
|
11125
11184
|
const parent = resolveTarget$1(target);
|
|
11185
|
+
const motion = options?.motion;
|
|
11126
11186
|
checkMotion(motion);
|
|
11127
|
-
checkOptions$
|
|
11187
|
+
checkOptions$11(options);
|
|
11128
11188
|
const labels = {
|
|
11129
11189
|
...LABELS$1,
|
|
11130
11190
|
...options.labels
|
|
@@ -11208,7 +11268,7 @@ function resolveTarget$1(target) {
|
|
|
11208
11268
|
function checkMotion(motion) {
|
|
11209
11269
|
if (typeof motion !== "object" || motion === null || typeof motion.chooseMode !== "function" || typeof motion.subscribe !== "function") throw new TypeError("motionSwitch needs a Motion, such as the page-wide `motion` or one from createMotion().");
|
|
11210
11270
|
}
|
|
11211
|
-
function checkOptions$
|
|
11271
|
+
function checkOptions$11(options) {
|
|
11212
11272
|
const { label, labels, hints, persist } = options;
|
|
11213
11273
|
if (label !== void 0 && typeof label !== "string") throw new TypeError(`motionSwitch: label must be a string, got ${typeof label}.`);
|
|
11214
11274
|
for (const [name, texts] of [["labels", labels], ["hints", hints]]) {
|
|
@@ -11225,7 +11285,7 @@ const LABELS = {
|
|
|
11225
11285
|
function playButton(target, playback, options = {}) {
|
|
11226
11286
|
const parent = resolveTarget(target);
|
|
11227
11287
|
checkPlayback(playback);
|
|
11228
|
-
checkOptions$
|
|
11288
|
+
checkOptions$10(options);
|
|
11229
11289
|
const labels = {
|
|
11230
11290
|
...LABELS,
|
|
11231
11291
|
...options.labels
|
|
@@ -11266,7 +11326,7 @@ function resolveTarget(target) {
|
|
|
11266
11326
|
function checkPlayback(playback) {
|
|
11267
11327
|
if (typeof playback !== "object" || playback === null || typeof playback.play !== "function" || typeof playback.pause !== "function" || typeof playback.subscribe !== "function") throw new TypeError("playButton needs a Playback, from playback().");
|
|
11268
11328
|
}
|
|
11269
|
-
function checkOptions$
|
|
11329
|
+
function checkOptions$10(options) {
|
|
11270
11330
|
const { labels } = options;
|
|
11271
11331
|
if (labels === void 0) return;
|
|
11272
11332
|
for (const [key, text] of Object.entries(labels)) if (typeof text !== "string" || text.trim() === "") throw new TypeError(`playButton: labels.${key} must be a string with some text, got ${JSON.stringify(text) ?? String(text)}.`);
|
|
@@ -11336,7 +11396,7 @@ const ORIENTS = [
|
|
|
11336
11396
|
];
|
|
11337
11397
|
const RIDES = ["center", "on"];
|
|
11338
11398
|
function travel(icon, options = {}) {
|
|
11339
|
-
checkOptions$
|
|
11399
|
+
checkOptions$9(icon, options);
|
|
11340
11400
|
function plan(mark, ctx) {
|
|
11341
11401
|
const resolved = typeof icon === "string" ? ctx.icons.get(icon) : icon;
|
|
11342
11402
|
if (!resolved) throw new RangeError(`travel: unknown icon "${String(icon)}". Register it with registerIcon(icon), or pass the icon itself.`);
|
|
@@ -11489,7 +11549,7 @@ function heading(walk, distance, window, leg) {
|
|
|
11489
11549
|
}
|
|
11490
11550
|
return walk.angle(distance / length);
|
|
11491
11551
|
}
|
|
11492
|
-
function checkOptions$
|
|
11552
|
+
function checkOptions$9(icon, options) {
|
|
11493
11553
|
if (!(typeof icon === "string" && icon !== "") && (typeof icon !== "object" || icon === null || typeof icon.name !== "string")) throw new TypeError(`travel needs an icon or an icon's name, got ${icon === null ? "null" : typeof icon}.`);
|
|
11494
11554
|
const { along, gait, size, orient, ride } = options;
|
|
11495
11555
|
if (along !== void 0 && typeof along !== "string") throw new RangeError(`travel: along must be a series name, got ${String(along)}.`);
|
|
@@ -11501,11 +11561,11 @@ function checkOptions$8(icon, options) {
|
|
|
11501
11561
|
// src/effects/flash.ts
|
|
11502
11562
|
const DURATION$7 = 900;
|
|
11503
11563
|
const PEAK = .25;
|
|
11504
|
-
const WIDTH$
|
|
11564
|
+
const WIDTH$3 = 8;
|
|
11505
11565
|
const OPACITY$2 = .35;
|
|
11506
11566
|
function flash(options = {}) {
|
|
11507
|
-
checkOptions$
|
|
11508
|
-
const width = options.width ?? WIDTH$
|
|
11567
|
+
checkOptions$8(options);
|
|
11568
|
+
const width = options.width ?? WIDTH$3;
|
|
11509
11569
|
const opacity = options.opacity ?? OPACITY$2;
|
|
11510
11570
|
const { color } = options;
|
|
11511
11571
|
const show = (ctx, progress) => {
|
|
@@ -11548,7 +11608,7 @@ function easeOut(x) {
|
|
|
11548
11608
|
const s = (lo + hi) / 2;
|
|
11549
11609
|
return 3 * s * s - 2 * s * s * s;
|
|
11550
11610
|
}
|
|
11551
|
-
function checkOptions$
|
|
11611
|
+
function checkOptions$8(options) {
|
|
11552
11612
|
const { width, opacity, color } = options;
|
|
11553
11613
|
if (width !== void 0 && !(typeof width === "number" && width > 0 && Number.isFinite(width))) throw new RangeError(`flash: width must be more than 0 px, got ${String(width)}.`);
|
|
11554
11614
|
if (opacity !== void 0 && !(typeof opacity === "number" && opacity > 0 && opacity <= 1)) throw new RangeError(`flash: opacity must be more than 0 and at most 1, got ${String(opacity)}.`);
|
|
@@ -11566,7 +11626,7 @@ const MIN_REACH = .5;
|
|
|
11566
11626
|
const SAMPLES = 64;
|
|
11567
11627
|
const MAX_ANGLE = Math.PI / 12;
|
|
11568
11628
|
function wiggle(options = {}) {
|
|
11569
|
-
checkOptions$
|
|
11629
|
+
checkOptions$7(options);
|
|
11570
11630
|
const swing = options.swing ?? SWING;
|
|
11571
11631
|
return {
|
|
11572
11632
|
kind: "geometry",
|
|
@@ -11611,7 +11671,7 @@ function rock(t) {
|
|
|
11611
11671
|
const index = Math.floor(position);
|
|
11612
11672
|
return SWINGS[index] * Math.sin(Math.PI * (position - index));
|
|
11613
11673
|
}
|
|
11614
|
-
function checkOptions$
|
|
11674
|
+
function checkOptions$7(options) {
|
|
11615
11675
|
const { swing } = options;
|
|
11616
11676
|
if (swing !== void 0 && !(typeof swing === "number" && swing > 0 && swing <= SWING)) throw new RangeError(`wiggle: swing must be more than 0 and at most ${SWING} px, got ${String(swing)}.`);
|
|
11617
11677
|
}
|
|
@@ -11619,13 +11679,13 @@ function checkOptions$6(options) {
|
|
|
11619
11679
|
const DURATION$5 = 600;
|
|
11620
11680
|
const TIMES = 2;
|
|
11621
11681
|
const MAX_TIMES = 6;
|
|
11622
|
-
const WIDTH$
|
|
11682
|
+
const WIDTH$2 = 12;
|
|
11623
11683
|
const OPACITY$1 = .4;
|
|
11624
11684
|
const LIMIT = 5e3;
|
|
11625
11685
|
function pulse(options = {}) {
|
|
11626
|
-
checkOptions$
|
|
11686
|
+
checkOptions$6(options);
|
|
11627
11687
|
const times = options.times ?? TIMES;
|
|
11628
|
-
const width = options.width ?? WIDTH$
|
|
11688
|
+
const width = options.width ?? WIDTH$2;
|
|
11629
11689
|
const { color } = options;
|
|
11630
11690
|
const show = (ctx, t) => {
|
|
11631
11691
|
const visible = t > 0 && t < 1;
|
|
@@ -11656,7 +11716,7 @@ function pulse(options = {}) {
|
|
|
11656
11716
|
clear() {}
|
|
11657
11717
|
};
|
|
11658
11718
|
}
|
|
11659
|
-
function checkOptions$
|
|
11719
|
+
function checkOptions$6(options) {
|
|
11660
11720
|
const { times, width, color } = options;
|
|
11661
11721
|
if (times !== void 0 && !(Number.isInteger(times) && times >= 1 && times <= MAX_TIMES)) throw new RangeError(`pulse: times must be a whole number from 1 to ${MAX_TIMES}, got ${String(times)}.`);
|
|
11662
11722
|
if (width !== void 0 && !(typeof width === "number" && width > 0 && Number.isFinite(width))) throw new RangeError(`pulse: width must be more than 0 px, got ${String(width)}.`);
|
|
@@ -11664,15 +11724,15 @@ function checkOptions$5(options) {
|
|
|
11664
11724
|
}
|
|
11665
11725
|
// src/effects/trace.ts
|
|
11666
11726
|
const DURATION$4 = 500;
|
|
11667
|
-
const WIDTH = 3;
|
|
11727
|
+
const WIDTH$1 = 3;
|
|
11668
11728
|
const OPACITY = .5;
|
|
11669
11729
|
const MIN_WALK$2 = .5;
|
|
11670
11730
|
function trace(options = {}) {
|
|
11671
|
-
checkOptions$
|
|
11731
|
+
checkOptions$5(options);
|
|
11672
11732
|
const duration = options.duration ?? DURATION$4;
|
|
11673
11733
|
const paint = {
|
|
11674
11734
|
stroke: options.color ?? "mark",
|
|
11675
|
-
width: options.width ?? WIDTH,
|
|
11735
|
+
width: options.width ?? WIDTH$1,
|
|
11676
11736
|
opacity: options.opacity ?? OPACITY,
|
|
11677
11737
|
linecap: "round"
|
|
11678
11738
|
};
|
|
@@ -11722,7 +11782,7 @@ function trace(options = {}) {
|
|
|
11722
11782
|
clear() {}
|
|
11723
11783
|
};
|
|
11724
11784
|
}
|
|
11725
|
-
function checkOptions$
|
|
11785
|
+
function checkOptions$5(options) {
|
|
11726
11786
|
const { color, width, opacity, duration } = options;
|
|
11727
11787
|
if (color !== void 0 && (typeof color !== "string" || color === "")) throw new RangeError(`trace: color must be a theme token or a CSS colour, got ${JSON.stringify(color) ?? String(color)}.`);
|
|
11728
11788
|
if (width !== void 0 && !(typeof width === "number" && width >= 0 && Number.isFinite(width))) throw new RangeError(`trace: width must be 0 px or more, got ${String(width)}.`);
|
|
@@ -11734,7 +11794,7 @@ const DURATION$3 = 750;
|
|
|
11734
11794
|
const FAINT = .3;
|
|
11735
11795
|
const MIN_WALK$1 = .5;
|
|
11736
11796
|
function drawIn(options = {}) {
|
|
11737
|
-
checkOptions$
|
|
11797
|
+
checkOptions$4(options);
|
|
11738
11798
|
const duration = options.duration ?? DURATION$3;
|
|
11739
11799
|
const faint = options.faint ?? FAINT;
|
|
11740
11800
|
return {
|
|
@@ -11793,7 +11853,7 @@ function drawIn(options = {}) {
|
|
|
11793
11853
|
};
|
|
11794
11854
|
}
|
|
11795
11855
|
const walk = (mark) => (mark.segments ?? [mark]).reduce((sum, part) => sum + part.length, 0);
|
|
11796
|
-
function checkOptions$
|
|
11856
|
+
function checkOptions$4(options) {
|
|
11797
11857
|
const { duration, faint } = options;
|
|
11798
11858
|
if (duration !== void 0 && !(typeof duration === "number" && duration >= 0 && Number.isFinite(duration))) throw new RangeError(`drawIn: duration must be 0 ms or more, got ${String(duration)}.`);
|
|
11799
11859
|
if (faint !== void 0 && !(typeof faint === "number" && faint >= 0 && faint <= 1)) throw new RangeError(`drawIn: faint must be from 0 to 1, got ${String(faint)}.`);
|
|
@@ -11818,9 +11878,9 @@ function captionPlace(mark, text) {
|
|
|
11818
11878
|
return past(mark.end, heading, PAST_END, own, boxes, text);
|
|
11819
11879
|
}
|
|
11820
11880
|
function past(from, toward, least, own, boxes, text) {
|
|
11821
|
-
if (!text) return placed$1(from, toward, Math.max(least, farthest(from, toward, boxes) ?? -
|
|
11881
|
+
if (!text) return placed$1(from, toward, Math.max(least, farthest(from, toward, boxes) ?? -1e400));
|
|
11822
11882
|
const { x, y, width, height } = text.box(placed$1(from, toward, 0));
|
|
11823
|
-
return placed$1(from, toward, clearOf(from, toward, Math.max(least, farthest(from, toward, own) ?? -
|
|
11883
|
+
return placed$1(from, toward, clearOf(from, toward, Math.max(least, farthest(from, toward, own) ?? -1e400), boxes, {
|
|
11824
11884
|
x: x - from.x,
|
|
11825
11885
|
y: y - from.y,
|
|
11826
11886
|
width,
|
|
@@ -11844,7 +11904,7 @@ function clearOf(from, toward, distance, boxes, reach, held) {
|
|
|
11844
11904
|
const within = meets(near);
|
|
11845
11905
|
if (!band || !within) return within;
|
|
11846
11906
|
const leaving = across ? Math.max(band[1], ((sin > 0 ? near.y + near.height : near.y) - from.y) / sin) : band[1];
|
|
11847
|
-
return [within[0], Math.max(leaving, meets(box)?.[1] ?? -
|
|
11907
|
+
return [within[0], Math.max(leaving, meets(box)?.[1] ?? -1e400)];
|
|
11848
11908
|
});
|
|
11849
11909
|
let at = distance;
|
|
11850
11910
|
for (let moved = true; moved;) {
|
|
@@ -11898,7 +11958,7 @@ function leaves(from, cos, sin, box) {
|
|
|
11898
11958
|
}
|
|
11899
11959
|
function span(from, cos, sin, box) {
|
|
11900
11960
|
let near = 0;
|
|
11901
|
-
let far =
|
|
11961
|
+
let far = 1e400;
|
|
11902
11962
|
for (const [origin, step, lo, hi] of [[
|
|
11903
11963
|
from.x,
|
|
11904
11964
|
cos,
|
|
@@ -11980,7 +12040,7 @@ const signed = (change) => {
|
|
|
11980
12040
|
return wording.format(change);
|
|
11981
12041
|
};
|
|
11982
12042
|
function delta(options = {}) {
|
|
11983
|
-
checkOptions$
|
|
12043
|
+
checkOptions$3(options);
|
|
11984
12044
|
const value = options.value ?? lastSample;
|
|
11985
12045
|
const format = options.format ?? signed;
|
|
11986
12046
|
const color = options.color ?? "text";
|
|
@@ -12012,7 +12072,7 @@ function delta(options = {}) {
|
|
|
12012
12072
|
clear() {}
|
|
12013
12073
|
};
|
|
12014
12074
|
}
|
|
12015
|
-
function checkOptions$
|
|
12075
|
+
function checkOptions$3(options) {
|
|
12016
12076
|
const { value, format, color } = options;
|
|
12017
12077
|
if (value !== void 0 && typeof value !== "function") throw new TypeError(`delta: value must be a function that reads the mark's value from its data, got ${typeof value}.`);
|
|
12018
12078
|
if (format !== void 0 && typeof format !== "function") throw new TypeError(`delta: format must be a function that words the change, got ${typeof format}.`);
|
|
@@ -12048,7 +12108,7 @@ const MIN_WALK = .5;
|
|
|
12048
12108
|
const TIE = 1e-9;
|
|
12049
12109
|
const WHENS = ["below", "above"];
|
|
12050
12110
|
function threshold(options) {
|
|
12051
|
-
checkOptions$
|
|
12111
|
+
checkOptions$2(options);
|
|
12052
12112
|
const { compareTo } = options;
|
|
12053
12113
|
const when = options.when ?? "below";
|
|
12054
12114
|
const color = options.color ?? "negative";
|
|
@@ -12219,13 +12279,57 @@ function firstAbove(values, x) {
|
|
|
12219
12279
|
}
|
|
12220
12280
|
return lo;
|
|
12221
12281
|
}
|
|
12222
|
-
function checkOptions$
|
|
12282
|
+
function checkOptions$2(options) {
|
|
12223
12283
|
const { compareTo, when, color } = options ?? {};
|
|
12224
12284
|
if (!(typeof compareTo === "string" ? compareTo !== "" : typeof compareTo === "number" && Number.isFinite(compareTo))) throw new RangeError(`threshold: compareTo must be a finite number or a series name, got ${show(compareTo)}.`);
|
|
12225
12285
|
if (when !== void 0 && !WHENS.includes(when)) throw new RangeError(`threshold: when must be "below" or "above", got ${show(when)}.`);
|
|
12226
12286
|
if (color !== void 0 && (typeof color !== "string" || color === "")) throw new RangeError(`threshold: color must be a theme token or a CSS colour, got ${show(color)}.`);
|
|
12227
12287
|
}
|
|
12228
12288
|
const show = (value) => typeof value === "string" ? JSON.stringify(value) : String(value);
|
|
12289
|
+
// src/effects/outline.ts
|
|
12290
|
+
const COLOR$1 = "text";
|
|
12291
|
+
const WIDTH = 2;
|
|
12292
|
+
function outline(options = {}) {
|
|
12293
|
+
checkOptions$1(options);
|
|
12294
|
+
const paint = {
|
|
12295
|
+
stroke: options.color ?? COLOR$1,
|
|
12296
|
+
width: options.width ?? WIDTH
|
|
12297
|
+
};
|
|
12298
|
+
const draw = (mark, ctx) => {
|
|
12299
|
+
const path = ctx.layer.path(mark.outline.d, paint);
|
|
12300
|
+
ctx.onChange((next) => path.update(next.outline.d));
|
|
12301
|
+
};
|
|
12302
|
+
return {
|
|
12303
|
+
kind: "geometry",
|
|
12304
|
+
async run(mark, ctx) {
|
|
12305
|
+
if (!ctx.signal.aborted) draw(mark, ctx);
|
|
12306
|
+
},
|
|
12307
|
+
end: draw,
|
|
12308
|
+
clear() {}
|
|
12309
|
+
};
|
|
12310
|
+
}
|
|
12311
|
+
function checkOptions$1(options) {
|
|
12312
|
+
const { color, width } = options;
|
|
12313
|
+
if (color !== void 0 && (typeof color !== "string" || color === "")) throw new RangeError(`outline: color must be a theme token or a CSS colour, got ${JSON.stringify(color) ?? String(color)}.`);
|
|
12314
|
+
if (width !== void 0 && !(typeof width === "number" && width > 0 && Number.isFinite(width))) throw new RangeError(`outline: width must be more than 0 px, got ${String(width)}.`);
|
|
12315
|
+
}
|
|
12316
|
+
// src/effects/wait.ts
|
|
12317
|
+
function wait(duration) {
|
|
12318
|
+
if (!(typeof duration === "number" && duration >= 0 && Number.isFinite(duration))) throw new RangeError(`wait: duration must be 0 ms or more, got ${String(duration)}.`);
|
|
12319
|
+
return {
|
|
12320
|
+
kind: "geometry",
|
|
12321
|
+
async run(_mark, ctx) {
|
|
12322
|
+
if (ctx.signal.aborted) return;
|
|
12323
|
+
await ctx.tween({
|
|
12324
|
+
duration,
|
|
12325
|
+
timing: "effect",
|
|
12326
|
+
update() {}
|
|
12327
|
+
}).finished;
|
|
12328
|
+
},
|
|
12329
|
+
end() {},
|
|
12330
|
+
clear() {}
|
|
12331
|
+
};
|
|
12332
|
+
}
|
|
12229
12333
|
// src/effects/morph.ts
|
|
12230
12334
|
const DURATION = 950;
|
|
12231
12335
|
const POINTS = 160;
|
|
@@ -12490,8 +12594,8 @@ function bandOf(outline) {
|
|
|
12490
12594
|
ring.push(segment.to);
|
|
12491
12595
|
}
|
|
12492
12596
|
if (areaOf(ring) < 0) ring.reverse();
|
|
12493
|
-
const left = ring.reduce((x, point) => Math.min(x, point.x),
|
|
12494
|
-
const right = ring.reduce((x, point) => Math.max(x, point.x), -
|
|
12597
|
+
const left = ring.reduce((x, point) => Math.min(x, point.x), 1e400);
|
|
12598
|
+
const right = ring.reduce((x, point) => Math.max(x, point.x), -1e400);
|
|
12495
12599
|
if (!(right - left > 2 * SAME_X)) return void 0;
|
|
12496
12600
|
const atLeft = (point) => point.x - left <= SAME_X;
|
|
12497
12601
|
const atRight = (point) => right - point.x <= SAME_X;
|
|
@@ -12608,7 +12712,7 @@ function landing(hole, own, other, area) {
|
|
|
12608
12712
|
}
|
|
12609
12713
|
function depth(point, area) {
|
|
12610
12714
|
if (windingAt(point, area) === 0) return 0;
|
|
12611
|
-
let nearest =
|
|
12715
|
+
let nearest = 1e400;
|
|
12612
12716
|
for (const ring of area) ring.forEach((p, i) => {
|
|
12613
12717
|
const q = ring[(i + 1) % ring.length];
|
|
12614
12718
|
const dx = q.x - p.x;
|
|
@@ -13078,8 +13182,8 @@ function inherit(parent, attributes) {
|
|
|
13078
13182
|
fill: paint("fill", parent.fill),
|
|
13079
13183
|
stroke: paint("stroke", parent.stroke),
|
|
13080
13184
|
width: width >= 0 ? width : parent.width,
|
|
13081
|
-
linecap: linecap === "butt" || linecap === "round" ? linecap : parent.linecap,
|
|
13082
|
-
linejoin: linejoin === "miter" || linejoin === "round" ? linejoin : parent.linejoin,
|
|
13185
|
+
linecap: linecap === "butt" || linecap === "round" || linecap === "square" ? linecap : parent.linecap,
|
|
13186
|
+
linejoin: linejoin === "miter" || linejoin === "round" || linejoin === "bevel" ? linejoin : parent.linejoin,
|
|
13083
13187
|
fillRule: fillRule === "nonzero" || fillRule === "evenodd" ? fillRule : parent.fillRule,
|
|
13084
13188
|
opacity: parent.opacity * (alpha(attributes.get("opacity")) ?? 1),
|
|
13085
13189
|
fillOpacity: alpha(attributes.get("fill-opacity")) ?? parent.fillOpacity,
|
|
@@ -13225,7 +13329,7 @@ function configure(options) {
|
|
|
13225
13329
|
}
|
|
13226
13330
|
}
|
|
13227
13331
|
// src/index.ts
|
|
13228
|
-
const VERSION = "0.
|
|
13332
|
+
const VERSION = "0.13.0";
|
|
13229
13333
|
const env = {
|
|
13230
13334
|
presets: presetRegistry,
|
|
13231
13335
|
icons: iconRegistry,
|
|
@@ -13252,9 +13356,15 @@ function expressive(target, options) {
|
|
|
13252
13356
|
function fromVegaView(view, options) {
|
|
13253
13357
|
return fromVegaView$1(view, options, env);
|
|
13254
13358
|
}
|
|
13255
|
-
function motionSwitch(target,
|
|
13256
|
-
|
|
13359
|
+
function motionSwitch(target, second, third) {
|
|
13360
|
+
const old = third !== void 0 || second !== void 0 && (typeof second !== "object" || second === null || "chooseMode" in second);
|
|
13361
|
+
const options = (old ? third : second) ?? {};
|
|
13362
|
+
const motion$1 = old && second !== void 0 ? second : options.motion ?? motion;
|
|
13363
|
+
return motionSwitch$1(target, {
|
|
13364
|
+
...options,
|
|
13365
|
+
motion: motion$1
|
|
13366
|
+
});
|
|
13257
13367
|
}
|
|
13258
|
-
export { VERSION, animated, barChart, chartSwitch, colorAssignment, configure, createClock, createMotion, defaultClock, defaultScaling, defineDataEffect, defineEffect, defineIcon, delta, describe, donutChart, drawIn, easeInOutCubic, easeOutCubic, expressive, flash, fromVegaView, gaits, hostView, iconFromSvg, icons, interpolateNumber, interpolatePoint, interpolateRecord, label, lineChart, linear, link, manualClock, matrix, mediaReducedMotion, morph, motion, motionSwitch, offset, only, parallel, playButton, playback, pulse, registerIcon, registerIcons, registerPreset, samplesAlong, scaleDuration, sequence, stagger, threshold, trace, travel, tween, wiggle };
|
|
13368
|
+
export { VERSION, animated, barChart, chartSwitch, colorAssignment, configure, createClock, createMotion, defaultClock, defaultScaling, defineDataEffect, defineEffect, defineIcon, delta, describe, donutChart, drawIn, easeInOutCubic, easeOutCubic, expressive, flash, fromVegaView, gaits, hostView, iconFromSvg, icons, interpolateNumber, interpolatePoint, interpolateRecord, label, lineChart, linear, link, manualClock, matrix, mediaReducedMotion, morph, motion, motionSwitch, offset, only, outline, parallel, playButton, playback, pulse, registerIcon, registerIcons, registerPreset, samplesAlong, scaleDuration, sequence, stagger, threshold, trace, travel, tween, wait, wiggle };
|
|
13259
13369
|
|
|
13260
13370
|
//# sourceMappingURL=index.js.map
|