@pixerate/editor 0.163.0 → 0.165.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 +54 -39
- package/dist/agent/index.js +24 -9
- package/dist/animation/index.cjs +6 -5
- package/dist/animation/index.js +5 -4
- package/dist/animation-editor/index.cjs +65 -64
- package/dist/animation-editor/index.js +8 -7
- package/dist/bridge/cli.cjs +3 -3
- package/dist/bridge/cli.js +2 -2
- package/dist/bridge/index.cjs +3 -3
- package/dist/bridge/index.js +2 -2
- package/dist/canvas/displacement.d.cts +34 -2
- package/dist/canvas/displacement.d.ts +34 -2
- package/dist/canvas/explosion-tools.d.cts +43 -0
- package/dist/canvas/explosion-tools.d.ts +43 -0
- package/dist/canvas/explosionLayout.d.cts +50 -0
- package/dist/canvas/explosionLayout.d.ts +50 -0
- package/dist/canvas/explosionState.d.cts +52 -0
- package/dist/canvas/explosionState.d.ts +52 -0
- package/dist/canvas/index.cjs +512 -168
- package/dist/canvas/index.d.cts +3 -0
- package/dist/canvas/index.d.ts +3 -0
- package/dist/canvas/index.js +434 -90
- package/dist/canvas/types.d.cts +27 -2
- package/dist/canvas/types.d.ts +27 -2
- package/dist/chart/controller.d.cts +31 -2
- package/dist/chart/controller.d.ts +31 -2
- package/dist/chart/index.cjs +504 -132
- package/dist/chart/index.d.cts +2 -0
- package/dist/chart/index.d.ts +2 -0
- package/dist/chart/index.js +386 -14
- package/dist/chart/layout-families.d.cts +7 -0
- package/dist/chart/layout-families.d.ts +7 -0
- package/dist/chart/links.d.cts +34 -0
- package/dist/chart/links.d.ts +34 -0
- package/dist/chart/mermaid.d.cts +9 -6
- package/dist/chart/mermaid.d.ts +9 -6
- package/dist/chart/schemas.d.cts +3 -0
- package/dist/chart/schemas.d.ts +3 -0
- package/dist/chart/spec.d.cts +3 -2
- package/dist/chart/spec.d.ts +3 -2
- package/dist/chart/style.d.cts +33 -0
- package/dist/chart/style.d.ts +33 -0
- package/dist/chart/types.d.cts +24 -2
- package/dist/chart/types.d.ts +24 -2
- package/dist/{chunk-TALQONZ5.js → chunk-2J5VLJHC.js} +3 -3
- package/dist/{chunk-3NEZJCBY.js → chunk-2ZRN43IN.js} +340 -201
- package/dist/{chunk-ZVNAMTFO.cjs → chunk-3FSUJIXN.cjs} +18 -174
- package/dist/{chunk-RQCMSEM5.cjs → chunk-4QUUHTGJ.cjs} +2 -2
- package/dist/{chunk-CIPIESX4.cjs → chunk-4ZC5QJE2.cjs} +3 -3
- package/dist/{chunk-S6X2QRVU.cjs → chunk-5UEFBM2M.cjs} +1 -138
- package/dist/{chunk-YSAGBIRW.cjs → chunk-64VWWR5U.cjs} +16 -16
- package/dist/{chunk-QYZGBVNC.js → chunk-7272D3K2.js} +10 -8
- package/dist/{chunk-462WGGXX.cjs → chunk-AMX23CSN.cjs} +27 -16
- package/dist/{chunk-3VLOOO3G.js → chunk-BDIM6NVW.js} +1 -1
- package/dist/{chunk-POR54B55.js → chunk-CRFSQWKQ.js} +4 -1
- package/dist/{chunk-GZ2FM3ZB.js → chunk-DKNEQX7T.js} +6 -162
- package/dist/{chunk-JCXMJUQO.cjs → chunk-EGZM52EO.cjs} +3 -3
- package/dist/{chunk-ES3UEVUT.cjs → chunk-EUIDTZNQ.cjs} +112 -110
- package/dist/{chunk-H3OEM3Q2.js → chunk-F6R67I3A.js} +1 -1
- package/dist/{chunk-5FNGLV2D.js → chunk-FEU2XVQH.js} +15 -3
- package/dist/{chunk-SZA42R4N.js → chunk-FRBRLKNQ.js} +154 -16
- package/dist/chunk-HIDFL5LQ.js +484 -0
- package/dist/{chunk-MKTDELCD.js → chunk-I5MRJW7B.js} +1 -1
- package/dist/{chunk-SDHZG5TF.js → chunk-ILP77UD6.js} +160 -2
- package/dist/{chunk-GKNEJ6EN.cjs → chunk-IMRXC7OA.cjs} +241 -103
- package/dist/chunk-KGRZMHZB.js +204 -0
- package/dist/{chunk-SET6KJOP.js → chunk-LPIKXPBM.js} +1 -1
- package/dist/{chunk-BQWGN5WH.js → chunk-M2TPMYJE.js} +1 -1
- package/dist/{chunk-GTELFJRE.cjs → chunk-M5GLQQWG.cjs} +2 -2
- package/dist/{chunk-4VU4CP7R.js → chunk-MHLU6GRJ.js} +1 -138
- package/dist/{chunk-D54JHQK2.cjs → chunk-MKXK6E4O.cjs} +51 -51
- package/dist/{chunk-DAPQGA55.js → chunk-N7NBGT2Y.js} +2 -2
- package/dist/chunk-O6OGNDND.js +164 -0
- package/dist/{chunk-22KLZZGH.cjs → chunk-ODFCS7HF.cjs} +8 -8
- package/dist/{chunk-PA3IMPPS.cjs → chunk-OVYQAYGH.cjs} +81 -81
- package/dist/{chunk-YXOW456B.js → chunk-PPEDZ5WR.js} +1 -1
- package/dist/{chunk-YGG7WDWT.cjs → chunk-Q25WAFTD.cjs} +21 -18
- package/dist/{chunk-SBQVEBSU.cjs → chunk-QO2T6KA5.cjs} +165 -67
- package/dist/{chunk-24M7VD6M.cjs → chunk-S4EIAIEW.cjs} +7 -7
- package/dist/{chunk-M4MIZPQI.cjs → chunk-SJ2CPTQC.cjs} +189 -15
- package/dist/chunk-TFF2GTGN.cjs +153 -0
- package/dist/chunk-TTCJPX4U.cjs +204 -0
- package/dist/{chunk-NZD2MZJC.cjs → chunk-TVQW26AV.cjs} +35 -23
- package/dist/{chunk-R3P2M7HU.cjs → chunk-UVXTOZ2B.cjs} +346 -207
- package/dist/{chunk-WI7QJA7A.cjs → chunk-UXETV2NC.cjs} +161 -3
- package/dist/{chunk-Z4P2RBMJ.js → chunk-V5GSY3NC.js} +101 -3
- package/dist/{chunk-QY4KUDMY.js → chunk-VRXXAXUT.js} +2 -2
- package/dist/chunk-VU6WQSMB.cjs +164 -0
- package/dist/{chunk-OXERWBKE.js → chunk-X5W645RI.js} +3 -3
- package/dist/{chunk-NHLYK3AX.js → chunk-XBQX76CT.js} +182 -8
- package/dist/{chunk-5AARIS3R.cjs → chunk-XCDGM7TD.cjs} +37 -37
- package/dist/{chunk-EVXQNQND.js → chunk-XZB3TJ6K.js} +16 -5
- package/dist/chunk-YBAPT7NL.js +153 -0
- package/dist/chunk-Z2UQYMPS.cjs +484 -0
- package/dist/color/index.cjs +5 -3
- package/dist/color/index.js +12 -10
- package/dist/diagram/index.cjs +55 -243
- package/dist/diagram/index.js +12 -200
- package/dist/export/index.cjs +7 -6
- package/dist/export/index.js +6 -5
- package/dist/extensions/index.cjs +12 -9
- package/dist/extensions/index.js +11 -8
- package/dist/gradient/index.cjs +29 -27
- package/dist/gradient/index.js +6 -4
- package/dist/image-editor/index.cjs +644 -643
- package/dist/image-editor/index.js +7 -6
- package/dist/index.cjs +21 -18
- package/dist/index.js +14 -11
- package/dist/paint-editor/index.cjs +19 -18
- package/dist/paint-editor/index.js +7 -6
- package/dist/parameters/index.cjs +2 -2
- package/dist/parameters/index.js +1 -1
- package/dist/persistence/assetWrites.d.cts +22 -0
- package/dist/persistence/assetWrites.d.ts +22 -0
- package/dist/persistence/assets.d.cts +71 -0
- package/dist/persistence/assets.d.ts +71 -0
- package/dist/persistence/documentStore.d.cts +17 -1
- package/dist/persistence/documentStore.d.ts +17 -1
- package/dist/persistence/documentTools.d.cts +5 -1
- package/dist/persistence/documentTools.d.ts +5 -1
- package/dist/persistence/editorAutosave.d.cts +7 -0
- package/dist/persistence/editorAutosave.d.ts +7 -0
- package/dist/persistence/index.cjs +141 -21
- package/dist/persistence/index.js +130 -10
- package/dist/persistence/storage.d.cts +13 -1
- package/dist/persistence/storage.d.ts +13 -1
- package/dist/spreadsheet/index.cjs +3 -3
- package/dist/spreadsheet/index.js +2 -2
- package/dist/tokens/index.cjs +11 -3
- package/dist/tokens/index.d.cts +1 -0
- package/dist/tokens/index.d.ts +1 -0
- package/dist/tokens/index.js +10 -2
- package/dist/tokens/style.d.cts +36 -0
- package/dist/tokens/style.d.ts +36 -0
- package/dist/tools/index.cjs +15 -3
- package/dist/tools/index.d.cts +2 -0
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.js +14 -2
- package/dist/tools/style-tools.d.cts +19 -0
- package/dist/tools/style-tools.d.ts +19 -0
- package/dist/tools/style.d.cts +212 -0
- package/dist/tools/style.d.ts +212 -0
- package/dist/tools/view.d.cts +6 -0
- package/dist/tools/view.d.ts +6 -0
- package/dist/typography/index.cjs +8 -6
- package/dist/typography/index.js +5 -3
- package/dist/vector/index.cjs +953 -952
- package/dist/vector/index.js +7 -6
- package/dist/video-editor/index.cjs +8 -7
- package/dist/video-editor/index.js +6 -5
- package/package.json +1 -1
- package/skills/README.md +12 -0
- package/skills/pixerate-agent-tools/SKILL.md +34 -1
- package/skills/pixerate-chart/SKILL.md +41 -9
- package/skills/pixerate-image-editor/SKILL.md +2 -0
- package/skills/pixerate-paint-editor/SKILL.md +2 -0
- package/skills/pixerate-tokens/SKILL.md +5 -0
- package/dist/chunk-ERAGQL2N.cjs +0 -68
- package/dist/chunk-KMU6QJB7.js +0 -68
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkUVXTOZ2Bcjs = require('./chunk-UVXTOZ2B.cjs');
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
var _chunk55AKPTLMcjs = require('./chunk-55AKPTLM.cjs');
|
|
@@ -907,7 +907,7 @@ function drawCallouts(ctx, plot) {
|
|
|
907
907
|
if (s.hidden || !s.callouts) continue;
|
|
908
908
|
s.callouts.forEach((label, i) => {
|
|
909
909
|
if (!label) return;
|
|
910
|
-
const mark = marks.find((m) => (m.role === "bar" || m.role === "point") && _optionalChain([m, 'access',
|
|
910
|
+
const mark = marks.find((m) => (m.role === "bar" || m.role === "point") && _optionalChain([m, 'access', _3 => _3.target, 'optionalAccess', _4 => _4.kind]) === "point" && m.target.seriesId === s.id && m.target.index === i);
|
|
911
911
|
const anchor = mark ? anchorOf(mark, horizontal && mark.kind === "rect") : null;
|
|
912
912
|
if (!anchor) {
|
|
913
913
|
unplaced++;
|
|
@@ -948,7 +948,7 @@ function drawCallouts(ctx, plot) {
|
|
|
948
948
|
}
|
|
949
949
|
if (unplaced) ctx.warn("annotations-skipped", `${unplaced} callout${unplaced === 1 ? " points" : "s point"} at a gap or a hidden value and ${unplaced === 1 ? "is" : "are"} not drawn.`);
|
|
950
950
|
}
|
|
951
|
-
var MUTED = /* @__PURE__ */ new Set(["bar", "line", "area", "point", "slice", "cell", "box", "whisker", "outlier", "connector", "trendline", "trendline-label", "error-bar", "data-label", "legend-swatch", "legend-label"]);
|
|
951
|
+
var MUTED = /* @__PURE__ */ new Set(["node", "bar", "line", "area", "point", "slice", "cell", "box", "whisker", "outlier", "connector", "trendline", "trendline-label", "error-bar", "data-label", "legend-swatch", "legend-label"]);
|
|
952
952
|
function applyHighlight(ctx) {
|
|
953
953
|
const { spec, marks } = ctx;
|
|
954
954
|
if (!spec.highlight.length) return;
|
|
@@ -992,8 +992,8 @@ var MAX_CHART_DATA_LABELS = 200;
|
|
|
992
992
|
var MAX_CHART_LINE_POINTS = 2e3;
|
|
993
993
|
var MAX_CHART_MARKERS = 1e3;
|
|
994
994
|
function scaleInfo(scale, range, format, axis) {
|
|
995
|
-
const logBase = _optionalChain([axis, 'optionalAccess',
|
|
996
|
-
const r = _optionalChain([axis, 'optionalAccess',
|
|
995
|
+
const logBase = _optionalChain([axis, 'optionalAccess', _5 => _5.scale]) === "log" ? _nullishCoalesce(axis.logBase, () => ( 10)) : void 0;
|
|
996
|
+
const r = _optionalChain([axis, 'optionalAccess', _6 => _6.reverse]) ? [range[1], range[0]] : range;
|
|
997
997
|
const vs = { domain: [scale.min, scale.max], range: r, logBase };
|
|
998
998
|
const raw = (v) => chartScaleToPixel(v, vs);
|
|
999
999
|
const px = (v) => logBase && !(v > 0) ? r[0] : raw(Math.min(scale.max, Math.max(scale.min, v)));
|
|
@@ -1014,7 +1014,7 @@ function categoryFrame(ctx, area, input) {
|
|
|
1014
1014
|
};
|
|
1015
1015
|
const valueLen0 = horizontal ? area.width : area.height;
|
|
1016
1016
|
const valueLabelWidth = primary.axis.show ? estimate(primary, valueLen0) : 0;
|
|
1017
|
-
const valueLabelWidth2 = _optionalChain([secondary, 'optionalAccess',
|
|
1017
|
+
const valueLabelWidth2 = _optionalChain([secondary, 'optionalAccess', _7 => _7.axis, 'access', _8 => _8.show]) ? estimate(secondary, valueLen0) : 0;
|
|
1018
1018
|
const catLabelWidth = Math.max(0, ...labels.map((c) => measure(c, fs)));
|
|
1019
1019
|
let left;
|
|
1020
1020
|
let bottom;
|
|
@@ -1138,7 +1138,7 @@ function categoryFrame(ctx, area, input) {
|
|
|
1138
1138
|
marks.push({ kind: "text", key: `axis-title-${horizontal ? "y" : "x"}`, role: "axis-title", x: plot.x + plot.width / 2, y: area.y + area.height, text: bottomTitle, anchor: "middle", baseline: "bottom", size: fs + 1, weight: 500, fill: theme.text, target: horizontal ? yTarget : xTarget });
|
|
1139
1139
|
if (leftTitle)
|
|
1140
1140
|
marks.push({ kind: "text", key: `axis-title-${horizontal ? "x" : "y"}`, role: "axis-title", x: area.x, y: plot.y + plot.height / 2, text: leftTitle, anchor: "middle", baseline: "top", size: fs + 1, weight: 500, fill: theme.text, rotate: -90, target: horizontal ? xTarget : yTarget });
|
|
1141
|
-
if (_optionalChain([secondary, 'optionalAccess',
|
|
1141
|
+
if (_optionalChain([secondary, 'optionalAccess', _9 => _9.axis, 'access', _10 => _10.title])) {
|
|
1142
1142
|
const target = { kind: "axis", axis: "y2" };
|
|
1143
1143
|
if (horizontal) marks.push({ kind: "text", key: "axis-title-y2", role: "axis-title", x: plot.x + plot.width / 2, y: area.y, text: secondary.axis.title, anchor: "middle", baseline: "top", size: fs + 1, weight: 500, fill: theme.text, target });
|
|
1144
1144
|
else marks.push({ kind: "text", key: "axis-title-y2", role: "axis-title", x: area.x + area.width, y: plot.y + plot.height / 2, text: secondary.axis.title, anchor: "middle", baseline: "top", size: fs + 1, weight: 500, fill: theme.text, rotate: 90, target });
|
|
@@ -1239,7 +1239,7 @@ function layoutCartesian(ctx, area, visible) {
|
|
|
1239
1239
|
const { spec, theme, marks, measure, fs } = ctx;
|
|
1240
1240
|
const horizontal = spec.orientation === "horizontal";
|
|
1241
1241
|
const n = spec.categories.length;
|
|
1242
|
-
const types = new Map(visible.map((s) => [s.id,
|
|
1242
|
+
const types = new Map(visible.map((s) => [s.id, _chunkUVXTOZ2Bcjs.chartSeriesType.call(void 0, spec, s)]));
|
|
1243
1243
|
const stacked = spec.stacking !== "none";
|
|
1244
1244
|
const percent = spec.stacking === "percent";
|
|
1245
1245
|
const onSecondary = (s) => s.axis === "secondary";
|
|
@@ -1276,9 +1276,9 @@ function layoutCartesian(ctx, area, visible) {
|
|
|
1276
1276
|
const stack = stacks.get(s.id);
|
|
1277
1277
|
errors.set(
|
|
1278
1278
|
s.id,
|
|
1279
|
-
|
|
1279
|
+
_chunkUVXTOZ2Bcjs.chartErrorAmounts.call(void 0, s.errorBars, s.values).map((e, i) => {
|
|
1280
1280
|
const raw = s.values[i];
|
|
1281
|
-
const seg = _optionalChain([stack, 'optionalAccess',
|
|
1281
|
+
const seg = _optionalChain([stack, 'optionalAccess', _11 => _11.segments, 'access', _12 => _12[i]]);
|
|
1282
1282
|
if (!e || raw === null || stack && !seg) return null;
|
|
1283
1283
|
const k = seg && percent ? raw ? (seg[1] - seg[0]) / raw : 0 : 1;
|
|
1284
1284
|
const center = (seg ? seg[1] : raw) + (e.center - raw) * k;
|
|
@@ -1300,7 +1300,7 @@ function layoutCartesian(ctx, area, visible) {
|
|
|
1300
1300
|
const stack = stacks.get(s.id);
|
|
1301
1301
|
if (stack) stack.segments.forEach((seg) => seg && (see(seg[0]), see(seg[1])));
|
|
1302
1302
|
else s.values.forEach((v) => v !== null && see(v));
|
|
1303
|
-
_optionalChain([errors, 'access',
|
|
1303
|
+
_optionalChain([errors, 'access', _13 => _13.get, 'call', _14 => _14(s.id), 'optionalAccess', _15 => _15.forEach, 'call', _16 => _16((e) => e && (see(e.lo), see(e.hi)))]);
|
|
1304
1304
|
}
|
|
1305
1305
|
for (const v of referenceValues(spec, secondary ? "y2" : "y")) see(v);
|
|
1306
1306
|
if (log) {
|
|
@@ -1346,7 +1346,7 @@ function layoutCartesian(ctx, area, visible) {
|
|
|
1346
1346
|
const drawOrder = [...visible].sort((a, b) => order(types.get(a.id)) - order(types.get(b.id)));
|
|
1347
1347
|
for (const s of drawOrder) {
|
|
1348
1348
|
const si = spec.series.indexOf(s);
|
|
1349
|
-
const color =
|
|
1349
|
+
const color = _chunkUVXTOZ2Bcjs.chartSeriesColor.call(void 0, spec, si);
|
|
1350
1350
|
const type = types.get(s.id);
|
|
1351
1351
|
const stack = stacks.get(s.id);
|
|
1352
1352
|
const selSeries = ctx.seriesSelected(s.id);
|
|
@@ -1372,7 +1372,7 @@ function layoutCartesian(ctx, area, visible) {
|
|
|
1372
1372
|
const selected = ctx.isSelected(target);
|
|
1373
1373
|
const [x, y] = map({ c: c0, v: Math.min(a, b) });
|
|
1374
1374
|
const rect = horizontal ? { x: Math.min(a, b), y: c0, width: Math.abs(b - a), height: cw } : { x, y, width: cw, height: Math.abs(b - a) };
|
|
1375
|
-
const fill =
|
|
1375
|
+
const fill = _chunkUVXTOZ2Bcjs.chartPointColor.call(void 0, spec, si, i);
|
|
1376
1376
|
marks.push({
|
|
1377
1377
|
kind: "rect",
|
|
1378
1378
|
key: `bar-${s.id}-${i}`,
|
|
@@ -1400,7 +1400,7 @@ function layoutCartesian(ctx, area, visible) {
|
|
|
1400
1400
|
} else {
|
|
1401
1401
|
const curve = _nullishCoalesce(s.curve, () => ( spec.curve));
|
|
1402
1402
|
const pointValue = (i) => {
|
|
1403
|
-
const v = stack ? _nullishCoalesce(_optionalChain([stack, 'access',
|
|
1403
|
+
const v = stack ? _nullishCoalesce(_optionalChain([stack, 'access', _17 => _17.segments, 'access', _18 => _18[i], 'optionalAccess', _19 => _19[1]]), () => ( null)) : s.values[i];
|
|
1404
1404
|
return v !== null && Number.isFinite(v) && !(log && (v <= 0 || (_nullishCoalesce(s.values[i], () => ( 0))) <= 0)) ? v : null;
|
|
1405
1405
|
};
|
|
1406
1406
|
const runs = [];
|
|
@@ -1424,7 +1424,7 @@ function layoutCartesian(ctx, area, visible) {
|
|
|
1424
1424
|
const drawn = runs.map(thin);
|
|
1425
1425
|
if (type === "area") {
|
|
1426
1426
|
const parts = drawn.map((r) => {
|
|
1427
|
-
const baseline = stack ? r.map((pt) => ({ c: pt.c, v: valuePx(_nullishCoalesce(_optionalChain([stack, 'access',
|
|
1427
|
+
const baseline = stack ? r.map((pt) => ({ c: pt.c, v: valuePx(_nullishCoalesce(_optionalChain([stack, 'access', _20 => _20.segments, 'access', _21 => _21[pt.i], 'optionalAccess', _22 => _22[0]]), () => ( 0))) })).reverse() : [
|
|
1428
1428
|
{ c: r[r.length - 1].c, v: info.zero },
|
|
1429
1429
|
{ c: r[0].c, v: info.zero }
|
|
1430
1430
|
];
|
|
@@ -1451,7 +1451,7 @@ function layoutCartesian(ctx, area, visible) {
|
|
|
1451
1451
|
const target = { kind: "point", seriesId: s.id, index: i };
|
|
1452
1452
|
const selected = ctx.isSelected(target);
|
|
1453
1453
|
const r = type === "scatter" ? 4.5 : 3.5;
|
|
1454
|
-
const pointColor =
|
|
1454
|
+
const pointColor = _chunkUVXTOZ2Bcjs.chartPointColor.call(void 0, spec, si, i);
|
|
1455
1455
|
const fill = showDots ? type === "scatter" ? pointColor : theme.surface : "transparent";
|
|
1456
1456
|
marks.push(
|
|
1457
1457
|
pointMark({ key: `point-${s.id}-${i}`, target, selected: selected || selSeries, opacity: type === "scatter" ? 0.85 : void 0 }, showDots ? marker : "hit", cx, cy, showDots ? r : 6, fill, showDots ? pointColor : void 0, 2)
|
|
@@ -1488,7 +1488,7 @@ function layoutCartesian(ctx, area, visible) {
|
|
|
1488
1488
|
if (d) errorMarks.push({ kind: "path", key: `error-bar-${s.id}-${i}`, role: "error-bar", d, fill: "none", stroke: type === "bar" ? theme.text : color, strokeWidth: selSeries ? 2 : 1.25, target: seriesTarget, selected: selSeries });
|
|
1489
1489
|
});
|
|
1490
1490
|
}
|
|
1491
|
-
if (trendsAllowed && _optionalChain([s, 'access',
|
|
1491
|
+
if (trendsAllowed && _optionalChain([s, 'access', _23 => _23.trendlines, 'optionalAccess', _24 => _24.length])) {
|
|
1492
1492
|
const points = [];
|
|
1493
1493
|
s.values.forEach((v, i) => v !== null && Number.isFinite(v) && points.push([i + 1, v]));
|
|
1494
1494
|
const toPx = (x, y) => map({ c: catCenter(x - 1), v: info.raw(y) });
|
|
@@ -1514,7 +1514,7 @@ function layoutXy(ctx, area, visible) {
|
|
|
1514
1514
|
const xLog = xAxis.scale === "log";
|
|
1515
1515
|
const yLog = yAxis.scale === "log";
|
|
1516
1516
|
let skipped = 0;
|
|
1517
|
-
const pointsOf = (s) => s.values.map((y, i) => ({ i, x: _nullishCoalesce(_optionalChain([s, 'access',
|
|
1517
|
+
const pointsOf = (s) => s.values.map((y, i) => ({ i, x: _nullishCoalesce(_optionalChain([s, 'access', _25 => _25.x, 'optionalAccess', _26 => _26[i]]), () => ( (bubble || !s.x ? i + 1 : null))), y, size: _nullishCoalesce(_optionalChain([s, 'access', _27 => _27.sizes, 'optionalAccess', _28 => _28[i]]), () => ( null)) })).filter((p) => {
|
|
1518
1518
|
if (p.x === null || p.y === null || !Number.isFinite(p.x) || !Number.isFinite(p.y)) return false;
|
|
1519
1519
|
if (xLog && p.x <= 0 || yLog && p.y <= 0) return skipped++, false;
|
|
1520
1520
|
return true;
|
|
@@ -1524,8 +1524,8 @@ function layoutXy(ctx, area, visible) {
|
|
|
1524
1524
|
const yErrors = /* @__PURE__ */ new Map();
|
|
1525
1525
|
const xErrors = /* @__PURE__ */ new Map();
|
|
1526
1526
|
for (const { s } of all) {
|
|
1527
|
-
if (s.errorBars) yErrors.set(s.id,
|
|
1528
|
-
if (s.xErrorBars) xErrors.set(s.id,
|
|
1527
|
+
if (s.errorBars) yErrors.set(s.id, _chunkUVXTOZ2Bcjs.chartErrorAmounts.call(void 0, s.errorBars, s.values));
|
|
1528
|
+
if (s.xErrorBars) xErrors.set(s.id, _chunkUVXTOZ2Bcjs.chartErrorAmounts.call(void 0, s.xErrorBars, s.values.map((_, i) => _nullishCoalesce(_optionalChain([s, 'access', _29 => _29.x, 'optionalAccess', _30 => _30[i]]), () => ( (bubble || !s.x ? i + 1 : null))))));
|
|
1529
1529
|
}
|
|
1530
1530
|
let xlo = Infinity;
|
|
1531
1531
|
let xhi = -Infinity;
|
|
@@ -1547,9 +1547,9 @@ function layoutXy(ctx, area, visible) {
|
|
|
1547
1547
|
seeX(p.x);
|
|
1548
1548
|
seeY(p.y);
|
|
1549
1549
|
if (p.size !== null && p.size > maxSize) maxSize = p.size;
|
|
1550
|
-
const ey = _optionalChain([yErrors, 'access',
|
|
1550
|
+
const ey = _optionalChain([yErrors, 'access', _31 => _31.get, 'call', _32 => _32(s.id), 'optionalAccess', _33 => _33[p.i]]);
|
|
1551
1551
|
if (ey) seeY(ey.center - ey.minus), seeY(ey.center + ey.plus);
|
|
1552
|
-
const ex = _optionalChain([xErrors, 'access',
|
|
1552
|
+
const ex = _optionalChain([xErrors, 'access', _34 => _34.get, 'call', _35 => _35(s.id), 'optionalAccess', _36 => _36[p.i]]);
|
|
1553
1553
|
if (ex) seeX(ex.center - ex.minus), seeX(ex.center + ex.plus);
|
|
1554
1554
|
}
|
|
1555
1555
|
for (const t of _nullishCoalesce(s.trendlines, () => ( []))) {
|
|
@@ -1608,8 +1608,8 @@ function layoutXy(ctx, area, visible) {
|
|
|
1608
1608
|
const trendLabels = [];
|
|
1609
1609
|
for (const { s, pts } of all) {
|
|
1610
1610
|
const si = spec.series.indexOf(s);
|
|
1611
|
-
const color =
|
|
1612
|
-
const type =
|
|
1611
|
+
const color = _chunkUVXTOZ2Bcjs.chartSeriesColor.call(void 0, spec, si);
|
|
1612
|
+
const type = _chunkUVXTOZ2Bcjs.chartSeriesType.call(void 0, spec, s);
|
|
1613
1613
|
const selSeries = ctx.seriesSelected(s.id);
|
|
1614
1614
|
const seriesTarget = { kind: "series", seriesId: s.id };
|
|
1615
1615
|
if (type === "line" || type === "area") {
|
|
@@ -1634,7 +1634,7 @@ function layoutXy(ctx, area, visible) {
|
|
|
1634
1634
|
}
|
|
1635
1635
|
const target = { kind: "point", seriesId: s.id, index: p.i };
|
|
1636
1636
|
const selected = ctx.isSelected(target);
|
|
1637
|
-
const pointColor =
|
|
1637
|
+
const pointColor = _chunkUVXTOZ2Bcjs.chartPointColor.call(void 0, spec, si, p.i);
|
|
1638
1638
|
const r = bubble ? maxSize > 0 && p.size !== null && p.size > 0 ? Math.max(2, Math.sqrt(p.size / maxSize) * maxR) : 2 : 4.5;
|
|
1639
1639
|
if (bubble) marks.push({ kind: "circle", key: `point-${s.id}-${p.i}`, role: "point", cx, cy, r, fill: pointColor, stroke: pointColor, strokeWidth: 1, opacity: 0.6, target, selected: selected || selSeries });
|
|
1640
1640
|
else marks.push(pointMark({ key: `point-${s.id}-${p.i}`, target, selected: selected || selSeries, opacity: 0.85 }, marker === "none" ? "hit" : marker, cx, cy, marker === "none" ? 6 : r, marker === "none" ? "transparent" : pointColor, marker === "none" ? void 0 : pointColor, 2));
|
|
@@ -1644,14 +1644,14 @@ function layoutXy(ctx, area, visible) {
|
|
|
1644
1644
|
const stroke = color;
|
|
1645
1645
|
const errorBar = (key, d) => d && errorMarks.push({ kind: "path", key, role: "error-bar", d, fill: "none", stroke, strokeWidth: selSeries ? 2 : 1.25, target: seriesTarget, selected: selSeries });
|
|
1646
1646
|
for (const p of pts) {
|
|
1647
|
-
const ey = _optionalChain([yErrors, 'access',
|
|
1647
|
+
const ey = _optionalChain([yErrors, 'access', _37 => _37.get, 'call', _38 => _38(s.id), 'optionalAccess', _39 => _39[p.i]]);
|
|
1648
1648
|
if (ey) {
|
|
1649
1649
|
const lo = ey.center - ey.minus;
|
|
1650
1650
|
const hi = ey.center + ey.plus;
|
|
1651
1651
|
const cap = s.errorBars.cap !== false;
|
|
1652
1652
|
errorBar(`error-bar-${s.id}-${p.i}`, errorBarPath((q) => [q.c, q.v], xPx(p.x), yPx(lo), yPx(hi), 8, cap && lo < ey.center, cap && hi > ey.center));
|
|
1653
1653
|
}
|
|
1654
|
-
const ex = _optionalChain([xErrors, 'access',
|
|
1654
|
+
const ex = _optionalChain([xErrors, 'access', _40 => _40.get, 'call', _41 => _41(s.id), 'optionalAccess', _42 => _42[p.i]]);
|
|
1655
1655
|
if (ex) {
|
|
1656
1656
|
const lo = ex.center - ex.minus;
|
|
1657
1657
|
const hi = ex.center + ex.plus;
|
|
@@ -1659,7 +1659,7 @@ function layoutXy(ctx, area, visible) {
|
|
|
1659
1659
|
errorBar(`error-bar-x-${s.id}-${p.i}`, errorBarPath((q) => [q.v, q.c], yPx(p.y), xPx(lo), xPx(hi), 8, cap && lo < ex.center, cap && hi > ex.center));
|
|
1660
1660
|
}
|
|
1661
1661
|
}
|
|
1662
|
-
if (_optionalChain([s, 'access',
|
|
1662
|
+
if (_optionalChain([s, 'access', _43 => _43.trendlines, 'optionalAccess', _44 => _44.length])) drawTrendlines(ctx, plot, s, color, pts.map((p) => [p.x, p.y]), (x, y) => [xRaw(x), yRaw(y)], trendLabels, xLog || yLog);
|
|
1663
1663
|
}
|
|
1664
1664
|
drawReferences(ctx, plot, refAxes, "lines");
|
|
1665
1665
|
marks.push(...errorMarks, ...labelMarks);
|
|
@@ -1678,7 +1678,7 @@ function trendlineLegendItems(spec, color) {
|
|
|
1678
1678
|
}
|
|
1679
1679
|
|
|
1680
1680
|
// src/chart/layout-families.ts
|
|
1681
|
-
var sliceColor = (ctx, series, i) => _optionalChain([series, 'access',
|
|
1681
|
+
var sliceColor = (ctx, series, i) => _optionalChain([series, 'access', _45 => _45.pointColors, 'optionalAccess', _46 => _46[i]]) || _chunkUVXTOZ2Bcjs.chartSliceColor.call(void 0, ctx.spec, i);
|
|
1682
1682
|
function layoutPie(ctx, area, series) {
|
|
1683
1683
|
const { spec, theme, marks, fs, selection } = ctx;
|
|
1684
1684
|
const values = spec.categories.map((_, i) => {
|
|
@@ -1708,7 +1708,7 @@ function layoutPie(ctx, area, series) {
|
|
|
1708
1708
|
angle = end;
|
|
1709
1709
|
const target = { kind: "point", seriesId: series.id, index: i };
|
|
1710
1710
|
const selected = ctx.isSelected(target) || ctx.isSelected({ kind: "category", index: i });
|
|
1711
|
-
const seriesSel = _optionalChain([selection, 'optionalAccess',
|
|
1711
|
+
const seriesSel = _optionalChain([selection, 'optionalAccess', _47 => _47.kind]) === "series" && selection.seriesId === series.id;
|
|
1712
1712
|
const mid = (start + end) / 2;
|
|
1713
1713
|
const off = selected ? 6 : 0;
|
|
1714
1714
|
const ox = cx + off * Math.sin(mid);
|
|
@@ -1794,7 +1794,7 @@ function layoutRadar(ctx, area, visible) {
|
|
|
1794
1794
|
});
|
|
1795
1795
|
for (const s of visible) {
|
|
1796
1796
|
const si = spec.series.indexOf(s);
|
|
1797
|
-
const color =
|
|
1797
|
+
const color = _chunkUVXTOZ2Bcjs.chartSeriesColor.call(void 0, spec, si);
|
|
1798
1798
|
const selSeries = ctx.seriesSelected(s.id);
|
|
1799
1799
|
const pts = s.values.map((v, i) => v !== null && Number.isFinite(v) ? at(i, rOf(v)) : null);
|
|
1800
1800
|
const present = pts.filter((p) => p !== null);
|
|
@@ -1844,7 +1844,7 @@ function layoutWaterfall(ctx, area, series) {
|
|
|
1844
1844
|
});
|
|
1845
1845
|
const { band, catCenter, map, value } = frame;
|
|
1846
1846
|
const w = band * (1 - spec.gapWidth);
|
|
1847
|
-
const color =
|
|
1847
|
+
const color = _chunkUVXTOZ2Bcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(series));
|
|
1848
1848
|
const format = _nullishCoalesce(series.format, () => ( spec.yAxis.format));
|
|
1849
1849
|
const labelsOn = _nullishCoalesce(series.dataLabels, () => ( spec.dataLabels));
|
|
1850
1850
|
let prevEnd = null;
|
|
@@ -1903,7 +1903,7 @@ function layoutHistogram(ctx, area, visible) {
|
|
|
1903
1903
|
const gap = k > 1 ? band * spec.gapWidth * 0.5 : 0;
|
|
1904
1904
|
const w = (band - gap) / k;
|
|
1905
1905
|
visible.forEach((s, si) => {
|
|
1906
|
-
const color =
|
|
1906
|
+
const color = _chunkUVXTOZ2Bcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(s));
|
|
1907
1907
|
const target = { kind: "series", seriesId: s.id };
|
|
1908
1908
|
const selected = ctx.seriesSelected(s.id);
|
|
1909
1909
|
counts[si].forEach((c, b) => {
|
|
@@ -1934,7 +1934,7 @@ function layoutBox(ctx, area, visible) {
|
|
|
1934
1934
|
visible.forEach((s, i) => {
|
|
1935
1935
|
const st = stats[i];
|
|
1936
1936
|
if (!st) return;
|
|
1937
|
-
const color =
|
|
1937
|
+
const color = _chunkUVXTOZ2Bcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(s));
|
|
1938
1938
|
const target = { kind: "series", seriesId: s.id };
|
|
1939
1939
|
const selected = ctx.seriesSelected(s.id);
|
|
1940
1940
|
const c = catCenter(i);
|
|
@@ -2153,7 +2153,7 @@ function layoutLikert(ctx, area, visible) {
|
|
|
2153
2153
|
if (x1 - x0 <= 0) return;
|
|
2154
2154
|
const target = { kind: "point", seriesId: s.id, index: i };
|
|
2155
2155
|
const selected = ctx.isSelected(target);
|
|
2156
|
-
const fill = _optionalChain([s, 'access',
|
|
2156
|
+
const fill = _optionalChain([s, 'access', _48 => _48.pointColors, 'optionalAccess', _49 => _49[i]]) || _chunkUVXTOZ2Bcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(s));
|
|
2157
2157
|
const rect = { x: x0, y, width: x1 - x0, height: barH };
|
|
2158
2158
|
marks.push({ kind: "rect", key, role: "bar", ...rect, fill, target, selected: selected || ctx.seriesSelected(s.id) || catSelected });
|
|
2159
2159
|
if (selected) ctx.outline(`${key}-selection`, { x: rect.x - 2, y: rect.y - 2, width: rect.width + 4, height: rect.height + 4 });
|
|
@@ -2252,22 +2252,22 @@ function layoutParliament(ctx, area, series) {
|
|
|
2252
2252
|
}
|
|
2253
2253
|
function treeColor(ctx, series, node, group, base, shade) {
|
|
2254
2254
|
if (node.color) return node.color;
|
|
2255
|
-
if (base === null) return _optionalChain([series, 'optionalAccess',
|
|
2256
|
-
return
|
|
2255
|
+
if (base === null) return _optionalChain([series, 'optionalAccess', _50 => _50.pointColors, 'optionalAccess', _51 => _51[group]]) || _chunkUVXTOZ2Bcjs.chartSliceColor.call(void 0, ctx.spec, group);
|
|
2256
|
+
return _chunkUVXTOZ2Bcjs.shadeChartColor.call(void 0, base, shade);
|
|
2257
2257
|
}
|
|
2258
2258
|
function layoutTreemapTree(ctx, area, series) {
|
|
2259
2259
|
const { spec, marks, theme, fs, measure } = ctx;
|
|
2260
|
-
const format = _nullishCoalesce(_optionalChain([series, 'optionalAccess',
|
|
2261
|
-
const labelsOn = _nullishCoalesce(_optionalChain([series, 'optionalAccess',
|
|
2260
|
+
const format = _nullishCoalesce(_optionalChain([series, 'optionalAccess', _52 => _52.format]), () => ( spec.yAxis.format));
|
|
2261
|
+
const labelsOn = _nullishCoalesce(_optionalChain([series, 'optionalAccess', _53 => _53.dataLabels]), () => ( true));
|
|
2262
2262
|
let unlabelled = 0;
|
|
2263
2263
|
const draw = (nodes, rect, key, group, base) => {
|
|
2264
|
-
const rects = chartSquarify(nodes.map(
|
|
2264
|
+
const rects = chartSquarify(nodes.map(_chunkUVXTOZ2Bcjs.chartTreeTotal), rect);
|
|
2265
2265
|
nodes.forEach((node, k) => {
|
|
2266
2266
|
const r = rects[k];
|
|
2267
2267
|
if (r.width <= 0.5 || r.height <= 0.5) return;
|
|
2268
2268
|
const g = _nullishCoalesce(group, () => ( k));
|
|
2269
2269
|
const target = { kind: "category", index: g };
|
|
2270
|
-
const selected = ctx.isSelected(target) || ctx.isSelected({ kind: "point", seriesId: _nullishCoalesce(_optionalChain([series, 'optionalAccess',
|
|
2270
|
+
const selected = ctx.isSelected(target) || ctx.isSelected({ kind: "point", seriesId: _nullishCoalesce(_optionalChain([series, 'optionalAccess', _54 => _54.id]), () => ( "")), index: g });
|
|
2271
2271
|
const id = `${key}-${k}`;
|
|
2272
2272
|
const fill = treeColor(ctx, series, node, g, base, base === null ? 0 : (k % 4 - 1.5) * 0.14);
|
|
2273
2273
|
if (node.children) {
|
|
@@ -2296,10 +2296,10 @@ function layoutTreemapTree(ctx, area, series) {
|
|
|
2296
2296
|
}
|
|
2297
2297
|
function layoutSunburst(ctx, area, series) {
|
|
2298
2298
|
const { spec, marks, theme, fs, measure } = ctx;
|
|
2299
|
-
const tree = spec.tree.length ? spec.tree :
|
|
2299
|
+
const tree = spec.tree.length ? spec.tree : _chunkUVXTOZ2Bcjs.chartTreeFromSeries.call(void 0, spec.categories, _nullishCoalesce(_optionalChain([series, 'optionalAccess', _55 => _55.values]), () => ( [])));
|
|
2300
2300
|
const indexOf = new Map(spec.categories.map((c, i) => [c.trim() || `${i + 1}`, i]));
|
|
2301
|
-
const depth =
|
|
2302
|
-
const total = tree.reduce((t, n) => t +
|
|
2301
|
+
const depth = _chunkUVXTOZ2Bcjs.chartTreeDepth.call(void 0, tree);
|
|
2302
|
+
const total = tree.reduce((t, n) => t + _chunkUVXTOZ2Bcjs.chartTreeTotal.call(void 0, n), 0);
|
|
2303
2303
|
const cx = area.x + area.width / 2;
|
|
2304
2304
|
const cy = area.y + area.height / 2;
|
|
2305
2305
|
const outer = Math.max(8, Math.min(area.width, area.height) / 2 - 4);
|
|
@@ -2310,20 +2310,20 @@ function layoutSunburst(ctx, area, series) {
|
|
|
2310
2310
|
}
|
|
2311
2311
|
const hole = outer * 0.28;
|
|
2312
2312
|
const ring = (outer - hole) / Math.max(1, depth);
|
|
2313
|
-
const format = _nullishCoalesce(_optionalChain([series, 'optionalAccess',
|
|
2313
|
+
const format = _nullishCoalesce(_optionalChain([series, 'optionalAccess', _56 => _56.format]), () => ( spec.yAxis.format));
|
|
2314
2314
|
let unlabelled = 0;
|
|
2315
2315
|
const walk = (nodes, start, sweep, level, key, group, base) => {
|
|
2316
|
-
const sum = nodes.reduce((t, n) => t +
|
|
2316
|
+
const sum = nodes.reduce((t, n) => t + _chunkUVXTOZ2Bcjs.chartTreeTotal.call(void 0, n), 0);
|
|
2317
2317
|
let at = start;
|
|
2318
2318
|
nodes.forEach((node, k) => {
|
|
2319
|
-
const value =
|
|
2319
|
+
const value = _chunkUVXTOZ2Bcjs.chartTreeTotal.call(void 0, node);
|
|
2320
2320
|
if (!(value > 0) || !sum) return;
|
|
2321
2321
|
const a0 = at;
|
|
2322
2322
|
const a1 = at + sweep * value / sum;
|
|
2323
2323
|
at = a1;
|
|
2324
2324
|
const g = _nullishCoalesce(_nullishCoalesce(group, () => ( indexOf.get(node.name))), () => ( k));
|
|
2325
2325
|
const target = { kind: "category", index: g };
|
|
2326
|
-
const selected = ctx.isSelected(target) || ctx.isSelected({ kind: "point", seriesId: _nullishCoalesce(_optionalChain([series, 'optionalAccess',
|
|
2326
|
+
const selected = ctx.isSelected(target) || ctx.isSelected({ kind: "point", seriesId: _nullishCoalesce(_optionalChain([series, 'optionalAccess', _57 => _57.id]), () => ( "")), index: g });
|
|
2327
2327
|
const fill = treeColor(ctx, series, node, g, base, 0.22 * level);
|
|
2328
2328
|
const id = `${key}-${k}`;
|
|
2329
2329
|
const r0 = hole + ring * level;
|
|
@@ -2349,17 +2349,109 @@ function layoutSunburst(ctx, area, series) {
|
|
|
2349
2349
|
}
|
|
2350
2350
|
return { plot };
|
|
2351
2351
|
}
|
|
2352
|
+
function layoutSankey(ctx, area, series) {
|
|
2353
|
+
const { spec, theme, marks, fs, measure } = ctx;
|
|
2354
|
+
const nodes = spec.sankeyNodes;
|
|
2355
|
+
const links = spec.links;
|
|
2356
|
+
const at = new Map(nodes.map((n, i) => [n, i]));
|
|
2357
|
+
const incoming = nodes.map(() => []);
|
|
2358
|
+
const outgoing = nodes.map(() => []);
|
|
2359
|
+
links.forEach((l, k) => {
|
|
2360
|
+
outgoing[at.get(l.source)].push(k);
|
|
2361
|
+
incoming[at.get(l.target)].push(k);
|
|
2362
|
+
});
|
|
2363
|
+
const column = nodes.map(() => -1);
|
|
2364
|
+
const depth = (i) => {
|
|
2365
|
+
if (column[i] >= 0) return column[i];
|
|
2366
|
+
column[i] = 0;
|
|
2367
|
+
column[i] = incoming[i].reduce((d, k) => Math.max(d, depth(at.get(links[k].source)) + 1), 0);
|
|
2368
|
+
return column[i];
|
|
2369
|
+
};
|
|
2370
|
+
nodes.forEach((_, i) => depth(i));
|
|
2371
|
+
const last = Math.max(...column);
|
|
2372
|
+
nodes.forEach((_, i) => {
|
|
2373
|
+
if (!outgoing[i].length) column[i] = last;
|
|
2374
|
+
});
|
|
2375
|
+
const value = _nullishCoalesce(_optionalChain([series, 'optionalAccess', _58 => _58.values, 'access', _59 => _59.map, 'call', _60 => _60((v) => _nullishCoalesce(v, () => ( 0)))]), () => ( nodes.map(() => 0)));
|
|
2376
|
+
const nodeW = Math.max(6, Math.min(16, area.width * 0.02));
|
|
2377
|
+
const gap = last > 0 ? (area.width - nodeW) / last : 0;
|
|
2378
|
+
const xOf = (c) => last > 0 ? area.x + c * gap : area.x + area.width / 2 - nodeW / 2;
|
|
2379
|
+
const columns = Array.from({ length: last + 1 }, (_, c) => nodes.map((_2, i) => i).filter((i) => column[i] === c));
|
|
2380
|
+
const pad = Math.max(4, Math.min(fs * 1.2, area.height / Math.max(1, Math.max(...columns.map((c) => c.length))) / 3));
|
|
2381
|
+
const ky = Math.min(...columns.filter((c) => c.length).map((c) => (area.height - pad * (c.length - 1)) / Math.max(1e-9, c.reduce((t, i) => t + value[i], 0))));
|
|
2382
|
+
const top = nodes.map(() => 0);
|
|
2383
|
+
for (const col of columns) {
|
|
2384
|
+
const used = col.reduce((t, i) => t + value[i] * ky, 0) + pad * Math.max(0, col.length - 1);
|
|
2385
|
+
let y = area.y + (area.height - used) / 2;
|
|
2386
|
+
for (const i of col) {
|
|
2387
|
+
top[i] = y;
|
|
2388
|
+
y += value[i] * ky + pad;
|
|
2389
|
+
}
|
|
2390
|
+
}
|
|
2391
|
+
const color = (i) => _optionalChain([series, 'optionalAccess', _61 => _61.pointColors, 'optionalAccess', _62 => _62[i]]) || _chunkUVXTOZ2Bcjs.chartSliceColor.call(void 0, spec, i);
|
|
2392
|
+
const named = new Set(spec.highlight);
|
|
2393
|
+
const lit = nodes.map((n) => named.has(n));
|
|
2394
|
+
const dimLinks = lit.some(Boolean);
|
|
2395
|
+
const outOffset = nodes.map(() => 0);
|
|
2396
|
+
const inOffset = nodes.map(() => 0);
|
|
2397
|
+
const startY = /* @__PURE__ */ new Map();
|
|
2398
|
+
const endY = /* @__PURE__ */ new Map();
|
|
2399
|
+
nodes.forEach((_, i) => {
|
|
2400
|
+
for (const k of [...outgoing[i]].sort((a, b) => top[at.get(links[a].target)] - top[at.get(links[b].target)])) {
|
|
2401
|
+
startY.set(k, top[i] + outOffset[i]);
|
|
2402
|
+
outOffset[i] += links[k].value * ky;
|
|
2403
|
+
}
|
|
2404
|
+
for (const k of [...incoming[i]].sort((a, b) => top[at.get(links[a].source)] - top[at.get(links[b].source)])) {
|
|
2405
|
+
endY.set(k, top[i] + inOffset[i]);
|
|
2406
|
+
inOffset[i] += links[k].value * ky;
|
|
2407
|
+
}
|
|
2408
|
+
});
|
|
2409
|
+
const selectedNode = (i) => ctx.isSelected({ kind: "category", index: i }) || ctx.isSelected({ kind: "point", seriesId: _nullishCoalesce(_optionalChain([series, 'optionalAccess', _63 => _63.id]), () => ( "")), index: i });
|
|
2410
|
+
links.forEach((l, k) => {
|
|
2411
|
+
const s = at.get(l.source);
|
|
2412
|
+
const t = at.get(l.target);
|
|
2413
|
+
const w = l.value * ky;
|
|
2414
|
+
const x0 = xOf(column[s]) + nodeW;
|
|
2415
|
+
const x1 = xOf(column[t]);
|
|
2416
|
+
const y0 = startY.get(k);
|
|
2417
|
+
const y1 = endY.get(k);
|
|
2418
|
+
const xm = (x0 + x1) / 2;
|
|
2419
|
+
const d = `M${r2(x0)},${r2(y0)}C${r2(xm)},${r2(y0)} ${r2(xm)},${r2(y1)} ${r2(x1)},${r2(y1)}L${r2(x1)},${r2(y1 + w)}C${r2(xm)},${r2(y1 + w)} ${r2(xm)},${r2(y0 + w)} ${r2(x0)},${r2(y0 + w)}Z`;
|
|
2420
|
+
const fill = _nullishCoalesce(l.color, () => ( (spec.sankeyLinkColor === "gray" ? theme.mutedText : color(spec.sankeyLinkColor === "target" ? t : s))));
|
|
2421
|
+
const emphasis = selectedNode(s) || selectedNode(t) ? 0.6 : 0.35;
|
|
2422
|
+
const opacity = dimLinks && !lit[s] && !lit[t] ? emphasis * 0.25 : emphasis;
|
|
2423
|
+
marks.push({ kind: "path", key: `link-${k}`, role: "link", d, fill, opacity });
|
|
2424
|
+
});
|
|
2425
|
+
const labelsOn = _nullishCoalesce(_optionalChain([series, 'optionalAccess', _64 => _64.dataLabels]), () => ( spec.dataLabels));
|
|
2426
|
+
const format = _nullishCoalesce(_optionalChain([series, 'optionalAccess', _65 => _65.format]), () => ( spec.yAxis.format));
|
|
2427
|
+
let hidden = 0;
|
|
2428
|
+
nodes.forEach((name, i) => {
|
|
2429
|
+
const x = xOf(column[i]);
|
|
2430
|
+
const h = Math.max(1, value[i] * ky);
|
|
2431
|
+
const target = { kind: "category", index: i };
|
|
2432
|
+
const selected = selectedNode(i);
|
|
2433
|
+
marks.push({ kind: "rect", key: `node-${i}`, role: "node", x, y: top[i], width: nodeW, height: h, fill: color(i), radius: 1, ...selected ? { stroke: theme.selection, strokeWidth: 2 } : {}, target, selected });
|
|
2434
|
+
const text = labelsOn ? `${name} ${formatChartNumber(value[i], format)}` : name;
|
|
2435
|
+
const room = (last > 0 ? gap : area.width / 2) - nodeW - 10;
|
|
2436
|
+
const shown = truncate(text, Math.max(fs * 2, room), fs, measure);
|
|
2437
|
+
if (shown !== text) hidden++;
|
|
2438
|
+
const right = column[i] < last || last === 0;
|
|
2439
|
+
marks.push({ kind: "text", key: `label-node-${i}`, role: "data-label", x: right ? x + nodeW + 5 : x - 5, y: top[i] + h / 2, text: shown, anchor: right ? "start" : "end", baseline: "middle", size: fs, weight: selected ? 600 : void 0, fill: selected ? theme.selection : theme.text, target, selected });
|
|
2440
|
+
});
|
|
2441
|
+
if (hidden) ctx.warn("labels-truncated", `${hidden} node label${hidden === 1 ? " was" : "s were"} shortened to fit between the columns.`);
|
|
2442
|
+
return { plot: area };
|
|
2443
|
+
}
|
|
2352
2444
|
|
|
2353
2445
|
// src/chart/layout.ts
|
|
2354
2446
|
function legendItems(spec, ctx) {
|
|
2355
|
-
const family =
|
|
2356
|
-
if (spec.type === "funnel" || spec.type === "slope") return [];
|
|
2357
|
-
if (
|
|
2447
|
+
const family = _chunkUVXTOZ2Bcjs.chartFamily.call(void 0, spec);
|
|
2448
|
+
if (spec.type === "funnel" || spec.type === "slope" || spec.type === "sankey") return [];
|
|
2449
|
+
if (_chunkUVXTOZ2Bcjs.chartSpecColorsByCategory.call(void 0, spec)) {
|
|
2358
2450
|
const first = spec.series.find((s) => !s.hidden);
|
|
2359
|
-
const seats = (i) => Math.max(0, Math.round(_nullishCoalesce(_optionalChain([first, 'optionalAccess',
|
|
2451
|
+
const seats = (i) => Math.max(0, Math.round(_nullishCoalesce(_optionalChain([first, 'optionalAccess', _66 => _66.values, 'access', _67 => _67[i]]), () => ( 0))));
|
|
2360
2452
|
return spec.categories.map((c, i) => ({
|
|
2361
2453
|
label: spec.type === "parliament" ? `${c} ${seats(i)}` : c,
|
|
2362
|
-
color: _optionalChain([first, 'optionalAccess',
|
|
2454
|
+
color: _optionalChain([first, 'optionalAccess', _68 => _68.pointColors, 'optionalAccess', _69 => _69[i]]) || _chunkUVXTOZ2Bcjs.chartSliceColor.call(void 0, spec, i),
|
|
2363
2455
|
target: { kind: "category", index: i },
|
|
2364
2456
|
faded: false,
|
|
2365
2457
|
selected: ctx.isSelected({ kind: "category", index: i }),
|
|
@@ -2373,17 +2465,17 @@ function legendItems(spec, ctx) {
|
|
|
2373
2465
|
return [
|
|
2374
2466
|
{ label: "Increase", color: ctx.theme.positive, target, faded: false, selected: false, shape: "square" },
|
|
2375
2467
|
{ label: "Decrease", color: ctx.theme.negative, target, faded: false, selected: false, shape: "square" },
|
|
2376
|
-
{ label: "Total", color:
|
|
2468
|
+
{ label: "Total", color: _chunkUVXTOZ2Bcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(first)), target, faded: false, selected: false, shape: "square" }
|
|
2377
2469
|
];
|
|
2378
2470
|
}
|
|
2379
2471
|
if (family === "box") return [];
|
|
2380
|
-
const trends = trendlineLegendItems(spec, (i) =>
|
|
2472
|
+
const trends = trendlineLegendItems(spec, (i) => _chunkUVXTOZ2Bcjs.chartSeriesColor.call(void 0, spec, i));
|
|
2381
2473
|
const items = [];
|
|
2382
2474
|
spec.series.forEach((s, i) => {
|
|
2383
|
-
const type =
|
|
2475
|
+
const type = _chunkUVXTOZ2Bcjs.chartSeriesType.call(void 0, spec, s);
|
|
2384
2476
|
items.push({
|
|
2385
2477
|
label: s.name,
|
|
2386
|
-
color:
|
|
2478
|
+
color: _chunkUVXTOZ2Bcjs.chartSeriesColor.call(void 0, spec, i),
|
|
2387
2479
|
target: { kind: "series", seriesId: s.id },
|
|
2388
2480
|
faded: !!s.hidden,
|
|
2389
2481
|
selected: ctx.seriesSelected(s.id),
|
|
@@ -2396,7 +2488,7 @@ function legendItems(spec, ctx) {
|
|
|
2396
2488
|
function layoutChart(spec, options) {
|
|
2397
2489
|
const width = Math.max(1, Number.isFinite(options.width) ? options.width : 1);
|
|
2398
2490
|
const height = Math.max(1, Number.isFinite(options.height) ? options.height : 1);
|
|
2399
|
-
const theme = { ...
|
|
2491
|
+
const theme = { ..._chunkUVXTOZ2Bcjs.DEFAULT_CHART_THEME, ...options.theme };
|
|
2400
2492
|
const selection = _nullishCoalesce(options.selection, () => ( null));
|
|
2401
2493
|
const marks = [];
|
|
2402
2494
|
const warnings = [];
|
|
@@ -2412,7 +2504,7 @@ function layoutChart(spec, options) {
|
|
|
2412
2504
|
warnings,
|
|
2413
2505
|
selection,
|
|
2414
2506
|
isSelected: (target) => sameChartSelection(selection, target),
|
|
2415
|
-
seriesSelected: (id) => _optionalChain([selection, 'optionalAccess',
|
|
2507
|
+
seriesSelected: (id) => _optionalChain([selection, 'optionalAccess', _70 => _70.kind]) === "series" && selection.seriesId === id,
|
|
2416
2508
|
outline: (key, box) => marks.push({ kind: "rect", key, role: "selection", ...box, fill: "none", stroke: theme.selection, strokeWidth: 1, radius: 3 }),
|
|
2417
2509
|
warn: (code, message) => {
|
|
2418
2510
|
if (!warnings.some((w) => w.code === code && w.message === message)) warnings.push({ code, message });
|
|
@@ -2435,17 +2527,17 @@ function layoutChart(spec, options) {
|
|
|
2435
2527
|
if (spec.title) titleMark("title", spec.title, theme.titleSize, 600, theme.text);
|
|
2436
2528
|
if (spec.subtitle) titleMark("subtitle", spec.subtitle, fs + 1, 400, theme.mutedText);
|
|
2437
2529
|
if (spec.title || spec.subtitle) top += 6;
|
|
2438
|
-
const family =
|
|
2530
|
+
const family = _chunkUVXTOZ2Bcjs.chartFamily.call(void 0, spec);
|
|
2439
2531
|
const visible = spec.series.filter((s) => !s.hidden);
|
|
2440
2532
|
const items = legendItems(spec, ctx);
|
|
2441
2533
|
let area = { x: pad, y: top, width: width - pad * 2, height: height - top - pad - noteHeight(spec, fs) };
|
|
2442
2534
|
const seriesLegend = family === "cartesian" || family === "xy" || family === "radar" || family === "histogram";
|
|
2443
2535
|
const hasTrend = items.some((i) => i.shape === "dash");
|
|
2444
|
-
const showLegend = spec.legend.show && items.length > 0 && (!seriesLegend ||
|
|
2536
|
+
const showLegend = spec.legend.show && items.length > 0 && (!seriesLegend || _chunkUVXTOZ2Bcjs.chartVariesColors.call(void 0, spec) || spec.series.length > 1 || spec.series.some((s) => s.hidden) || hasTrend);
|
|
2445
2537
|
if (showLegend) area = layoutLegend(items, spec.legend.position, area, ctx, ctx.isSelected({ kind: "legend" }));
|
|
2446
2538
|
const finish = (result) => {
|
|
2447
2539
|
if (result.plot.width > 0) {
|
|
2448
|
-
if (chartAnnotationFamily(
|
|
2540
|
+
if (chartAnnotationFamily(_chunkUVXTOZ2Bcjs.chartFamily.call(void 0, spec))) drawCallouts(ctx, result.plot);
|
|
2449
2541
|
else if (spec.referenceLines.length || spec.referenceBands.length || spec.series.some((s) => s.callouts))
|
|
2450
2542
|
ctx.warn("annotations-skipped", `Reference lines, bands and callouts are drawn on bar, line, area, scatter and bubble charts; this ${spec.type} chart leaves them out.`);
|
|
2451
2543
|
}
|
|
@@ -2493,6 +2585,12 @@ function layoutChart(spec, options) {
|
|
|
2493
2585
|
return finish(layoutFunnel(ctx, area, visible[0]));
|
|
2494
2586
|
case "treemap":
|
|
2495
2587
|
return finish(spec.tree.length ? layoutTreemapTree(ctx, area, spec.series[0]) : layoutTreemap(ctx, area, visible[0]));
|
|
2588
|
+
case "sankey":
|
|
2589
|
+
if (!spec.links.length) {
|
|
2590
|
+
ctx.warn("type-fallback", "A Sankey diagram needs flows (set_chart_links); it is drawn as a bar chart until then.");
|
|
2591
|
+
return finish(layoutCartesian(ctx, area, visible));
|
|
2592
|
+
}
|
|
2593
|
+
return finish(layoutSankey(ctx, area, spec.series[0]));
|
|
2496
2594
|
case "sunburst":
|
|
2497
2595
|
return finish(layoutSunburst(ctx, area, spec.tree.length ? spec.series[0] : visible[0]));
|
|
2498
2596
|
case "slope":
|
|
@@ -2588,9 +2686,9 @@ function layoutLegend(items, position, area, ctx, legendSelected) {
|
|
|
2588
2686
|
function addReadout(ctx, readout, plot) {
|
|
2589
2687
|
const { spec, marks, theme, fs, measure } = ctx;
|
|
2590
2688
|
const series = spec.series.find((s) => s.id === readout.seriesId);
|
|
2591
|
-
const value = _optionalChain([series, 'optionalAccess',
|
|
2689
|
+
const value = _optionalChain([series, 'optionalAccess', _71 => _71.values, 'access', _72 => _72[readout.index]]);
|
|
2592
2690
|
if (!series || value === null || value === void 0) return;
|
|
2593
|
-
const mark = marks.find((m) => (m.role === "point" || m.role === "bar") && _optionalChain([m, 'access',
|
|
2691
|
+
const mark = marks.find((m) => (m.role === "point" || m.role === "bar") && _optionalChain([m, 'access', _73 => _73.target, 'optionalAccess', _74 => _74.kind]) === "point" && m.target.seriesId === readout.seriesId && m.target.index === readout.index);
|
|
2594
2692
|
if (!mark) return;
|
|
2595
2693
|
let ax;
|
|
2596
2694
|
let ay;
|
|
@@ -2602,8 +2700,8 @@ function addReadout(ctx, readout, plot) {
|
|
|
2602
2700
|
ay = mark.cy - mark.r;
|
|
2603
2701
|
} else return;
|
|
2604
2702
|
const axis = series.axis === "secondary" ? spec.yAxis2 : spec.yAxis;
|
|
2605
|
-
const x = _optionalChain([series, 'access',
|
|
2606
|
-
const text = x !== null && x !== void 0 &&
|
|
2703
|
+
const x = _optionalChain([series, 'access', _75 => _75.x, 'optionalAccess', _76 => _76[readout.index]]);
|
|
2704
|
+
const text = x !== null && x !== void 0 && _chunkUVXTOZ2Bcjs.chartFamily.call(void 0, spec) === "xy" ? `${formatChartNumber(x, spec.xAxis.format)}, ${formatChartNumber(value, axis.format)}` : `${_nullishCoalesce(spec.categories[readout.index], () => ( ""))}: ${formatChartNumber(value, _nullishCoalesce(series.format, () => ( axis.format)))}`;
|
|
2607
2705
|
const w = measure(text, fs, 600) + 10;
|
|
2608
2706
|
const h = fs + 8;
|
|
2609
2707
|
const bx = Math.max(plot.x, Math.min(plot.x + plot.width - w, ax - w / 2));
|
|
@@ -2652,7 +2750,7 @@ function chartXAtPoint(scene, point) {
|
|
|
2652
2750
|
if (!scale) return void 0;
|
|
2653
2751
|
return chartScaleFromPixel(point.x, scale);
|
|
2654
2752
|
}
|
|
2655
|
-
function snapChartValue(scene, value, step, ticks = _nullishCoalesce(_optionalChain([scene, 'access',
|
|
2753
|
+
function snapChartValue(scene, value, step, ticks = _nullishCoalesce(_optionalChain([scene, 'access', _77 => _77.valueScale, 'optionalAccess', _78 => _78.ticks]), () => ( [])), logBase) {
|
|
2656
2754
|
if (logBase && step === void 0) return value > 0 && Number.isFinite(value) ? Number(value.toPrecision(2)) : value;
|
|
2657
2755
|
const unit = _nullishCoalesce(step, () => ( (ticks.length > 1 ? (ticks[1] - ticks[0]) / 10 : 1)));
|
|
2658
2756
|
if (!(unit > 0)) return value;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkAMX23CSNcjs = require('./chunk-AMX23CSN.cjs');
|
|
7
7
|
|
|
8
8
|
// src/bridge/index.ts
|
|
9
9
|
var _http = require('http');
|
|
@@ -197,7 +197,7 @@ var SKILL_INSTRUCTIONS = "Each editor's tools are documented by an agent skill (
|
|
|
197
197
|
async function createToolBridge(options) {
|
|
198
198
|
const log = _nullishCoalesce(options.log, () => ( ((message) => process.stderr.write(`[${options.name}] ${message}
|
|
199
199
|
`))));
|
|
200
|
-
const port = _nullishCoalesce(options.port, () => (
|
|
200
|
+
const port = _nullishCoalesce(options.port, () => ( _chunkAMX23CSNcjs.TOOL_BRIDGE_DEFAULT_PORT));
|
|
201
201
|
const retryMs = _nullishCoalesce(options.retryMs, () => ( 2e3));
|
|
202
202
|
const timeoutMs = _nullishCoalesce(options.timeoutMs, () => ( 6e4));
|
|
203
203
|
const extraOrigins = new Set(_nullishCoalesce(options.origins, () => ( [])));
|
|
@@ -211,7 +211,7 @@ async function createToolBridge(options) {
|
|
|
211
211
|
let closed = false;
|
|
212
212
|
let retry;
|
|
213
213
|
const send = (editor, message) => editor.socket.send(JSON.stringify(message));
|
|
214
|
-
const registry = new (0,
|
|
214
|
+
const registry = new (0, _chunkAMX23CSNcjs.ToolRegistry)();
|
|
215
215
|
const listeners = /* @__PURE__ */ new Set();
|
|
216
216
|
const toolsChanged = () => listeners.forEach((l) => l());
|
|
217
217
|
const describeEditors = () => [...editors.values()].map((e) => `${e.id} (${e.name})`).join(", ");
|
|
@@ -319,13 +319,13 @@ async function createToolBridge(options) {
|
|
|
319
319
|
return;
|
|
320
320
|
}
|
|
321
321
|
if (message.t === "hello") {
|
|
322
|
-
if (message.v !==
|
|
322
|
+
if (message.v !== _chunkAMX23CSNcjs.TOOL_BRIDGE_PROTOCOL) {
|
|
323
323
|
log(`refused an editor speaking protocol v${String(message.v)}`);
|
|
324
|
-
return ws.close(1008, `This bridge speaks protocol v${
|
|
324
|
+
return ws.close(1008, `This bridge speaks protocol v${_chunkAMX23CSNcjs.TOOL_BRIDGE_PROTOCOL}; update @pixerate/editor.`);
|
|
325
325
|
}
|
|
326
326
|
editor = { id: `e${++editorCounter}`, name: String(message.name || "Editor"), ...message.kind ? { kind: message.kind } : {}, socket: ws, tools: Array.isArray(message.tools) ? message.tools : [], activeAt: Date.now(), activeSeq: ++activity };
|
|
327
327
|
editors.set(editor.id, editor);
|
|
328
|
-
ws.send(JSON.stringify({ t: "welcome", v:
|
|
328
|
+
ws.send(JSON.stringify({ t: "welcome", v: _chunkAMX23CSNcjs.TOOL_BRIDGE_PROTOCOL, id: editor.id }));
|
|
329
329
|
log(`editor ${editor.id} connected: ${editor.name} (${editor.tools.length} tools)`);
|
|
330
330
|
toolsChanged();
|
|
331
331
|
} else if (message.t === "tools" && editor) {
|
|
@@ -381,7 +381,7 @@ async function createToolBridge(options) {
|
|
|
381
381
|
`)]);
|
|
382
382
|
const skills = options.skills === false ? {} : _nullishCoalesce(options.skills, () => ( loadSkillFiles()));
|
|
383
383
|
const hasSkills = Object.keys(skills).length > 0;
|
|
384
|
-
const mcp =
|
|
384
|
+
const mcp = _chunkAMX23CSNcjs.createMcpServer.call(void 0, registry, {
|
|
385
385
|
name: options.name,
|
|
386
386
|
version: _nullishCoalesce(options.version, () => ( "0.1.0")),
|
|
387
387
|
instructions: [options.instructions, BRIDGE_INSTRUCTIONS, hasSkills ? SKILL_INSTRUCTIONS : ""].filter(Boolean).join("\n\n"),
|