@pixerate/editor 0.255.0 → 0.257.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 +40 -38
- package/dist/agent/index.js +9 -7
- package/dist/animation/index.cjs +4 -2
- package/dist/animation/index.js +4 -2
- package/dist/animation-editor/index.cjs +63 -61
- package/dist/animation-editor/index.js +7 -5
- package/dist/brushes/colour.d.cts +11 -0
- package/dist/brushes/colour.d.ts +11 -0
- package/dist/brushes/index.cjs +51 -30
- package/dist/brushes/index.d.cts +1 -0
- package/dist/brushes/index.d.ts +1 -0
- package/dist/brushes/index.js +25 -4
- package/dist/brushes/resolve.d.cts +2 -0
- package/dist/brushes/resolve.d.ts +2 -0
- package/dist/brushes/schema.d.cts +1 -0
- package/dist/brushes/schema.d.ts +1 -0
- package/dist/brushes/tools.d.cts +7 -0
- package/dist/brushes/tools.d.ts +7 -0
- package/dist/brushes/types.d.cts +10 -2
- package/dist/brushes/types.d.ts +10 -2
- package/dist/brushes/ui.d.cts +14 -3
- package/dist/brushes/ui.d.ts +14 -3
- package/dist/{brushstrokeRender-HCOQUSWW.js → brushstrokeRender-JI4W6F2G.js} +2 -2
- package/dist/{brushstrokeRender-ZZOXI5O5.cjs → brushstrokeRender-MQ6PSDM5.cjs} +11 -11
- package/dist/canvas/index.cjs +20 -18
- package/dist/canvas/index.js +7 -5
- package/dist/chart/index.cjs +159 -157
- package/dist/chart/index.js +9 -7
- package/dist/{chunk-7272D3K2.js → chunk-2EUW2XZX.js} +27 -276
- package/dist/{chunk-L6Y7TSQ4.js → chunk-2VJ6OVJV.js} +1 -1
- package/dist/{chunk-6ZZKRH7R.js → chunk-47V3WXDG.js} +2 -2
- package/dist/{chunk-H7ET2ISK.cjs → chunk-4IMD2TLY.cjs} +52 -52
- package/dist/{chunk-VUKUTT2W.js → chunk-4M4E3N6X.js} +1 -1
- package/dist/{chunk-TBAVCLEQ.cjs → chunk-5Q5MLXAD.cjs} +23 -23
- package/dist/{chunk-MONXNVZK.js → chunk-6I23ZCGK.js} +5 -3
- package/dist/{chunk-GOBOCZZI.js → chunk-6NQPKNUZ.js} +1 -1
- package/dist/{chunk-WYGSR3IJ.js → chunk-AORZ5M5C.js} +1 -1
- package/dist/chunk-AVTPZO4Z.cjs +142 -0
- package/dist/{chunk-WKMUBATU.js → chunk-C2WEIEUB.js} +1 -1
- package/dist/{chunk-P3K2JCJA.js → chunk-D5BXSOSU.js} +3 -3
- package/dist/chunk-E2V5DA3W.js +36 -0
- package/dist/{chunk-WZOGDKCQ.js → chunk-F7CPSRLN.js} +0 -133
- package/dist/chunk-FJBQTZS4.js +17 -0
- package/dist/{chunk-SOSBOS5T.cjs → chunk-G23BTQA5.cjs} +22 -22
- package/dist/{chunk-EUIDTZNQ.cjs → chunk-I3Y2Q3PM.cjs} +59 -308
- package/dist/{chunk-YHUMGBZD.js → chunk-ICTPLVSR.js} +22 -4
- package/dist/{chunk-LRNUZKWV.cjs → chunk-IPUTIUGQ.cjs} +1 -1
- package/dist/{chunk-6GRUVGKU.js → chunk-ITURMC2M.js} +3 -3
- package/dist/{chunk-HYWRU5VX.js → chunk-IXQZHCOF.js} +1 -1
- package/dist/chunk-J5UQHWVL.js +142 -0
- package/dist/{chunk-YBAPT7NL.js → chunk-JC2SHA4A.js} +1 -23
- package/dist/chunk-LRTR4ASZ.cjs +17 -0
- package/dist/{chunk-HUAISCUX.cjs → chunk-M2HG5DJ2.cjs} +18 -18
- package/dist/{chunk-N76AMOKE.cjs → chunk-MDLEGVEN.cjs} +42 -42
- package/dist/chunk-MEGSQUQO.cjs +36 -0
- package/dist/chunk-MLLTWAXH.cjs +276 -0
- package/dist/{chunk-RHPSE2YR.js → chunk-MQ6MGIQM.js} +2 -2
- package/dist/{chunk-PGPFWC35.cjs → chunk-MQGQTKVW.cjs} +51 -33
- package/dist/{chunk-5YWWQ36H.cjs → chunk-O3ZVZSNJ.cjs} +9 -9
- package/dist/{chunk-GCTUOTCW.cjs → chunk-P3PZ63M3.cjs} +35 -35
- package/dist/{chunk-WRZ6C4TU.cjs → chunk-P6WYDBTH.cjs} +4 -4
- package/dist/{chunk-CJ6TBL2N.cjs → chunk-RHEMMGCN.cjs} +16 -16
- package/dist/{chunk-HIMGBZAM.cjs → chunk-RSIKDWOP.cjs} +201 -38
- package/dist/{chunk-SABJMH6M.cjs → chunk-RVGP2XLF.cjs} +2 -135
- package/dist/{chunk-JVRLGV3C.js → chunk-SMTUQWGY.js} +184 -21
- package/dist/{chunk-DMTEQ6SH.js → chunk-SSFMWJDK.js} +4 -4
- package/dist/{chunk-TFF2GTGN.cjs → chunk-SXQHWXEL.cjs} +2 -24
- package/dist/{chunk-IWEVV63O.cjs → chunk-UEYLANO3.cjs} +18 -16
- package/dist/chunk-VR6OGHU5.js +276 -0
- package/dist/{chunk-AF23QK5F.js → chunk-YQ4PQTBB.js} +1 -1
- package/dist/{chunk-B7V34GIH.cjs → chunk-YSGW7VV4.cjs} +88 -88
- package/dist/{chunk-3NS5C7FB.cjs → chunk-YYBW6DF2.cjs} +76 -76
- package/dist/{chunk-UFEDHACQ.js → chunk-Z7BX4TWO.js} +2 -2
- package/dist/{chunk-RUONPPMC.cjs → chunk-ZSE25IZA.cjs} +8 -8
- package/dist/color/index.cjs +7 -3
- package/dist/color/index.js +18 -14
- package/dist/export/index.cjs +8 -6
- package/dist/export/index.js +7 -5
- package/dist/extensions/index.cjs +11 -9
- package/dist/extensions/index.js +10 -8
- package/dist/gradient/index.cjs +33 -31
- package/dist/gradient/index.js +5 -3
- package/dist/image-editor/brush-presets.d.cts +4 -1
- package/dist/image-editor/brush-presets.d.ts +4 -1
- package/dist/image-editor/controller.d.cts +10 -5
- package/dist/image-editor/controller.d.ts +10 -5
- package/dist/image-editor/index.cjs +1090 -1073
- package/dist/image-editor/index.js +37 -20
- package/dist/index.cjs +17 -15
- package/dist/index.js +11 -9
- package/dist/paint-editor/brushes.d.cts +18 -1
- package/dist/paint-editor/brushes.d.ts +18 -1
- package/dist/paint-editor/collaboration-tools.d.cts +19 -0
- package/dist/paint-editor/collaboration-tools.d.ts +19 -0
- package/dist/paint-editor/collaboration.d.cts +180 -0
- package/dist/paint-editor/collaboration.d.ts +180 -0
- package/dist/paint-editor/controller.d.cts +83 -0
- package/dist/paint-editor/controller.d.ts +83 -0
- package/dist/paint-editor/engine.d.cts +7 -0
- package/dist/paint-editor/engine.d.ts +7 -0
- package/dist/paint-editor/index.cjs +2027 -1331
- package/dist/paint-editor/index.d.cts +2 -0
- package/dist/paint-editor/index.d.ts +2 -0
- package/dist/paint-editor/index.js +1671 -975
- package/dist/paint-editor/mark-settings.d.cts +1 -1
- package/dist/paint-editor/mark-settings.d.ts +1 -1
- package/dist/paint-editor/procedural.d.cts +4 -2
- package/dist/paint-editor/procedural.d.ts +4 -2
- package/dist/paint-editor/stamp-tip.d.cts +45 -0
- package/dist/paint-editor/stamp-tip.d.ts +45 -0
- package/dist/paint-editor/stroke.d.cts +2 -0
- package/dist/paint-editor/stroke.d.ts +2 -0
- package/dist/stickers/index.cjs +4 -2
- package/dist/stickers/index.js +6 -4
- package/dist/typography/index.cjs +3 -2
- package/dist/typography/index.js +2 -1
- package/dist/vector/index.cjs +971 -969
- package/dist/vector/index.js +8 -6
- package/dist/video-editor/index.cjs +4 -2
- package/dist/video-editor/index.js +4 -2
- package/package.json +1 -1
- package/skills/pixerate-brushes/SKILL.md +21 -11
- package/skills/pixerate-brushes-design/SKILL.md +6 -2
- package/skills/pixerate-brushes-design/evals/canvas-chalk.json +8 -8
- package/skills/pixerate-canvas/SKILL.md +3 -2
- package/skills/pixerate-image-editor/SKILL.md +1 -1
- package/skills/pixerate-paint-editor/SKILL.md +35 -47
- package/skills/pixerate-paint-editor/references/painting-alongside.md +19 -0
- package/skills/pixerate-vector/SKILL.md +1 -1
|
@@ -14,7 +14,7 @@ var _chunkTTCJPX4Ucjs = require('./chunk-TTCJPX4U.cjs');
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
var
|
|
17
|
+
var _chunkMDLEGVENcjs = require('./chunk-MDLEGVEN.cjs');
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
@@ -47,7 +47,7 @@ var _chunkN76AMOKEcjs = require('./chunk-N76AMOKE.cjs');
|
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
|
|
50
|
-
var
|
|
50
|
+
var _chunkP6WYDBTHcjs = require('./chunk-P6WYDBTH.cjs');
|
|
51
51
|
|
|
52
52
|
|
|
53
53
|
|
|
@@ -86,7 +86,7 @@ var csvField = (text) => /[",\n]|^\s|\s$/.test(text) ? `"${text.replace(/"/g, '"
|
|
|
86
86
|
var treemapName = (name) => !name.includes('"') ? `"${name}"` : !name.includes("'") ? `'${name}'` : `"${name.replace(/"/g, "'")}"`;
|
|
87
87
|
var yamlText = (text) => /^[\w][\w .,!?()/&+-]*$/.test(text) && !/:\s/.test(text) ? text : JSON.stringify(text);
|
|
88
88
|
function chartMermaidFamily(spec) {
|
|
89
|
-
const family =
|
|
89
|
+
const family = _chunkP6WYDBTHcjs.chartFamily.call(void 0, spec);
|
|
90
90
|
if (family === "sankey" && _optionalChain([spec, 'access', _2 => _2.links, 'optionalAccess', _3 => _3.length])) return "sankey";
|
|
91
91
|
if (family === "treemap" || family === "sunburst") return "treemap";
|
|
92
92
|
if (family === "pie" || family === "funnel" || family === "parliament") return "pie";
|
|
@@ -139,7 +139,7 @@ function chartToMermaid(spec, options = {}) {
|
|
|
139
139
|
lines.push("treemap-beta");
|
|
140
140
|
if (spec.title) lines.push(`title ${spec.title}`);
|
|
141
141
|
const first = _nullishCoalesce(visible[0], () => ( spec.series[0]));
|
|
142
|
-
const tree = spec.tree.length ? spec.tree :
|
|
142
|
+
const tree = spec.tree.length ? spec.tree : _chunkP6WYDBTHcjs.chartTreeFromSeries.call(void 0, spec.categories, _nullishCoalesce(_optionalChain([first, 'optionalAccess', _4 => _4.values]), () => ( [])));
|
|
143
143
|
const write = (nodes, depth) => {
|
|
144
144
|
for (const n of nodes) {
|
|
145
145
|
const pad = ind.repeat(depth);
|
|
@@ -274,8 +274,8 @@ function chartFromMermaid(text, options = {}) {
|
|
|
274
274
|
let title = _nullishCoalesce(frontTitle, () => ( ""));
|
|
275
275
|
const categories = [];
|
|
276
276
|
const series = [];
|
|
277
|
-
const xAxis =
|
|
278
|
-
const yAxis =
|
|
277
|
+
const xAxis = _chunkP6WYDBTHcjs.defaultChartAxis.call(void 0, false);
|
|
278
|
+
const yAxis = _chunkP6WYDBTHcjs.defaultChartAxis.call(void 0, true);
|
|
279
279
|
const radarAxes = [];
|
|
280
280
|
const pieSlices = [];
|
|
281
281
|
let legendShow = true;
|
|
@@ -437,7 +437,7 @@ function chartFromMermaid(text, options = {}) {
|
|
|
437
437
|
input.series = metaSeries.map((extra, i) => ({ ..._nullishCoalesce(base[i], () => ( {})), ..._nullishCoalesce(extra, () => ( {})) }));
|
|
438
438
|
}
|
|
439
439
|
}
|
|
440
|
-
const { spec, issues: specIssues } =
|
|
440
|
+
const { spec, issues: specIssues } = _chunkP6WYDBTHcjs.normalizeChartSpec.call(void 0, input);
|
|
441
441
|
if (!family && !partial && !issues.length) issues.push({ path: "header", message: "The text is empty: expected a chart header (xychart-beta, pie, radar-beta, sankey-beta or treemap-beta)." });
|
|
442
442
|
return { spec, issues: [...issues, ...specIssues], family, hasMeta: !!meta };
|
|
443
443
|
}
|
|
@@ -467,7 +467,7 @@ function readWholeMermaid(family, all, headerLine, partial, title, issues) {
|
|
|
467
467
|
const tree = items.map(toNode);
|
|
468
468
|
const leaf = (n) => !n.children;
|
|
469
469
|
const flatOrOneLevel = tree.every(leaf) || tree.every((n) => _optionalChain([n, 'access', _18 => _18.children, 'optionalAccess', _19 => _19.every, 'call', _20 => _20(leaf)]));
|
|
470
|
-
return { type: flatOrOneLevel ? "treemap" : "sunburst", title: name, tree, categories: tree.map((n) => n.name), series: [{ id: "series-1", name: "Values", values: tree.map(
|
|
470
|
+
return { type: flatOrOneLevel ? "treemap" : "sunburst", title: name, tree, categories: tree.map((n) => n.name), series: [{ id: "series-1", name: "Values", values: tree.map(_chunkP6WYDBTHcjs.chartTreeTotal) }] };
|
|
471
471
|
}
|
|
472
472
|
function findMermaidCharts(text) {
|
|
473
473
|
const lines = text.replace(/^/, "").split(/\r?\n/);
|
|
@@ -512,11 +512,11 @@ function findMermaidCharts(text) {
|
|
|
512
512
|
}
|
|
513
513
|
|
|
514
514
|
// src/chart/summary.ts
|
|
515
|
-
function summarizeChart(spec, size = { width: 640, height: 400 }, scene =
|
|
515
|
+
function summarizeChart(spec, size = { width: 640, height: 400 }, scene = _chunkMDLEGVENcjs.layoutChart.call(void 0, spec, { ...size, selection: null })) {
|
|
516
516
|
const visible = spec.series.filter((s) => !s.hidden);
|
|
517
|
-
const series = visible.map((s) =>
|
|
518
|
-
const colors =
|
|
519
|
-
const check =
|
|
517
|
+
const series = visible.map((s) => _chunkMDLEGVENcjs.summarizeChartSeries.call(void 0, s, spec.categories));
|
|
518
|
+
const colors = _chunkP6WYDBTHcjs.chartSpecColorsByCategory.call(void 0, spec) ? spec.categories.map((_, i) => _optionalChain([visible, 'access', _24 => _24[0], 'optionalAccess', _25 => _25.pointColors, 'optionalAccess', _26 => _26[i]]) || _chunkP6WYDBTHcjs.chartSliceColor.call(void 0, spec, i)) : visible.map((s) => _chunkP6WYDBTHcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(s)));
|
|
519
|
+
const check = _chunkP6WYDBTHcjs.checkChartColors.call(void 0, colors, { surface: scene.theme.surface.startsWith("var(") ? "#ffffff" : scene.theme.surface });
|
|
520
520
|
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;
|
|
521
521
|
return {
|
|
522
522
|
type: spec.type,
|
|
@@ -531,12 +531,12 @@ function summarizeChart(spec, size = { width: 640, height: 400 }, scene = _chunk
|
|
|
531
531
|
description: describeChart(spec, series)
|
|
532
532
|
};
|
|
533
533
|
}
|
|
534
|
-
function describeChart(spec, series = spec.series.filter((s) => !s.hidden).map((s) =>
|
|
535
|
-
const kind =
|
|
534
|
+
function describeChart(spec, series = spec.series.filter((s) => !s.hidden).map((s) => _chunkMDLEGVENcjs.summarizeChartSeries.call(void 0, s, spec.categories))) {
|
|
535
|
+
const kind = _chunkP6WYDBTHcjs.CHART_TYPE_LABELS[spec.type].toLowerCase();
|
|
536
536
|
const parts = [];
|
|
537
|
-
const family =
|
|
537
|
+
const family = _chunkP6WYDBTHcjs.chartFamily.call(void 0, spec);
|
|
538
538
|
const format = spec.yAxis.format;
|
|
539
|
-
const fmt = (v) => v === null ? "blank" :
|
|
539
|
+
const fmt = (v) => v === null ? "blank" : _chunkMDLEGVENcjs.formatChartNumber.call(void 0, v, format);
|
|
540
540
|
const head = spec.title ? `${spec.title}: a ${kind} chart` : `A ${kind} chart`;
|
|
541
541
|
if (!series.length || series.every((s) => s.count === 0)) return `${head} with no data.`;
|
|
542
542
|
if (family === "pie" || family === "funnel" || family === "treemap" || family === "sunburst") {
|
|
@@ -546,16 +546,16 @@ function describeChart(spec, series = spec.series.filter((s) => !s.hidden).map((
|
|
|
546
546
|
parts.push(`${head} of ${s.name} across ${spec.categories.length} categories, totalling ${fmt(s.sum)}.`);
|
|
547
547
|
parts.push(`The largest is ${s.maxAt} at ${fmt(s.max)}${share(s.max)}; the smallest is ${s.minAt} at ${fmt(s.min)}${share(s.min)}.`);
|
|
548
548
|
if (spec.tree.length) {
|
|
549
|
-
const depth =
|
|
550
|
-
const items =
|
|
549
|
+
const depth = _chunkP6WYDBTHcjs.chartTreeDepth.call(void 0, spec.tree);
|
|
550
|
+
const items = _chunkP6WYDBTHcjs.chartTreeToRows.call(void 0, spec.tree).length;
|
|
551
551
|
parts.push(`The data is grouped ${depth} level${depth === 1 ? "" : "s"} deep with ${items} item${items === 1 ? "" : "s"}.`);
|
|
552
552
|
}
|
|
553
553
|
return parts.join(" ");
|
|
554
554
|
}
|
|
555
555
|
if (family === "choropleth") {
|
|
556
556
|
const s = spec.series.find((x) => !x.hidden);
|
|
557
|
-
const map =
|
|
558
|
-
const matches = map ?
|
|
557
|
+
const map = _chunkMDLEGVENcjs.getChartMap.call(void 0, spec.map);
|
|
558
|
+
const matches = map ? _chunkMDLEGVENcjs.matchChartMapRegions.call(void 0, map, spec.categories) : spec.categories.map(() => null);
|
|
559
559
|
const rows = spec.categories.flatMap((c, i) => matches[i] && s.values[i] !== null ? [{ name: matches[i].name, v: s.values[i] }] : []).sort((a, b) => b.v - a.v);
|
|
560
560
|
const missing = spec.categories.filter((_, i) => !matches[i]).length;
|
|
561
561
|
if (!rows.length) return `${head} of ${_nullishCoalesce(_optionalChain([map, 'optionalAccess', _27 => _27.name]), () => ( spec.map))} with no regions matched.`;
|
|
@@ -563,8 +563,8 @@ function describeChart(spec, series = spec.series.filter((s) => !s.hidden).map((
|
|
|
563
563
|
}
|
|
564
564
|
if (family === "barrace") {
|
|
565
565
|
const n = spec.categories.length;
|
|
566
|
-
const first =
|
|
567
|
-
const last =
|
|
566
|
+
const first = _chunkMDLEGVENcjs.chartRaceRanking.call(void 0, spec, 0)[0];
|
|
567
|
+
const last = _chunkMDLEGVENcjs.chartRaceRanking.call(void 0, spec, n - 1)[0];
|
|
568
568
|
const lead = (e, at) => e ? `${e.name} leads at ${at} with ${fmt(e.value)}` : "";
|
|
569
569
|
return `${head} of ${series.length} names over ${n} time points (${spec.categories[0]} to ${spec.categories[n - 1]}), showing the top ${Math.min(spec.raceTopN, series.length)}. ${lead(first, spec.categories[0])}; ${lead(last, spec.categories[n - 1])}.`;
|
|
570
570
|
}
|
|
@@ -650,7 +650,7 @@ function describeChart(spec, series = spec.series.filter((s) => !s.hidden).map((
|
|
|
650
650
|
}
|
|
651
651
|
parts.push(...axes);
|
|
652
652
|
for (const s of spec.series.filter((x) => !x.hidden && (x.errorBars || x.xErrorBars)).slice(0, 8)) {
|
|
653
|
-
const bars = [s.errorBars ?
|
|
653
|
+
const bars = [s.errorBars ? _chunkP6WYDBTHcjs.describeChartErrorBars.call(void 0, s.errorBars) : "", s.xErrorBars ? `x ${_chunkP6WYDBTHcjs.describeChartErrorBars.call(void 0, s.xErrorBars)}` : ""].filter(Boolean).join(" and ");
|
|
654
654
|
parts.push(`${s.name} has ${bars}.`);
|
|
655
655
|
}
|
|
656
656
|
return parts.join(" ");
|
|
@@ -715,7 +715,7 @@ function chartSceneToSvg(scene, options = {}) {
|
|
|
715
715
|
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>`;
|
|
716
716
|
}
|
|
717
717
|
function chartToSvg(spec, options) {
|
|
718
|
-
const scene =
|
|
718
|
+
const scene = _chunkMDLEGVENcjs.layoutChart.call(void 0, spec, { ...options, selection: null });
|
|
719
719
|
return chartSceneToSvg(scene, { ...options, ariaLabel: _nullishCoalesce(options.ariaLabel, () => ( (spec.title || void 0))), description: _nullishCoalesce(options.description, () => ( describeChart(spec))) });
|
|
720
720
|
}
|
|
721
721
|
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
@@ -753,10 +753,10 @@ var CHART_LAYOUT_PRESETS = [
|
|
|
753
753
|
];
|
|
754
754
|
function monochromeChartPalette(base, count = 6) {
|
|
755
755
|
const steps = count <= 1 ? [0] : Array.from({ length: count }, (_, i) => -0.45 + 1.05 * i / (count - 1));
|
|
756
|
-
return steps.map((t) =>
|
|
756
|
+
return steps.map((t) => _chunkP6WYDBTHcjs.shadeChartColor.call(void 0, base, t));
|
|
757
757
|
}
|
|
758
758
|
var CHART_COLOR_SCHEMES = [
|
|
759
|
-
{ id: "default", label: "Default", description: "Ten distinct colours, readable on light and dark backgrounds.", palette:
|
|
759
|
+
{ id: "default", label: "Default", description: "Ten distinct colours, readable on light and dark backgrounds.", palette: _chunkP6WYDBTHcjs.DEFAULT_CHART_PALETTE },
|
|
760
760
|
{ 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"] },
|
|
761
761
|
{ id: "office", label: "Office", description: "The six accent colours of the default Office theme.", palette: ["#4472c4", "#ed7d31", "#a5a5a5", "#ffc000", "#5b9bd5", "#70ad47"] },
|
|
762
762
|
{ id: "warm", label: "Warm", description: "Reds, oranges and yellows.", palette: ["#b2182b", "#d6604d", "#f4a582", "#e08214", "#fdb863", "#8c510a"] },
|
|
@@ -834,7 +834,7 @@ var ChartController = (_class = class {
|
|
|
834
834
|
this.history = _nullishCoalesce(options.history, () => ( new (0, _chunkWKPXOGZZcjs.HistoryManager)()));
|
|
835
835
|
this.onChange = options.onChange;
|
|
836
836
|
this.raceTicker = _nullishCoalesce(options.raceTicker, () => ( defaultRaceTicker));
|
|
837
|
-
const { spec, issues } =
|
|
837
|
+
const { spec, issues } = _chunkP6WYDBTHcjs.normalizeChartSpec.call(void 0, _nullishCoalesce(options.spec, () => ( {})));
|
|
838
838
|
this.spec = spec;
|
|
839
839
|
this.issues = issues;
|
|
840
840
|
this.state = this.computeState();
|
|
@@ -939,7 +939,7 @@ var ChartController = (_class = class {
|
|
|
939
939
|
const hadIssues = this.issues.length > 0;
|
|
940
940
|
this.issues = [];
|
|
941
941
|
if (sameChartJson(before, next)) {
|
|
942
|
-
const reselect = select !== void 0 && !
|
|
942
|
+
const reselect = select !== void 0 && !_chunkMDLEGVENcjs.sameChartSelection.call(void 0, this.selection, select) && !(select === null && this.selection === null);
|
|
943
943
|
if (reselect) this.selection = select;
|
|
944
944
|
if (reselect || hadIssues) this.notify(false);
|
|
945
945
|
return;
|
|
@@ -962,7 +962,7 @@ var ChartController = (_class = class {
|
|
|
962
962
|
}
|
|
963
963
|
/** A copy of the spec with `edit` applied (series and categories copied as needed). */
|
|
964
964
|
edited(edit) {
|
|
965
|
-
const draft =
|
|
965
|
+
const draft = _chunkP6WYDBTHcjs.cloneChartSpec.call(void 0, this.spec);
|
|
966
966
|
edit(draft);
|
|
967
967
|
return draft;
|
|
968
968
|
}
|
|
@@ -992,7 +992,7 @@ var ChartController = (_class = class {
|
|
|
992
992
|
legend: patch.legend ? { ...s.legend, ...patch.legend } : s.legend,
|
|
993
993
|
version: 1
|
|
994
994
|
};
|
|
995
|
-
const { spec, issues } =
|
|
995
|
+
const { spec, issues } = _chunkP6WYDBTHcjs.normalizeChartSpec.call(void 0, merged);
|
|
996
996
|
if (issues.length) return this.reject(issues.map((i) => i.message).join(" "), issues);
|
|
997
997
|
if (JSON.stringify(spec) === JSON.stringify(s)) return { ok: true };
|
|
998
998
|
this.commit(_nullishCoalesce(options.label, () => ( updateLabel(patch))), spec);
|
|
@@ -1046,7 +1046,7 @@ var ChartController = (_class = class {
|
|
|
1046
1046
|
const series = this.getSeries(seriesId);
|
|
1047
1047
|
if (!series) return this.unknownSeries(seriesId);
|
|
1048
1048
|
if (!Number.isInteger(index) || index < 0 || index >= this.spec.categories.length) return this.badIndex(index);
|
|
1049
|
-
const parsed =
|
|
1049
|
+
const parsed = _chunkP6WYDBTHcjs.parseChartValue.call(void 0, value);
|
|
1050
1050
|
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.` }]);
|
|
1051
1051
|
if (series.values[index] === parsed) {
|
|
1052
1052
|
if (this.issues.length) {
|
|
@@ -1071,7 +1071,7 @@ var ChartController = (_class = class {
|
|
|
1071
1071
|
if (!this.getSeries(cell.seriesId)) issues.push({ path: cell.seriesId, message: this.unknownSeries(cell.seriesId).message });
|
|
1072
1072
|
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 });
|
|
1073
1073
|
else {
|
|
1074
|
-
const value =
|
|
1074
|
+
const value = _chunkP6WYDBTHcjs.parseChartValue.call(void 0, cell.value);
|
|
1075
1075
|
if (value === void 0) issues.push({ path: `${cell.seriesId}[${cell.index}]`, message: `"${String(cell.value)}" is not a number.` });
|
|
1076
1076
|
else parsed.push({ seriesId: cell.seriesId, index: cell.index, value });
|
|
1077
1077
|
}
|
|
@@ -1085,12 +1085,12 @@ var ChartController = (_class = class {
|
|
|
1085
1085
|
}
|
|
1086
1086
|
/** Adds a series (values padded to the categories) and selects it. Returns its id. */
|
|
1087
1087
|
addSeries(input = {}, options = {}) {
|
|
1088
|
-
const id = input.id && !this.getSeries(input.id) ? input.id :
|
|
1088
|
+
const id = input.id && !this.getSeries(input.id) ? input.id : _chunkP6WYDBTHcjs.uniqueChartSeriesId.call(void 0, this.spec.series);
|
|
1089
1089
|
const name = _nullishCoalesce(input.name, () => ( `Series ${this.spec.series.length + 1}`));
|
|
1090
1090
|
const at = Math.max(0, Math.min(this.spec.series.length, _nullishCoalesce(options.at, () => ( this.spec.series.length))));
|
|
1091
1091
|
const series = [...this.spec.series];
|
|
1092
1092
|
series.splice(at, 0, { ...input, id, name, values: _nullishCoalesce(input.values, () => ( [])) });
|
|
1093
|
-
const { spec, issues } =
|
|
1093
|
+
const { spec, issues } = _chunkP6WYDBTHcjs.normalizeChartSpec.call(void 0, { ...this.spec, series });
|
|
1094
1094
|
if (issues.length) return this.reject(issues.map((i) => i.message).join(" "), issues);
|
|
1095
1095
|
this.commit(`Add series "${name}"`, spec, { kind: "series", seriesId: id });
|
|
1096
1096
|
return { ok: true, id };
|
|
@@ -1110,7 +1110,7 @@ var ChartController = (_class = class {
|
|
|
1110
1110
|
updateSeries(id, patch) {
|
|
1111
1111
|
const series = this.getSeries(id);
|
|
1112
1112
|
if (!series) return this.unknownSeries(id);
|
|
1113
|
-
const next =
|
|
1113
|
+
const next = _chunkP6WYDBTHcjs.cloneChartSeries.call(void 0, series);
|
|
1114
1114
|
if (patch.name !== void 0) next.name = String(patch.name);
|
|
1115
1115
|
if (patch.color === null || patch.color === "") delete next.color;
|
|
1116
1116
|
else if (patch.color !== void 0) next.color = patch.color;
|
|
@@ -1130,7 +1130,7 @@ var ChartController = (_class = class {
|
|
|
1130
1130
|
const series2 = this.spec.series.map((s) => s.id === id ? next : s);
|
|
1131
1131
|
const renamed = next.name !== series.name && this.spec.highlight.includes(series.name) && !this.spec.categories.includes(series.name);
|
|
1132
1132
|
const highlight = renamed ? this.spec.highlight.map((h) => h === series.name ? next.name : h) : this.spec.highlight;
|
|
1133
|
-
const { spec, issues } =
|
|
1133
|
+
const { spec, issues } = _chunkP6WYDBTHcjs.normalizeChartSpec.call(void 0, { ...this.spec, series: series2, highlight });
|
|
1134
1134
|
if (issues.length) return this.reject(issues.map((i) => i.message).join(" "), issues);
|
|
1135
1135
|
if (JSON.stringify(spec.series) === JSON.stringify(this.spec.series)) return { ok: true };
|
|
1136
1136
|
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}"`;
|
|
@@ -1236,7 +1236,7 @@ var ChartController = (_class = class {
|
|
|
1236
1236
|
const width = Math.max(...rows.map((r) => r.length));
|
|
1237
1237
|
const lastSeries = column + width - 1;
|
|
1238
1238
|
while (d.series.length <= lastSeries) {
|
|
1239
|
-
const id =
|
|
1239
|
+
const id = _chunkP6WYDBTHcjs.uniqueChartSeriesId.call(void 0, d.series);
|
|
1240
1240
|
d.series.push({ id, name: `Series ${d.series.length + 1}`, values: d.categories.map(() => null) });
|
|
1241
1241
|
}
|
|
1242
1242
|
const lastRow = row + rows.length - 1;
|
|
@@ -1250,7 +1250,7 @@ var ChartController = (_class = class {
|
|
|
1250
1250
|
const index = row + r;
|
|
1251
1251
|
if (col < 0) d.categories[index] = cell === null || cell === void 0 ? "" : String(cell).trim();
|
|
1252
1252
|
else {
|
|
1253
|
-
const parsed =
|
|
1253
|
+
const parsed = _chunkP6WYDBTHcjs.parseChartValue.call(void 0, cell);
|
|
1254
1254
|
if (parsed === void 0) issues.push({ path: `${d.series[col].id}[${index}]`, message: `"${String(cell)}" is not a number; it was left blank.` });
|
|
1255
1255
|
d.series[col].values[index] = _nullishCoalesce(parsed, () => ( null));
|
|
1256
1256
|
}
|
|
@@ -1269,14 +1269,14 @@ var ChartController = (_class = class {
|
|
|
1269
1269
|
* colours and types are kept by name.
|
|
1270
1270
|
*/
|
|
1271
1271
|
importTable(rows, options = {}) {
|
|
1272
|
-
const data =
|
|
1272
|
+
const data = _chunkP6WYDBTHcjs.chartDataFromTable.call(void 0, rows, options);
|
|
1273
1273
|
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.");
|
|
1274
1274
|
const byName = new Map(this.spec.series.map((s) => [s.name, s]));
|
|
1275
1275
|
const series = data.series.map((s) => {
|
|
1276
1276
|
const old = byName.get(s.name);
|
|
1277
1277
|
return { ...s, ..._optionalChain([old, 'optionalAccess', _65 => _65.color]) ? { color: old.color } : {}, ..._optionalChain([old, 'optionalAccess', _66 => _66.type]) ? { type: old.type } : {}, ...old ? { id: old.id } : {} };
|
|
1278
1278
|
});
|
|
1279
|
-
const { spec } =
|
|
1279
|
+
const { spec } = _chunkP6WYDBTHcjs.normalizeChartSpec.call(void 0, { ...this.spec, categories: data.categories, series, tree: [], links: [] });
|
|
1280
1280
|
this.commit("Import data", spec);
|
|
1281
1281
|
if (data.issues.length) {
|
|
1282
1282
|
this.issues = data.issues;
|
|
@@ -1307,7 +1307,7 @@ var ChartController = (_class = class {
|
|
|
1307
1307
|
/** Replaces the grouped data (an empty list goes back to the table, keeping the totals as values). One undo step. */
|
|
1308
1308
|
setTree(tree, options = {}) {
|
|
1309
1309
|
const issues = [];
|
|
1310
|
-
const next =
|
|
1310
|
+
const next = _chunkP6WYDBTHcjs.normalizeChartTree.call(void 0, tree, issues);
|
|
1311
1311
|
if (issues.length) return this.reject(issues.map((i) => i.message).join(" "), issues);
|
|
1312
1312
|
return this.update({ tree: next, links: [] }, { label: _nullishCoalesce(options.label, () => ( (next.length ? "Replace grouped data" : "Ungroup data"))) });
|
|
1313
1313
|
}
|
|
@@ -1317,11 +1317,11 @@ var ChartController = (_class = class {
|
|
|
1317
1317
|
*/
|
|
1318
1318
|
setTreeRows(rows, options = {}) {
|
|
1319
1319
|
const issues = [];
|
|
1320
|
-
const next =
|
|
1320
|
+
const next = _chunkP6WYDBTHcjs.chartTreeFromRows.call(void 0, rows, issues);
|
|
1321
1321
|
if (issues.length) return this.reject(issues.map((i) => i.message).join(" "), issues);
|
|
1322
1322
|
const keepColors = (list, prefix) => {
|
|
1323
1323
|
for (const n of list) {
|
|
1324
|
-
const old =
|
|
1324
|
+
const old = _chunkP6WYDBTHcjs.findChartTreeNode.call(void 0, this.spec.tree, [...prefix, n.name]);
|
|
1325
1325
|
if (_optionalChain([old, 'optionalAccess', _67 => _67.color])) n.color = old.color;
|
|
1326
1326
|
if (n.children) keepColors(n.children, [...prefix, n.name]);
|
|
1327
1327
|
}
|
|
@@ -1332,15 +1332,15 @@ var ChartController = (_class = class {
|
|
|
1332
1332
|
/** Replaces the data with a table of names and values (group, …, item, value); see `chartTreeFromTable`. */
|
|
1333
1333
|
importTreeTable(rows, options = {}) {
|
|
1334
1334
|
const issues = [];
|
|
1335
|
-
const next =
|
|
1335
|
+
const next = _chunkP6WYDBTHcjs.chartTreeFromTable.call(void 0, rows, options, issues);
|
|
1336
1336
|
if (issues.length) return this.reject(issues.map((i) => i.message).join(" "), issues);
|
|
1337
1337
|
if (!next.length) return this.reject('There is no grouped data to import: expected rows of names followed by a value, e.g. "Europe,France,40".');
|
|
1338
1338
|
return this.update({ tree: next, links: [] }, { label: "Import grouped data" });
|
|
1339
1339
|
}
|
|
1340
1340
|
nodeAt(path) {
|
|
1341
|
-
const node =
|
|
1341
|
+
const node = _chunkP6WYDBTHcjs.findChartTreeNode.call(void 0, this.spec.tree, path);
|
|
1342
1342
|
if (node) return node;
|
|
1343
|
-
const known = path.length > 1 ?
|
|
1343
|
+
const known = path.length > 1 ? _chunkP6WYDBTHcjs.findChartTreeNode.call(void 0, this.spec.tree, path.slice(0, -1)) : null;
|
|
1344
1344
|
const siblings = _nullishCoalesce((path.length > 1 ? _optionalChain([known, 'optionalAccess', _68 => _68.children]) : this.spec.tree), () => ( []));
|
|
1345
1345
|
return fail(
|
|
1346
1346
|
`There is no node ${JSON.stringify(path)}. ${siblings.length ? `${path.length > 1 && known ? `"${known.name}" contains` : "The top level has"} ${siblings.map((n) => `"${n.name}"`).slice(0, 20).join(", ")}.` : "The chart has no grouped data yet; add nodes with add_chart_tree_node or set_chart_tree."}`
|
|
@@ -1356,12 +1356,12 @@ var ChartController = (_class = class {
|
|
|
1356
1356
|
siblings = group.children;
|
|
1357
1357
|
}
|
|
1358
1358
|
const issues = [];
|
|
1359
|
-
const [node] =
|
|
1359
|
+
const [node] = _chunkP6WYDBTHcjs.normalizeChartTree.call(void 0, [input], issues, "node");
|
|
1360
1360
|
if (!node || issues.length) return this.reject(issues.map((i) => i.message).join(" ") || "The node is not valid.", issues);
|
|
1361
1361
|
if (siblings.some((n) => n.name === node.name)) return this.reject(`"${node.name}" is already there; names under one group must be unique.`);
|
|
1362
1362
|
const at = Math.max(0, Math.min(siblings.length, _nullishCoalesce(options.at, () => ( siblings.length))));
|
|
1363
|
-
const tree =
|
|
1364
|
-
const list = parent.length ?
|
|
1363
|
+
const tree = _chunkP6WYDBTHcjs.cloneChartTree.call(void 0, this.spec.tree);
|
|
1364
|
+
const list = parent.length ? _chunkP6WYDBTHcjs.findChartTreeNode.call(void 0, tree, parent).children : tree;
|
|
1365
1365
|
list.splice(at, 0, node);
|
|
1366
1366
|
const result = this.update({ tree }, { label: `Add "${node.name}"` });
|
|
1367
1367
|
if (!result.ok) return result;
|
|
@@ -1373,16 +1373,16 @@ var ChartController = (_class = class {
|
|
|
1373
1373
|
if ("ok" in node) return node;
|
|
1374
1374
|
if (patch.value !== void 0 && node.children) return this.reject(`"${node.name}" is a group: its value is the sum of its items. Change the items instead.`);
|
|
1375
1375
|
const name = patch.name !== void 0 ? String(patch.name).trim() : node.name;
|
|
1376
|
-
const siblings = (path.length > 1 ?
|
|
1376
|
+
const siblings = (path.length > 1 ? _chunkP6WYDBTHcjs.findChartTreeNode.call(void 0, this.spec.tree, path.slice(0, -1)).children : this.spec.tree).filter((n) => n !== node);
|
|
1377
1377
|
if (siblings.some((n) => n.name === name)) return this.reject(`There is already a "${name}" next to "${node.name}"; names under one group must be unique.`);
|
|
1378
|
-
const tree =
|
|
1379
|
-
const target =
|
|
1378
|
+
const tree = _chunkP6WYDBTHcjs.cloneChartTree.call(void 0, this.spec.tree);
|
|
1379
|
+
const target = _chunkP6WYDBTHcjs.findChartTreeNode.call(void 0, tree, path);
|
|
1380
1380
|
const merged = { ...target, name };
|
|
1381
1381
|
if (patch.value !== void 0) merged.value = patch.value;
|
|
1382
1382
|
if (patch.color === null) delete merged.color;
|
|
1383
1383
|
else if (patch.color !== void 0) merged.color = patch.color;
|
|
1384
1384
|
const issues = [];
|
|
1385
|
-
const [checked] =
|
|
1385
|
+
const [checked] = _chunkP6WYDBTHcjs.normalizeChartTree.call(void 0, [merged], issues, "node");
|
|
1386
1386
|
if (!checked || issues.length) return this.reject(issues.map((i) => i.message).join(" "), issues);
|
|
1387
1387
|
Object.assign(target, checked);
|
|
1388
1388
|
if (patch.color === null) delete target.color;
|
|
@@ -1394,8 +1394,8 @@ var ChartController = (_class = class {
|
|
|
1394
1394
|
removeTreeNode(path) {
|
|
1395
1395
|
const node = this.nodeAt(path);
|
|
1396
1396
|
if ("ok" in node) return node;
|
|
1397
|
-
const tree =
|
|
1398
|
-
const parent = path.length > 1 ?
|
|
1397
|
+
const tree = _chunkP6WYDBTHcjs.cloneChartTree.call(void 0, this.spec.tree);
|
|
1398
|
+
const parent = path.length > 1 ? _chunkP6WYDBTHcjs.findChartTreeNode.call(void 0, tree, path.slice(0, -1)) : null;
|
|
1399
1399
|
const list = parent ? parent.children : tree;
|
|
1400
1400
|
list.splice(
|
|
1401
1401
|
list.findIndex((n) => n.name === node.name),
|
|
@@ -1416,7 +1416,7 @@ var ChartController = (_class = class {
|
|
|
1416
1416
|
*/
|
|
1417
1417
|
setLinks(links, options = {}) {
|
|
1418
1418
|
const issues = [];
|
|
1419
|
-
const next =
|
|
1419
|
+
const next = _chunkP6WYDBTHcjs.normalizeChartLinks.call(void 0, links, issues);
|
|
1420
1420
|
if (issues.length) return this.reject(issues.map((i) => i.message).join(" "), issues);
|
|
1421
1421
|
const used = new Set(next.flatMap((l) => [l.source, l.target]));
|
|
1422
1422
|
const sankeyNodes = options.nodes ? [...options.nodes] : this.spec.sankeyNodes.filter((n) => used.has(n));
|
|
@@ -1424,7 +1424,7 @@ var ChartController = (_class = class {
|
|
|
1424
1424
|
}
|
|
1425
1425
|
/** Replaces the data with flows from a table of source, target and value columns. */
|
|
1426
1426
|
importLinksTable(rows, options = {}) {
|
|
1427
|
-
const raw =
|
|
1427
|
+
const raw = _chunkP6WYDBTHcjs.chartLinksFromTable.call(void 0, rows, options);
|
|
1428
1428
|
if (!raw.length) return this.reject('There are no flows to import: expected rows of source, target and value, e.g. "Website,Signup,120".');
|
|
1429
1429
|
return this.setLinks(raw, { label: "Import flows" });
|
|
1430
1430
|
}
|
|
@@ -1488,7 +1488,7 @@ var ChartController = (_class = class {
|
|
|
1488
1488
|
/** Why a reference on `axis` at `values` cannot be drawn on this chart, or null. */
|
|
1489
1489
|
referenceProblem(axis, values) {
|
|
1490
1490
|
const s = this.spec;
|
|
1491
|
-
const family =
|
|
1491
|
+
const family = _chunkP6WYDBTHcjs.chartFamily.call(void 0, s);
|
|
1492
1492
|
if (family !== "cartesian" && family !== "xy") return `Reference lines and bands are drawn on bar, line, area, scatter and bubble charts; this is a ${s.type} chart.`;
|
|
1493
1493
|
if (axis === "x" && family !== "xy") return 'axis "x" needs a scatter or bubble chart with numeric x values; use "y" for the value axis.';
|
|
1494
1494
|
if (axis === "y2" && (family !== "cartesian" || !s.series.some((x) => !x.hidden && x.axis === "secondary")))
|
|
@@ -1507,7 +1507,7 @@ var ChartController = (_class = class {
|
|
|
1507
1507
|
/** Adds a reference line (a target, floor or average). Returns its index. */
|
|
1508
1508
|
addReferenceLine(input) {
|
|
1509
1509
|
const issues = [];
|
|
1510
|
-
const line =
|
|
1510
|
+
const line = _chunkP6WYDBTHcjs.normalizeChartReferenceLine.call(void 0, input, "referenceLine", issues);
|
|
1511
1511
|
if (!line || issues.length) return this.reject(issues.map((i) => i.message).join(" "), issues);
|
|
1512
1512
|
const problem = this.referenceProblem(line.axis, [line.value]);
|
|
1513
1513
|
if (problem) return this.reject(problem);
|
|
@@ -1522,7 +1522,7 @@ var ChartController = (_class = class {
|
|
|
1522
1522
|
const merged = { ...current, ...patch };
|
|
1523
1523
|
for (const [k, v] of Object.entries(patch)) if (v === null) delete merged[k];
|
|
1524
1524
|
const issues = [];
|
|
1525
|
-
const line =
|
|
1525
|
+
const line = _chunkP6WYDBTHcjs.normalizeChartReferenceLine.call(void 0, merged, "referenceLine", issues);
|
|
1526
1526
|
if (!line || issues.length) return this.reject(issues.map((i) => i.message).join(" "), issues);
|
|
1527
1527
|
const problem = this.referenceProblem(line.axis, [line.value]);
|
|
1528
1528
|
if (problem) return this.reject(problem);
|
|
@@ -1537,7 +1537,7 @@ var ChartController = (_class = class {
|
|
|
1537
1537
|
/** Adds a reference band (a target range). Returns its index. */
|
|
1538
1538
|
addReferenceBand(input) {
|
|
1539
1539
|
const issues = [];
|
|
1540
|
-
const band =
|
|
1540
|
+
const band = _chunkP6WYDBTHcjs.normalizeChartReferenceBand.call(void 0, input, "referenceBand", issues);
|
|
1541
1541
|
if (!band || issues.length) return this.reject(issues.map((i) => i.message).join(" "), issues);
|
|
1542
1542
|
const problem = this.referenceProblem(band.axis, [band.from, band.to]);
|
|
1543
1543
|
if (problem) return this.reject(problem);
|
|
@@ -1552,7 +1552,7 @@ var ChartController = (_class = class {
|
|
|
1552
1552
|
const merged = { ...current, ...patch };
|
|
1553
1553
|
for (const [k, v] of Object.entries(patch)) if (v === null) delete merged[k];
|
|
1554
1554
|
const issues = [];
|
|
1555
|
-
const band =
|
|
1555
|
+
const band = _chunkP6WYDBTHcjs.normalizeChartReferenceBand.call(void 0, merged, "referenceBand", issues);
|
|
1556
1556
|
if (!band || issues.length) return this.reject(issues.map((i) => i.message).join(" "), issues);
|
|
1557
1557
|
const problem = this.referenceProblem(band.axis, [band.from, band.to]);
|
|
1558
1558
|
if (problem) return this.reject(problem);
|
|
@@ -1575,7 +1575,7 @@ var ChartController = (_class = class {
|
|
|
1575
1575
|
const series = this.getSeries(seriesId);
|
|
1576
1576
|
if (!series) return this.unknownSeries(seriesId);
|
|
1577
1577
|
if (!Number.isInteger(index) || index < 0 || index >= this.spec.categories.length) return this.badIndex(index);
|
|
1578
|
-
const family =
|
|
1578
|
+
const family = _chunkP6WYDBTHcjs.chartFamily.call(void 0, this.spec);
|
|
1579
1579
|
const text = label === null ? "" : String(label).trim();
|
|
1580
1580
|
if (text && family !== "cartesian" && family !== "xy") return this.reject(`Callouts are drawn on bar, line, area, scatter and bubble charts; this is a ${this.spec.type} chart.`);
|
|
1581
1581
|
if (text && (series.values[index] === null || series.values[index] === void 0))
|
|
@@ -1597,10 +1597,10 @@ var ChartController = (_class = class {
|
|
|
1597
1597
|
addTrendline(seriesId, input) {
|
|
1598
1598
|
const series = this.getSeries(seriesId);
|
|
1599
1599
|
if (!series) return this.unknownSeries(seriesId);
|
|
1600
|
-
if (!
|
|
1600
|
+
if (!_chunkMDLEGVENcjs.chartSupportsTrendlines.call(void 0, this.spec.type, this.spec.stacking))
|
|
1601
1601
|
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.`);
|
|
1602
1602
|
const issues = [];
|
|
1603
|
-
const line =
|
|
1603
|
+
const line = _chunkP6WYDBTHcjs.normalizeChartTrendline.call(void 0, input, "trendline", issues);
|
|
1604
1604
|
if (!line || issues.length) return this.reject(issues.map((i) => i.message).join(" ") || "The trendline is not valid.", issues);
|
|
1605
1605
|
const index = _nullishCoalesce(_optionalChain([series, 'access', _71 => _71.trendlines, 'optionalAccess', _72 => _72.length]), () => ( 0));
|
|
1606
1606
|
const next = this.edited((d) => {
|
|
@@ -1619,7 +1619,7 @@ var ChartController = (_class = class {
|
|
|
1619
1619
|
const issues = [];
|
|
1620
1620
|
const merged = { ...current, ...patch };
|
|
1621
1621
|
for (const [k, v] of Object.entries(patch)) if (v === null) delete merged[k];
|
|
1622
|
-
const line =
|
|
1622
|
+
const line = _chunkP6WYDBTHcjs.normalizeChartTrendline.call(void 0, merged, "trendline", issues);
|
|
1623
1623
|
if (!line || issues.length) return this.reject(issues.map((i) => i.message).join(" "), issues);
|
|
1624
1624
|
this.commit(
|
|
1625
1625
|
"Change trendline",
|
|
@@ -1647,7 +1647,7 @@ var ChartController = (_class = class {
|
|
|
1647
1647
|
trendlinePoints(seriesId) {
|
|
1648
1648
|
const series = this.getSeries(seriesId);
|
|
1649
1649
|
if (!series) return [];
|
|
1650
|
-
const xy =
|
|
1650
|
+
const xy = _chunkP6WYDBTHcjs.chartFamily.call(void 0, this.spec) === "xy";
|
|
1651
1651
|
const out = [];
|
|
1652
1652
|
series.values.forEach((v, i) => {
|
|
1653
1653
|
const x = xy ? _nullishCoalesce(_optionalChain([series, 'access', _79 => _79.x, 'optionalAccess', _80 => _80[i]]), () => ( (this.spec.type === "bubble" ? i + 1 : null))) : i + 1;
|
|
@@ -1659,13 +1659,13 @@ var ChartController = (_class = class {
|
|
|
1659
1659
|
trendlineFit(seriesId, index) {
|
|
1660
1660
|
const line = _optionalChain([this, 'access', _81 => _81.getSeries, 'call', _82 => _82(seriesId), 'optionalAccess', _83 => _83.trendlines, 'optionalAccess', _84 => _84[index]]);
|
|
1661
1661
|
if (!line) return null;
|
|
1662
|
-
return
|
|
1662
|
+
return _chunkMDLEGVENcjs.fitChartTrendline.call(void 0, line, this.trendlinePoints(seriesId));
|
|
1663
1663
|
}
|
|
1664
1664
|
/** The moving-average points of a trendline (empty for other kinds). */
|
|
1665
1665
|
trendlineMovingAverage(seriesId, index) {
|
|
1666
1666
|
const line = _optionalChain([this, 'access', _85 => _85.getSeries, 'call', _86 => _86(seriesId), 'optionalAccess', _87 => _87.trendlines, 'optionalAccess', _88 => _88[index]]);
|
|
1667
1667
|
if (!line || line.type !== "moving-average") return [];
|
|
1668
|
-
return
|
|
1668
|
+
return _chunkMDLEGVENcjs.chartMovingAverage.call(void 0, this.trendlinePoints(seriesId), _nullishCoalesce(line.period, () => ( 2)));
|
|
1669
1669
|
}
|
|
1670
1670
|
// -------------------------------------------------------------------------
|
|
1671
1671
|
// Reshaping
|
|
@@ -1686,7 +1686,7 @@ var ChartController = (_class = class {
|
|
|
1686
1686
|
used.add(id);
|
|
1687
1687
|
return { id, name, values: s.series.map((x) => _nullishCoalesce(x.values[i], () => ( null))) };
|
|
1688
1688
|
});
|
|
1689
|
-
const { spec } =
|
|
1689
|
+
const { spec } = _chunkP6WYDBTHcjs.normalizeChartSpec.call(void 0, { ...s, categories: s.series.map((x) => x.name), series });
|
|
1690
1690
|
this.commit("Switch rows and columns", spec, null);
|
|
1691
1691
|
return { ok: true };
|
|
1692
1692
|
}
|
|
@@ -1745,7 +1745,7 @@ var ChartController = (_class = class {
|
|
|
1745
1745
|
/** Selects a chart element (view state; not an undo step). */
|
|
1746
1746
|
select(selection) {
|
|
1747
1747
|
const next = this.validSelection(selection, this.spec);
|
|
1748
|
-
if (
|
|
1748
|
+
if (_chunkMDLEGVENcjs.sameChartSelection.call(void 0, next, this.selection) || next === null && this.selection === null) return;
|
|
1749
1749
|
this.selection = next;
|
|
1750
1750
|
this.notify(false);
|
|
1751
1751
|
}
|
|
@@ -1822,14 +1822,14 @@ var ChartController = (_class = class {
|
|
|
1822
1822
|
// -------------------------------------------------------------------------
|
|
1823
1823
|
/** The spec, for saving (a copy). */
|
|
1824
1824
|
toJSON() {
|
|
1825
|
-
return
|
|
1825
|
+
return _chunkP6WYDBTHcjs.cloneChartSpec.call(void 0, this.spec);
|
|
1826
1826
|
}
|
|
1827
1827
|
/**
|
|
1828
1828
|
* Replaces the chart without an undo step (e.g. when opening a document). Problems are
|
|
1829
1829
|
* fixed with defaults and reported in `state.issues` (and returned).
|
|
1830
1830
|
*/
|
|
1831
1831
|
load(input, options = {}) {
|
|
1832
|
-
const { spec, issues } =
|
|
1832
|
+
const { spec, issues } = _chunkP6WYDBTHcjs.normalizeChartSpec.call(void 0, input);
|
|
1833
1833
|
this.spec = spec;
|
|
1834
1834
|
this.issues = issues;
|
|
1835
1835
|
this.selection = this.validSelection(this.selection, spec);
|
|
@@ -1849,7 +1849,7 @@ var ChartController = (_class = class {
|
|
|
1849
1849
|
* nothing changes and every problem is returned (and shown in `state.issues`).
|
|
1850
1850
|
*/
|
|
1851
1851
|
replace(input, options = {}) {
|
|
1852
|
-
const { spec, issues } =
|
|
1852
|
+
const { spec, issues } = _chunkP6WYDBTHcjs.normalizeChartSpec.call(void 0, input);
|
|
1853
1853
|
if (issues.length) return this.reject(issues.map((i) => i.message).join(" "), issues);
|
|
1854
1854
|
this.commit(_nullishCoalesce(options.label, () => ( "Replace chart")), spec, this.validSelection(this.selection, spec));
|
|
1855
1855
|
return { ok: true };
|
|
@@ -1931,7 +1931,7 @@ function layoutSparkline(values, options) {
|
|
|
1931
1931
|
const h = Number.isFinite(options.height) ? Math.max(1, options.height) : 1;
|
|
1932
1932
|
const color = _nullishCoalesce(options.color, () => ( "#4269d0"));
|
|
1933
1933
|
const negative = _nullishCoalesce(options.negativeColor, () => ( "#e5484d"));
|
|
1934
|
-
const theme = { ...
|
|
1934
|
+
const theme = { ..._chunkP6WYDBTHcjs.DEFAULT_CHART_THEME, background: "transparent" };
|
|
1935
1935
|
const marks = [];
|
|
1936
1936
|
const scene = { width: w, height: h, plot: { x: 0, y: 0, width: w, height: h }, marks, percent: false, theme, warnings: [] };
|
|
1937
1937
|
const vals = values.slice(0, MAX_POINTS).map((v) => v !== null && Number.isFinite(v) ? Math.max(-1e300, Math.min(1e300, v)) : null);
|
|
@@ -1964,7 +1964,7 @@ function layoutSparkline(values, options) {
|
|
|
1964
1964
|
const flush = () => {
|
|
1965
1965
|
if (run.length >= 2) {
|
|
1966
1966
|
const pts = run.length > 4e3 ? run.filter((_, i) => i % (Math.floor(run.length / 2e3) + 1) === 0) : run;
|
|
1967
|
-
d += pts.map(([x, y], i) => `${i ? "L" : "M"}${
|
|
1967
|
+
d += pts.map(([x, y], i) => `${i ? "L" : "M"}${_chunkMDLEGVENcjs.r2.call(void 0, x)},${_chunkMDLEGVENcjs.r2.call(void 0, y)}`).join("");
|
|
1968
1968
|
}
|
|
1969
1969
|
run = [];
|
|
1970
1970
|
};
|
|
@@ -11,10 +11,10 @@ import {
|
|
|
11
11
|
CHART_OOXML_NS,
|
|
12
12
|
CHART_OOXML_RELATIONSHIP,
|
|
13
13
|
chartToOoxml
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-2VJ6OVJV.js";
|
|
15
15
|
import {
|
|
16
16
|
normalizeChartSpec
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-47V3WXDG.js";
|
|
18
18
|
|
|
19
19
|
// src/export/images.ts
|
|
20
20
|
var DOCX_IMAGE_TYPES = {
|
|
@@ -11,10 +11,10 @@ var _chunkYN6JKAUEcjs = require('./chunk-YN6JKAUE.cjs');
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _chunkM2HG5DJ2cjs = require('./chunk-M2HG5DJ2.cjs');
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
var
|
|
17
|
+
var _chunkP6WYDBTHcjs = require('./chunk-P6WYDBTH.cjs');
|
|
18
18
|
|
|
19
19
|
// src/export/images.ts
|
|
20
20
|
var DOCX_IMAGE_TYPES = {
|
|
@@ -1028,12 +1028,12 @@ var DocxBuilder = (_class2 = class {
|
|
|
1028
1028
|
this.drop("node", "chart", "chart has no spec");
|
|
1029
1029
|
return;
|
|
1030
1030
|
}
|
|
1031
|
-
const spec =
|
|
1032
|
-
const written =
|
|
1031
|
+
const spec = _chunkP6WYDBTHcjs.normalizeChartSpec.call(void 0, raw).spec;
|
|
1032
|
+
const written = _chunkM2HG5DJ2cjs.chartToOoxml.call(void 0, spec);
|
|
1033
1033
|
for (const issue of written.issues) this.drop("node", "chart", issue);
|
|
1034
1034
|
const name = `chart${this.charts.length + 1}.xml`;
|
|
1035
1035
|
this.charts.push(written.xml);
|
|
1036
|
-
const relId = this.rels.add(
|
|
1036
|
+
const relId = this.rels.add(_chunkM2HG5DJ2cjs.CHART_OOXML_RELATIONSHIP, `charts/${name}`);
|
|
1037
1037
|
let width = _nullishCoalesce(pixelAttr(_optionalChain([node, 'access', _91 => _91.attrs, 'optionalAccess', _92 => _92.width])), () => ( MAX_IMAGE_WIDTH_PX));
|
|
1038
1038
|
let height = _nullishCoalesce(pixelAttr(_optionalChain([node, 'access', _93 => _93.attrs, 'optionalAccess', _94 => _94.height])), () => ( 320));
|
|
1039
1039
|
if (width > MAX_IMAGE_WIDTH_PX) {
|
|
@@ -1050,8 +1050,8 @@ var DocxBuilder = (_class2 = class {
|
|
|
1050
1050
|
drawing.empty("wp:extent", { cx, cy }).empty("wp:effectExtent", { l: 0, t: 0, r: 0, b: 0 });
|
|
1051
1051
|
drawing.empty("wp:docPr", { id, name: `Chart ${id}`, descr: title || void 0, title: title || void 0 });
|
|
1052
1052
|
drawing.empty("wp:cNvGraphicFramePr");
|
|
1053
|
-
drawing.open("a:graphic").open("a:graphicData", { uri:
|
|
1054
|
-
drawing.empty("c:chart", { "xmlns:c":
|
|
1053
|
+
drawing.open("a:graphic").open("a:graphicData", { uri: _chunkM2HG5DJ2cjs.CHART_OOXML_NS });
|
|
1054
|
+
drawing.empty("c:chart", { "xmlns:c": _chunkM2HG5DJ2cjs.CHART_OOXML_NS, "r:id": relId });
|
|
1055
1055
|
drawing.close("a:graphicData").close("a:graphic").close("wp:inline").close("w:drawing").close("w:r");
|
|
1056
1056
|
this.report.written.paragraphs++;
|
|
1057
1057
|
w.open("w:p");
|
|
@@ -1384,7 +1384,7 @@ var DocxBuilder = (_class2 = class {
|
|
|
1384
1384
|
if (people) add("word/people.xml", people, `${CT_WML}people+xml`);
|
|
1385
1385
|
parts.push({ name: "word/_rels/document.xml.rels", data: this.rels.xml() });
|
|
1386
1386
|
for (const file of this.media) parts.push({ name: `word/media/${file.name}`, data: file.bytes });
|
|
1387
|
-
this.charts.forEach((xml, i) => add(`word/charts/chart${i + 1}.xml`, xml,
|
|
1387
|
+
this.charts.forEach((xml, i) => add(`word/charts/chart${i + 1}.xml`, xml, _chunkM2HG5DJ2cjs.CHART_OOXML_CONTENT_TYPE));
|
|
1388
1388
|
add("docProps/core.xml", this.coreXml(now), "application/vnd.openxmlformats-package.core-properties+xml");
|
|
1389
1389
|
const app = new XmlWriter();
|
|
1390
1390
|
app.open("Properties", { xmlns: "http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" });
|