expressive-charts 0.7.0 → 0.9.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 +36 -0
- package/README.md +8 -8
- package/dist/expressive-charts.global.js +6 -6
- package/dist/expressive-charts.global.js.map +1 -1
- package/dist/index.cjs +488 -110
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +169 -96
- package/dist/index.d.ts +169 -96
- package/dist/index.js +488 -111
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -656,8 +656,10 @@ function layoutBars(input) {
|
|
|
656
656
|
const domain = niceDomain(rows.map((row) => row.total));
|
|
657
657
|
const texts = rows.map((row) => input.format(row.total));
|
|
658
658
|
const ticks = domain.ticks.map(input.format);
|
|
659
|
-
const
|
|
660
|
-
|
|
659
|
+
const make = (values) => (input.encoding.orientation === "horizontal" ? horizontalFrame : verticalFrame)(input, rows, domain, values, ticks);
|
|
660
|
+
let frame = make(texts);
|
|
661
|
+
let labels = thinLabels(frame, rows, texts, input.measure);
|
|
662
|
+
if (!labels.values) labels = thinLabels(frame = make(), rows, texts, input.measure, false);
|
|
661
663
|
return {
|
|
662
664
|
width: frame.bands.width,
|
|
663
665
|
height: frame.bands.height,
|
|
@@ -676,10 +678,10 @@ function layoutBars(input) {
|
|
|
676
678
|
labels
|
|
677
679
|
};
|
|
678
680
|
}
|
|
679
|
-
function thinLabels(frame, rows, texts, measure) {
|
|
681
|
+
function thinLabels(frame, rows, texts, measure, values = true) {
|
|
680
682
|
const placed = rows.map((row, slot) => placeLabels$1(frame, slot, row.total, row.category, texts[slot]));
|
|
681
683
|
const horizontal = frame.orientation === "horizontal";
|
|
682
|
-
|
|
684
|
+
values && (values = !overlaps$1(boxesOf(placed.map(({ value }) => value), measure, "ec-value", VALUE_SIZE$2), horizontal));
|
|
683
685
|
const categories = (every) => boxesOf(placed.filter((_, slot) => slot % every === 0).map(({ label }) => label), measure, "ec-label", LABEL_SIZE$1);
|
|
684
686
|
let k = 0;
|
|
685
687
|
while (thinStep(k) < rows.length && overlaps$1(categories(thinStep(k)), horizontal)) k++;
|
|
@@ -924,12 +926,12 @@ function horizontalFrame(input, rows, domain, values, ticks) {
|
|
|
924
926
|
const { width, measure } = input;
|
|
925
927
|
const n = rows.length;
|
|
926
928
|
const labelWidth = widest$1(rows.map((row) => row.category), "ec-label", LABEL_SIZE$1, measure);
|
|
927
|
-
const
|
|
929
|
+
const valueRoom = values ? widest$1(values, "ec-value", VALUE_SIZE$2, measure) + PAD$1 : 0;
|
|
928
930
|
const tickWidth = widest$1(ticks, "ec-tick", TICK_SIZE$1, measure);
|
|
929
931
|
const { positive, negative } = reach(input, rows);
|
|
930
|
-
const negativeRoom = domain.lo < 0 ?
|
|
932
|
+
const negativeRoom = domain.lo < 0 ? valueRoom : 0;
|
|
931
933
|
const left = Math.max(labelWidth + 10 + negativeRoom + negative, tickWidth / 2 + 2);
|
|
932
|
-
const right = Math.max(
|
|
934
|
+
const right = Math.max(valueRoom + 4 + positive, tickWidth / 2 + 2);
|
|
933
935
|
const rowSize = input.height === void 0 || n === 0 ? ROW : Math.max(0, input.height - TOP$1 - AXIS$1) / n;
|
|
934
936
|
return {
|
|
935
937
|
orientation: "horizontal",
|
|
@@ -950,15 +952,15 @@ function horizontalFrame(input, rows, domain, values, ticks) {
|
|
|
950
952
|
}
|
|
951
953
|
};
|
|
952
954
|
}
|
|
953
|
-
function verticalFrame(input, rows, domain,
|
|
955
|
+
function verticalFrame(input, rows, domain, values, ticks) {
|
|
954
956
|
const { width, measure } = input;
|
|
955
957
|
const n = rows.length;
|
|
956
958
|
const height = input.height ?? VERTICAL_HEIGHT;
|
|
957
959
|
const tickWidth = widest$1(ticks, "ec-tick", TICK_SIZE$1, measure);
|
|
958
960
|
const { positive, negative } = reach(input, rows);
|
|
959
|
-
const top = (domain.hi > 0 ? 20.5 : TOP$1) + positive;
|
|
960
|
-
const
|
|
961
|
-
const bottom = AXIS$1 +
|
|
961
|
+
const top = (values && domain.hi > 0 ? 20.5 : TOP$1) + positive;
|
|
962
|
+
const under = values && domain.lo < 0 ? 18.5 : 0;
|
|
963
|
+
const bottom = AXIS$1 + under + negative;
|
|
962
964
|
const left = tickWidth + 8 + 2;
|
|
963
965
|
const plot = {
|
|
964
966
|
x: left,
|
|
@@ -975,7 +977,7 @@ function verticalFrame(input, rows, domain, _values, ticks) {
|
|
|
975
977
|
hi: domain.hi,
|
|
976
978
|
from: base,
|
|
977
979
|
extent: -plot.height,
|
|
978
|
-
label: base +
|
|
980
|
+
label: base + under + 18
|
|
979
981
|
},
|
|
980
982
|
bands: {
|
|
981
983
|
start: plot.x,
|
|
@@ -2321,6 +2323,11 @@ function chartHover(options) {
|
|
|
2321
2323
|
}] : [];
|
|
2322
2324
|
});
|
|
2323
2325
|
const marksFor = (keys) => keys.length === 1 ? marksOf(keys[0]) : [...new Set(keys.flatMap(marksOf))];
|
|
2326
|
+
const standIns = (keys) => keys.flatMap((key) => {
|
|
2327
|
+
const input = options.standIn?.(key);
|
|
2328
|
+
return input ? [input] : [];
|
|
2329
|
+
});
|
|
2330
|
+
const standingFor = (keys, source, marks) => source === "linked" && marks.length === 0 ? keys.find((key) => options.standIn?.(key) !== void 0) : void 0;
|
|
2324
2331
|
function hoverMarks(marks, source, effects, segment) {
|
|
2325
2332
|
if (marks.length === 0) return;
|
|
2326
2333
|
if (effects) runner.hover(marks.map(({ input }) => input));
|
|
@@ -2351,11 +2358,13 @@ function chartHover(options) {
|
|
|
2351
2358
|
}
|
|
2352
2359
|
function startHover(keys, source, segment, effects = true) {
|
|
2353
2360
|
const marks = onScreen(marksFor(keys));
|
|
2361
|
+
const standing = standingFor(keys, source, marks);
|
|
2354
2362
|
const started = {
|
|
2355
2363
|
keys,
|
|
2356
2364
|
source,
|
|
2357
2365
|
marks: marks.map((mark) => mark.key),
|
|
2358
|
-
effects
|
|
2366
|
+
effects,
|
|
2367
|
+
standing
|
|
2359
2368
|
};
|
|
2360
2369
|
hovered = started;
|
|
2361
2370
|
for (const { key: mark } of marks) heat(mark, true);
|
|
@@ -2364,8 +2373,9 @@ function chartHover(options) {
|
|
|
2364
2373
|
options.tooltip.show(keys[0]);
|
|
2365
2374
|
listenForEscape(true);
|
|
2366
2375
|
}
|
|
2376
|
+
if (standing !== void 0) options.stand?.(standing);
|
|
2367
2377
|
hoverMarks(marks, source, effects, segment);
|
|
2368
|
-
if (source !== "linked" && hovered === started) linked?.hover(marks.map(({ input }) => input));
|
|
2378
|
+
if (source !== "linked" && hovered === started) linked?.hover(marks.length > 0 ? marks.map(({ input }) => input) : standIns(keys));
|
|
2369
2379
|
}
|
|
2370
2380
|
function endHover() {
|
|
2371
2381
|
const ended = hovered;
|
|
@@ -2373,6 +2383,7 @@ function chartHover(options) {
|
|
|
2373
2383
|
listenForEscape(false);
|
|
2374
2384
|
svg.classList.remove("ec-hovering");
|
|
2375
2385
|
options.tooltip.hide();
|
|
2386
|
+
if (ended?.standing !== void 0) options.stand?.(void 0);
|
|
2376
2387
|
leaveMarks(ended?.marks ?? []);
|
|
2377
2388
|
if (own(ended)) linked?.leave();
|
|
2378
2389
|
}
|
|
@@ -2451,14 +2462,20 @@ function chartHover(options) {
|
|
|
2451
2462
|
get key() {
|
|
2452
2463
|
return own(hovered) ? hovered.keys[0] : void 0;
|
|
2453
2464
|
},
|
|
2465
|
+
get standing() {
|
|
2466
|
+
return hovered?.standing;
|
|
2467
|
+
},
|
|
2454
2468
|
get ringKey() {
|
|
2455
2469
|
return ringKey;
|
|
2456
2470
|
},
|
|
2457
2471
|
link: {
|
|
2458
|
-
targets: () => options.order().map((key) =>
|
|
2459
|
-
key
|
|
2460
|
-
|
|
2461
|
-
|
|
2472
|
+
targets: () => options.order().map((key) => {
|
|
2473
|
+
const marks = onScreen(marksOf(key)).map(({ input }) => input);
|
|
2474
|
+
return {
|
|
2475
|
+
key,
|
|
2476
|
+
marks: marks.length > 0 ? marks : standIns([key])
|
|
2477
|
+
};
|
|
2478
|
+
}),
|
|
2462
2479
|
hover(keys, effects) {
|
|
2463
2480
|
if (hovered !== void 0) endHover();
|
|
2464
2481
|
const live = keys.filter(options.live);
|
|
@@ -2494,9 +2511,12 @@ function chartHover(options) {
|
|
|
2494
2511
|
}
|
|
2495
2512
|
const { source, marks: before, effects } = hovered;
|
|
2496
2513
|
const now = onScreen(marksFor(keys));
|
|
2514
|
+
const standing = standingFor(keys, source, now);
|
|
2515
|
+
if (standing !== hovered.standing) options.stand?.(standing);
|
|
2497
2516
|
hovered = {
|
|
2498
2517
|
...hovered,
|
|
2499
|
-
keys
|
|
2518
|
+
keys,
|
|
2519
|
+
standing
|
|
2500
2520
|
};
|
|
2501
2521
|
if (now.length === before.length && now.every((mark, i) => mark.key === before[i])) return;
|
|
2502
2522
|
const had = new Set(before);
|
|
@@ -2678,6 +2698,10 @@ function tableModel(input) {
|
|
|
2678
2698
|
text: "",
|
|
2679
2699
|
numeric: false
|
|
2680
2700
|
});
|
|
2701
|
+
const missing = {
|
|
2702
|
+
text: input.missing ?? "missing",
|
|
2703
|
+
numeric: true
|
|
2704
|
+
};
|
|
2681
2705
|
const headers = [
|
|
2682
2706
|
{
|
|
2683
2707
|
text: options.category ?? input.category ?? "Category",
|
|
@@ -2708,10 +2732,7 @@ function tableModel(input) {
|
|
|
2708
2732
|
numeric: false
|
|
2709
2733
|
},
|
|
2710
2734
|
...first.map((column) => columnCell(column, row, format)),
|
|
2711
|
-
...input.series.map((series) => row.missing?.has(series) ?
|
|
2712
|
-
text: MISSING,
|
|
2713
|
-
numeric: true
|
|
2714
|
-
} : number(values.get(series) ?? 0)),
|
|
2735
|
+
...input.series.map((series) => row.missing?.has(series) ? missing : number(values.get(series) ?? 0)),
|
|
2715
2736
|
...totals ? [number(row.total)] : [],
|
|
2716
2737
|
...share(row.total),
|
|
2717
2738
|
...last.map((column) => columnCell(column, row, format))
|
|
@@ -3080,6 +3101,42 @@ function watchFonts(doc, loaded) {
|
|
|
3080
3101
|
fonts?.addEventListener?.("loadingdone", loaded);
|
|
3081
3102
|
return () => fonts?.removeEventListener?.("loadingdone", loaded);
|
|
3082
3103
|
}
|
|
3104
|
+
const PROBE_TEXT = "Hamburgefonstiv 0123456789";
|
|
3105
|
+
function watchText(svg, clock, changed) {
|
|
3106
|
+
if (typeof ResizeObserver !== "function") return () => {};
|
|
3107
|
+
const probe = svgElement("text", {
|
|
3108
|
+
"font-size": 11,
|
|
3109
|
+
visibility: "hidden",
|
|
3110
|
+
"pointer-events": "none",
|
|
3111
|
+
"aria-hidden": "true"
|
|
3112
|
+
}, svg);
|
|
3113
|
+
probe.textContent = PROBE_TEXT;
|
|
3114
|
+
let measured = 0;
|
|
3115
|
+
let pending = 0;
|
|
3116
|
+
let stopFrame;
|
|
3117
|
+
const observer = new ResizeObserver((entries) => {
|
|
3118
|
+
const next = entries.find((entry) => entry.target === probe)?.contentRect.width ?? 0;
|
|
3119
|
+
if (!(next > 0) || Math.abs(next - pending) < .5) return;
|
|
3120
|
+
pending = next;
|
|
3121
|
+
if (!measured) {
|
|
3122
|
+
measured = next;
|
|
3123
|
+
return;
|
|
3124
|
+
}
|
|
3125
|
+
stopFrame ?? (stopFrame = clock.onFrame(() => {
|
|
3126
|
+
stopFrame?.();
|
|
3127
|
+
stopFrame = void 0;
|
|
3128
|
+
if (Math.abs(pending - measured) < .5) return;
|
|
3129
|
+
measured = pending;
|
|
3130
|
+
changed();
|
|
3131
|
+
}));
|
|
3132
|
+
});
|
|
3133
|
+
observer.observe(probe);
|
|
3134
|
+
return () => {
|
|
3135
|
+
observer.disconnect();
|
|
3136
|
+
stopFrame?.();
|
|
3137
|
+
probe.remove();
|
|
3138
|
+
};
|
|
3139
|
+
}
|
|
3083
3140
|
function watchHoverDuration(svg, motion) {
|
|
3084
3141
|
const sync = () => svg.style.setProperty("--ec-hover-duration", `${motion.duration(100, "feedback")}ms`);
|
|
3085
3142
|
sync();
|
|
@@ -3560,6 +3617,10 @@ function barChart$1(target, options, env) {
|
|
|
3560
3617
|
series: row.values.map((v) => v.series),
|
|
3561
3618
|
slot: animated(row.slot, interpolateNumber, env),
|
|
3562
3619
|
presence: animated(entering ? 0 : 1, interpolateNumber, env),
|
|
3620
|
+
drawn: {
|
|
3621
|
+
label: animated(Number(row.drawn.label), interpolateNumber, env),
|
|
3622
|
+
value: animated(Number(row.drawn.value), interpolateNumber, env)
|
|
3623
|
+
},
|
|
3563
3624
|
count: void 0,
|
|
3564
3625
|
leave: void 0
|
|
3565
3626
|
};
|
|
@@ -3568,15 +3629,17 @@ function barChart$1(target, options, env) {
|
|
|
3568
3629
|
return record;
|
|
3569
3630
|
}
|
|
3570
3631
|
function drawMark(record, row) {
|
|
3571
|
-
const before = record.parts
|
|
3632
|
+
const before = record.parts;
|
|
3572
3633
|
record.shown = row;
|
|
3573
3634
|
setAttributes(record.hit, { ...row.hit });
|
|
3574
3635
|
placeText(record.label, row.label);
|
|
3575
3636
|
placeText(record.value, row.value);
|
|
3576
|
-
const
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3637
|
+
const opacity = (drawn, fade) => {
|
|
3638
|
+
const shown = record.presence.value * (drawn ? fade.value : 1);
|
|
3639
|
+
return shown < 1 ? shown : void 0;
|
|
3640
|
+
};
|
|
3641
|
+
setAttributes(record.label, { opacity: opacity(row.drawn.label, record.drawn.label) });
|
|
3642
|
+
setAttributes(record.value, { opacity: opacity(row.drawn.value, record.drawn.value) });
|
|
3580
3643
|
const segments = row.geometry.segments ?? [];
|
|
3581
3644
|
const keep = /* @__PURE__ */ new Set();
|
|
3582
3645
|
const ownColors = byCategory(current) ? seriesColors(colors.slot(record.key)) : void 0;
|
|
@@ -3609,7 +3672,7 @@ function barChart$1(target, options, env) {
|
|
|
3609
3672
|
const drawn = Array.from(record.body.children).filter((child) => child.classList.contains("ec-segment"));
|
|
3610
3673
|
if (record.parts.some((part, i) => drawn[i] !== part.element)) for (const part of record.parts) record.body.appendChild(part.element);
|
|
3611
3674
|
record.handle.repaint();
|
|
3612
|
-
if (record.parts
|
|
3675
|
+
if (record.parts.length !== before.length || record.parts.some((part, i) => part.colors.color !== before[i].colors.color)) surface.recolor(record.key);
|
|
3613
3676
|
if (record.key === hover.ringKey) drawRing(record.key);
|
|
3614
3677
|
}
|
|
3615
3678
|
function drawRing(key) {
|
|
@@ -3716,6 +3779,10 @@ function barChart$1(target, options, env) {
|
|
|
3716
3779
|
}));
|
|
3717
3780
|
const total = values.reduce((sum, v) => sum + v.value, 0);
|
|
3718
3781
|
const text = record.count === void 0 ? row.value.text : format(current)(round$5(total, record.count));
|
|
3782
|
+
const drawn = {
|
|
3783
|
+
label: record.drawn.label.value > 0,
|
|
3784
|
+
value: record.drawn.value.value > 0
|
|
3785
|
+
};
|
|
3719
3786
|
return placeRow(frame, {
|
|
3720
3787
|
key: row.key,
|
|
3721
3788
|
datum: row.datum,
|
|
@@ -3724,7 +3791,7 @@ function barChart$1(target, options, env) {
|
|
|
3724
3791
|
values,
|
|
3725
3792
|
slot: record.slot.value,
|
|
3726
3793
|
text,
|
|
3727
|
-
drawn
|
|
3794
|
+
drawn
|
|
3728
3795
|
}, measure);
|
|
3729
3796
|
}
|
|
3730
3797
|
function addTick(value, opacity) {
|
|
@@ -3846,8 +3913,11 @@ function barChart$1(target, options, env) {
|
|
|
3846
3913
|
let first;
|
|
3847
3914
|
let second;
|
|
3848
3915
|
let grow;
|
|
3916
|
+
let out;
|
|
3917
|
+
let into;
|
|
3849
3918
|
if (!jump && motion.staged) {
|
|
3850
3919
|
const wait = values ? STAGE$2 : 0;
|
|
3920
|
+
const half = values && positions ? STAGE$2 : STAGE$2 / 2;
|
|
3851
3921
|
first = { duration: STAGE$2 };
|
|
3852
3922
|
second = {
|
|
3853
3923
|
duration: STAGE$2,
|
|
@@ -3857,6 +3927,11 @@ function barChart$1(target, options, env) {
|
|
|
3857
3927
|
duration: STAGE$2 / 2,
|
|
3858
3928
|
delay: wait + STAGE$2 / 2
|
|
3859
3929
|
};
|
|
3930
|
+
out = { duration: half };
|
|
3931
|
+
into = {
|
|
3932
|
+
duration: half,
|
|
3933
|
+
delay: half
|
|
3934
|
+
};
|
|
3860
3935
|
} else if (!jump) first = second = grow = { duration: (values && positions ? 2 : 1) * STAGE$2 };
|
|
3861
3936
|
const running = [];
|
|
3862
3937
|
const move = (value, to, equal, timing) => {
|
|
@@ -3867,6 +3942,13 @@ function barChart$1(target, options, env) {
|
|
|
3867
3942
|
move(scale, frame.scale, sameFields, first);
|
|
3868
3943
|
move(bands, frame.bands, sameFields, second);
|
|
3869
3944
|
for (const tick of ticks.values()) move(tick.opacity, tick.wanted ? 1 : 0, same, first);
|
|
3945
|
+
for (const record of order) {
|
|
3946
|
+
const fades = !arriving.has(record);
|
|
3947
|
+
for (const part of ["label", "value"]) {
|
|
3948
|
+
const to = Number(record.row.drawn[part]);
|
|
3949
|
+
move(record.drawn[part], to, same, fades ? to ? into : out : void 0);
|
|
3950
|
+
}
|
|
3951
|
+
}
|
|
3870
3952
|
for (const record of staying) {
|
|
3871
3953
|
move(record.values, valuesOf(record.row), sameFields, first);
|
|
3872
3954
|
move(record.presence, 1, same, first);
|
|
@@ -3941,14 +4023,16 @@ function barChart$1(target, options, env) {
|
|
|
3941
4023
|
for (const record of order) record.row = rows.get(record.key) ?? record.row;
|
|
3942
4024
|
transitionTo(next, true);
|
|
3943
4025
|
}
|
|
4026
|
+
const remeasure = () => {
|
|
4027
|
+
measure.clear();
|
|
4028
|
+
relayout();
|
|
4029
|
+
};
|
|
4030
|
+
const unwatchText = watchText(svg, clock, remeasure);
|
|
3944
4031
|
const unwatchWidth = watchWidth(container, clock, measuredWidth, (width) => {
|
|
3945
4032
|
measuredWidth = width;
|
|
3946
4033
|
if (current.width === void 0) relayout();
|
|
3947
4034
|
});
|
|
3948
|
-
const unwatchFonts = watchFonts(doc,
|
|
3949
|
-
measure.clear();
|
|
3950
|
-
relayout();
|
|
3951
|
-
});
|
|
4035
|
+
const unwatchFonts = watchFonts(doc, remeasure);
|
|
3952
4036
|
describeChart(svg, current);
|
|
3953
4037
|
syncLegend(laidOut);
|
|
3954
4038
|
table.render(firstTable);
|
|
@@ -4007,7 +4091,7 @@ function barChart$1(target, options, env) {
|
|
|
4007
4091
|
}, () => arrange(nextLayout), (diff) => {
|
|
4008
4092
|
if (announcing) announceChange(previous, diff);
|
|
4009
4093
|
});
|
|
4010
|
-
if (byCategory(current) !== byCategory(previous)) for (const record of [...order, ...leaving.values()]) dirty.add(record);
|
|
4094
|
+
if ("colors" in next || byCategory(current) !== byCategory(previous)) for (const record of [...order, ...leaving.values()]) dirty.add(record);
|
|
4011
4095
|
const settled = transitionTo(nextLayout, motion.mode === "off" || nextLayout.orientation !== orientation);
|
|
4012
4096
|
await transitions.wait(settled, leaves);
|
|
4013
4097
|
},
|
|
@@ -4040,13 +4124,16 @@ function barChart$1(target, options, env) {
|
|
|
4040
4124
|
table.destroy();
|
|
4041
4125
|
announcer?.destroy();
|
|
4042
4126
|
unwatchHoverDuration();
|
|
4127
|
+
unwatchText();
|
|
4043
4128
|
unwatchWidth();
|
|
4044
4129
|
unwatchFonts();
|
|
4045
4130
|
for (const record of [...order, ...leaving.values()]) {
|
|
4046
4131
|
for (const value of [
|
|
4047
4132
|
record.values,
|
|
4048
4133
|
record.slot,
|
|
4049
|
-
record.presence
|
|
4134
|
+
record.presence,
|
|
4135
|
+
record.drawn.label,
|
|
4136
|
+
record.drawn.value
|
|
4050
4137
|
]) value.stop();
|
|
4051
4138
|
record.leave?.resolve();
|
|
4052
4139
|
}
|
|
@@ -4905,14 +4992,16 @@ function donutChart$1(target, options, env) {
|
|
|
4905
4992
|
for (const record of order) record.row = slices.get(record.key) ?? record.row;
|
|
4906
4993
|
transitionTo(next, true);
|
|
4907
4994
|
}
|
|
4995
|
+
const remeasure = () => {
|
|
4996
|
+
measure.clear();
|
|
4997
|
+
relayout();
|
|
4998
|
+
};
|
|
4999
|
+
const unwatchText = watchText(svg, clock, remeasure);
|
|
4908
5000
|
const unwatchWidth = watchWidth(container, clock, measuredWidth, (width) => {
|
|
4909
5001
|
measuredWidth = width;
|
|
4910
5002
|
if (current.width === void 0) relayout();
|
|
4911
5003
|
});
|
|
4912
|
-
const unwatchFonts = watchFonts(doc,
|
|
4913
|
-
measure.clear();
|
|
4914
|
-
relayout();
|
|
4915
|
-
});
|
|
5004
|
+
const unwatchFonts = watchFonts(doc, remeasure);
|
|
4916
5005
|
describeDonut();
|
|
4917
5006
|
syncLegend();
|
|
4918
5007
|
table.render(firstTable);
|
|
@@ -5005,6 +5094,7 @@ function donutChart$1(target, options, env) {
|
|
|
5005
5094
|
table.destroy();
|
|
5006
5095
|
announcer?.destroy();
|
|
5007
5096
|
unwatchHoverDuration();
|
|
5097
|
+
unwatchText();
|
|
5008
5098
|
unwatchWidth();
|
|
5009
5099
|
unwatchFonts();
|
|
5010
5100
|
for (const record of [...order, ...leaving.values()]) {
|
|
@@ -5261,7 +5351,6 @@ function cubic(v0, c1, c2, v1, u) {
|
|
|
5261
5351
|
return s * s * s * v0 + 3 * s * s * u * c1 + 3 * s * u * u * c2 + u * u * u * v1;
|
|
5262
5352
|
}
|
|
5263
5353
|
// src/charts/time.ts
|
|
5264
|
-
const TIME_ZONES = ["UTC", "local"];
|
|
5265
5354
|
const SECOND = 1e3;
|
|
5266
5355
|
const MINUTE = 60 * SECOND;
|
|
5267
5356
|
const HOUR = 60 * MINUTE;
|
|
@@ -5369,6 +5458,16 @@ const FIELDS = {
|
|
|
5369
5458
|
fractionalSecondDigits: 3
|
|
5370
5459
|
}
|
|
5371
5460
|
};
|
|
5461
|
+
function isTimeZone(zone) {
|
|
5462
|
+
if (zone === "UTC" || zone === "local") return true;
|
|
5463
|
+
if (typeof zone !== "string") return false;
|
|
5464
|
+
try {
|
|
5465
|
+
clockOf(zone);
|
|
5466
|
+
return true;
|
|
5467
|
+
} catch {
|
|
5468
|
+
return false;
|
|
5469
|
+
}
|
|
5470
|
+
}
|
|
5372
5471
|
function timeStep(span) {
|
|
5373
5472
|
for (const step of STEPS) if (LONGEST$1[step.unit] * step.count >= span) return step;
|
|
5374
5473
|
return {
|
|
@@ -5438,15 +5537,7 @@ function monthsOn(t, months, zone) {
|
|
|
5438
5537
|
const last = /* @__PURE__ */ new Date(0);
|
|
5439
5538
|
last.setUTCFullYear(year, month + months + 1, 0);
|
|
5440
5539
|
const day = Math.min(date, last.getUTCDate());
|
|
5441
|
-
|
|
5442
|
-
if (zone === "UTC") {
|
|
5443
|
-
d.setUTCFullYear(year, month + months, day);
|
|
5444
|
-
d.setUTCHours(hours, minutes, seconds, ms);
|
|
5445
|
-
} else {
|
|
5446
|
-
d.setFullYear(year, month + months, day);
|
|
5447
|
-
d.setHours(hours, minutes, seconds, ms);
|
|
5448
|
-
}
|
|
5449
|
-
return d.getTime();
|
|
5540
|
+
return timeAt(zone, year, month + months, day, hours, minutes, seconds, ms);
|
|
5450
5541
|
}
|
|
5451
5542
|
function timeLevel(t, zone) {
|
|
5452
5543
|
const { ms, seconds, minutes, hours, date, month } = partsOf(t, zone);
|
|
@@ -5458,7 +5549,8 @@ function timeLevel(t, zone) {
|
|
|
5458
5549
|
return month !== 0 ? "month" : "year";
|
|
5459
5550
|
}
|
|
5460
5551
|
function timeName(times, zone) {
|
|
5461
|
-
const
|
|
5552
|
+
const shown = clockReader(zone);
|
|
5553
|
+
const finest = times.reduce((max, t) => Math.max(max, LEVELS.indexOf(timeLevel(shown(t), "UTC"))), 0);
|
|
5462
5554
|
const timeZone = zoneOption(zone);
|
|
5463
5555
|
const timeStyle = finest >= LEVELS.indexOf("second") ? "medium" : finest >= LEVELS.indexOf("hour") ? "short" : void 0;
|
|
5464
5556
|
const options = finest === LEVELS.indexOf("millisecond") ? {
|
|
@@ -5472,7 +5564,17 @@ function timeName(times, zone) {
|
|
|
5472
5564
|
timeZone
|
|
5473
5565
|
};
|
|
5474
5566
|
const format = new Intl.DateTimeFormat(void 0, options);
|
|
5475
|
-
return (t) => format.format(t);
|
|
5567
|
+
if (zone === "UTC" || !timeStyle) return (t) => format.format(t);
|
|
5568
|
+
const named = new Intl.DateTimeFormat(void 0, {
|
|
5569
|
+
timeZone,
|
|
5570
|
+
timeZoneName: "short"
|
|
5571
|
+
});
|
|
5572
|
+
return (t) => {
|
|
5573
|
+
const text = format.format(t);
|
|
5574
|
+
if (twinOf(t, shown) === void 0) return text;
|
|
5575
|
+
const name = named.formatToParts(t).find((part) => part.type === "timeZoneName")?.value;
|
|
5576
|
+
return name ? `${text} ${name}` : text;
|
|
5577
|
+
};
|
|
5476
5578
|
}
|
|
5477
5579
|
function tickWording(zone) {
|
|
5478
5580
|
const formats = /* @__PURE__ */ new Map();
|
|
@@ -5489,19 +5591,10 @@ function tickWording(zone) {
|
|
|
5489
5591
|
return format.format(t);
|
|
5490
5592
|
};
|
|
5491
5593
|
}
|
|
5492
|
-
const zoneOption = (zone) => zone === "
|
|
5594
|
+
const zoneOption = (zone) => zone === "local" ? void 0 : zone;
|
|
5493
5595
|
function partsOf(t, zone) {
|
|
5494
|
-
const d = new Date(t);
|
|
5495
|
-
return zone === "
|
|
5496
|
-
year: d.getUTCFullYear(),
|
|
5497
|
-
month: d.getUTCMonth(),
|
|
5498
|
-
date: d.getUTCDate(),
|
|
5499
|
-
weekday: d.getUTCDay(),
|
|
5500
|
-
hours: d.getUTCHours(),
|
|
5501
|
-
minutes: d.getUTCMinutes(),
|
|
5502
|
-
seconds: d.getUTCSeconds(),
|
|
5503
|
-
ms: d.getUTCMilliseconds()
|
|
5504
|
-
} : {
|
|
5596
|
+
const d = new Date(zone === "UTC" || zone === "local" ? t : shownAt(t, zone));
|
|
5597
|
+
return zone === "local" ? {
|
|
5505
5598
|
year: d.getFullYear(),
|
|
5506
5599
|
month: d.getMonth(),
|
|
5507
5600
|
date: d.getDate(),
|
|
@@ -5510,19 +5603,88 @@ function partsOf(t, zone) {
|
|
|
5510
5603
|
minutes: d.getMinutes(),
|
|
5511
5604
|
seconds: d.getSeconds(),
|
|
5512
5605
|
ms: d.getMilliseconds()
|
|
5606
|
+
} : {
|
|
5607
|
+
year: d.getUTCFullYear(),
|
|
5608
|
+
month: d.getUTCMonth(),
|
|
5609
|
+
date: d.getUTCDate(),
|
|
5610
|
+
weekday: d.getUTCDay(),
|
|
5611
|
+
hours: d.getUTCHours(),
|
|
5612
|
+
minutes: d.getUTCMinutes(),
|
|
5613
|
+
seconds: d.getUTCSeconds(),
|
|
5614
|
+
ms: d.getUTCMilliseconds()
|
|
5513
5615
|
};
|
|
5514
5616
|
}
|
|
5515
5617
|
function midnight(zone, year, month, date) {
|
|
5516
|
-
|
|
5517
|
-
|
|
5518
|
-
|
|
5519
|
-
|
|
5520
|
-
|
|
5618
|
+
return timeAt(zone, year, month, date);
|
|
5619
|
+
}
|
|
5620
|
+
function timeAt(zone, year, month, date, hours = 0, minutes = 0, seconds = 0, ms = 0) {
|
|
5621
|
+
if (zone === "local") {
|
|
5622
|
+
const d = /* @__PURE__ */ new Date(0);
|
|
5521
5623
|
d.setFullYear(year, month, date);
|
|
5522
|
-
d.setHours(
|
|
5624
|
+
d.setHours(hours, minutes, seconds, ms);
|
|
5625
|
+
return d.getTime();
|
|
5523
5626
|
}
|
|
5627
|
+
const shown = utc(year, month, date, hours, minutes, seconds, ms);
|
|
5628
|
+
if (zone === "UTC") return shown;
|
|
5629
|
+
const before = shown - (shownAt(shown - DAY, zone) - (shown - DAY));
|
|
5630
|
+
const after = shown - (shownAt(shown + DAY, zone) - (shown + DAY));
|
|
5631
|
+
if (before === after) return before;
|
|
5632
|
+
const fits = [before, after].filter((t) => shownAt(t, zone) === shown);
|
|
5633
|
+
return fits.length > 0 ? Math.min(...fits) : before;
|
|
5634
|
+
}
|
|
5635
|
+
function utc(year, month, date, hours = 0, minutes = 0, seconds = 0, ms = 0) {
|
|
5636
|
+
const d = /* @__PURE__ */ new Date(0);
|
|
5637
|
+
d.setUTCFullYear(year, month, date);
|
|
5638
|
+
d.setUTCHours(hours, minutes, seconds, ms);
|
|
5524
5639
|
return d.getTime();
|
|
5525
5640
|
}
|
|
5641
|
+
function shownAt(t, zone) {
|
|
5642
|
+
if (zone === "UTC") return t;
|
|
5643
|
+
if (zone === "local") {
|
|
5644
|
+
const d = new Date(t);
|
|
5645
|
+
return utc(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds());
|
|
5646
|
+
}
|
|
5647
|
+
const ms = (t % SECOND + SECOND) % SECOND;
|
|
5648
|
+
const fields = {};
|
|
5649
|
+
for (const part of clockOf(zone).formatToParts(t - ms)) fields[part.type] = part.value;
|
|
5650
|
+
const year = Number(fields["year"]);
|
|
5651
|
+
return utc(fields["era"] === "BC" ? 1 - year : year, Number(fields["month"]) - 1, Number(fields["day"]), Number(fields["hour"]) % 24, Number(fields["minute"]), Number(fields["second"]), ms);
|
|
5652
|
+
}
|
|
5653
|
+
function clockReader(zone) {
|
|
5654
|
+
if (zone === "UTC" || zone === "local") return (t) => shownAt(t, zone);
|
|
5655
|
+
const kept = /* @__PURE__ */ new Map();
|
|
5656
|
+
return (t) => {
|
|
5657
|
+
let shown = kept.get(t);
|
|
5658
|
+
if (shown === void 0) kept.set(t, shown = shownAt(t, zone));
|
|
5659
|
+
return shown;
|
|
5660
|
+
};
|
|
5661
|
+
}
|
|
5662
|
+
function twinOf(t, shown) {
|
|
5663
|
+
const at = shown(t);
|
|
5664
|
+
for (const near of [t - DAY, t + DAY]) {
|
|
5665
|
+
const other = at - (shown(near) - near);
|
|
5666
|
+
if (other !== t && shown(other) === at) return other;
|
|
5667
|
+
}
|
|
5668
|
+
}
|
|
5669
|
+
const clocks = /* @__PURE__ */ new Map();
|
|
5670
|
+
function clockOf(zone) {
|
|
5671
|
+
let clock = clocks.get(zone);
|
|
5672
|
+
if (!clock) {
|
|
5673
|
+
clock = new Intl.DateTimeFormat("en-US", {
|
|
5674
|
+
timeZone: zone,
|
|
5675
|
+
hourCycle: "h23",
|
|
5676
|
+
era: "short",
|
|
5677
|
+
year: "numeric",
|
|
5678
|
+
month: "numeric",
|
|
5679
|
+
day: "numeric",
|
|
5680
|
+
hour: "numeric",
|
|
5681
|
+
minute: "numeric",
|
|
5682
|
+
second: "numeric"
|
|
5683
|
+
});
|
|
5684
|
+
clocks.set(zone, clock);
|
|
5685
|
+
}
|
|
5686
|
+
return clock;
|
|
5687
|
+
}
|
|
5526
5688
|
// src/charts/line-layout.ts
|
|
5527
5689
|
const LINE_WIDTH = 2.25;
|
|
5528
5690
|
const DOT_RADIUS = 4.5;
|
|
@@ -5550,7 +5712,7 @@ function lineEncoding(options) {
|
|
|
5550
5712
|
const labels = options.labels;
|
|
5551
5713
|
if (labels !== void 0 && labels !== false && typeof labels !== "function") throw new TypeError("lineChart: labels must be false or a function that returns a line's end label.");
|
|
5552
5714
|
const timeZone = options.timeZone ?? "UTC";
|
|
5553
|
-
if (!
|
|
5715
|
+
if (!isTimeZone(timeZone)) throw new TypeError(`lineChart: timeZone must be "UTC", "local" or the name of a zone Intl knows, such as "Europe/London", got ${show$1(timeZone)}.`);
|
|
5554
5716
|
const xFormat = options.xFormat;
|
|
5555
5717
|
if (xFormat !== void 0 && typeof xFormat !== "function") throw new TypeError("lineChart: xFormat must be a function that turns an x into text.");
|
|
5556
5718
|
const curve = options.curve ?? "linear";
|
|
@@ -6047,6 +6209,7 @@ function lineChart$1(target, options, env) {
|
|
|
6047
6209
|
const container = resolveTarget$2(target, "lineChart");
|
|
6048
6210
|
checkChartOptions(options, "lineChart");
|
|
6049
6211
|
let hoverKind = hoverOf(options);
|
|
6212
|
+
missingOf(options);
|
|
6050
6213
|
let current = options;
|
|
6051
6214
|
const motion = chartMotion(options.motion, env.motion);
|
|
6052
6215
|
let effects = resolveEffects(options.on, env.presets);
|
|
@@ -6076,17 +6239,19 @@ function lineChart$1(target, options, env) {
|
|
|
6076
6239
|
"aria-hidden": "true",
|
|
6077
6240
|
visibility: "hidden"
|
|
6078
6241
|
}, svg);
|
|
6079
|
-
const
|
|
6242
|
+
const linesLayer = svgElement("g", { class: "ec-lines" }, svgElement("g", {
|
|
6080
6243
|
class: "ec-marks",
|
|
6081
6244
|
"aria-hidden": "true"
|
|
6082
|
-
}, svg);
|
|
6083
|
-
const linesLayer = svgElement("g", { class: "ec-lines" }, marksLayer);
|
|
6084
|
-
const pointsLayer = svgElement("g", { class: "ec-points" }, marksLayer);
|
|
6085
|
-
const columnsLayer = svgElement("g", { class: "ec-columns" }, svg);
|
|
6245
|
+
}, svg));
|
|
6086
6246
|
const overlay = svgElement("g", {
|
|
6087
6247
|
class: "ec-overlay",
|
|
6088
6248
|
"aria-hidden": "true"
|
|
6089
6249
|
}, svg);
|
|
6250
|
+
const pointsLayer = svgElement("g", { class: "ec-points" }, svgElement("g", {
|
|
6251
|
+
class: "ec-marks",
|
|
6252
|
+
"aria-hidden": "true"
|
|
6253
|
+
}, svg));
|
|
6254
|
+
const columnsLayer = svgElement("g", { class: "ec-columns" }, svg);
|
|
6090
6255
|
const measure = textMeasure(svg);
|
|
6091
6256
|
let rowOrder = [];
|
|
6092
6257
|
const rows = /* @__PURE__ */ new Map();
|
|
@@ -6624,6 +6789,14 @@ function lineChart$1(target, options, env) {
|
|
|
6624
6789
|
crosshair.setAttribute("visibility", "hidden");
|
|
6625
6790
|
tooltip.hide();
|
|
6626
6791
|
}
|
|
6792
|
+
function stand(key) {
|
|
6793
|
+
const record = key === void 0 ? void 0 : rows.get(key);
|
|
6794
|
+
if (!record || !revealed(record)) crosshair.setAttribute("visibility", "hidden");
|
|
6795
|
+
else setAttributes(crosshair, {
|
|
6796
|
+
...placeCrosshair(drawnFrame, record.px),
|
|
6797
|
+
visibility: void 0
|
|
6798
|
+
});
|
|
6799
|
+
}
|
|
6627
6800
|
let ringLine;
|
|
6628
6801
|
function drawRing(key) {
|
|
6629
6802
|
const point = key === void 0 ? void 0 : points.get(key);
|
|
@@ -6663,6 +6836,7 @@ function lineChart$1(target, options, env) {
|
|
|
6663
6836
|
}
|
|
6664
6837
|
function followHover() {
|
|
6665
6838
|
if (hover.key !== void 0) showHover(hover.key);
|
|
6839
|
+
if (hover.standing !== void 0) stand(hover.standing);
|
|
6666
6840
|
if (hover.ringKey !== void 0) drawRing(hover.ringKey);
|
|
6667
6841
|
}
|
|
6668
6842
|
const input = (record) => ({
|
|
@@ -6673,6 +6847,28 @@ function lineChart$1(target, options, env) {
|
|
|
6673
6847
|
mark: record.shown.geometry,
|
|
6674
6848
|
data: record.shown.data
|
|
6675
6849
|
});
|
|
6850
|
+
function standIn(key) {
|
|
6851
|
+
const record = rows.get(key);
|
|
6852
|
+
if (!record || !revealed(record)) return void 0;
|
|
6853
|
+
const { row } = record;
|
|
6854
|
+
return {
|
|
6855
|
+
mark: describePoint({
|
|
6856
|
+
key,
|
|
6857
|
+
x: record.px,
|
|
6858
|
+
y: drawnFrame.box.top,
|
|
6859
|
+
r: DOT_RADIUS
|
|
6860
|
+
}),
|
|
6861
|
+
data: {
|
|
6862
|
+
datum: row.datum,
|
|
6863
|
+
samples: [{
|
|
6864
|
+
t: 0,
|
|
6865
|
+
value: NaN,
|
|
6866
|
+
at: laidOut.time ? new Date(row.x) : row.x
|
|
6867
|
+
}],
|
|
6868
|
+
related: () => void 0
|
|
6869
|
+
}
|
|
6870
|
+
};
|
|
6871
|
+
}
|
|
6676
6872
|
function liveRowOf(eventTarget) {
|
|
6677
6873
|
const element = eventTarget;
|
|
6678
6874
|
const column = typeof element?.closest === "function" ? element.closest(".ec-column") : null;
|
|
@@ -6768,7 +6964,7 @@ function lineChart$1(target, options, env) {
|
|
|
6768
6964
|
if (hoverKind !== "point") return;
|
|
6769
6965
|
if (!stopsLayer) {
|
|
6770
6966
|
stopsLayer = svgElement("g", { class: "ec-stops" }, svg);
|
|
6771
|
-
svg.insertBefore(stopsLayer,
|
|
6967
|
+
svg.insertBefore(stopsLayer, columnsLayer.nextSibling);
|
|
6772
6968
|
plotHit = svgElement("rect", { class: "ec-hit" }, stopsLayer);
|
|
6773
6969
|
stopsLayer.addEventListener("click", (event) => {
|
|
6774
6970
|
const point = pointAt(event.clientX, event.clientY);
|
|
@@ -6940,6 +7136,8 @@ function lineChart$1(target, options, env) {
|
|
|
6940
7136
|
const record = findMark(key);
|
|
6941
7137
|
return record && onScreen(record);
|
|
6942
7138
|
},
|
|
7139
|
+
standIn,
|
|
7140
|
+
stand,
|
|
6943
7141
|
ring: drawRing,
|
|
6944
7142
|
tooltip: {
|
|
6945
7143
|
show: showHover,
|
|
@@ -6968,7 +7166,8 @@ function lineChart$1(target, options, env) {
|
|
|
6968
7166
|
total: total(row.values)
|
|
6969
7167
|
})),
|
|
6970
7168
|
format: format(opts),
|
|
6971
|
-
total: false
|
|
7169
|
+
total: false,
|
|
7170
|
+
missing: missingOf(opts)
|
|
6972
7171
|
});
|
|
6973
7172
|
}
|
|
6974
7173
|
function labelColumn(record) {
|
|
@@ -7207,14 +7406,16 @@ function lineChart$1(target, options, env) {
|
|
|
7207
7406
|
for (const point of points.values()) point.target = placed.points.get(point.key) ?? point.target;
|
|
7208
7407
|
transitionTo(next, true);
|
|
7209
7408
|
}
|
|
7409
|
+
const remeasure = () => {
|
|
7410
|
+
measure.clear();
|
|
7411
|
+
relayout();
|
|
7412
|
+
};
|
|
7413
|
+
const unwatchText = watchText(svg, clock, remeasure);
|
|
7210
7414
|
const unwatchWidth = watchWidth(container, clock, measuredWidth, (width) => {
|
|
7211
7415
|
measuredWidth = width;
|
|
7212
7416
|
if (current.width === void 0) relayout();
|
|
7213
7417
|
});
|
|
7214
|
-
const unwatchFonts = watchFonts(doc,
|
|
7215
|
-
measure.clear();
|
|
7216
|
-
relayout();
|
|
7217
|
-
});
|
|
7418
|
+
const unwatchFonts = watchFonts(doc, remeasure);
|
|
7218
7419
|
describeChart(svg, current);
|
|
7219
7420
|
syncLegend();
|
|
7220
7421
|
table.render(firstTable);
|
|
@@ -7258,6 +7459,7 @@ function lineChart$1(target, options, env) {
|
|
|
7258
7459
|
};
|
|
7259
7460
|
checkChartOptions(merged, "lineChart");
|
|
7260
7461
|
const kind = hoverOf(merged);
|
|
7462
|
+
missingOf(merged);
|
|
7261
7463
|
const swapped = "on" in next ? nextEffects(effects, current.on, merged.on, env.presets) : effects;
|
|
7262
7464
|
const nextLayout = layout(merged, swapped);
|
|
7263
7465
|
const nextTable = tableFor(merged, nextLayout);
|
|
@@ -7361,6 +7563,7 @@ function lineChart$1(target, options, env) {
|
|
|
7361
7563
|
table.destroy();
|
|
7362
7564
|
announcer?.destroy();
|
|
7363
7565
|
unwatchHoverDuration();
|
|
7566
|
+
unwatchText();
|
|
7364
7567
|
unwatchWidth();
|
|
7365
7568
|
unwatchFonts();
|
|
7366
7569
|
for (const record of [...rowOrder, ...leavingRows.values()]) for (const value of [
|
|
@@ -7463,9 +7666,10 @@ function labelled(values, options) {
|
|
|
7463
7666
|
}
|
|
7464
7667
|
function said(values, options) {
|
|
7465
7668
|
const formatted = format(options);
|
|
7669
|
+
const missing = missingOf(options);
|
|
7466
7670
|
return values.map((v) => {
|
|
7467
7671
|
const label = seriesLabel(options.seriesLabels, v.series);
|
|
7468
|
-
return v.value === void 0 ? `${label} missing` : `${formatted(v.value)} ${label}`;
|
|
7672
|
+
return v.value === void 0 ? `${label} ${missing}` : `${formatted(v.value)} ${label}`;
|
|
7469
7673
|
});
|
|
7470
7674
|
}
|
|
7471
7675
|
function summary(row, options) {
|
|
@@ -7522,6 +7726,11 @@ function hoverOf(options) {
|
|
|
7522
7726
|
if (hover !== "x" && hover !== "point") throw new TypeError(`lineChart: hover must be "x" or "point", got ${typeof hover === "string" ? JSON.stringify(hover) : String(hover)}.`);
|
|
7523
7727
|
return hover;
|
|
7524
7728
|
}
|
|
7729
|
+
function missingOf(options) {
|
|
7730
|
+
const { missing = MISSING } = options;
|
|
7731
|
+
if (typeof missing !== "string" || missing.trim() === "") throw new TypeError(`lineChart: missing must be a word for a missing value, such as "no data", got ${typeof missing === "string" ? JSON.stringify(missing) : String(missing)}.`);
|
|
7732
|
+
return missing;
|
|
7733
|
+
}
|
|
7525
7734
|
// src/core/geometry/ring.ts
|
|
7526
7735
|
const ROUND = .5;
|
|
7527
7736
|
function goesRound(mark) {
|
|
@@ -7925,11 +8134,25 @@ function hostColors(element, root) {
|
|
|
7925
8134
|
const color = paint === "fill" ? fill : paintOf$1(element, root, "stroke");
|
|
7926
8135
|
if (color === void 0 || color === NONE) return void 0;
|
|
7927
8136
|
return {
|
|
7928
|
-
color,
|
|
7929
|
-
strong: `color-mix(in oklab, ${color}, ${cssColor("text")} ${STRONG})`,
|
|
8137
|
+
...strongColors(color),
|
|
7930
8138
|
paint
|
|
7931
8139
|
};
|
|
7932
8140
|
}
|
|
8141
|
+
function strongColors(color) {
|
|
8142
|
+
return {
|
|
8143
|
+
color,
|
|
8144
|
+
strong: `color-mix(in oklab, ${color}, ${cssColor("text")} ${STRONG})`
|
|
8145
|
+
};
|
|
8146
|
+
}
|
|
8147
|
+
function drawnStyle(element, root, property) {
|
|
8148
|
+
const computed = element.ownerDocument.defaultView?.getComputedStyle?.(element).getPropertyValue(property).trim() ?? "";
|
|
8149
|
+
if (attributesComputed(root)) return computed;
|
|
8150
|
+
for (let node = element; node; node = node === root ? null : node.parentElement) {
|
|
8151
|
+
const value = node.style?.getPropertyValue(property) || node.getAttribute(property);
|
|
8152
|
+
if (value) return value.trim();
|
|
8153
|
+
}
|
|
8154
|
+
return computed;
|
|
8155
|
+
}
|
|
7933
8156
|
const STRONG = "25%";
|
|
7934
8157
|
const NONE = "none";
|
|
7935
8158
|
const SVG_NS$1 = "http://www.w3.org/2000/svg";
|
|
@@ -8340,6 +8563,8 @@ const WRAPPING_ROLES = /* @__PURE__ */ new Set([
|
|
|
8340
8563
|
"graphics-symbol",
|
|
8341
8564
|
"graphics-object"
|
|
8342
8565
|
]);
|
|
8566
|
+
const insides = /* @__PURE__ */ new WeakMap();
|
|
8567
|
+
const insidesOf = (port) => port ? insides.get(port) : void 0;
|
|
8343
8568
|
function expressive$1(target, options, env) {
|
|
8344
8569
|
checkOptions$12(options);
|
|
8345
8570
|
const motion = chartMotion(options.motion, env.motion);
|
|
@@ -8669,8 +8894,10 @@ function expressive$1(target, options, env) {
|
|
|
8669
8894
|
const runs = make("g", { class: "ec-runs" }, overlay);
|
|
8670
8895
|
const ring = maskedRing(overlay);
|
|
8671
8896
|
const find = (key) => records.get(key) ?? leaving.get(key);
|
|
8897
|
+
const measure = textMeasure(runs);
|
|
8672
8898
|
const surface = svgSurface({
|
|
8673
8899
|
overlay: runs,
|
|
8900
|
+
measure,
|
|
8674
8901
|
mark: (key) => ({
|
|
8675
8902
|
set: (style) => find(key)?.handle.set(style),
|
|
8676
8903
|
reset: () => find(key)?.handle.reset()
|
|
@@ -8688,6 +8915,12 @@ function expressive$1(target, options, env) {
|
|
|
8688
8915
|
mark: record.mark.geometry,
|
|
8689
8916
|
data: record.mark.data
|
|
8690
8917
|
});
|
|
8918
|
+
function remeasure() {
|
|
8919
|
+
measure.clear();
|
|
8920
|
+
for (const record of order) runner.change(record.mark.geometry, record.mark.data);
|
|
8921
|
+
}
|
|
8922
|
+
let unwatchText = () => {};
|
|
8923
|
+
const unwatchFonts = watchFonts(doc, remeasure);
|
|
8691
8924
|
function createRecord(mark) {
|
|
8692
8925
|
const record = {
|
|
8693
8926
|
key: mark.key,
|
|
@@ -8728,7 +8961,7 @@ function expressive$1(target, options, env) {
|
|
|
8728
8961
|
from: from.geometry
|
|
8729
8962
|
});
|
|
8730
8963
|
else if (newRow || geometryChanged(from.geometry, mark.geometry) || samplesChanged(from.data.samples, mark.data.samples)) diff.moved.push(record);
|
|
8731
|
-
if (from.parts
|
|
8964
|
+
if (from.parts.length !== mark.parts.length || mark.parts.some((part, i) => part.colors?.color !== from.parts[i].colors?.color)) recolor.push(mark.key);
|
|
8732
8965
|
record.mark = mark;
|
|
8733
8966
|
} else {
|
|
8734
8967
|
record = leaving.get(mark.key);
|
|
@@ -8798,6 +9031,7 @@ function expressive$1(target, options, env) {
|
|
|
8798
9031
|
function moveTo(next) {
|
|
8799
9032
|
detach();
|
|
8800
9033
|
root = next;
|
|
9034
|
+
unwatchText = watchText(root, clock, remeasure);
|
|
8801
9035
|
root.appendChild(overlay);
|
|
8802
9036
|
if ((options.keyboard === true || options.markLabel) && root.getAttribute("role") === "img" && !warnedImage) {
|
|
8803
9037
|
warnedImage = true;
|
|
@@ -8829,6 +9063,7 @@ function expressive$1(target, options, env) {
|
|
|
8829
9063
|
endHover();
|
|
8830
9064
|
interaction?.destroy();
|
|
8831
9065
|
interaction = void 0;
|
|
9066
|
+
unwatchText();
|
|
8832
9067
|
}
|
|
8833
9068
|
function ownerOf(eventTarget) {
|
|
8834
9069
|
for (let node = eventTarget; node && node !== root; node = node.parentElement) {
|
|
@@ -9128,6 +9363,15 @@ function expressive$1(target, options, env) {
|
|
|
9128
9363
|
return true;
|
|
9129
9364
|
}
|
|
9130
9365
|
};
|
|
9366
|
+
insides.set(link, {
|
|
9367
|
+
root: () => root,
|
|
9368
|
+
ancestor: () => ancestor,
|
|
9369
|
+
elements: () => order.flatMap((record) => record.mark.parts.map((part) => part.element)),
|
|
9370
|
+
keyOf: (element) => ownerOf(element)?.record.key,
|
|
9371
|
+
colorOf: (key) => records.get(key)?.mark.parts[0]?.colors?.color,
|
|
9372
|
+
moveTabStop: (key) => keyboard?.moveTabStop(key) ?? false,
|
|
9373
|
+
edits
|
|
9374
|
+
});
|
|
9131
9375
|
return linkable(link, {
|
|
9132
9376
|
refresh(next) {
|
|
9133
9377
|
if (destroyed) return;
|
|
@@ -9206,6 +9450,7 @@ function expressive$1(target, options, env) {
|
|
|
9206
9450
|
watching?.destroy();
|
|
9207
9451
|
runner.destroy();
|
|
9208
9452
|
unsubscribeMotion?.();
|
|
9453
|
+
unwatchFonts();
|
|
9209
9454
|
keyboard?.destroy();
|
|
9210
9455
|
detach();
|
|
9211
9456
|
overlay.remove();
|
|
@@ -9356,6 +9601,119 @@ function geometryChanged(from, to) {
|
|
|
9356
9601
|
const b = to.segments ?? [];
|
|
9357
9602
|
return a.length !== b.length || a.some((segment, i) => segment.key !== b[i].key || segment.outline.d !== b[i].outline.d);
|
|
9358
9603
|
}
|
|
9604
|
+
// src/charts/adapter/host-view.ts
|
|
9605
|
+
const FONT = [
|
|
9606
|
+
"font-family",
|
|
9607
|
+
"font-size",
|
|
9608
|
+
"font-style",
|
|
9609
|
+
"font-weight",
|
|
9610
|
+
"font-variant-numeric",
|
|
9611
|
+
"letter-spacing",
|
|
9612
|
+
"word-spacing",
|
|
9613
|
+
"dominant-baseline",
|
|
9614
|
+
"fill"
|
|
9615
|
+
];
|
|
9616
|
+
const LENGTHS = /* @__PURE__ */ new Set([
|
|
9617
|
+
"font-size",
|
|
9618
|
+
"letter-spacing",
|
|
9619
|
+
"word-spacing"
|
|
9620
|
+
]);
|
|
9621
|
+
function first(element, name) {
|
|
9622
|
+
const list = element[name]?.baseVal;
|
|
9623
|
+
if (list && list.numberOfItems > 0) return list.getItem(0).value;
|
|
9624
|
+
return Number.parseFloat(element.getAttribute(name) ?? "") || 0;
|
|
9625
|
+
}
|
|
9626
|
+
function scaled(value, scale) {
|
|
9627
|
+
if (scale === 1) return value;
|
|
9628
|
+
return value.replace(/(-?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?)(px)?(?![\w.%])/gi, (_, n, px) => `${Math.round(Number(n) * scale * 1e3) / 1e3}${px ?? ""}`);
|
|
9629
|
+
}
|
|
9630
|
+
function hostView(attachment, options = {}) {
|
|
9631
|
+
const port = typeof attachment === "object" && attachment !== null ? portOf(attachment) : void 0;
|
|
9632
|
+
const inside = insidesOf(port);
|
|
9633
|
+
if (!port || !inside?.root()) throw new TypeError("hostView needs an attachment that expressive() or fromVegaView() returned, with marks in an <svg>.");
|
|
9634
|
+
if (typeof options !== "object" || options === null || options.labels !== void 0 && typeof options.labels !== "function") throw new TypeError("hostView: labels must be a function that returns the host's labels, such as () => names.map((element) => ({ element, key: element.textContent, role: \"category\" })).");
|
|
9635
|
+
const { edits } = inside;
|
|
9636
|
+
const svg = () => inside.root();
|
|
9637
|
+
let given;
|
|
9638
|
+
let hidden = [];
|
|
9639
|
+
function read() {
|
|
9640
|
+
if (!options.labels) return [];
|
|
9641
|
+
const keys = new Set(attachment.marks().map((mark) => mark.key));
|
|
9642
|
+
try {
|
|
9643
|
+
return Array.from(options.labels()).filter((label) => label?.element?.localName === "text" && svg().contains(label.element) && keys.has(label.key) && (label.role === "category" || label.role === "value"));
|
|
9644
|
+
} catch (error) {
|
|
9645
|
+
report(error);
|
|
9646
|
+
return [];
|
|
9647
|
+
}
|
|
9648
|
+
}
|
|
9649
|
+
function chartLabel({ element, key, role }) {
|
|
9650
|
+
const root = svg();
|
|
9651
|
+
const m = between$1(view.space, element, root);
|
|
9652
|
+
const at = matrix.apply(m, {
|
|
9653
|
+
x: first(element, "x"),
|
|
9654
|
+
y: first(element, "y")
|
|
9655
|
+
});
|
|
9656
|
+
const scale = scaleOf$2(m);
|
|
9657
|
+
const text = element.ownerDocument.createElementNS(SVG_NS$2, "text");
|
|
9658
|
+
text.textContent = element.textContent;
|
|
9659
|
+
for (const name of ["dx", "dy"]) {
|
|
9660
|
+
const value = element.getAttribute(name);
|
|
9661
|
+
if (value !== null) text.setAttribute(name, scaled(value, scale));
|
|
9662
|
+
}
|
|
9663
|
+
setStyles(text, Object.fromEntries(FONT.map((property) => {
|
|
9664
|
+
const value = drawnStyle(element, root, property);
|
|
9665
|
+
return [property, (LENGTHS.has(property) ? scaled(value, scale) : value) || void 0];
|
|
9666
|
+
})));
|
|
9667
|
+
const anchor = drawnStyle(element, root, "text-anchor");
|
|
9668
|
+
return {
|
|
9669
|
+
key,
|
|
9670
|
+
role,
|
|
9671
|
+
text: element.textContent ?? "",
|
|
9672
|
+
x: at.x,
|
|
9673
|
+
y: at.y,
|
|
9674
|
+
anchor: anchor === "middle" || anchor === "end" ? anchor : "start",
|
|
9675
|
+
element: text
|
|
9676
|
+
};
|
|
9677
|
+
}
|
|
9678
|
+
const view = {
|
|
9679
|
+
get element() {
|
|
9680
|
+
return svg();
|
|
9681
|
+
},
|
|
9682
|
+
get space() {
|
|
9683
|
+
return inside.ancestor() ?? svg();
|
|
9684
|
+
},
|
|
9685
|
+
refresh: (source) => attachment.refresh(source),
|
|
9686
|
+
update: (next) => attachment.update(next),
|
|
9687
|
+
on: (type, listener) => attachment.on(type, listener),
|
|
9688
|
+
marks: () => attachment.marks(),
|
|
9689
|
+
focus: (key) => attachment.focus(key),
|
|
9690
|
+
leave: () => attachment.leave(),
|
|
9691
|
+
destroy() {
|
|
9692
|
+
given = void 0;
|
|
9693
|
+
hidden = [];
|
|
9694
|
+
attachment.destroy();
|
|
9695
|
+
},
|
|
9696
|
+
labels: () => (given ?? read()).map(chartLabel),
|
|
9697
|
+
paintOf(key) {
|
|
9698
|
+
const color = inside.colorOf(key);
|
|
9699
|
+
return color === void 0 ? void 0 : {
|
|
9700
|
+
color: key,
|
|
9701
|
+
drawn: true,
|
|
9702
|
+
cssColor: color
|
|
9703
|
+
};
|
|
9704
|
+
},
|
|
9705
|
+
keyOf: (element) => inside.keyOf(element),
|
|
9706
|
+
moveTabStop: (key) => inside.moveTabStop(key),
|
|
9707
|
+
morphing(on) {
|
|
9708
|
+
for (const element of hidden) edits.style(element, "visibility", void 0);
|
|
9709
|
+
given = on ? read() : void 0;
|
|
9710
|
+
hidden = given ? [...inside.elements(), ...given.map((label) => label.element)] : [];
|
|
9711
|
+
for (const element of hidden) edits.style(element, "visibility", "hidden");
|
|
9712
|
+
edits.toggleClass(svg(), "ec-morphing", on);
|
|
9713
|
+
}
|
|
9714
|
+
};
|
|
9715
|
+
return linkable(port, view);
|
|
9716
|
+
}
|
|
9359
9717
|
// src/charts/adapter/vega.ts
|
|
9360
9718
|
const MARK_TYPES = [
|
|
9361
9719
|
"line",
|
|
@@ -9793,13 +10151,14 @@ function chartSwitch$1(target, options, env) {
|
|
|
9793
10151
|
const runsLayer = svgElement("g", { class: "ec-switch-runs" }, overlay);
|
|
9794
10152
|
const labelsLayer = svgElement("g", { class: "ec-switch-labels" }, overlay);
|
|
9795
10153
|
const announcer = options.announce ? chartAnnouncer(overlay) : void 0;
|
|
10154
|
+
const tokensOf = (paint) => markColorStyles(paint.cssColor === void 0 ? seriesColors(colors.slot(paint.color)) : strongColors(paint.cssColor));
|
|
9796
10155
|
const orders = /* @__PURE__ */ new WeakMap();
|
|
9797
10156
|
const surfaceFor = (paints, extras) => ({ group(key, order) {
|
|
9798
10157
|
const group = svgElement("g", {
|
|
9799
10158
|
class: "ec-run",
|
|
9800
10159
|
"data-key": key
|
|
9801
10160
|
}, runsLayer);
|
|
9802
|
-
setStyles(group,
|
|
10161
|
+
setStyles(group, tokensOf(paints[order] ?? { color: key }));
|
|
9803
10162
|
orders.set(group, order);
|
|
9804
10163
|
const above = Array.from(runsLayer.children).find((child) => (orders.get(child) ?? -Infinity) > order);
|
|
9805
10164
|
runsLayer.insertBefore(group, above ?? null);
|
|
@@ -9839,7 +10198,7 @@ function chartSwitch$1(target, options, env) {
|
|
|
9839
10198
|
]].forEach(([end, opacity, color]) => {
|
|
9840
10199
|
if (!end) return;
|
|
9841
10200
|
const element = endDot();
|
|
9842
|
-
setStyles(element,
|
|
10201
|
+
setStyles(element, tokensOf(color));
|
|
9843
10202
|
placeDot(element, end);
|
|
9844
10203
|
dots.push({
|
|
9845
10204
|
element,
|
|
@@ -9914,8 +10273,9 @@ function chartSwitch$1(target, options, env) {
|
|
|
9914
10273
|
function readFocus(from) {
|
|
9915
10274
|
const element = focused();
|
|
9916
10275
|
const inside = element !== null && from.container.contains(element);
|
|
9917
|
-
const
|
|
9918
|
-
const
|
|
10276
|
+
const stop = inside ? element : from.chart.element.querySelector("[tabindex=\"0\"]");
|
|
10277
|
+
const keyed = stop?.closest("[data-key]");
|
|
10278
|
+
const key = (stop && from.chart.keyOf?.(stop)) ?? (keyed && from.chart.element.contains(keyed) ? keyed.getAttribute("data-key") : null);
|
|
9919
10279
|
if (!inside && key === null) return void 0;
|
|
9920
10280
|
return {
|
|
9921
10281
|
keys: key === null ? [] : from.chart.standsFor?.(key) ?? [key],
|
|
@@ -9968,6 +10328,7 @@ function chartSwitch$1(target, options, env) {
|
|
|
9968
10328
|
each.container.classList.remove("ec-switch-inactive");
|
|
9969
10329
|
each.container.classList.add("ec-switching");
|
|
9970
10330
|
each.container.setAttribute("inert", "");
|
|
10331
|
+
each.chart.morphing?.(true);
|
|
9971
10332
|
each.chart.element.classList.add("ec-morphing");
|
|
9972
10333
|
}
|
|
9973
10334
|
const { pairs, surface, scene } = prepare(from, to);
|
|
@@ -10043,6 +10404,7 @@ function chartSwitch$1(target, options, env) {
|
|
|
10043
10404
|
const to = session.forward ? session.b : session.a;
|
|
10044
10405
|
for (const each of [session.a, session.b]) {
|
|
10045
10406
|
each.chart.element.classList.remove("ec-morphing");
|
|
10407
|
+
each.chart.morphing?.(false);
|
|
10046
10408
|
each.container.classList.remove("ec-switching");
|
|
10047
10409
|
each.container.style.removeProperty("opacity");
|
|
10048
10410
|
}
|
|
@@ -10055,8 +10417,8 @@ function chartSwitch$1(target, options, env) {
|
|
|
10055
10417
|
session.settle();
|
|
10056
10418
|
}
|
|
10057
10419
|
function prepare(a, b) {
|
|
10058
|
-
const toA = between$1(overlay, a.chart.element, wrapper);
|
|
10059
|
-
const toB = between$1(overlay, b.chart.element, wrapper);
|
|
10420
|
+
const toA = between$1(overlay, a.chart.space ?? a.chart.element, wrapper);
|
|
10421
|
+
const toB = between$1(overlay, b.chart.space ?? b.chart.element, wrapper);
|
|
10060
10422
|
const scaleA = scaleOf(toA);
|
|
10061
10423
|
const scaleB = scaleOf(toB);
|
|
10062
10424
|
const from = a.chart.marks().map((mark) => mapMark(mark, toA));
|
|
@@ -10076,8 +10438,8 @@ function chartSwitch$1(target, options, env) {
|
|
|
10076
10438
|
from: was.drawn ? partner : dot$1(partner),
|
|
10077
10439
|
to: will.drawn ? mark : dot$1(mark)
|
|
10078
10440
|
});
|
|
10079
|
-
paints.push(will
|
|
10080
|
-
extras.push(extrasFor([ringOf(was, scaleA), ringOf(will, scaleB)], [endOf(was, partner, scaleA), endOf(will, mark, scaleB)], [was
|
|
10441
|
+
paints.push(will);
|
|
10442
|
+
extras.push(extrasFor([ringOf(was, scaleA), ringOf(will, scaleB)], [endOf(was, partner, scaleA), endOf(will, mark, scaleB)], [was, will]));
|
|
10081
10443
|
}
|
|
10082
10444
|
const drawings = [];
|
|
10083
10445
|
if (extras.some((each) => each !== void 0)) drawings.push((s) => {
|
|
@@ -10092,16 +10454,18 @@ function chartSwitch$1(target, options, env) {
|
|
|
10092
10454
|
const id = (label) => `${label.role}\n${label.key}`;
|
|
10093
10455
|
const labelsA = a.chart.labels();
|
|
10094
10456
|
const labelsB = b.chart.labels();
|
|
10457
|
+
const sizeA = a.chart.space ? scaleA : 1;
|
|
10458
|
+
const sizeB = b.chart.space ? scaleB : 1;
|
|
10095
10459
|
const byId = new Map(labelsA.map((label) => [id(label), label]));
|
|
10096
10460
|
const matched = /* @__PURE__ */ new Set();
|
|
10097
10461
|
for (const label of labelsB) {
|
|
10098
10462
|
const partner = byId.get(id(label));
|
|
10099
10463
|
if (!partner) continue;
|
|
10100
10464
|
matched.add(id(label));
|
|
10101
|
-
drawings.push(moveLabel(copyLabel(partner, toA), copyLabel(label, toB)));
|
|
10465
|
+
drawings.push(moveLabel(copyLabel(partner, toA, sizeA), copyLabel(label, toB, sizeB)));
|
|
10102
10466
|
}
|
|
10103
|
-
for (const label of labelsA) if (!matched.has(id(label))) drawings.push(fadeLabel(copyLabel(label, toA), fadeOut));
|
|
10104
|
-
for (const label of labelsB) if (!byId.has(id(label))) drawings.push(fadeLabel(copyLabel(label, toB), fadeIn));
|
|
10467
|
+
for (const label of labelsA) if (!matched.has(id(label))) drawings.push(fadeLabel(copyLabel(label, toA, sizeA), fadeOut));
|
|
10468
|
+
for (const label of labelsB) if (!byId.has(id(label))) drawings.push(fadeLabel(copyLabel(label, toB, sizeB), fadeIn));
|
|
10105
10469
|
drawings.push((s) => {
|
|
10106
10470
|
setOpacity(a.container, 1 - clamp$1(s / OUT_BY));
|
|
10107
10471
|
setOpacity(b.container, clamp$1((s - HALF) / .5));
|
|
@@ -10126,7 +10490,7 @@ function chartSwitch$1(target, options, env) {
|
|
|
10126
10490
|
class: "ec-switch-fade",
|
|
10127
10491
|
"data-key": mark.key
|
|
10128
10492
|
}, fadesLayer);
|
|
10129
|
-
setStyles(group,
|
|
10493
|
+
setStyles(group, tokensOf(paint));
|
|
10130
10494
|
const ring = ringOf(paint, scale);
|
|
10131
10495
|
svgLayer(group).path(mark.outline.d, mark.outline.closed ? {
|
|
10132
10496
|
fill: "mark",
|
|
@@ -10151,7 +10515,7 @@ function chartSwitch$1(target, options, env) {
|
|
|
10151
10515
|
});
|
|
10152
10516
|
return element;
|
|
10153
10517
|
}
|
|
10154
|
-
function copyLabel(label, m) {
|
|
10518
|
+
function copyLabel(label, m, scale) {
|
|
10155
10519
|
const text = label.element.cloneNode(true);
|
|
10156
10520
|
for (const name of [
|
|
10157
10521
|
"id",
|
|
@@ -10160,17 +10524,19 @@ function chartSwitch$1(target, options, env) {
|
|
|
10160
10524
|
"aria-hidden"
|
|
10161
10525
|
]) text.removeAttribute(name);
|
|
10162
10526
|
text.textContent = label.text;
|
|
10163
|
-
const
|
|
10527
|
+
const copy = {
|
|
10528
|
+
text,
|
|
10529
|
+
at: matrix.apply(m, label),
|
|
10530
|
+
scale
|
|
10531
|
+
};
|
|
10164
10532
|
setAttributes(text, {
|
|
10165
|
-
x: at.x,
|
|
10166
|
-
y: at.y,
|
|
10167
|
-
"text-anchor": label.anchor
|
|
10533
|
+
x: copy.at.x,
|
|
10534
|
+
y: copy.at.y,
|
|
10535
|
+
"text-anchor": label.anchor,
|
|
10536
|
+
...scaledAt(copy, copy.at.x, copy.at.y)
|
|
10168
10537
|
});
|
|
10169
10538
|
labelsLayer.appendChild(text);
|
|
10170
|
-
return
|
|
10171
|
-
text,
|
|
10172
|
-
at
|
|
10173
|
-
};
|
|
10539
|
+
return copy;
|
|
10174
10540
|
}
|
|
10175
10541
|
const api = {
|
|
10176
10542
|
get current() {
|
|
@@ -10222,6 +10588,7 @@ function chartSwitch$1(target, options, env) {
|
|
|
10222
10588
|
session.driver?.cancel();
|
|
10223
10589
|
session.transition?.clear();
|
|
10224
10590
|
session.scene.clear();
|
|
10591
|
+
for (const each of [session.a, session.b]) each.chart.morphing?.(false);
|
|
10225
10592
|
session.settle();
|
|
10226
10593
|
}
|
|
10227
10594
|
stopMotion();
|
|
@@ -10321,15 +10688,25 @@ function moveLabel(a, b) {
|
|
|
10321
10688
|
setAttributes(a.text, {
|
|
10322
10689
|
x,
|
|
10323
10690
|
y,
|
|
10324
|
-
visibility: second ? "hidden" : void 0
|
|
10691
|
+
visibility: second ? "hidden" : void 0,
|
|
10692
|
+
...scaledAt(a, x, y)
|
|
10325
10693
|
});
|
|
10326
10694
|
setAttributes(b.text, {
|
|
10327
10695
|
x,
|
|
10328
10696
|
y,
|
|
10329
|
-
visibility: second ? void 0 : "hidden"
|
|
10697
|
+
visibility: second ? void 0 : "hidden",
|
|
10698
|
+
...scaledAt(b, x, y)
|
|
10330
10699
|
});
|
|
10331
10700
|
};
|
|
10332
10701
|
}
|
|
10702
|
+
const scaledAt = (copy, x, y) => copy.scale === 1 ? {} : { transform: transformAttribute([
|
|
10703
|
+
copy.scale,
|
|
10704
|
+
0,
|
|
10705
|
+
0,
|
|
10706
|
+
copy.scale,
|
|
10707
|
+
x * (1 - copy.scale),
|
|
10708
|
+
y * (1 - copy.scale)
|
|
10709
|
+
]) };
|
|
10333
10710
|
function fadeLabel(label, opacity) {
|
|
10334
10711
|
return (s) => setAttributes(label.text, { opacity: opacity(s) });
|
|
10335
10712
|
}
|
|
@@ -12505,7 +12882,7 @@ function configure(options) {
|
|
|
12505
12882
|
}
|
|
12506
12883
|
}
|
|
12507
12884
|
// src/index.ts
|
|
12508
|
-
const VERSION = "0.
|
|
12885
|
+
const VERSION = "0.9.0";
|
|
12509
12886
|
const env = {
|
|
12510
12887
|
presets: presetRegistry,
|
|
12511
12888
|
icons: iconRegistry,
|
|
@@ -12535,6 +12912,6 @@ function fromVegaView(view, options) {
|
|
|
12535
12912
|
function motionSwitch(target, motion$1 = motion, options) {
|
|
12536
12913
|
return motionSwitch$1(target, motion$1, options);
|
|
12537
12914
|
}
|
|
12538
|
-
export { VERSION, animated, barChart, chartSwitch, colorAssignment, configure, createClock, createMotion, defaultClock, defaultScaling, defineDataEffect, defineEffect, defineIcon, delta, describe, donutChart, drawIn, easeInOutCubic, easeOutCubic, expressive, flash, fromVegaView, gaits, 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 };
|
|
12915
|
+
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 };
|
|
12539
12916
|
|
|
12540
12917
|
//# sourceMappingURL=index.js.map
|