@pixerate/editor 0.160.0 → 0.162.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/dist/agent/index.cjs +36 -35
- package/dist/agent/index.js +7 -6
- package/dist/animation/index.cjs +5 -4
- package/dist/animation/index.js +4 -3
- package/dist/animation-editor/index.cjs +62 -61
- package/dist/animation-editor/index.js +6 -5
- package/dist/canvas/index.cjs +33 -32
- package/dist/canvas/index.js +6 -5
- package/dist/chart/index.cjs +88 -87
- package/dist/chart/index.js +7 -6
- package/dist/{chunk-QMI5HZWA.cjs → chunk-236TKNUR.cjs} +3 -3
- package/dist/{chunk-6UPGM3JB.js → chunk-2TKHLX6H.js} +1 -1
- package/dist/{chunk-3YDQLQH2.cjs → chunk-32MMQYCQ.cjs} +81 -81
- package/dist/{chunk-MHEXLG3M.cjs → chunk-3GJH2MGH.cjs} +37 -37
- package/dist/{chunk-AKDWAWSY.cjs → chunk-3IHNXRUV.cjs} +45 -45
- package/dist/{chunk-VKF3PWKR.cjs → chunk-3OSXHLIT.cjs} +259 -28
- package/dist/{chunk-TVO6W2Q6.cjs → chunk-4NGVHHJB.cjs} +17 -17
- package/dist/chunk-4VU4CP7R.js +769 -0
- package/dist/chunk-6DM3PUQD.cjs +767 -0
- package/dist/{chunk-DBIVICAO.js → chunk-7CKPUUN4.js} +1 -1
- package/dist/{chunk-57JLBGJ5.cjs → chunk-7YBDRJXT.cjs} +8 -8
- package/dist/{chunk-KY3FYKP3.js → chunk-BQWGN5WH.js} +1 -1
- package/dist/{chunk-LEUZ4FRC.cjs → chunk-CIPIESX4.cjs} +3 -3
- package/dist/chunk-CJE5MOIS.js +347 -0
- package/dist/{chunk-5QBRAIVK.js → chunk-CX6JLDFC.js} +3 -3
- package/dist/{chunk-R3QY7PPL.js → chunk-DTSTNRPH.js} +1 -1
- package/dist/{chunk-6LUYFHHN.cjs → chunk-EQ46F75O.cjs} +51 -51
- package/dist/{chunk-UKCJ43YL.cjs → chunk-ES3UEVUT.cjs} +130 -898
- package/dist/{chunk-UM3RPYC5.js → chunk-EVPZ5IKN.js} +1 -1
- package/dist/{chunk-XNQ5EFB4.cjs → chunk-EY22AY6R.cjs} +16 -16
- package/dist/chunk-FKUKJ3XA.cjs +347 -0
- package/dist/{chunk-YABNLNY7.js → chunk-GLMP22FT.js} +3 -3
- package/dist/{chunk-SUF6WRXR.cjs → chunk-GTELFJRE.cjs} +2 -2
- package/dist/{chunk-72BGL3I2.js → chunk-GWV4T5NZ.js} +1 -1
- package/dist/{chunk-AY65VQSU.js → chunk-H3OEM3Q2.js} +1 -1
- package/dist/{chunk-4YWAEV4W.cjs → chunk-HDGBM7EA.cjs} +26 -26
- package/dist/{chunk-H5XX4KHB.js → chunk-HLOKB7WW.js} +5 -3
- package/dist/{chunk-WNAAWLZ5.js → chunk-KGTF55R3.js} +2 -2
- package/dist/{chunk-WPPJH6X4.cjs → chunk-LL3H5XUH.cjs} +6 -4
- package/dist/{chunk-4T44CJ5K.cjs → chunk-NA4UVVJ4.cjs} +15 -15
- package/dist/{chunk-Q6PA362P.js → chunk-NO5QQDHZ.js} +2 -2
- package/dist/{chunk-AA34BA7G.js → chunk-QYZGBVNC.js} +30 -798
- package/dist/chunk-S6X2QRVU.cjs +769 -0
- package/dist/{chunk-SSCL7QQ4.js → chunk-XDCFJEU7.js} +2 -2
- package/dist/{chunk-IQ6KKXOU.js → chunk-YN4AYYBJ.js} +243 -12
- package/dist/chunk-ZGOHKS3X.js +767 -0
- package/dist/color/index.cjs +6 -2
- package/dist/color/index.d.cts +1 -0
- package/dist/color/index.d.ts +1 -0
- package/dist/color/index.js +28 -24
- package/dist/color/suggest.d.cts +12 -0
- package/dist/color/suggest.d.ts +12 -0
- package/dist/effects/index.cjs +44 -771
- package/dist/effects/index.js +34 -761
- package/dist/effects/ui.d.cts +20 -3
- package/dist/effects/ui.d.ts +20 -3
- package/dist/export/index.cjs +6 -5
- package/dist/export/index.js +5 -4
- package/dist/extensions/index.cjs +9 -8
- package/dist/extensions/index.js +8 -7
- package/dist/gradient/index.cjs +28 -26
- package/dist/gradient/index.js +7 -5
- package/dist/image-editor/index.cjs +638 -637
- package/dist/image-editor/index.js +5 -4
- package/dist/index.cjs +15 -14
- package/dist/index.js +9 -8
- package/dist/paint-editor/index.cjs +17 -16
- package/dist/paint-editor/index.js +6 -5
- package/dist/typography/accessibility.d.cts +44 -0
- package/dist/typography/accessibility.d.ts +44 -0
- package/dist/typography/catalog.d.cts +98 -0
- package/dist/typography/catalog.d.ts +98 -0
- package/dist/typography/index.cjs +1099 -0
- package/dist/typography/index.d.cts +16 -0
- package/dist/typography/index.d.ts +16 -0
- package/dist/typography/index.js +1099 -0
- package/dist/typography/metrics.d.cts +31 -0
- package/dist/typography/metrics.d.ts +31 -0
- package/dist/typography/picker.d.cts +132 -0
- package/dist/typography/picker.d.ts +132 -0
- package/dist/typography/registry.d.cts +66 -0
- package/dist/typography/registry.d.ts +66 -0
- package/dist/typography/scale.d.cts +62 -0
- package/dist/typography/scale.d.ts +62 -0
- package/dist/typography/segment.d.cts +26 -0
- package/dist/typography/segment.d.ts +26 -0
- package/dist/typography/stack.d.cts +26 -0
- package/dist/typography/stack.d.ts +26 -0
- package/dist/typography/tools.d.cts +34 -0
- package/dist/typography/tools.d.ts +34 -0
- package/dist/typography/types.d.cts +96 -0
- package/dist/typography/types.d.ts +96 -0
- package/dist/typography/weight.d.cts +13 -0
- package/dist/typography/weight.d.ts +13 -0
- package/dist/vector/index.cjs +950 -949
- package/dist/vector/index.js +5 -4
- package/dist/video-editor/audio.d.cts +9 -0
- package/dist/video-editor/audio.d.ts +9 -0
- package/dist/video-editor/check.d.cts +1 -1
- package/dist/video-editor/check.d.ts +1 -1
- package/dist/video-editor/controller.d.cts +47 -0
- package/dist/video-editor/controller.d.ts +47 -0
- package/dist/video-editor/dialogue-tools.d.cts +19 -0
- package/dist/video-editor/dialogue-tools.d.ts +19 -0
- package/dist/video-editor/effect-authoring.d.cts +54 -0
- package/dist/video-editor/effect-authoring.d.ts +54 -0
- package/dist/video-editor/evaluate.d.cts +11 -0
- package/dist/video-editor/evaluate.d.ts +11 -0
- package/dist/video-editor/export.d.cts +7 -1
- package/dist/video-editor/export.d.ts +7 -1
- package/dist/video-editor/index.cjs +1857 -531
- package/dist/video-editor/index.d.cts +7 -0
- package/dist/video-editor/index.d.ts +7 -0
- package/dist/video-editor/index.js +1516 -190
- package/dist/video-editor/lut.d.cts +12 -2
- package/dist/video-editor/lut.d.ts +12 -2
- package/dist/video-editor/mask.d.cts +48 -0
- package/dist/video-editor/mask.d.ts +48 -0
- package/dist/video-editor/mix.d.cts +107 -0
- package/dist/video-editor/mix.d.ts +107 -0
- package/dist/video-editor/music-tools.d.cts +19 -0
- package/dist/video-editor/music-tools.d.ts +19 -0
- package/dist/video-editor/parse.d.cts +3 -1
- package/dist/video-editor/parse.d.ts +3 -1
- package/dist/video-editor/plan.d.cts +75 -0
- package/dist/video-editor/plan.d.ts +75 -0
- package/dist/video-editor/render.d.cts +1 -1
- package/dist/video-editor/render.d.ts +1 -1
- package/dist/video-editor/timeline.d.cts +2 -0
- package/dist/video-editor/timeline.d.ts +2 -0
- package/dist/video-editor/tools.d.cts +90 -0
- package/dist/video-editor/tools.d.ts +90 -0
- package/dist/video-editor/transcript-controller.d.cts +106 -0
- package/dist/video-editor/transcript-controller.d.ts +106 -0
- package/dist/video-editor/transcript.d.cts +40 -0
- package/dist/video-editor/transcript.d.ts +40 -0
- package/dist/video-editor/types.d.cts +62 -2
- package/dist/video-editor/types.d.ts +62 -2
- package/dist/video-editor/ui.d.cts +21 -1
- package/dist/video-editor/ui.d.ts +21 -1
- package/package.json +11 -1
- package/skills/README.md +3 -0
- package/skills/pixerate-bgm-alignment/SKILL.md +82 -0
- package/skills/pixerate-talking-head-edit/SKILL.md +80 -0
- package/skills/pixerate-typography/SKILL.md +91 -0
- package/skills/pixerate-video-editor/SKILL.md +40 -2
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
var
|
|
21
|
+
var _chunk236TKNURcjs = require('./chunk-236TKNUR.cjs');
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
|
|
@@ -29,7 +29,7 @@ var _chunkGF2RBSDMcjs = require('./chunk-GF2RBSDM.cjs');
|
|
|
29
29
|
var _chunkDWJJI6RTcjs = require('./chunk-DWJJI6RT.cjs');
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
var
|
|
32
|
+
var _chunkCIPIESX4cjs = require('./chunk-CIPIESX4.cjs');
|
|
33
33
|
|
|
34
34
|
// src/vector/blend.ts
|
|
35
35
|
var lerpN = (a, b, t) => a + (b - a) * t;
|
|
@@ -37,7 +37,7 @@ var lerpP = (a, b, t) => [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t];
|
|
|
37
37
|
var toP = (v) => [v.x, v.y];
|
|
38
38
|
var mapP = (m, p) => [m[0] * p[0] + m[2] * p[1] + m[4], m[1] * p[0] + m[3] * p[1] + m[5]];
|
|
39
39
|
var curvesOf = (c) => Math.max(0, (c.pts.length - 1) / 3) | 0;
|
|
40
|
-
function subpathToMorphContour(sp, m =
|
|
40
|
+
function subpathToMorphContour(sp, m = _chunk236TKNURcjs.IDENTITY_MATRIX) {
|
|
41
41
|
const n = sp.anchors.length;
|
|
42
42
|
if (!n) return null;
|
|
43
43
|
const first = mapP(m, toP(sp.anchors[0]));
|
|
@@ -67,8 +67,8 @@ function isStraight(p0, p1, p2, p3) {
|
|
|
67
67
|
const u2 = along(p2);
|
|
68
68
|
return off(p1) < tol && off(p2) < tol && u1 >= -1e-9 && u1 <= 1 + 1e-9 && u2 >= -1e-9 && u2 <= 1 + 1e-9;
|
|
69
69
|
}
|
|
70
|
-
function morphContourToSubpath(c, m =
|
|
71
|
-
const pts =
|
|
70
|
+
function morphContourToSubpath(c, m = _chunk236TKNURcjs.IDENTITY_MATRIX, closed = c.closed) {
|
|
71
|
+
const pts = _chunk236TKNURcjs.isIdentityMatrix.call(void 0, m) ? c.pts : c.pts.map((p) => mapP(m, p));
|
|
72
72
|
const curves = curvesOf(c);
|
|
73
73
|
const dropLast = closed && c.closed && curves > 0;
|
|
74
74
|
const count = dropLast ? curves : curves + 1;
|
|
@@ -84,7 +84,7 @@ function morphContourToSubpath(c, m = _chunkQMI5HZWAcjs.IDENTITY_MATRIX, closed
|
|
|
84
84
|
anchors[(k + 1) % count].in = { x: p2[0], y: p2[1] };
|
|
85
85
|
}
|
|
86
86
|
for (const a of anchors) {
|
|
87
|
-
const type =
|
|
87
|
+
const type = _chunk236TKNURcjs.inferAnchorType.call(void 0, a);
|
|
88
88
|
if (type !== "corner") a.type = type;
|
|
89
89
|
}
|
|
90
90
|
const isClosed = closed && curves > 0;
|
|
@@ -267,7 +267,7 @@ function bestStart(fixed, free, useShapeContext) {
|
|
|
267
267
|
return best;
|
|
268
268
|
}
|
|
269
269
|
function placeIn(c, from, to) {
|
|
270
|
-
const b =
|
|
270
|
+
const b = _chunk236TKNURcjs.unionBounds.call(void 0, [boundsOfPoints(c.pts)]);
|
|
271
271
|
const p = b ? [b.x + b.width / 2, b.y + b.height / 2] : c.pts[0];
|
|
272
272
|
if (!from || !to) return p;
|
|
273
273
|
const fx = from.width > 0 ? (p[0] - from.x) / from.width : 0.5;
|
|
@@ -452,11 +452,11 @@ function interpolateRigidMatrix(a, b, t) {
|
|
|
452
452
|
function interpolateVectorColor(a, b, t) {
|
|
453
453
|
if (t <= 0) return a;
|
|
454
454
|
if (t >= 1) return b;
|
|
455
|
-
return _nullishCoalesce(
|
|
455
|
+
return _nullishCoalesce(_chunkCIPIESX4cjs.mixColorsOklab.call(void 0, a, b, t), () => ( (t < 0.5 ? a : b)));
|
|
456
456
|
}
|
|
457
457
|
function resampleGradientStops(g, offsets) {
|
|
458
458
|
return offsets.map((offset) => {
|
|
459
|
-
const s =
|
|
459
|
+
const s = _chunk236TKNURcjs.sampleVectorGradient.call(void 0, g, offset);
|
|
460
460
|
return s.opacity < 1 ? { offset, color: s.color, opacity: Math.round(s.opacity * 1e4) / 1e4 } : { offset, color: s.color };
|
|
461
461
|
});
|
|
462
462
|
}
|
|
@@ -467,11 +467,11 @@ function lerpAngle(a, b, t) {
|
|
|
467
467
|
var lerpPoint = (a, b, t) => ({ x: lerpN(a.x, b.x, t), y: lerpN(a.y, b.y, t) });
|
|
468
468
|
var sameColourModel = (a, b) => (_nullishCoalesce(a.interpolation, () => ( "srgb"))) === (_nullishCoalesce(b.interpolation, () => ( "srgb"))) && (_nullishCoalesce(a.smoothness, () => ( 0))) === (_nullishCoalesce(b.smoothness, () => ( 0)));
|
|
469
469
|
function lerpStops(a, b, t) {
|
|
470
|
-
let stopsA =
|
|
471
|
-
let stopsB =
|
|
470
|
+
let stopsA = _chunk236TKNURcjs.sortedVectorGradientStops.call(void 0, a);
|
|
471
|
+
let stopsB = _chunk236TKNURcjs.sortedVectorGradientStops.call(void 0, b);
|
|
472
472
|
const resampled = stopsA.length !== stopsB.length || !sameColourModel(a, b);
|
|
473
473
|
if (resampled) {
|
|
474
|
-
const offs = [...
|
|
474
|
+
const offs = [..._chunk236TKNURcjs.expandVectorGradientStops.call(void 0, a), ..._chunk236TKNURcjs.expandVectorGradientStops.call(void 0, b), ...stopsA, ...stopsB].map((s) => s.offset).filter(Number.isFinite).sort((x, y) => x - y);
|
|
475
475
|
const common = offs.filter((o, i) => i === 0 || o - offs[i - 1] > 1e-4);
|
|
476
476
|
stopsA = resampleGradientStops(a, common);
|
|
477
477
|
stopsB = resampleGradientStops(b, common);
|
|
@@ -498,8 +498,8 @@ function lerpGradient(a, b, t) {
|
|
|
498
498
|
}
|
|
499
499
|
if (near.spread && near.spread !== "pad") out.spread = near.spread;
|
|
500
500
|
if (near.strokeMode && near.strokeMode !== "within") out.strokeMode = near.strokeMode;
|
|
501
|
-
const ea =
|
|
502
|
-
const eb =
|
|
501
|
+
const ea = _chunk236TKNURcjs.hasExplicitGradientGeometry.call(void 0, a);
|
|
502
|
+
const eb = _chunk236TKNURcjs.hasExplicitGradientGeometry.call(void 0, b);
|
|
503
503
|
if (!ea && !eb) {
|
|
504
504
|
if (a.angle !== void 0 || b.angle !== void 0 || a.type === "linear" || a.type === "reflected") {
|
|
505
505
|
const fallback = a.type === "linear" || a.type === "reflected" ? 180 : 90;
|
|
@@ -512,10 +512,10 @@ function lerpGradient(a, b, t) {
|
|
|
512
512
|
}
|
|
513
513
|
return out;
|
|
514
514
|
}
|
|
515
|
-
const pa =
|
|
516
|
-
const pb =
|
|
515
|
+
const pa = _chunk236TKNURcjs.vectorGradientPoints.call(void 0, a);
|
|
516
|
+
const pb = _chunk236TKNURcjs.vectorGradientPoints.call(void 0, b);
|
|
517
517
|
if (pa.units !== pb.units) {
|
|
518
|
-
const src =
|
|
518
|
+
const src = _chunk236TKNURcjs.explicitVectorGradient.call(void 0, near);
|
|
519
519
|
return { ...src, stops: out.stops, ...out.interpolation ? { interpolation: out.interpolation } : {}, ...out.smoothness ? { smoothness: out.smoothness } : {} };
|
|
520
520
|
}
|
|
521
521
|
out.start = lerpPoint(pa.start, pb.start, t);
|
|
@@ -535,14 +535,14 @@ function solidLike(color, like) {
|
|
|
535
535
|
function interpolateVectorPaint(a, b, t) {
|
|
536
536
|
if (t <= 0) return a;
|
|
537
537
|
if (t >= 1) return b;
|
|
538
|
-
const pa =
|
|
539
|
-
const pb =
|
|
538
|
+
const pa = _chunk236TKNURcjs.hasPaint.call(void 0, a);
|
|
539
|
+
const pb = _chunk236TKNURcjs.hasPaint.call(void 0, b);
|
|
540
540
|
if (!pa && !pb) return t < 0.5 ? a : b;
|
|
541
541
|
if (typeof a === "string" && pa && typeof b === "string" && pb) return interpolateVectorColor(a, b, t);
|
|
542
542
|
if (!pa && typeof b === "string") return interpolateVectorColor("transparent", b, t);
|
|
543
543
|
if (!pb && typeof a === "string") return interpolateVectorColor(a, "transparent", t);
|
|
544
|
-
const ga = pa &&
|
|
545
|
-
const gb = pb &&
|
|
544
|
+
const ga = pa && _chunk236TKNURcjs.isVectorGradient.call(void 0, a) ? a : null;
|
|
545
|
+
const gb = pb && _chunk236TKNURcjs.isVectorGradient.call(void 0, b) ? b : null;
|
|
546
546
|
if (ga && gb) return _nullishCoalesce(lerpGradient(ga, gb, t), () => ( (t < 0.5 ? a : b)));
|
|
547
547
|
if (gb) return _nullishCoalesce(lerpGradient(solidLike(pa ? a : null, gb), gb, t), () => ( b));
|
|
548
548
|
if (ga) return _nullishCoalesce(lerpGradient(ga, solidLike(pb ? b : null, ga), t), () => ( a));
|
|
@@ -553,8 +553,8 @@ function interpolateWidthProfiles(a, b, t) {
|
|
|
553
553
|
const at = [..._nullishCoalesce(a, () => ( [])), ..._nullishCoalesce(b, () => ( [])), { t: 0 }, { t: 1 }].map((p) => p.t).sort((x, y) => x - y);
|
|
554
554
|
const ts = at.filter((v, i) => i === 0 || v - at[i - 1] > 1e-6);
|
|
555
555
|
return ts.map((pos) => {
|
|
556
|
-
const x =
|
|
557
|
-
const y =
|
|
556
|
+
const x = _chunk236TKNURcjs.widthProfileAt.call(void 0, a, pos);
|
|
557
|
+
const y = _chunk236TKNURcjs.widthProfileAt.call(void 0, b, pos);
|
|
558
558
|
return { t: pos, left: lerpN(x.left, y.left, t), right: lerpN(x.right, y.right, t) };
|
|
559
559
|
});
|
|
560
560
|
}
|
|
@@ -597,7 +597,7 @@ function reversedStyle(s) {
|
|
|
597
597
|
out.endArrow = s.startArrow;
|
|
598
598
|
out.startArrowScale = s.endArrowScale;
|
|
599
599
|
out.endArrowScale = s.startArrowScale;
|
|
600
|
-
if (_optionalChain([s, 'access', _6 => _6.strokeWidthProfile, 'optionalAccess', _7 => _7.length])) out.strokeWidthProfile =
|
|
600
|
+
if (_optionalChain([s, 'access', _6 => _6.strokeWidthProfile, 'optionalAccess', _7 => _7.length])) out.strokeWidthProfile = _chunk236TKNURcjs.reverseWidthProfile.call(void 0, s.strokeWidthProfile);
|
|
601
601
|
for (const k of ["startArrow", "endArrow", "startArrowScale", "endArrowScale"]) if (out[k] === void 0) delete out[k];
|
|
602
602
|
return out;
|
|
603
603
|
}
|
|
@@ -623,19 +623,19 @@ function styleOf(n) {
|
|
|
623
623
|
return out;
|
|
624
624
|
}
|
|
625
625
|
function contoursOf(node, m) {
|
|
626
|
-
return
|
|
626
|
+
return _chunk236TKNURcjs.expandVectorCorners.call(void 0, node.subpaths).map((sp) => subpathToMorphContour(sp, m)).filter((c) => !!c);
|
|
627
627
|
}
|
|
628
|
-
function preparePathMorph(a, b, options, ma =
|
|
628
|
+
function preparePathMorph(a, b, options, ma = _chunk236TKNURcjs.nodeMatrix.call(void 0, a), mb = _chunk236TKNURcjs.nodeMatrix.call(void 0, b)) {
|
|
629
629
|
const corr = correspondMorphContours(contoursOf(a, ma), contoursOf(b, mb), options);
|
|
630
630
|
const sim = procrustes(corr.a, corr.b);
|
|
631
631
|
const styleA = styleOf(a);
|
|
632
632
|
const styleB = corr.reversed ? reversedStyle(styleOf(b)) : styleOf(b);
|
|
633
|
-
const rigid = !
|
|
633
|
+
const rigid = !_chunk236TKNURcjs.isIdentityMatrix.call(void 0, ma) || !_chunk236TKNURcjs.isIdentityMatrix.call(void 0, mb);
|
|
634
634
|
const id = _nullishCoalesce(options.id, () => ( a.id));
|
|
635
635
|
return (t) => {
|
|
636
636
|
const contours = interpolateMorphContours(corr.a, corr.b, t, { linear: options.linear, rigidity: options.rigidity, similarity: sim });
|
|
637
|
-
const m = rigid ? interpolateRigidMatrix(ma, mb, t) :
|
|
638
|
-
const back = rigid ?
|
|
637
|
+
const m = rigid ? interpolateRigidMatrix(ma, mb, t) : _chunk236TKNURcjs.IDENTITY_MATRIX;
|
|
638
|
+
const back = rigid ? _chunk236TKNURcjs.invertMatrix.call(void 0, m) : _chunk236TKNURcjs.IDENTITY_MATRIX;
|
|
639
639
|
const subpaths = contours.map((c, k) => {
|
|
640
640
|
const closed = t <= 0 ? corr.a[k].closed : t >= 1 ? corr.b[k].closed : corr.a[k].closed && corr.b[k].closed;
|
|
641
641
|
return morphContourToSubpath({ closed: corr.a[k].closed && corr.b[k].closed, pts: c.pts }, back, closed);
|
|
@@ -643,14 +643,14 @@ function preparePathMorph(a, b, options, ma = _chunkQMI5HZWAcjs.nodeMatrix.call(
|
|
|
643
643
|
const node = { id, type: "path", subpaths, ...interpolateVectorStyle(styleA, styleB, t) };
|
|
644
644
|
const opacity = lerpN(_nullishCoalesce(a.opacity, () => ( 1)), _nullishCoalesce(b.opacity, () => ( 1)), t);
|
|
645
645
|
if (opacity < 1) node.opacity = opacity;
|
|
646
|
-
if (rigid && !
|
|
646
|
+
if (rigid && !_chunk236TKNURcjs.isIdentityMatrix.call(void 0, m)) node.transform = m;
|
|
647
647
|
return node;
|
|
648
648
|
};
|
|
649
649
|
}
|
|
650
|
-
function flattenPaths(node, parent =
|
|
651
|
-
const m =
|
|
650
|
+
function flattenPaths(node, parent = _chunk236TKNURcjs.IDENTITY_MATRIX) {
|
|
651
|
+
const m = _chunk236TKNURcjs.multiplyMatrices.call(void 0, _chunk236TKNURcjs.nodeMatrix.call(void 0, node), parent);
|
|
652
652
|
if (node.type === "path") return [{ path: node, m, opacity: 1 }];
|
|
653
|
-
if (node.type === "text" || node.type === "instance") return flattenPaths(
|
|
653
|
+
if (node.type === "text" || node.type === "instance") return flattenPaths(_chunk236TKNURcjs.expandVectorAppearance.call(void 0, node), parent);
|
|
654
654
|
const o = _nullishCoalesce(node.opacity, () => ( 1));
|
|
655
655
|
return node.children.filter((c) => c.visible !== false).flatMap((c) => flattenPaths(c, m)).map((e) => ({ ...e, opacity: e.opacity * o }));
|
|
656
656
|
}
|
|
@@ -672,8 +672,8 @@ function createVectorMorph(a, b, options = {}) {
|
|
|
672
672
|
}
|
|
673
673
|
const pa = flattenPaths(a);
|
|
674
674
|
const pb = flattenPaths(b);
|
|
675
|
-
const ba =
|
|
676
|
-
const bb =
|
|
675
|
+
const ba = _chunk236TKNURcjs.unionBounds.call(void 0, pa.map((e) => placedBounds(e.path, e.m)));
|
|
676
|
+
const bb = _chunk236TKNURcjs.unionBounds.call(void 0, pb.map((e) => placedBounds(e.path, e.m)));
|
|
677
677
|
const id = _nullishCoalesce(options.id, () => ( a.id));
|
|
678
678
|
const parts = [];
|
|
679
679
|
const opacities = [];
|
|
@@ -685,10 +685,10 @@ function createVectorMorph(a, b, options = {}) {
|
|
|
685
685
|
parts.push(preparePathMorph(x.path, y.path, sub, x.m, y.m));
|
|
686
686
|
opacities.push([x.opacity, y.opacity]);
|
|
687
687
|
} else if (x) {
|
|
688
|
-
parts.push(preparePathMorph(x.path, collapsedPath(x.path, x.m, ba, bb), sub, x.m,
|
|
688
|
+
parts.push(preparePathMorph(x.path, collapsedPath(x.path, x.m, ba, bb), sub, x.m, _chunk236TKNURcjs.IDENTITY_MATRIX));
|
|
689
689
|
opacities.push([x.opacity, x.opacity]);
|
|
690
690
|
} else if (y) {
|
|
691
|
-
parts.push(preparePathMorph(collapsedPath(y.path, y.m, bb, ba), y.path, sub,
|
|
691
|
+
parts.push(preparePathMorph(collapsedPath(y.path, y.m, bb, ba), y.path, sub, _chunk236TKNURcjs.IDENTITY_MATRIX, y.m));
|
|
692
692
|
opacities.push([y.opacity, y.opacity]);
|
|
693
693
|
}
|
|
694
694
|
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkHDGBM7EAcjs = require('./chunk-HDGBM7EA.cjs');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
@@ -27,7 +27,7 @@ var _chunk4YWAEV4Wcjs = require('./chunk-4YWAEV4W.cjs');
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
var
|
|
30
|
+
var _chunkLL3H5XUHcjs = require('./chunk-LL3H5XUH.cjs');
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
|
|
@@ -63,7 +63,7 @@ function splitOutside(text, sep) {
|
|
|
63
63
|
return out;
|
|
64
64
|
}
|
|
65
65
|
function chartMermaidFamily(spec) {
|
|
66
|
-
const family =
|
|
66
|
+
const family = _chunkLL3H5XUHcjs.chartFamily.call(void 0, spec);
|
|
67
67
|
if (family === "pie" || family === "funnel" || family === "treemap") return "pie";
|
|
68
68
|
if (family === "radar") return "radar";
|
|
69
69
|
return "xychart";
|
|
@@ -227,8 +227,8 @@ function chartFromMermaid(text, options = {}) {
|
|
|
227
227
|
let title = _nullishCoalesce(frontTitle, () => ( ""));
|
|
228
228
|
const categories = [];
|
|
229
229
|
const series = [];
|
|
230
|
-
const xAxis =
|
|
231
|
-
const yAxis =
|
|
230
|
+
const xAxis = _chunkLL3H5XUHcjs.defaultChartAxis.call(void 0, false);
|
|
231
|
+
const yAxis = _chunkLL3H5XUHcjs.defaultChartAxis.call(void 0, true);
|
|
232
232
|
const radarAxes = [];
|
|
233
233
|
const pieSlices = [];
|
|
234
234
|
let legendShow = true;
|
|
@@ -388,7 +388,7 @@ function chartFromMermaid(text, options = {}) {
|
|
|
388
388
|
input.series = metaSeries.map((extra, i) => ({ ..._nullishCoalesce(base[i], () => ( {})), ..._nullishCoalesce(extra, () => ( {})) }));
|
|
389
389
|
}
|
|
390
390
|
}
|
|
391
|
-
const { spec, issues: specIssues } =
|
|
391
|
+
const { spec, issues: specIssues } = _chunkLL3H5XUHcjs.normalizeChartSpec.call(void 0, input);
|
|
392
392
|
if (!family && !partial && !issues.length) issues.push({ path: "header", message: "The text is empty: expected a chart header (xychart-beta, pie or radar-beta)." });
|
|
393
393
|
return { spec, issues: [...issues, ...specIssues], family, hasMeta: !!meta };
|
|
394
394
|
}
|
|
@@ -427,11 +427,11 @@ function findMermaidCharts(text) {
|
|
|
427
427
|
}
|
|
428
428
|
|
|
429
429
|
// src/chart/summary.ts
|
|
430
|
-
function summarizeChart(spec, size = { width: 640, height: 400 }, scene =
|
|
430
|
+
function summarizeChart(spec, size = { width: 640, height: 400 }, scene = _chunkHDGBM7EAcjs.layoutChart.call(void 0, spec, { ...size, selection: null })) {
|
|
431
431
|
const visible = spec.series.filter((s) => !s.hidden);
|
|
432
|
-
const series = visible.map((s) =>
|
|
433
|
-
const colors =
|
|
434
|
-
const check =
|
|
432
|
+
const series = visible.map((s) => _chunkHDGBM7EAcjs.summarizeChartSeries.call(void 0, s, spec.categories));
|
|
433
|
+
const colors = _chunkLL3H5XUHcjs.chartColorsByCategory.call(void 0, spec.type) ? spec.categories.map((_, i) => _optionalChain([visible, 'access', _10 => _10[0], 'optionalAccess', _11 => _11.pointColors, 'optionalAccess', _12 => _12[i]]) || _chunkLL3H5XUHcjs.chartSliceColor.call(void 0, spec, i)) : visible.map((s) => _chunkLL3H5XUHcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(s)));
|
|
434
|
+
const check = _chunkLL3H5XUHcjs.checkChartColors.call(void 0, colors, { surface: scene.theme.surface.startsWith("var(") ? "#ffffff" : scene.theme.surface });
|
|
435
435
|
const axis = (s, a) => s ? { min: s.domain[0], max: s.domain[1], ticks: [...s.ticks], ...s.logBase ? { logBase: s.logBase } : {}, ...a.reverse ? { reversed: true } : {} } : void 0;
|
|
436
436
|
return {
|
|
437
437
|
type: spec.type,
|
|
@@ -446,12 +446,12 @@ function summarizeChart(spec, size = { width: 640, height: 400 }, scene = _chunk
|
|
|
446
446
|
description: describeChart(spec, series)
|
|
447
447
|
};
|
|
448
448
|
}
|
|
449
|
-
function describeChart(spec, series = spec.series.filter((s) => !s.hidden).map((s) =>
|
|
450
|
-
const kind =
|
|
449
|
+
function describeChart(spec, series = spec.series.filter((s) => !s.hidden).map((s) => _chunkHDGBM7EAcjs.summarizeChartSeries.call(void 0, s, spec.categories))) {
|
|
450
|
+
const kind = _chunkLL3H5XUHcjs.CHART_TYPE_LABELS[spec.type].toLowerCase();
|
|
451
451
|
const parts = [];
|
|
452
|
-
const family =
|
|
452
|
+
const family = _chunkLL3H5XUHcjs.chartFamily.call(void 0, spec);
|
|
453
453
|
const format = spec.yAxis.format;
|
|
454
|
-
const fmt = (v) => v === null ? "blank" :
|
|
454
|
+
const fmt = (v) => v === null ? "blank" : _chunkHDGBM7EAcjs.formatChartNumber.call(void 0, v, format);
|
|
455
455
|
const head = spec.title ? `${spec.title}: a ${kind} chart` : `A ${kind} chart`;
|
|
456
456
|
if (!series.length || series.every((s) => s.count === 0)) return `${head} with no data.`;
|
|
457
457
|
if (family === "pie" || family === "funnel" || family === "treemap") {
|
|
@@ -499,7 +499,7 @@ function describeChart(spec, series = spec.series.filter((s) => !s.hidden).map((
|
|
|
499
499
|
}
|
|
500
500
|
parts.push(...axes);
|
|
501
501
|
for (const s of spec.series.filter((x) => !x.hidden && (x.errorBars || x.xErrorBars)).slice(0, 8)) {
|
|
502
|
-
const bars = [s.errorBars ?
|
|
502
|
+
const bars = [s.errorBars ? _chunkLL3H5XUHcjs.describeChartErrorBars.call(void 0, s.errorBars) : "", s.xErrorBars ? `x ${_chunkLL3H5XUHcjs.describeChartErrorBars.call(void 0, s.xErrorBars)}` : ""].filter(Boolean).join(" and ");
|
|
503
503
|
parts.push(`${s.name} has ${bars}.`);
|
|
504
504
|
}
|
|
505
505
|
return parts.join(" ");
|
|
@@ -564,7 +564,7 @@ function chartSceneToSvg(scene, options = {}) {
|
|
|
564
564
|
return `<svg xmlns="http://www.w3.org/2000/svg" width="${scene.width}" height="${scene.height}" viewBox="0 0 ${scene.width} ${scene.height}" role="img"${label ? ` aria-label="${escape(label)}"` : ""}${labelled ? ` aria-labelledby="${labelled}"` : ""}>${head}${body}</svg>`;
|
|
565
565
|
}
|
|
566
566
|
function chartToSvg(spec, options) {
|
|
567
|
-
const scene =
|
|
567
|
+
const scene = _chunkHDGBM7EAcjs.layoutChart.call(void 0, spec, { ...options, selection: null });
|
|
568
568
|
return chartSceneToSvg(scene, { ...options, ariaLabel: _nullishCoalesce(options.ariaLabel, () => ( (spec.title || void 0))), description: _nullishCoalesce(options.description, () => ( describeChart(spec))) });
|
|
569
569
|
}
|
|
570
570
|
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
@@ -602,10 +602,10 @@ var CHART_LAYOUT_PRESETS = [
|
|
|
602
602
|
];
|
|
603
603
|
function monochromeChartPalette(base, count = 6) {
|
|
604
604
|
const steps = count <= 1 ? [0] : Array.from({ length: count }, (_, i) => -0.45 + 1.05 * i / (count - 1));
|
|
605
|
-
return steps.map((t) =>
|
|
605
|
+
return steps.map((t) => _chunkLL3H5XUHcjs.shadeChartColor.call(void 0, base, t));
|
|
606
606
|
}
|
|
607
607
|
var CHART_COLOR_SCHEMES = [
|
|
608
|
-
{ id: "default", label: "Default", description: "Ten distinct colours, readable on light and dark backgrounds.", palette:
|
|
608
|
+
{ id: "default", label: "Default", description: "Ten distinct colours, readable on light and dark backgrounds.", palette: _chunkLL3H5XUHcjs.DEFAULT_CHART_PALETTE },
|
|
609
609
|
{ id: "okabe-ito", label: "Okabe\u2013Ito", description: "Eight colours chosen to stay distinct with colour-blindness.", palette: ["#e69f00", "#56b4e9", "#009e73", "#f0e442", "#0072b2", "#d55e00", "#cc79a7", "#000000"] },
|
|
610
610
|
{ id: "office", label: "Office", description: "The six accent colours of the default Office theme.", palette: ["#4472c4", "#ed7d31", "#a5a5a5", "#ffc000", "#5b9bd5", "#70ad47"] },
|
|
611
611
|
{ id: "warm", label: "Warm", description: "Reds, oranges and yellows.", palette: ["#b2182b", "#d6604d", "#f4a582", "#e08214", "#fdb863", "#8c510a"] },
|
|
@@ -664,7 +664,7 @@ var ChartController = (_class = class {
|
|
|
664
664
|
constructor(options = {}) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);_class.prototype.__init6.call(this);_class.prototype.__init7.call(this);_class.prototype.__init8.call(this);_class.prototype.__init9.call(this);_class.prototype.__init10.call(this);
|
|
665
665
|
this.history = _nullishCoalesce(options.history, () => ( new (0, _chunkFJ2MSI43cjs.HistoryManager)()));
|
|
666
666
|
this.onChange = options.onChange;
|
|
667
|
-
const { spec, issues } =
|
|
667
|
+
const { spec, issues } = _chunkLL3H5XUHcjs.normalizeChartSpec.call(void 0, _nullishCoalesce(options.spec, () => ( {})));
|
|
668
668
|
this.spec = spec;
|
|
669
669
|
this.issues = issues;
|
|
670
670
|
this.state = this.computeState();
|
|
@@ -767,7 +767,7 @@ var ChartController = (_class = class {
|
|
|
767
767
|
const hadIssues = this.issues.length > 0;
|
|
768
768
|
this.issues = [];
|
|
769
769
|
if (sameChartJson(before, next)) {
|
|
770
|
-
const reselect = select !== void 0 && !
|
|
770
|
+
const reselect = select !== void 0 && !_chunkHDGBM7EAcjs.sameChartSelection.call(void 0, this.selection, select) && !(select === null && this.selection === null);
|
|
771
771
|
if (reselect) this.selection = select;
|
|
772
772
|
if (reselect || hadIssues) this.notify(false);
|
|
773
773
|
return;
|
|
@@ -790,7 +790,7 @@ var ChartController = (_class = class {
|
|
|
790
790
|
}
|
|
791
791
|
/** A copy of the spec with `edit` applied (series and categories copied as needed). */
|
|
792
792
|
edited(edit) {
|
|
793
|
-
const draft =
|
|
793
|
+
const draft = _chunkLL3H5XUHcjs.cloneChartSpec.call(void 0, this.spec);
|
|
794
794
|
edit(draft);
|
|
795
795
|
return draft;
|
|
796
796
|
}
|
|
@@ -820,7 +820,7 @@ var ChartController = (_class = class {
|
|
|
820
820
|
legend: patch.legend ? { ...s.legend, ...patch.legend } : s.legend,
|
|
821
821
|
version: 1
|
|
822
822
|
};
|
|
823
|
-
const { spec, issues } =
|
|
823
|
+
const { spec, issues } = _chunkLL3H5XUHcjs.normalizeChartSpec.call(void 0, merged);
|
|
824
824
|
if (issues.length) return this.reject(issues.map((i) => i.message).join(" "), issues);
|
|
825
825
|
if (JSON.stringify(spec) === JSON.stringify(s)) return { ok: true };
|
|
826
826
|
this.commit(_nullishCoalesce(options.label, () => ( updateLabel(patch))), spec);
|
|
@@ -871,7 +871,7 @@ var ChartController = (_class = class {
|
|
|
871
871
|
const series = this.getSeries(seriesId);
|
|
872
872
|
if (!series) return this.unknownSeries(seriesId);
|
|
873
873
|
if (!Number.isInteger(index) || index < 0 || index >= this.spec.categories.length) return this.badIndex(index);
|
|
874
|
-
const parsed =
|
|
874
|
+
const parsed = _chunkLL3H5XUHcjs.parseChartValue.call(void 0, value);
|
|
875
875
|
if (parsed === void 0) return this.reject(`"${String(value)}" is not a number; enter a number or leave the cell blank.`, [{ path: `${seriesId}[${index}]`, message: `"${String(value)}" is not a number.` }]);
|
|
876
876
|
if (series.values[index] === parsed) {
|
|
877
877
|
if (this.issues.length) {
|
|
@@ -894,7 +894,7 @@ var ChartController = (_class = class {
|
|
|
894
894
|
if (!this.getSeries(cell.seriesId)) issues.push({ path: cell.seriesId, message: this.unknownSeries(cell.seriesId).message });
|
|
895
895
|
else if (!Number.isInteger(cell.index) || cell.index < 0 || cell.index >= this.spec.categories.length) issues.push({ path: `${cell.seriesId}[${cell.index}]`, message: this.badIndex(cell.index).message });
|
|
896
896
|
else {
|
|
897
|
-
const value =
|
|
897
|
+
const value = _chunkLL3H5XUHcjs.parseChartValue.call(void 0, cell.value);
|
|
898
898
|
if (value === void 0) issues.push({ path: `${cell.seriesId}[${cell.index}]`, message: `"${String(cell.value)}" is not a number.` });
|
|
899
899
|
else parsed.push({ seriesId: cell.seriesId, index: cell.index, value });
|
|
900
900
|
}
|
|
@@ -908,12 +908,12 @@ var ChartController = (_class = class {
|
|
|
908
908
|
}
|
|
909
909
|
/** Adds a series (values padded to the categories) and selects it. Returns its id. */
|
|
910
910
|
addSeries(input = {}, options = {}) {
|
|
911
|
-
const id = input.id && !this.getSeries(input.id) ? input.id :
|
|
911
|
+
const id = input.id && !this.getSeries(input.id) ? input.id : _chunkLL3H5XUHcjs.uniqueChartSeriesId.call(void 0, this.spec.series);
|
|
912
912
|
const name = _nullishCoalesce(input.name, () => ( `Series ${this.spec.series.length + 1}`));
|
|
913
913
|
const at = Math.max(0, Math.min(this.spec.series.length, _nullishCoalesce(options.at, () => ( this.spec.series.length))));
|
|
914
914
|
const series = [...this.spec.series];
|
|
915
915
|
series.splice(at, 0, { ...input, id, name, values: _nullishCoalesce(input.values, () => ( [])) });
|
|
916
|
-
const { spec, issues } =
|
|
916
|
+
const { spec, issues } = _chunkLL3H5XUHcjs.normalizeChartSpec.call(void 0, { ...this.spec, series });
|
|
917
917
|
if (issues.length) return this.reject(issues.map((i) => i.message).join(" "), issues);
|
|
918
918
|
this.commit(`Add series "${name}"`, spec, { kind: "series", seriesId: id });
|
|
919
919
|
return { ok: true, id };
|
|
@@ -932,7 +932,7 @@ var ChartController = (_class = class {
|
|
|
932
932
|
updateSeries(id, patch) {
|
|
933
933
|
const series = this.getSeries(id);
|
|
934
934
|
if (!series) return this.unknownSeries(id);
|
|
935
|
-
const next =
|
|
935
|
+
const next = _chunkLL3H5XUHcjs.cloneChartSeries.call(void 0, series);
|
|
936
936
|
if (patch.name !== void 0) next.name = String(patch.name);
|
|
937
937
|
if (patch.color === null || patch.color === "") delete next.color;
|
|
938
938
|
else if (patch.color !== void 0) next.color = patch.color;
|
|
@@ -950,7 +950,7 @@ var ChartController = (_class = class {
|
|
|
950
950
|
}
|
|
951
951
|
if (next.axis === "primary") delete next.axis;
|
|
952
952
|
const series2 = this.spec.series.map((s) => s.id === id ? next : s);
|
|
953
|
-
const { spec, issues } =
|
|
953
|
+
const { spec, issues } = _chunkLL3H5XUHcjs.normalizeChartSpec.call(void 0, { ...this.spec, series: series2 });
|
|
954
954
|
if (issues.length) return this.reject(issues.map((i) => i.message).join(" "), issues);
|
|
955
955
|
if (JSON.stringify(spec.series) === JSON.stringify(this.spec.series)) return { ok: true };
|
|
956
956
|
const label = patch.hidden !== void 0 && Object.keys(patch).length === 1 ? `${patch.hidden ? "Hide" : "Show"} "${series.name}"` : patch.name !== void 0 && Object.keys(patch).length === 1 ? "Rename series" : `Change series "${series.name}"`;
|
|
@@ -1043,7 +1043,7 @@ var ChartController = (_class = class {
|
|
|
1043
1043
|
const width = Math.max(...rows.map((r) => r.length));
|
|
1044
1044
|
const lastSeries = column + width - 1;
|
|
1045
1045
|
while (d.series.length <= lastSeries) {
|
|
1046
|
-
const id =
|
|
1046
|
+
const id = _chunkLL3H5XUHcjs.uniqueChartSeriesId.call(void 0, d.series);
|
|
1047
1047
|
d.series.push({ id, name: `Series ${d.series.length + 1}`, values: d.categories.map(() => null) });
|
|
1048
1048
|
}
|
|
1049
1049
|
const lastRow = row + rows.length - 1;
|
|
@@ -1057,7 +1057,7 @@ var ChartController = (_class = class {
|
|
|
1057
1057
|
const index = row + r;
|
|
1058
1058
|
if (col < 0) d.categories[index] = cell === null || cell === void 0 ? "" : String(cell).trim();
|
|
1059
1059
|
else {
|
|
1060
|
-
const parsed =
|
|
1060
|
+
const parsed = _chunkLL3H5XUHcjs.parseChartValue.call(void 0, cell);
|
|
1061
1061
|
if (parsed === void 0) issues.push({ path: `${d.series[col].id}[${index}]`, message: `"${String(cell)}" is not a number; it was left blank.` });
|
|
1062
1062
|
d.series[col].values[index] = _nullishCoalesce(parsed, () => ( null));
|
|
1063
1063
|
}
|
|
@@ -1076,14 +1076,14 @@ var ChartController = (_class = class {
|
|
|
1076
1076
|
* colours and types are kept by name.
|
|
1077
1077
|
*/
|
|
1078
1078
|
importTable(rows, options = {}) {
|
|
1079
|
-
const data =
|
|
1079
|
+
const data = _chunkLL3H5XUHcjs.chartDataFromTable.call(void 0, rows, options);
|
|
1080
1080
|
if (!data.categories.length || !data.series.length) return this.reject("There is no data to import: expected a header row and at least one row of values.");
|
|
1081
1081
|
const byName = new Map(this.spec.series.map((s) => [s.name, s]));
|
|
1082
1082
|
const series = data.series.map((s) => {
|
|
1083
1083
|
const old = byName.get(s.name);
|
|
1084
1084
|
return { ...s, ..._optionalChain([old, 'optionalAccess', _27 => _27.color]) ? { color: old.color } : {}, ..._optionalChain([old, 'optionalAccess', _28 => _28.type]) ? { type: old.type } : {}, ...old ? { id: old.id } : {} };
|
|
1085
1085
|
});
|
|
1086
|
-
const { spec } =
|
|
1086
|
+
const { spec } = _chunkLL3H5XUHcjs.normalizeChartSpec.call(void 0, { ...this.spec, categories: data.categories, series });
|
|
1087
1087
|
this.commit("Import data", spec);
|
|
1088
1088
|
if (data.issues.length) {
|
|
1089
1089
|
this.issues = data.issues;
|
|
@@ -1104,10 +1104,10 @@ var ChartController = (_class = class {
|
|
|
1104
1104
|
addTrendline(seriesId, input) {
|
|
1105
1105
|
const series = this.getSeries(seriesId);
|
|
1106
1106
|
if (!series) return this.unknownSeries(seriesId);
|
|
1107
|
-
if (!
|
|
1107
|
+
if (!_chunkHDGBM7EAcjs.chartSupportsTrendlines.call(void 0, this.spec.type, this.spec.stacking))
|
|
1108
1108
|
return this.reject(`Trendlines need an unstacked bar, line, area, scatter or bubble chart; this is a ${this.spec.stacking !== "none" ? `${this.spec.stacking} ` : ""}${this.spec.type} chart.`);
|
|
1109
1109
|
const issues = [];
|
|
1110
|
-
const line =
|
|
1110
|
+
const line = _chunkLL3H5XUHcjs.normalizeChartTrendline.call(void 0, input, "trendline", issues);
|
|
1111
1111
|
if (!line || issues.length) return this.reject(issues.map((i) => i.message).join(" ") || "The trendline is not valid.", issues);
|
|
1112
1112
|
const index = _nullishCoalesce(_optionalChain([series, 'access', _29 => _29.trendlines, 'optionalAccess', _30 => _30.length]), () => ( 0));
|
|
1113
1113
|
const next = this.edited((d) => {
|
|
@@ -1126,7 +1126,7 @@ var ChartController = (_class = class {
|
|
|
1126
1126
|
const issues = [];
|
|
1127
1127
|
const merged = { ...current, ...patch };
|
|
1128
1128
|
for (const [k, v] of Object.entries(patch)) if (v === null) delete merged[k];
|
|
1129
|
-
const line =
|
|
1129
|
+
const line = _chunkLL3H5XUHcjs.normalizeChartTrendline.call(void 0, merged, "trendline", issues);
|
|
1130
1130
|
if (!line || issues.length) return this.reject(issues.map((i) => i.message).join(" "), issues);
|
|
1131
1131
|
this.commit(
|
|
1132
1132
|
"Change trendline",
|
|
@@ -1154,7 +1154,7 @@ var ChartController = (_class = class {
|
|
|
1154
1154
|
trendlinePoints(seriesId) {
|
|
1155
1155
|
const series = this.getSeries(seriesId);
|
|
1156
1156
|
if (!series) return [];
|
|
1157
|
-
const xy =
|
|
1157
|
+
const xy = _chunkLL3H5XUHcjs.chartFamily.call(void 0, this.spec) === "xy";
|
|
1158
1158
|
const out = [];
|
|
1159
1159
|
series.values.forEach((v, i) => {
|
|
1160
1160
|
const x = xy ? _nullishCoalesce(_optionalChain([series, 'access', _37 => _37.x, 'optionalAccess', _38 => _38[i]]), () => ( (this.spec.type === "bubble" ? i + 1 : null))) : i + 1;
|
|
@@ -1166,13 +1166,13 @@ var ChartController = (_class = class {
|
|
|
1166
1166
|
trendlineFit(seriesId, index) {
|
|
1167
1167
|
const line = _optionalChain([this, 'access', _39 => _39.getSeries, 'call', _40 => _40(seriesId), 'optionalAccess', _41 => _41.trendlines, 'optionalAccess', _42 => _42[index]]);
|
|
1168
1168
|
if (!line) return null;
|
|
1169
|
-
return
|
|
1169
|
+
return _chunkHDGBM7EAcjs.fitChartTrendline.call(void 0, line, this.trendlinePoints(seriesId));
|
|
1170
1170
|
}
|
|
1171
1171
|
/** The moving-average points of a trendline (empty for other kinds). */
|
|
1172
1172
|
trendlineMovingAverage(seriesId, index) {
|
|
1173
1173
|
const line = _optionalChain([this, 'access', _43 => _43.getSeries, 'call', _44 => _44(seriesId), 'optionalAccess', _45 => _45.trendlines, 'optionalAccess', _46 => _46[index]]);
|
|
1174
1174
|
if (!line || line.type !== "moving-average") return [];
|
|
1175
|
-
return
|
|
1175
|
+
return _chunkHDGBM7EAcjs.chartMovingAverage.call(void 0, this.trendlinePoints(seriesId), _nullishCoalesce(line.period, () => ( 2)));
|
|
1176
1176
|
}
|
|
1177
1177
|
// -------------------------------------------------------------------------
|
|
1178
1178
|
// Reshaping
|
|
@@ -1191,7 +1191,7 @@ var ChartController = (_class = class {
|
|
|
1191
1191
|
used.add(id);
|
|
1192
1192
|
return { id, name, values: s.series.map((x) => _nullishCoalesce(x.values[i], () => ( null))) };
|
|
1193
1193
|
});
|
|
1194
|
-
const { spec } =
|
|
1194
|
+
const { spec } = _chunkLL3H5XUHcjs.normalizeChartSpec.call(void 0, { ...s, categories: s.series.map((x) => x.name), series });
|
|
1195
1195
|
this.commit("Switch rows and columns", spec, null);
|
|
1196
1196
|
return { ok: true };
|
|
1197
1197
|
}
|
|
@@ -1201,7 +1201,7 @@ var ChartController = (_class = class {
|
|
|
1201
1201
|
/** Selects a chart element (view state; not an undo step). */
|
|
1202
1202
|
select(selection) {
|
|
1203
1203
|
const next = this.validSelection(selection, this.spec);
|
|
1204
|
-
if (
|
|
1204
|
+
if (_chunkHDGBM7EAcjs.sameChartSelection.call(void 0, next, this.selection) || next === null && this.selection === null) return;
|
|
1205
1205
|
this.selection = next;
|
|
1206
1206
|
this.notify(false);
|
|
1207
1207
|
}
|
|
@@ -1276,14 +1276,14 @@ var ChartController = (_class = class {
|
|
|
1276
1276
|
// -------------------------------------------------------------------------
|
|
1277
1277
|
/** The spec, for saving (a copy). */
|
|
1278
1278
|
toJSON() {
|
|
1279
|
-
return
|
|
1279
|
+
return _chunkLL3H5XUHcjs.cloneChartSpec.call(void 0, this.spec);
|
|
1280
1280
|
}
|
|
1281
1281
|
/**
|
|
1282
1282
|
* Replaces the chart without an undo step (e.g. when opening a document). Problems are
|
|
1283
1283
|
* fixed with defaults and reported in `state.issues` (and returned).
|
|
1284
1284
|
*/
|
|
1285
1285
|
load(input, options = {}) {
|
|
1286
|
-
const { spec, issues } =
|
|
1286
|
+
const { spec, issues } = _chunkLL3H5XUHcjs.normalizeChartSpec.call(void 0, input);
|
|
1287
1287
|
this.spec = spec;
|
|
1288
1288
|
this.issues = issues;
|
|
1289
1289
|
this.selection = this.validSelection(this.selection, spec);
|
|
@@ -1303,7 +1303,7 @@ var ChartController = (_class = class {
|
|
|
1303
1303
|
* nothing changes and every problem is returned (and shown in `state.issues`).
|
|
1304
1304
|
*/
|
|
1305
1305
|
replace(input, options = {}) {
|
|
1306
|
-
const { spec, issues } =
|
|
1306
|
+
const { spec, issues } = _chunkLL3H5XUHcjs.normalizeChartSpec.call(void 0, input);
|
|
1307
1307
|
if (issues.length) return this.reject(issues.map((i) => i.message).join(" "), issues);
|
|
1308
1308
|
this.commit(_nullishCoalesce(options.label, () => ( "Replace chart")), spec, this.validSelection(this.selection, spec));
|
|
1309
1309
|
return { ok: true };
|
|
@@ -1365,7 +1365,7 @@ function layoutSparkline(values, options) {
|
|
|
1365
1365
|
const h = Number.isFinite(options.height) ? Math.max(1, options.height) : 1;
|
|
1366
1366
|
const color = _nullishCoalesce(options.color, () => ( "#4269d0"));
|
|
1367
1367
|
const negative = _nullishCoalesce(options.negativeColor, () => ( "#e5484d"));
|
|
1368
|
-
const theme = { ...
|
|
1368
|
+
const theme = { ..._chunkLL3H5XUHcjs.DEFAULT_CHART_THEME, background: "transparent" };
|
|
1369
1369
|
const marks = [];
|
|
1370
1370
|
const scene = { width: w, height: h, plot: { x: 0, y: 0, width: w, height: h }, marks, percent: false, theme, warnings: [] };
|
|
1371
1371
|
const vals = values.slice(0, MAX_POINTS).map((v) => v !== null && Number.isFinite(v) ? Math.max(-1e300, Math.min(1e300, v)) : null);
|
|
@@ -1398,7 +1398,7 @@ function layoutSparkline(values, options) {
|
|
|
1398
1398
|
const flush = () => {
|
|
1399
1399
|
if (run.length >= 2) {
|
|
1400
1400
|
const pts = run.length > 4e3 ? run.filter((_, i) => i % (Math.floor(run.length / 2e3) + 1) === 0) : run;
|
|
1401
|
-
d += pts.map(([x, y], i) => `${i ? "L" : "M"}${
|
|
1401
|
+
d += pts.map(([x, y], i) => `${i ? "L" : "M"}${_chunkHDGBM7EAcjs.r2.call(void 0, x)},${_chunkHDGBM7EAcjs.r2.call(void 0, y)}`).join("");
|
|
1402
1402
|
}
|
|
1403
1403
|
run = [];
|
|
1404
1404
|
};
|