expressive-charts 0.10.0 → 0.11.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 +11 -0
- package/README.md +7 -7
- package/dist/expressive-charts.global.js +6 -6
- package/dist/expressive-charts.global.js.map +1 -1
- package/dist/index.cjs +319 -77
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +54 -7
- package/dist/index.d.ts +54 -7
- package/dist/index.js +319 -77
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -7986,6 +7986,40 @@ function between$1(outer, inner, root, screen = screenMatrix) {
|
|
|
7986
7986
|
if (a && b) return matrix.multiply(invert(a), b);
|
|
7987
7987
|
return matrix.multiply(invert(fromRoot(outer, root)), fromRoot(inner, root));
|
|
7988
7988
|
}
|
|
7989
|
+
function mapMark(mark, m) {
|
|
7990
|
+
if (isIdentity$1(m)) return mark;
|
|
7991
|
+
const point = (p) => matrix.apply(m, p);
|
|
7992
|
+
const path = (d) => formatPath(transformPath(parsePath(d), m));
|
|
7993
|
+
const scale = scaleOf$2(m);
|
|
7994
|
+
const { outline } = mark;
|
|
7995
|
+
return {
|
|
7996
|
+
key: mark.key,
|
|
7997
|
+
...mark.series === void 0 ? {} : { series: mark.series },
|
|
7998
|
+
start: point(mark.start),
|
|
7999
|
+
end: point(mark.end),
|
|
8000
|
+
length: mark.length * scale,
|
|
8001
|
+
path: (t) => point(mark.path(t)),
|
|
8002
|
+
angle: (t) => {
|
|
8003
|
+
const angle = mark.angle(t);
|
|
8004
|
+
const cos = Math.cos(angle);
|
|
8005
|
+
const sin = Math.sin(angle);
|
|
8006
|
+
return Math.atan2(m[1] * cos + m[3] * sin, m[0] * cos + m[2] * sin);
|
|
8007
|
+
},
|
|
8008
|
+
slice: (t0, t1) => path(mark.slice(t0, t1)),
|
|
8009
|
+
...mark.gaps === void 0 ? {} : { gaps: mark.gaps },
|
|
8010
|
+
thickness: mark.thickness * scale,
|
|
8011
|
+
outline: {
|
|
8012
|
+
d: path(outline.d),
|
|
8013
|
+
closed: outline.closed,
|
|
8014
|
+
sample: (n) => outline.sample(n).map(point)
|
|
8015
|
+
},
|
|
8016
|
+
bounds: boxIn(m, mark.bounds),
|
|
8017
|
+
center: point(mark.center),
|
|
8018
|
+
pivot: point(mark.pivot),
|
|
8019
|
+
...mark.segments === void 0 ? {} : { segments: mark.segments.map((segment) => mapMark(segment, m)) }
|
|
8020
|
+
};
|
|
8021
|
+
}
|
|
8022
|
+
const isIdentity$1 = (m) => m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1 && m[4] === 0 && m[5] === 0;
|
|
7989
8023
|
function ownTransform(element) {
|
|
7990
8024
|
return parseTransform(element.getAttribute("transform") ?? "");
|
|
7991
8025
|
}
|
|
@@ -9026,7 +9060,7 @@ function expressive$1(target, options, env) {
|
|
|
9026
9060
|
if (root.lastElementChild !== overlay) root.appendChild(overlay);
|
|
9027
9061
|
overlay.removeAttribute("transform");
|
|
9028
9062
|
const m = between$1(overlay, ancestor, root);
|
|
9029
|
-
if (!isIdentity
|
|
9063
|
+
if (!isIdentity(m)) overlay.setAttribute("transform", transformAttribute(m));
|
|
9030
9064
|
}
|
|
9031
9065
|
function moveTo(next) {
|
|
9032
9066
|
detach();
|
|
@@ -9577,7 +9611,7 @@ function tryInvert(m) {
|
|
|
9577
9611
|
return;
|
|
9578
9612
|
}
|
|
9579
9613
|
}
|
|
9580
|
-
function isIdentity
|
|
9614
|
+
function isIdentity(m) {
|
|
9581
9615
|
return Math.abs(m[0] - 1) < 1e-9 && Math.abs(m[1]) < 1e-9 && Math.abs(m[2]) < 1e-9 && Math.abs(m[3] - 1) < 1e-9 && Math.abs(m[4]) < 1e-6 && Math.abs(m[5]) < 1e-6;
|
|
9582
9616
|
}
|
|
9583
9617
|
function valuesChanged(from, to) {
|
|
@@ -9630,19 +9664,37 @@ function scaled(value, scale) {
|
|
|
9630
9664
|
if (scale === 1) return value;
|
|
9631
9665
|
return value.replace(/(-?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?)(px)?(?![\w.%])/gi, (_, n, px) => `${Math.round(Number(n) * scale * 1e3) / 1e3}${px ?? ""}`);
|
|
9632
9666
|
}
|
|
9633
|
-
function hostView(
|
|
9634
|
-
const
|
|
9635
|
-
|
|
9636
|
-
|
|
9667
|
+
function hostView(attachments, options = {}) {
|
|
9668
|
+
const list = Array.isArray(attachments) ? attachments : [attachments];
|
|
9669
|
+
if (list.length === 0) throw new TypeError("hostView needs an attachment, or an array of attachments on one <svg>: hostView([dots, connectors]).");
|
|
9670
|
+
const parts = list.map((attachment, i) => {
|
|
9671
|
+
const port = typeof attachment === "object" && attachment !== null ? portOf(attachment) : void 0;
|
|
9672
|
+
const inside = insidesOf(port);
|
|
9673
|
+
if (!port || !inside?.root()) throw new TypeError(list === attachments ? `hostView needs attachments that expressive() or fromVegaView() returned, each with marks in an <svg>: attachments[${i}] isn't one.` : "hostView needs an attachment that expressive() or fromVegaView() returned, with marks in an <svg>.");
|
|
9674
|
+
if (list.indexOf(attachment) !== i) throw new TypeError(`hostView: attachments[${i}] is attachments[${list.indexOf(attachment)}] again. Each attachment is in a view once.`);
|
|
9675
|
+
return {
|
|
9676
|
+
attachment,
|
|
9677
|
+
port,
|
|
9678
|
+
inside,
|
|
9679
|
+
hidden: []
|
|
9680
|
+
};
|
|
9681
|
+
});
|
|
9637
9682
|
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\" })).");
|
|
9638
|
-
|
|
9639
|
-
const
|
|
9683
|
+
if (options.guides !== void 0 && typeof options.guides !== "function") throw new TypeError("hostView: guides must be a function that returns the host's guides, such as () => [{ element: svg.querySelector(\"g.axis\"), key: \"y\" }].");
|
|
9684
|
+
const lead = parts[0];
|
|
9685
|
+
const several = parts.length > 1;
|
|
9686
|
+
const { edits } = lead.inside;
|
|
9687
|
+
const svg = () => lead.inside.root();
|
|
9640
9688
|
let given;
|
|
9641
|
-
let
|
|
9689
|
+
let guided;
|
|
9642
9690
|
let classed;
|
|
9691
|
+
const clash = several ? clashOf(parts, svg()) : void 0;
|
|
9692
|
+
if (clash) throw new TypeError(`hostView: ${clash.problem}.`);
|
|
9693
|
+
const drawn = () => parts.filter((part) => part.inside.root() === svg());
|
|
9694
|
+
const ownerOf = (key) => drawn().find((part) => part.attachment.marks().some((mark) => mark.key === key));
|
|
9643
9695
|
function read() {
|
|
9644
9696
|
if (!options.labels) return [];
|
|
9645
|
-
const keys = new Set(attachment.marks().map((mark) => mark.key));
|
|
9697
|
+
const keys = new Set(drawn().flatMap((part) => part.attachment.marks().map((mark) => mark.key)));
|
|
9646
9698
|
try {
|
|
9647
9699
|
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"));
|
|
9648
9700
|
} catch (error) {
|
|
@@ -9650,6 +9702,16 @@ function hostView(attachment, options = {}) {
|
|
|
9650
9702
|
return [];
|
|
9651
9703
|
}
|
|
9652
9704
|
}
|
|
9705
|
+
function guides() {
|
|
9706
|
+
if (!options.guides) return [];
|
|
9707
|
+
const root = svg();
|
|
9708
|
+
try {
|
|
9709
|
+
return Array.from(options.guides()).filter((guide) => (guide?.element)?.nodeType === 1 && guide.element !== root && root.contains(guide.element) && typeof guide.key === "string");
|
|
9710
|
+
} catch (error) {
|
|
9711
|
+
report(error);
|
|
9712
|
+
return [];
|
|
9713
|
+
}
|
|
9714
|
+
}
|
|
9653
9715
|
function chartLabel({ element, key, role }) {
|
|
9654
9716
|
const root = svg();
|
|
9655
9717
|
const m = between$1(view.space, element, root);
|
|
@@ -9680,16 +9742,27 @@ function hostView(attachment, options = {}) {
|
|
|
9680
9742
|
};
|
|
9681
9743
|
}
|
|
9682
9744
|
const hide = (on) => {
|
|
9745
|
+
if (on && given === void 0 && several) {
|
|
9746
|
+
const found = clashOf(parts, svg());
|
|
9747
|
+
if (found) report(/* @__PURE__ */ new TypeError(`hostView: ${found.problem}. The switch plays on, and ${found.left}.`));
|
|
9748
|
+
}
|
|
9683
9749
|
const root = on ? svg() : void 0;
|
|
9684
9750
|
given = on ? read() : void 0;
|
|
9685
|
-
|
|
9751
|
+
guided = on ? guides() : void 0;
|
|
9752
|
+
const named = [...(given ?? []).map((label) => label.element), ...(guided ?? []).map((guide) => guide.element)];
|
|
9753
|
+
const now = parts.map(({ inside, hidden }, i) => new Set(given ? [
|
|
9686
9754
|
...inside.elements(),
|
|
9687
|
-
...
|
|
9755
|
+
...i === 0 ? named : [],
|
|
9688
9756
|
...hidden.filter((element) => root?.contains(element))
|
|
9689
|
-
] : []);
|
|
9690
|
-
for (const element of
|
|
9691
|
-
|
|
9692
|
-
|
|
9757
|
+
] : []));
|
|
9758
|
+
for (let i = 1; i < now.length; i++) for (const element of now[i]) if (now.some((earlier, j) => j < i && earlier.has(element))) now[i].delete(element);
|
|
9759
|
+
parts.forEach((part, i) => {
|
|
9760
|
+
for (const element of part.hidden) if (!now[i].has(element)) part.inside.edits.style(element, "visibility", void 0);
|
|
9761
|
+
});
|
|
9762
|
+
parts.forEach((part, i) => {
|
|
9763
|
+
part.hidden = [...now[i]];
|
|
9764
|
+
for (const element of part.hidden) part.inside.edits.style(element, "visibility", "hidden");
|
|
9765
|
+
});
|
|
9693
9766
|
if (classed !== root) {
|
|
9694
9767
|
if (classed) edits.toggleClass(classed, "ec-morphing", false);
|
|
9695
9768
|
if (root) edits.toggleClass(root, "ec-morphing", true);
|
|
@@ -9701,36 +9774,82 @@ function hostView(attachment, options = {}) {
|
|
|
9701
9774
|
return svg();
|
|
9702
9775
|
},
|
|
9703
9776
|
get space() {
|
|
9704
|
-
|
|
9705
|
-
|
|
9706
|
-
|
|
9707
|
-
|
|
9708
|
-
|
|
9709
|
-
|
|
9710
|
-
|
|
9711
|
-
|
|
9777
|
+
const root = svg();
|
|
9778
|
+
const [space, ...others] = drawn().map((part) => part.inside.ancestor() ?? root);
|
|
9779
|
+
let common = space;
|
|
9780
|
+
for (const other of others) while (common !== root && !common.contains(other)) common = common.parentElement ?? root;
|
|
9781
|
+
return common;
|
|
9782
|
+
},
|
|
9783
|
+
refresh(source) {
|
|
9784
|
+
if (several && source !== void 0) throw new TypeError("hostView: a view of several attachments refreshes each from what it last read, with refresh(). To read new sources, refresh each attachment with its own.");
|
|
9785
|
+
for (const { attachment } of parts) attachment.refresh(source);
|
|
9786
|
+
},
|
|
9787
|
+
update: (next) => several ? Promise.all(parts.map(({ attachment }) => attachment.update(next))).then(() => {}) : lead.attachment.update(next),
|
|
9788
|
+
on(type, listener) {
|
|
9789
|
+
const stops = parts.map(({ attachment }) => attachment.on(type, listener));
|
|
9790
|
+
return several ? () => stops.forEach((stop) => stop()) : stops[0];
|
|
9791
|
+
},
|
|
9792
|
+
marks() {
|
|
9793
|
+
const root = svg();
|
|
9794
|
+
const space = view.space;
|
|
9795
|
+
const keys = /* @__PURE__ */ new Set();
|
|
9796
|
+
return drawn().flatMap(({ attachment, inside }) => {
|
|
9797
|
+
const ancestor = inside.ancestor() ?? root;
|
|
9798
|
+
const m = ancestor === space ? void 0 : between$1(space, ancestor, root);
|
|
9799
|
+
return attachment.marks().flatMap((mark) => keys.has(mark.key) ? [] : (keys.add(mark.key), [m ? mapMark(mark, m) : mark]));
|
|
9800
|
+
});
|
|
9801
|
+
},
|
|
9802
|
+
focus: (key) => ownerOf(key)?.attachment.focus(key),
|
|
9803
|
+
leave() {
|
|
9804
|
+
for (const { attachment } of parts) attachment.leave();
|
|
9805
|
+
},
|
|
9712
9806
|
destroy() {
|
|
9713
|
-
given = classed = void 0;
|
|
9714
|
-
hidden = [];
|
|
9715
|
-
attachment.destroy();
|
|
9807
|
+
given = guided = classed = void 0;
|
|
9808
|
+
for (const part of parts) part.hidden = [];
|
|
9809
|
+
for (const { attachment } of [...parts].reverse()) attachment.destroy();
|
|
9716
9810
|
},
|
|
9717
9811
|
labels: () => (given ?? read()).map(chartLabel),
|
|
9812
|
+
guides: () => guided ?? guides(),
|
|
9718
9813
|
paintOf(key) {
|
|
9719
|
-
const
|
|
9720
|
-
|
|
9721
|
-
color
|
|
9722
|
-
|
|
9723
|
-
|
|
9724
|
-
|
|
9814
|
+
for (const { inside } of drawn()) {
|
|
9815
|
+
const color = inside.colorOf(key);
|
|
9816
|
+
if (color !== void 0) return {
|
|
9817
|
+
color: key,
|
|
9818
|
+
drawn: true,
|
|
9819
|
+
cssColor: color
|
|
9820
|
+
};
|
|
9821
|
+
}
|
|
9822
|
+
},
|
|
9823
|
+
keyOf(element) {
|
|
9824
|
+
for (const { inside } of parts) {
|
|
9825
|
+
const key = inside.keyOf(element);
|
|
9826
|
+
if (key !== void 0) return key;
|
|
9827
|
+
}
|
|
9725
9828
|
},
|
|
9726
|
-
|
|
9727
|
-
moveTabStop: (key) => inside.moveTabStop(key),
|
|
9829
|
+
moveTabStop: (key) => drawn().some(({ inside }) => inside.moveTabStop(key)),
|
|
9728
9830
|
morphing: hide
|
|
9729
9831
|
};
|
|
9730
|
-
inside.refreshed.add(() => {
|
|
9832
|
+
for (const { inside } of parts) inside.refreshed.add(() => {
|
|
9731
9833
|
if (given) hide(true);
|
|
9732
9834
|
});
|
|
9733
|
-
return linkable(port, view);
|
|
9835
|
+
return several ? view : linkable(lead.port, view);
|
|
9836
|
+
}
|
|
9837
|
+
function clashOf(parts, root) {
|
|
9838
|
+
const owners = /* @__PURE__ */ new Map();
|
|
9839
|
+
for (const [i, { attachment, inside }] of parts.entries()) {
|
|
9840
|
+
if (inside.root() !== root) return {
|
|
9841
|
+
problem: `attachments[${i}]'s marks are in another <svg> than attachments[0]'s, and a view's attachments share one`,
|
|
9842
|
+
left: `attachments[${i}]'s marks are left out`
|
|
9843
|
+
};
|
|
9844
|
+
for (const { key } of attachment.marks()) {
|
|
9845
|
+
const owner = owners.get(key);
|
|
9846
|
+
if (owner !== void 0 && owner !== i) return {
|
|
9847
|
+
problem: `attachments[${owner}] and attachments[${i}] both have a mark with the key ${JSON.stringify(key)}, and each key must be one mark's. Key each one's marks apart, such as (d) => \`first@\${d.name}\``,
|
|
9848
|
+
left: `the key stays attachments[${owner}]'s: attachments[${i}]'s mark is left out`
|
|
9849
|
+
};
|
|
9850
|
+
owners.set(key, i);
|
|
9851
|
+
}
|
|
9852
|
+
}
|
|
9734
9853
|
}
|
|
9735
9854
|
// src/charts/adapter/vega.ts
|
|
9736
9855
|
const MARK_TYPES = [
|
|
@@ -10347,14 +10466,16 @@ function chartSwitch$1(target, options, env) {
|
|
|
10347
10466
|
reached();
|
|
10348
10467
|
return Promise.resolve();
|
|
10349
10468
|
}
|
|
10469
|
+
const guides = [];
|
|
10350
10470
|
for (const each of [from, to]) {
|
|
10351
10471
|
each.container.classList.remove("ec-switch-inactive");
|
|
10472
|
+
guides.push(guidesOf(each));
|
|
10352
10473
|
each.container.classList.add("ec-switching");
|
|
10353
10474
|
each.container.setAttribute("inert", "");
|
|
10354
10475
|
each.chart.morphing?.(true);
|
|
10355
10476
|
each.chart.element.classList.add("ec-morphing");
|
|
10356
10477
|
}
|
|
10357
|
-
const { pairs, surface, scene } = prepare(from, to);
|
|
10478
|
+
const { pairs, surface, scene } = prepare(from, to, guides);
|
|
10358
10479
|
const { done, settle } = carried ?? deferred();
|
|
10359
10480
|
const session = {
|
|
10360
10481
|
a: from,
|
|
@@ -10452,7 +10573,7 @@ function chartSwitch$1(target, options, env) {
|
|
|
10452
10573
|
}
|
|
10453
10574
|
session.settle();
|
|
10454
10575
|
}
|
|
10455
|
-
function prepare(a, b) {
|
|
10576
|
+
function prepare(a, b, guides) {
|
|
10456
10577
|
const toA = between$1(overlay, a.chart.space ?? a.chart.element, wrapper);
|
|
10457
10578
|
const toB = between$1(overlay, b.chart.space ?? b.chart.element, wrapper);
|
|
10458
10579
|
const scaleA = scaleOf(toA);
|
|
@@ -10502,9 +10623,39 @@ function chartSwitch$1(target, options, env) {
|
|
|
10502
10623
|
}
|
|
10503
10624
|
for (const label of labelsA) if (!matched.has(id(label))) drawings.push(fadeLabel(copyLabel(label, toA, sizeA), fadeOut));
|
|
10504
10625
|
for (const label of labelsB) if (!byId.has(id(label))) drawings.push(fadeLabel(copyLabel(label, toB, sizeB), fadeIn));
|
|
10626
|
+
const [guidesA = [], guidesB = []] = guides;
|
|
10627
|
+
const partners = /* @__PURE__ */ new Map();
|
|
10628
|
+
for (const guide of guidesA) if (!partners.has(guide.key)) partners.set(guide.key, guide);
|
|
10629
|
+
const kept = /* @__PURE__ */ new Set();
|
|
10630
|
+
for (const guide of guidesB) {
|
|
10631
|
+
const partner = partners.get(guide.key);
|
|
10632
|
+
partners.delete(guide.key);
|
|
10633
|
+
if (partner && sameGuide(partner, guide)) kept.add(partner).add(guide);
|
|
10634
|
+
}
|
|
10635
|
+
let guidesLayer;
|
|
10636
|
+
if (guidesA.length + guidesB.length > 0) {
|
|
10637
|
+
const layer = guidesLayer = doc.createElementNS(SVG_NS$2, "g");
|
|
10638
|
+
layer.setAttribute("class", "ec-switch-guides");
|
|
10639
|
+
overlay.insertBefore(layer, fadesLayer);
|
|
10640
|
+
[[
|
|
10641
|
+
guidesA,
|
|
10642
|
+
(s) => s < HALF ? 1 : 0,
|
|
10643
|
+
othersOut
|
|
10644
|
+
], [
|
|
10645
|
+
guidesB,
|
|
10646
|
+
(s) => s < HALF ? 0 : 1,
|
|
10647
|
+
othersIn
|
|
10648
|
+
]].forEach(([list, steady, fading]) => {
|
|
10649
|
+
for (const guide of list) {
|
|
10650
|
+
layer.appendChild(guide.group);
|
|
10651
|
+
const opacity = kept.has(guide) ? steady : fading;
|
|
10652
|
+
drawings.push((s) => guide.group.setAttribute("opacity", opacityText(opacity(s))));
|
|
10653
|
+
}
|
|
10654
|
+
});
|
|
10655
|
+
}
|
|
10505
10656
|
drawings.push((s) => {
|
|
10506
|
-
setOpacity(a.container,
|
|
10507
|
-
setOpacity(b.container,
|
|
10657
|
+
setOpacity(a.container, othersOut(s));
|
|
10658
|
+
setOpacity(b.container, othersIn(s));
|
|
10508
10659
|
});
|
|
10509
10660
|
return {
|
|
10510
10661
|
pairs,
|
|
@@ -10514,6 +10665,7 @@ function chartSwitch$1(target, options, env) {
|
|
|
10514
10665
|
for (const draw of drawings) draw(s);
|
|
10515
10666
|
},
|
|
10516
10667
|
clear: () => {
|
|
10668
|
+
guidesLayer?.remove();
|
|
10517
10669
|
fadesLayer.replaceChildren();
|
|
10518
10670
|
runsLayer.replaceChildren();
|
|
10519
10671
|
labelsLayer.replaceChildren();
|
|
@@ -10521,6 +10673,31 @@ function chartSwitch$1(target, options, env) {
|
|
|
10521
10673
|
}
|
|
10522
10674
|
};
|
|
10523
10675
|
}
|
|
10676
|
+
function guidesOf(view) {
|
|
10677
|
+
const root = view.chart.element;
|
|
10678
|
+
return (view.chart.guides?.() ?? []).flatMap((guide) => {
|
|
10679
|
+
const element = guide?.element;
|
|
10680
|
+
const parent = element?.parentElement;
|
|
10681
|
+
if (typeof guide?.key !== "string" || !parent || !root.contains(parent)) return [];
|
|
10682
|
+
const m = between$1(overlay, parent, wrapper);
|
|
10683
|
+
const copy = paintedCopy(element, root);
|
|
10684
|
+
const group = doc.createElementNS(SVG_NS$2, "g");
|
|
10685
|
+
setAttributes(group, {
|
|
10686
|
+
class: "ec-switch-guide",
|
|
10687
|
+
"data-key": guide.key,
|
|
10688
|
+
transform: isIdentity$1(m) ? void 0 : transformAttribute(m)
|
|
10689
|
+
});
|
|
10690
|
+
group.appendChild(copy);
|
|
10691
|
+
const own = ownTransform(element);
|
|
10692
|
+
return [{
|
|
10693
|
+
key: guide.key,
|
|
10694
|
+
group,
|
|
10695
|
+
markup: copy.outerHTML,
|
|
10696
|
+
corners: cornersOf(element).map((p) => matrix.apply(m, matrix.apply(own, p))),
|
|
10697
|
+
place: m
|
|
10698
|
+
}];
|
|
10699
|
+
});
|
|
10700
|
+
}
|
|
10524
10701
|
function fadeMark(mark, paint, scale, opacity) {
|
|
10525
10702
|
const group = svgElement("g", {
|
|
10526
10703
|
class: "ec-switch-fade",
|
|
@@ -10726,8 +10903,105 @@ function setActive(container, active) {
|
|
|
10726
10903
|
else container.setAttribute("aria-hidden", "true");
|
|
10727
10904
|
}
|
|
10728
10905
|
function setOpacity(container, opacity) {
|
|
10729
|
-
container.style.setProperty("opacity",
|
|
10906
|
+
container.style.setProperty("opacity", opacityText(opacity));
|
|
10907
|
+
}
|
|
10908
|
+
const opacityText = (opacity) => String(Math.round(opacity * 1e3) / 1e3);
|
|
10909
|
+
const INHERITED = [
|
|
10910
|
+
"fill",
|
|
10911
|
+
"fill-opacity",
|
|
10912
|
+
"fill-rule",
|
|
10913
|
+
"stroke",
|
|
10914
|
+
"stroke-opacity",
|
|
10915
|
+
"stroke-width",
|
|
10916
|
+
"stroke-dasharray",
|
|
10917
|
+
"stroke-dashoffset",
|
|
10918
|
+
"stroke-linecap",
|
|
10919
|
+
"stroke-linejoin",
|
|
10920
|
+
"stroke-miterlimit",
|
|
10921
|
+
"paint-order",
|
|
10922
|
+
"marker-start",
|
|
10923
|
+
"marker-mid",
|
|
10924
|
+
"marker-end",
|
|
10925
|
+
"color",
|
|
10926
|
+
"visibility",
|
|
10927
|
+
"font-family",
|
|
10928
|
+
"font-size",
|
|
10929
|
+
"font-style",
|
|
10930
|
+
"font-weight",
|
|
10931
|
+
"font-stretch",
|
|
10932
|
+
"font-variant-caps",
|
|
10933
|
+
"font-variant-ligatures",
|
|
10934
|
+
"font-variant-numeric",
|
|
10935
|
+
"font-feature-settings",
|
|
10936
|
+
"font-kerning",
|
|
10937
|
+
"letter-spacing",
|
|
10938
|
+
"word-spacing",
|
|
10939
|
+
"text-anchor",
|
|
10940
|
+
"dominant-baseline",
|
|
10941
|
+
"text-rendering",
|
|
10942
|
+
"shape-rendering",
|
|
10943
|
+
"writing-mode",
|
|
10944
|
+
"direction"
|
|
10945
|
+
];
|
|
10946
|
+
const OWN = {
|
|
10947
|
+
opacity: "1",
|
|
10948
|
+
display: "inline",
|
|
10949
|
+
"clip-path": "none",
|
|
10950
|
+
mask: "none",
|
|
10951
|
+
filter: "none",
|
|
10952
|
+
"vector-effect": "none"
|
|
10953
|
+
};
|
|
10954
|
+
function paintedCopy(source, root) {
|
|
10955
|
+
const copy = source.cloneNode(true);
|
|
10956
|
+
const sources = [source, ...source.querySelectorAll("*")];
|
|
10957
|
+
const copies = [copy, ...copy.querySelectorAll("*")];
|
|
10958
|
+
sources.forEach((element, i) => {
|
|
10959
|
+
const target = copies[i];
|
|
10960
|
+
target.removeAttribute("id");
|
|
10961
|
+
const computed = element.ownerDocument.defaultView?.getComputedStyle?.(element);
|
|
10962
|
+
const styles = {};
|
|
10963
|
+
for (const property of INHERITED) styles[property] = drawnStyle(element, root, property) || void 0;
|
|
10964
|
+
for (const [property, initial] of Object.entries(OWN)) {
|
|
10965
|
+
const value = computed?.getPropertyValue(property).trim();
|
|
10966
|
+
if (value && value !== initial) styles[property] = value;
|
|
10967
|
+
}
|
|
10968
|
+
setStyles(target, styles);
|
|
10969
|
+
});
|
|
10970
|
+
return copy;
|
|
10730
10971
|
}
|
|
10972
|
+
function cornersOf(element) {
|
|
10973
|
+
try {
|
|
10974
|
+
const box = element.getBBox?.();
|
|
10975
|
+
if (box) return [
|
|
10976
|
+
{
|
|
10977
|
+
x: box.x,
|
|
10978
|
+
y: box.y
|
|
10979
|
+
},
|
|
10980
|
+
{
|
|
10981
|
+
x: box.x + box.width,
|
|
10982
|
+
y: box.y
|
|
10983
|
+
},
|
|
10984
|
+
{
|
|
10985
|
+
x: box.x,
|
|
10986
|
+
y: box.y + box.height
|
|
10987
|
+
},
|
|
10988
|
+
{
|
|
10989
|
+
x: box.x + box.width,
|
|
10990
|
+
y: box.y + box.height
|
|
10991
|
+
}
|
|
10992
|
+
];
|
|
10993
|
+
} catch {}
|
|
10994
|
+
return [{
|
|
10995
|
+
x: 0,
|
|
10996
|
+
y: 0
|
|
10997
|
+
}];
|
|
10998
|
+
}
|
|
10999
|
+
const sameGuide = (a, b) => a.markup === b.markup && a.corners.length === b.corners.length && a.corners.every((p, i) => Math.hypot(p.x - b.corners[i].x, p.y - b.corners[i].y) <= .5) && [
|
|
11000
|
+
0,
|
|
11001
|
+
1,
|
|
11002
|
+
2,
|
|
11003
|
+
3
|
|
11004
|
+
].every((i) => Math.abs(a.place[i] - b.place[i]) <= 1e-4);
|
|
10731
11005
|
function moveLabel(a, b) {
|
|
10732
11006
|
return (s) => {
|
|
10733
11007
|
const x = mix$1(a.at.x, b.at.x, s);
|
|
@@ -10760,6 +11034,8 @@ function fadeLabel(label, opacity) {
|
|
|
10760
11034
|
}
|
|
10761
11035
|
const fadeOut = (s) => 1 - clamp$1(s / HALF);
|
|
10762
11036
|
const fadeIn = (s) => clamp$1((s - HALF) / .5);
|
|
11037
|
+
const othersOut = (s) => 1 - clamp$1(s / OUT_BY);
|
|
11038
|
+
const othersIn = fadeIn;
|
|
10763
11039
|
const clamp$1 = (value) => Math.min(1, Math.max(0, value));
|
|
10764
11040
|
const mix$1 = (x, y, s) => x * (1 - s) + y * s;
|
|
10765
11041
|
function paintOf(view, mark) {
|
|
@@ -10793,41 +11069,7 @@ function placeDot(element, end) {
|
|
|
10793
11069
|
"stroke-width": end.ring
|
|
10794
11070
|
});
|
|
10795
11071
|
}
|
|
10796
|
-
const isIdentity = (m) => m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1 && m[4] === 0 && m[5] === 0;
|
|
10797
11072
|
const scaleOf = (m) => Math.sqrt(Math.abs(m[0] * m[3] - m[1] * m[2]));
|
|
10798
|
-
function mapMark(mark, m) {
|
|
10799
|
-
if (isIdentity(m)) return mark;
|
|
10800
|
-
const point = (p) => matrix.apply(m, p);
|
|
10801
|
-
const path = (d) => formatPath(transformPath(parsePath(d), m));
|
|
10802
|
-
const scale = scaleOf(m);
|
|
10803
|
-
const { outline } = mark;
|
|
10804
|
-
return {
|
|
10805
|
-
key: mark.key,
|
|
10806
|
-
...mark.series === void 0 ? {} : { series: mark.series },
|
|
10807
|
-
start: point(mark.start),
|
|
10808
|
-
end: point(mark.end),
|
|
10809
|
-
length: mark.length * scale,
|
|
10810
|
-
path: (t) => point(mark.path(t)),
|
|
10811
|
-
angle: (t) => {
|
|
10812
|
-
const angle = mark.angle(t);
|
|
10813
|
-
const cos = Math.cos(angle);
|
|
10814
|
-
const sin = Math.sin(angle);
|
|
10815
|
-
return Math.atan2(m[1] * cos + m[3] * sin, m[0] * cos + m[2] * sin);
|
|
10816
|
-
},
|
|
10817
|
-
slice: (t0, t1) => path(mark.slice(t0, t1)),
|
|
10818
|
-
...mark.gaps === void 0 ? {} : { gaps: mark.gaps },
|
|
10819
|
-
thickness: mark.thickness * scale,
|
|
10820
|
-
outline: {
|
|
10821
|
-
d: path(outline.d),
|
|
10822
|
-
closed: outline.closed,
|
|
10823
|
-
sample: (n) => outline.sample(n).map(point)
|
|
10824
|
-
},
|
|
10825
|
-
bounds: boxIn(m, mark.bounds),
|
|
10826
|
-
center: point(mark.center),
|
|
10827
|
-
pivot: point(mark.pivot),
|
|
10828
|
-
...mark.segments === void 0 ? {} : { segments: mark.segments.map((segment) => mapMark(segment, m)) }
|
|
10829
|
-
};
|
|
10830
|
-
}
|
|
10831
11073
|
function deferred() {
|
|
10832
11074
|
let settle;
|
|
10833
11075
|
return {
|
|
@@ -12983,7 +13225,7 @@ function configure(options) {
|
|
|
12983
13225
|
}
|
|
12984
13226
|
}
|
|
12985
13227
|
// src/index.ts
|
|
12986
|
-
const VERSION = "0.
|
|
13228
|
+
const VERSION = "0.11.0";
|
|
12987
13229
|
const env = {
|
|
12988
13230
|
presets: presetRegistry,
|
|
12989
13231
|
icons: iconRegistry,
|