@pixerate/editor 0.180.0 → 0.182.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 +39 -39
- package/dist/agent/index.js +8 -8
- package/dist/animation/index.cjs +2 -2
- package/dist/animation/index.js +1 -1
- package/dist/canvas/index.cjs +6 -6
- package/dist/canvas/index.js +2 -2
- package/dist/chart/index.cjs +169 -164
- package/dist/chart/index.d.cts +1 -0
- package/dist/chart/index.d.ts +1 -0
- package/dist/chart/index.js +13 -8
- package/dist/chart/layout-streamgraph.d.cts +15 -0
- package/dist/chart/layout-streamgraph.d.ts +15 -0
- package/dist/chart/spec.d.cts +1 -1
- package/dist/chart/spec.d.ts +1 -1
- package/dist/chart/types.d.cts +2 -1
- package/dist/chart/types.d.ts +2 -1
- package/dist/{chunk-KPWG3PSW.js → chunk-23E5GI2U.js} +8 -2
- package/dist/{chunk-IMHRN4ZZ.js → chunk-3MO3ZS7E.js} +3 -3
- package/dist/{chunk-5EMS4BZG.cjs → chunk-3SLBXKAW.cjs} +15 -7
- package/dist/{chunk-GXEC4FS6.cjs → chunk-5DQPDXOM.cjs} +82 -76
- package/dist/{chunk-ORZF4JOO.js → chunk-6ZZKRH7R.js} +3 -1
- package/dist/{chunk-FHNGNL3V.cjs → chunk-CZBRY4SW.cjs} +51 -51
- package/dist/{chunk-WL4IN36A.js → chunk-EHTX34RE.js} +13 -5
- package/dist/{chunk-ZXTO6U7T.js → chunk-GI3AVES4.js} +1 -1
- package/dist/{chunk-34UCPHYO.js → chunk-GOBOCZZI.js} +2 -2
- package/dist/{chunk-VKHJJUBK.cjs → chunk-HUAISCUX.cjs} +22 -18
- package/dist/{chunk-O2ANJFUF.js → chunk-IVSWRVB4.js} +8 -1
- package/dist/{chunk-SWTUM32H.cjs → chunk-K7ENM55P.cjs} +8 -1
- package/dist/{chunk-OLCHKGGO.js → chunk-L6Y7TSQ4.js} +5 -1
- package/dist/{chunk-TUXKLM5W.cjs → chunk-N76AMOKE.cjs} +224 -42
- package/dist/{chunk-RLOIEDA3.cjs → chunk-O7QXVGMP.cjs} +16 -16
- package/dist/{chunk-R2VHVQVY.js → chunk-PI2UYMZY.js} +3 -3
- package/dist/{chunk-E45AIIWY.cjs → chunk-RUONPPMC.cjs} +8 -8
- package/dist/{chunk-GTF4RYXJ.cjs → chunk-SOSBOS5T.cjs} +22 -22
- package/dist/{chunk-NJGFSOPP.cjs → chunk-U4QN36YT.cjs} +2 -2
- package/dist/{chunk-FKYGM35R.js → chunk-UFEDHACQ.js} +2 -2
- package/dist/{chunk-OJQVKJYD.js → chunk-WKMUBATU.js} +183 -1
- package/dist/{chunk-OUO3DSRT.cjs → chunk-WRZ6C4TU.cjs} +3 -1
- package/dist/commands/index.cjs +3 -3
- package/dist/commands/index.js +2 -2
- package/dist/diagram/index.cjs +7 -7
- package/dist/diagram/index.js +1 -1
- package/dist/export/index.cjs +4 -4
- package/dist/export/index.js +3 -3
- package/dist/extensions/index.cjs +7 -7
- package/dist/extensions/index.js +6 -6
- package/dist/image-editor/controller.d.cts +2 -0
- package/dist/image-editor/controller.d.ts +2 -0
- package/dist/image-editor/index.cjs +135 -115
- package/dist/image-editor/index.js +28 -8
- package/dist/image-editor/playback.d.cts +14 -4
- package/dist/image-editor/playback.d.ts +14 -4
- package/dist/image-editor/selection/segmentation.d.cts +3 -0
- package/dist/image-editor/selection/segmentation.d.ts +3 -0
- package/dist/index.cjs +13 -13
- package/dist/index.js +7 -7
- package/dist/paint-editor/index.cjs +6 -6
- package/dist/paint-editor/index.js +1 -1
- package/dist/tools/index.cjs +4 -4
- package/dist/tools/index.js +3 -3
- package/dist/tools/playback.d.cts +4 -1
- package/dist/tools/playback.d.ts +4 -1
- package/dist/tools/presence.d.cts +15 -3
- package/dist/tools/presence.d.ts +15 -3
- package/dist/tools/registry.d.cts +7 -1
- package/dist/tools/registry.d.ts +7 -1
- package/package.json +1 -1
|
@@ -14,7 +14,7 @@ var _chunkTTCJPX4Ucjs = require('./chunk-TTCJPX4U.cjs');
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
var
|
|
17
|
+
var _chunkN76AMOKEcjs = require('./chunk-N76AMOKE.cjs');
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
@@ -47,7 +47,7 @@ var _chunkTUXKLM5Wcjs = require('./chunk-TUXKLM5W.cjs');
|
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
|
|
50
|
-
var
|
|
50
|
+
var _chunkWRZ6C4TUcjs = require('./chunk-WRZ6C4TU.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 = _chunkWRZ6C4TUcjs.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 : _chunkWRZ6C4TUcjs.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 = _chunkWRZ6C4TUcjs.defaultChartAxis.call(void 0, false);
|
|
278
|
+
const yAxis = _chunkWRZ6C4TUcjs.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 } = _chunkWRZ6C4TUcjs.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(_chunkWRZ6C4TUcjs.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 = _chunkN76AMOKEcjs.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) => _chunkN76AMOKEcjs.summarizeChartSeries.call(void 0, s, spec.categories));
|
|
518
|
+
const colors = _chunkWRZ6C4TUcjs.chartSpecColorsByCategory.call(void 0, spec) ? spec.categories.map((_, i) => _optionalChain([visible, 'access', _24 => _24[0], 'optionalAccess', _25 => _25.pointColors, 'optionalAccess', _26 => _26[i]]) || _chunkWRZ6C4TUcjs.chartSliceColor.call(void 0, spec, i)) : visible.map((s) => _chunkWRZ6C4TUcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(s)));
|
|
519
|
+
const check = _chunkWRZ6C4TUcjs.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) => _chunkN76AMOKEcjs.summarizeChartSeries.call(void 0, s, spec.categories))) {
|
|
535
|
+
const kind = _chunkWRZ6C4TUcjs.CHART_TYPE_LABELS[spec.type].toLowerCase();
|
|
536
536
|
const parts = [];
|
|
537
|
-
const family =
|
|
537
|
+
const family = _chunkWRZ6C4TUcjs.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" : _chunkN76AMOKEcjs.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 = _chunkWRZ6C4TUcjs.chartTreeDepth.call(void 0, spec.tree);
|
|
550
|
+
const items = _chunkWRZ6C4TUcjs.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 = _chunkN76AMOKEcjs.getChartMap.call(void 0, spec.map);
|
|
558
|
+
const matches = map ? _chunkN76AMOKEcjs.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 = _chunkN76AMOKEcjs.chartRaceRanking.call(void 0, spec, 0)[0];
|
|
567
|
+
const last = _chunkN76AMOKEcjs.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
|
}
|
|
@@ -607,6 +607,12 @@ function describeChart(spec, series = spec.series.filter((s) => !s.hidden).map((
|
|
|
607
607
|
const pct = (v) => `${Math.round(v * 100)}%`;
|
|
608
608
|
return `${head} of ${spec.categories.length} questions with ${answers.length} answers from ${_optionalChain([answers, 'access', _31 => _31[0], 'optionalAccess', _32 => _32.name])} to ${_optionalChain([answers, 'access', _33 => _33[answers.length - 1], 'optionalAccess', _34 => _34.name])}. Most positive: ${_optionalChain([best, 'access', _35 => _35[0], 'optionalAccess', _36 => _36.c])} (${pct(_nullishCoalesce(_optionalChain([best, 'access', _37 => _37[0], 'optionalAccess', _38 => _38.share]), () => ( 0)))}); least: ${_optionalChain([best, 'access', _39 => _39[best.length - 1], 'optionalAccess', _40 => _40.c])} (${pct(_nullishCoalesce(_optionalChain([best, 'access', _41 => _41[best.length - 1], 'optionalAccess', _42 => _42.share]), () => ( 0)))}).`;
|
|
609
609
|
}
|
|
610
|
+
if (family === "streamgraph") {
|
|
611
|
+
const n = spec.categories.length;
|
|
612
|
+
const totals = spec.categories.map((_, i) => spec.series.filter((x) => !x.hidden).reduce((sum, s) => sum + Math.max(0, _nullishCoalesce(s.values[i], () => ( 0))), 0));
|
|
613
|
+
const maxTotal = Math.max(0, ...totals);
|
|
614
|
+
return `${head} of ${series.length} series over ${n} categories${n ? ` (${spec.categories[0]} to ${spec.categories[n - 1]})` : ""}, stacked symmetrically around a center baseline with a peak volume of ${fmt(maxTotal)}.`;
|
|
615
|
+
}
|
|
610
616
|
if (family === "waterfall") {
|
|
611
617
|
const s = spec.series.find((x) => !x.hidden);
|
|
612
618
|
const steps = s.values.filter((v, i) => v !== null && Number.isFinite(v) && !/\b(sub)?total\b/i.test(_nullishCoalesce(spec.categories[i], () => ( ""))));
|
|
@@ -644,7 +650,7 @@ function describeChart(spec, series = spec.series.filter((s) => !s.hidden).map((
|
|
|
644
650
|
}
|
|
645
651
|
parts.push(...axes);
|
|
646
652
|
for (const s of spec.series.filter((x) => !x.hidden && (x.errorBars || x.xErrorBars)).slice(0, 8)) {
|
|
647
|
-
const bars = [s.errorBars ?
|
|
653
|
+
const bars = [s.errorBars ? _chunkWRZ6C4TUcjs.describeChartErrorBars.call(void 0, s.errorBars) : "", s.xErrorBars ? `x ${_chunkWRZ6C4TUcjs.describeChartErrorBars.call(void 0, s.xErrorBars)}` : ""].filter(Boolean).join(" and ");
|
|
648
654
|
parts.push(`${s.name} has ${bars}.`);
|
|
649
655
|
}
|
|
650
656
|
return parts.join(" ");
|
|
@@ -709,7 +715,7 @@ function chartSceneToSvg(scene, options = {}) {
|
|
|
709
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>`;
|
|
710
716
|
}
|
|
711
717
|
function chartToSvg(spec, options) {
|
|
712
|
-
const scene =
|
|
718
|
+
const scene = _chunkN76AMOKEcjs.layoutChart.call(void 0, spec, { ...options, selection: null });
|
|
713
719
|
return chartSceneToSvg(scene, { ...options, ariaLabel: _nullishCoalesce(options.ariaLabel, () => ( (spec.title || void 0))), description: _nullishCoalesce(options.description, () => ( describeChart(spec))) });
|
|
714
720
|
}
|
|
715
721
|
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
@@ -747,10 +753,10 @@ var CHART_LAYOUT_PRESETS = [
|
|
|
747
753
|
];
|
|
748
754
|
function monochromeChartPalette(base, count = 6) {
|
|
749
755
|
const steps = count <= 1 ? [0] : Array.from({ length: count }, (_, i) => -0.45 + 1.05 * i / (count - 1));
|
|
750
|
-
return steps.map((t) =>
|
|
756
|
+
return steps.map((t) => _chunkWRZ6C4TUcjs.shadeChartColor.call(void 0, base, t));
|
|
751
757
|
}
|
|
752
758
|
var CHART_COLOR_SCHEMES = [
|
|
753
|
-
{ 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: _chunkWRZ6C4TUcjs.DEFAULT_CHART_PALETTE },
|
|
754
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"] },
|
|
755
761
|
{ id: "office", label: "Office", description: "The six accent colours of the default Office theme.", palette: ["#4472c4", "#ed7d31", "#a5a5a5", "#ffc000", "#5b9bd5", "#70ad47"] },
|
|
756
762
|
{ id: "warm", label: "Warm", description: "Reds, oranges and yellows.", palette: ["#b2182b", "#d6604d", "#f4a582", "#e08214", "#fdb863", "#8c510a"] },
|
|
@@ -828,7 +834,7 @@ var ChartController = (_class = class {
|
|
|
828
834
|
this.history = _nullishCoalesce(options.history, () => ( new (0, _chunkFJ2MSI43cjs.HistoryManager)()));
|
|
829
835
|
this.onChange = options.onChange;
|
|
830
836
|
this.raceTicker = _nullishCoalesce(options.raceTicker, () => ( defaultRaceTicker));
|
|
831
|
-
const { spec, issues } =
|
|
837
|
+
const { spec, issues } = _chunkWRZ6C4TUcjs.normalizeChartSpec.call(void 0, _nullishCoalesce(options.spec, () => ( {})));
|
|
832
838
|
this.spec = spec;
|
|
833
839
|
this.issues = issues;
|
|
834
840
|
this.state = this.computeState();
|
|
@@ -933,7 +939,7 @@ var ChartController = (_class = class {
|
|
|
933
939
|
const hadIssues = this.issues.length > 0;
|
|
934
940
|
this.issues = [];
|
|
935
941
|
if (sameChartJson(before, next)) {
|
|
936
|
-
const reselect = select !== void 0 && !
|
|
942
|
+
const reselect = select !== void 0 && !_chunkN76AMOKEcjs.sameChartSelection.call(void 0, this.selection, select) && !(select === null && this.selection === null);
|
|
937
943
|
if (reselect) this.selection = select;
|
|
938
944
|
if (reselect || hadIssues) this.notify(false);
|
|
939
945
|
return;
|
|
@@ -956,7 +962,7 @@ var ChartController = (_class = class {
|
|
|
956
962
|
}
|
|
957
963
|
/** A copy of the spec with `edit` applied (series and categories copied as needed). */
|
|
958
964
|
edited(edit) {
|
|
959
|
-
const draft =
|
|
965
|
+
const draft = _chunkWRZ6C4TUcjs.cloneChartSpec.call(void 0, this.spec);
|
|
960
966
|
edit(draft);
|
|
961
967
|
return draft;
|
|
962
968
|
}
|
|
@@ -986,7 +992,7 @@ var ChartController = (_class = class {
|
|
|
986
992
|
legend: patch.legend ? { ...s.legend, ...patch.legend } : s.legend,
|
|
987
993
|
version: 1
|
|
988
994
|
};
|
|
989
|
-
const { spec, issues } =
|
|
995
|
+
const { spec, issues } = _chunkWRZ6C4TUcjs.normalizeChartSpec.call(void 0, merged);
|
|
990
996
|
if (issues.length) return this.reject(issues.map((i) => i.message).join(" "), issues);
|
|
991
997
|
if (JSON.stringify(spec) === JSON.stringify(s)) return { ok: true };
|
|
992
998
|
this.commit(_nullishCoalesce(options.label, () => ( updateLabel(patch))), spec);
|
|
@@ -1040,7 +1046,7 @@ var ChartController = (_class = class {
|
|
|
1040
1046
|
const series = this.getSeries(seriesId);
|
|
1041
1047
|
if (!series) return this.unknownSeries(seriesId);
|
|
1042
1048
|
if (!Number.isInteger(index) || index < 0 || index >= this.spec.categories.length) return this.badIndex(index);
|
|
1043
|
-
const parsed =
|
|
1049
|
+
const parsed = _chunkWRZ6C4TUcjs.parseChartValue.call(void 0, value);
|
|
1044
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.` }]);
|
|
1045
1051
|
if (series.values[index] === parsed) {
|
|
1046
1052
|
if (this.issues.length) {
|
|
@@ -1065,7 +1071,7 @@ var ChartController = (_class = class {
|
|
|
1065
1071
|
if (!this.getSeries(cell.seriesId)) issues.push({ path: cell.seriesId, message: this.unknownSeries(cell.seriesId).message });
|
|
1066
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 });
|
|
1067
1073
|
else {
|
|
1068
|
-
const value =
|
|
1074
|
+
const value = _chunkWRZ6C4TUcjs.parseChartValue.call(void 0, cell.value);
|
|
1069
1075
|
if (value === void 0) issues.push({ path: `${cell.seriesId}[${cell.index}]`, message: `"${String(cell.value)}" is not a number.` });
|
|
1070
1076
|
else parsed.push({ seriesId: cell.seriesId, index: cell.index, value });
|
|
1071
1077
|
}
|
|
@@ -1079,12 +1085,12 @@ var ChartController = (_class = class {
|
|
|
1079
1085
|
}
|
|
1080
1086
|
/** Adds a series (values padded to the categories) and selects it. Returns its id. */
|
|
1081
1087
|
addSeries(input = {}, options = {}) {
|
|
1082
|
-
const id = input.id && !this.getSeries(input.id) ? input.id :
|
|
1088
|
+
const id = input.id && !this.getSeries(input.id) ? input.id : _chunkWRZ6C4TUcjs.uniqueChartSeriesId.call(void 0, this.spec.series);
|
|
1083
1089
|
const name = _nullishCoalesce(input.name, () => ( `Series ${this.spec.series.length + 1}`));
|
|
1084
1090
|
const at = Math.max(0, Math.min(this.spec.series.length, _nullishCoalesce(options.at, () => ( this.spec.series.length))));
|
|
1085
1091
|
const series = [...this.spec.series];
|
|
1086
1092
|
series.splice(at, 0, { ...input, id, name, values: _nullishCoalesce(input.values, () => ( [])) });
|
|
1087
|
-
const { spec, issues } =
|
|
1093
|
+
const { spec, issues } = _chunkWRZ6C4TUcjs.normalizeChartSpec.call(void 0, { ...this.spec, series });
|
|
1088
1094
|
if (issues.length) return this.reject(issues.map((i) => i.message).join(" "), issues);
|
|
1089
1095
|
this.commit(`Add series "${name}"`, spec, { kind: "series", seriesId: id });
|
|
1090
1096
|
return { ok: true, id };
|
|
@@ -1104,7 +1110,7 @@ var ChartController = (_class = class {
|
|
|
1104
1110
|
updateSeries(id, patch) {
|
|
1105
1111
|
const series = this.getSeries(id);
|
|
1106
1112
|
if (!series) return this.unknownSeries(id);
|
|
1107
|
-
const next =
|
|
1113
|
+
const next = _chunkWRZ6C4TUcjs.cloneChartSeries.call(void 0, series);
|
|
1108
1114
|
if (patch.name !== void 0) next.name = String(patch.name);
|
|
1109
1115
|
if (patch.color === null || patch.color === "") delete next.color;
|
|
1110
1116
|
else if (patch.color !== void 0) next.color = patch.color;
|
|
@@ -1124,7 +1130,7 @@ var ChartController = (_class = class {
|
|
|
1124
1130
|
const series2 = this.spec.series.map((s) => s.id === id ? next : s);
|
|
1125
1131
|
const renamed = next.name !== series.name && this.spec.highlight.includes(series.name) && !this.spec.categories.includes(series.name);
|
|
1126
1132
|
const highlight = renamed ? this.spec.highlight.map((h) => h === series.name ? next.name : h) : this.spec.highlight;
|
|
1127
|
-
const { spec, issues } =
|
|
1133
|
+
const { spec, issues } = _chunkWRZ6C4TUcjs.normalizeChartSpec.call(void 0, { ...this.spec, series: series2, highlight });
|
|
1128
1134
|
if (issues.length) return this.reject(issues.map((i) => i.message).join(" "), issues);
|
|
1129
1135
|
if (JSON.stringify(spec.series) === JSON.stringify(this.spec.series)) return { ok: true };
|
|
1130
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}"`;
|
|
@@ -1230,7 +1236,7 @@ var ChartController = (_class = class {
|
|
|
1230
1236
|
const width = Math.max(...rows.map((r) => r.length));
|
|
1231
1237
|
const lastSeries = column + width - 1;
|
|
1232
1238
|
while (d.series.length <= lastSeries) {
|
|
1233
|
-
const id =
|
|
1239
|
+
const id = _chunkWRZ6C4TUcjs.uniqueChartSeriesId.call(void 0, d.series);
|
|
1234
1240
|
d.series.push({ id, name: `Series ${d.series.length + 1}`, values: d.categories.map(() => null) });
|
|
1235
1241
|
}
|
|
1236
1242
|
const lastRow = row + rows.length - 1;
|
|
@@ -1244,7 +1250,7 @@ var ChartController = (_class = class {
|
|
|
1244
1250
|
const index = row + r;
|
|
1245
1251
|
if (col < 0) d.categories[index] = cell === null || cell === void 0 ? "" : String(cell).trim();
|
|
1246
1252
|
else {
|
|
1247
|
-
const parsed =
|
|
1253
|
+
const parsed = _chunkWRZ6C4TUcjs.parseChartValue.call(void 0, cell);
|
|
1248
1254
|
if (parsed === void 0) issues.push({ path: `${d.series[col].id}[${index}]`, message: `"${String(cell)}" is not a number; it was left blank.` });
|
|
1249
1255
|
d.series[col].values[index] = _nullishCoalesce(parsed, () => ( null));
|
|
1250
1256
|
}
|
|
@@ -1263,14 +1269,14 @@ var ChartController = (_class = class {
|
|
|
1263
1269
|
* colours and types are kept by name.
|
|
1264
1270
|
*/
|
|
1265
1271
|
importTable(rows, options = {}) {
|
|
1266
|
-
const data =
|
|
1272
|
+
const data = _chunkWRZ6C4TUcjs.chartDataFromTable.call(void 0, rows, options);
|
|
1267
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.");
|
|
1268
1274
|
const byName = new Map(this.spec.series.map((s) => [s.name, s]));
|
|
1269
1275
|
const series = data.series.map((s) => {
|
|
1270
1276
|
const old = byName.get(s.name);
|
|
1271
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 } : {} };
|
|
1272
1278
|
});
|
|
1273
|
-
const { spec } =
|
|
1279
|
+
const { spec } = _chunkWRZ6C4TUcjs.normalizeChartSpec.call(void 0, { ...this.spec, categories: data.categories, series, tree: [], links: [] });
|
|
1274
1280
|
this.commit("Import data", spec);
|
|
1275
1281
|
if (data.issues.length) {
|
|
1276
1282
|
this.issues = data.issues;
|
|
@@ -1301,7 +1307,7 @@ var ChartController = (_class = class {
|
|
|
1301
1307
|
/** Replaces the grouped data (an empty list goes back to the table, keeping the totals as values). One undo step. */
|
|
1302
1308
|
setTree(tree, options = {}) {
|
|
1303
1309
|
const issues = [];
|
|
1304
|
-
const next =
|
|
1310
|
+
const next = _chunkWRZ6C4TUcjs.normalizeChartTree.call(void 0, tree, issues);
|
|
1305
1311
|
if (issues.length) return this.reject(issues.map((i) => i.message).join(" "), issues);
|
|
1306
1312
|
return this.update({ tree: next, links: [] }, { label: _nullishCoalesce(options.label, () => ( (next.length ? "Replace grouped data" : "Ungroup data"))) });
|
|
1307
1313
|
}
|
|
@@ -1311,11 +1317,11 @@ var ChartController = (_class = class {
|
|
|
1311
1317
|
*/
|
|
1312
1318
|
setTreeRows(rows, options = {}) {
|
|
1313
1319
|
const issues = [];
|
|
1314
|
-
const next =
|
|
1320
|
+
const next = _chunkWRZ6C4TUcjs.chartTreeFromRows.call(void 0, rows, issues);
|
|
1315
1321
|
if (issues.length) return this.reject(issues.map((i) => i.message).join(" "), issues);
|
|
1316
1322
|
const keepColors = (list, prefix) => {
|
|
1317
1323
|
for (const n of list) {
|
|
1318
|
-
const old =
|
|
1324
|
+
const old = _chunkWRZ6C4TUcjs.findChartTreeNode.call(void 0, this.spec.tree, [...prefix, n.name]);
|
|
1319
1325
|
if (_optionalChain([old, 'optionalAccess', _67 => _67.color])) n.color = old.color;
|
|
1320
1326
|
if (n.children) keepColors(n.children, [...prefix, n.name]);
|
|
1321
1327
|
}
|
|
@@ -1326,15 +1332,15 @@ var ChartController = (_class = class {
|
|
|
1326
1332
|
/** Replaces the data with a table of names and values (group, …, item, value); see `chartTreeFromTable`. */
|
|
1327
1333
|
importTreeTable(rows, options = {}) {
|
|
1328
1334
|
const issues = [];
|
|
1329
|
-
const next =
|
|
1335
|
+
const next = _chunkWRZ6C4TUcjs.chartTreeFromTable.call(void 0, rows, options, issues);
|
|
1330
1336
|
if (issues.length) return this.reject(issues.map((i) => i.message).join(" "), issues);
|
|
1331
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".');
|
|
1332
1338
|
return this.update({ tree: next, links: [] }, { label: "Import grouped data" });
|
|
1333
1339
|
}
|
|
1334
1340
|
nodeAt(path) {
|
|
1335
|
-
const node =
|
|
1341
|
+
const node = _chunkWRZ6C4TUcjs.findChartTreeNode.call(void 0, this.spec.tree, path);
|
|
1336
1342
|
if (node) return node;
|
|
1337
|
-
const known = path.length > 1 ?
|
|
1343
|
+
const known = path.length > 1 ? _chunkWRZ6C4TUcjs.findChartTreeNode.call(void 0, this.spec.tree, path.slice(0, -1)) : null;
|
|
1338
1344
|
const siblings = _nullishCoalesce((path.length > 1 ? _optionalChain([known, 'optionalAccess', _68 => _68.children]) : this.spec.tree), () => ( []));
|
|
1339
1345
|
return fail(
|
|
1340
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."}`
|
|
@@ -1350,12 +1356,12 @@ var ChartController = (_class = class {
|
|
|
1350
1356
|
siblings = group.children;
|
|
1351
1357
|
}
|
|
1352
1358
|
const issues = [];
|
|
1353
|
-
const [node] =
|
|
1359
|
+
const [node] = _chunkWRZ6C4TUcjs.normalizeChartTree.call(void 0, [input], issues, "node");
|
|
1354
1360
|
if (!node || issues.length) return this.reject(issues.map((i) => i.message).join(" ") || "The node is not valid.", issues);
|
|
1355
1361
|
if (siblings.some((n) => n.name === node.name)) return this.reject(`"${node.name}" is already there; names under one group must be unique.`);
|
|
1356
1362
|
const at = Math.max(0, Math.min(siblings.length, _nullishCoalesce(options.at, () => ( siblings.length))));
|
|
1357
|
-
const tree =
|
|
1358
|
-
const list = parent.length ?
|
|
1363
|
+
const tree = _chunkWRZ6C4TUcjs.cloneChartTree.call(void 0, this.spec.tree);
|
|
1364
|
+
const list = parent.length ? _chunkWRZ6C4TUcjs.findChartTreeNode.call(void 0, tree, parent).children : tree;
|
|
1359
1365
|
list.splice(at, 0, node);
|
|
1360
1366
|
const result = this.update({ tree }, { label: `Add "${node.name}"` });
|
|
1361
1367
|
if (!result.ok) return result;
|
|
@@ -1367,16 +1373,16 @@ var ChartController = (_class = class {
|
|
|
1367
1373
|
if ("ok" in node) return node;
|
|
1368
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.`);
|
|
1369
1375
|
const name = patch.name !== void 0 ? String(patch.name).trim() : node.name;
|
|
1370
|
-
const siblings = (path.length > 1 ?
|
|
1376
|
+
const siblings = (path.length > 1 ? _chunkWRZ6C4TUcjs.findChartTreeNode.call(void 0, this.spec.tree, path.slice(0, -1)).children : this.spec.tree).filter((n) => n !== node);
|
|
1371
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.`);
|
|
1372
|
-
const tree =
|
|
1373
|
-
const target =
|
|
1378
|
+
const tree = _chunkWRZ6C4TUcjs.cloneChartTree.call(void 0, this.spec.tree);
|
|
1379
|
+
const target = _chunkWRZ6C4TUcjs.findChartTreeNode.call(void 0, tree, path);
|
|
1374
1380
|
const merged = { ...target, name };
|
|
1375
1381
|
if (patch.value !== void 0) merged.value = patch.value;
|
|
1376
1382
|
if (patch.color === null) delete merged.color;
|
|
1377
1383
|
else if (patch.color !== void 0) merged.color = patch.color;
|
|
1378
1384
|
const issues = [];
|
|
1379
|
-
const [checked] =
|
|
1385
|
+
const [checked] = _chunkWRZ6C4TUcjs.normalizeChartTree.call(void 0, [merged], issues, "node");
|
|
1380
1386
|
if (!checked || issues.length) return this.reject(issues.map((i) => i.message).join(" "), issues);
|
|
1381
1387
|
Object.assign(target, checked);
|
|
1382
1388
|
if (patch.color === null) delete target.color;
|
|
@@ -1388,8 +1394,8 @@ var ChartController = (_class = class {
|
|
|
1388
1394
|
removeTreeNode(path) {
|
|
1389
1395
|
const node = this.nodeAt(path);
|
|
1390
1396
|
if ("ok" in node) return node;
|
|
1391
|
-
const tree =
|
|
1392
|
-
const parent = path.length > 1 ?
|
|
1397
|
+
const tree = _chunkWRZ6C4TUcjs.cloneChartTree.call(void 0, this.spec.tree);
|
|
1398
|
+
const parent = path.length > 1 ? _chunkWRZ6C4TUcjs.findChartTreeNode.call(void 0, tree, path.slice(0, -1)) : null;
|
|
1393
1399
|
const list = parent ? parent.children : tree;
|
|
1394
1400
|
list.splice(
|
|
1395
1401
|
list.findIndex((n) => n.name === node.name),
|
|
@@ -1410,7 +1416,7 @@ var ChartController = (_class = class {
|
|
|
1410
1416
|
*/
|
|
1411
1417
|
setLinks(links, options = {}) {
|
|
1412
1418
|
const issues = [];
|
|
1413
|
-
const next =
|
|
1419
|
+
const next = _chunkWRZ6C4TUcjs.normalizeChartLinks.call(void 0, links, issues);
|
|
1414
1420
|
if (issues.length) return this.reject(issues.map((i) => i.message).join(" "), issues);
|
|
1415
1421
|
const used = new Set(next.flatMap((l) => [l.source, l.target]));
|
|
1416
1422
|
const sankeyNodes = options.nodes ? [...options.nodes] : this.spec.sankeyNodes.filter((n) => used.has(n));
|
|
@@ -1418,7 +1424,7 @@ var ChartController = (_class = class {
|
|
|
1418
1424
|
}
|
|
1419
1425
|
/** Replaces the data with flows from a table of source, target and value columns. */
|
|
1420
1426
|
importLinksTable(rows, options = {}) {
|
|
1421
|
-
const raw =
|
|
1427
|
+
const raw = _chunkWRZ6C4TUcjs.chartLinksFromTable.call(void 0, rows, options);
|
|
1422
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".');
|
|
1423
1429
|
return this.setLinks(raw, { label: "Import flows" });
|
|
1424
1430
|
}
|
|
@@ -1482,7 +1488,7 @@ var ChartController = (_class = class {
|
|
|
1482
1488
|
/** Why a reference on `axis` at `values` cannot be drawn on this chart, or null. */
|
|
1483
1489
|
referenceProblem(axis, values) {
|
|
1484
1490
|
const s = this.spec;
|
|
1485
|
-
const family =
|
|
1491
|
+
const family = _chunkWRZ6C4TUcjs.chartFamily.call(void 0, s);
|
|
1486
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.`;
|
|
1487
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.';
|
|
1488
1494
|
if (axis === "y2" && (family !== "cartesian" || !s.series.some((x) => !x.hidden && x.axis === "secondary")))
|
|
@@ -1501,7 +1507,7 @@ var ChartController = (_class = class {
|
|
|
1501
1507
|
/** Adds a reference line (a target, floor or average). Returns its index. */
|
|
1502
1508
|
addReferenceLine(input) {
|
|
1503
1509
|
const issues = [];
|
|
1504
|
-
const line =
|
|
1510
|
+
const line = _chunkWRZ6C4TUcjs.normalizeChartReferenceLine.call(void 0, input, "referenceLine", issues);
|
|
1505
1511
|
if (!line || issues.length) return this.reject(issues.map((i) => i.message).join(" "), issues);
|
|
1506
1512
|
const problem = this.referenceProblem(line.axis, [line.value]);
|
|
1507
1513
|
if (problem) return this.reject(problem);
|
|
@@ -1516,7 +1522,7 @@ var ChartController = (_class = class {
|
|
|
1516
1522
|
const merged = { ...current, ...patch };
|
|
1517
1523
|
for (const [k, v] of Object.entries(patch)) if (v === null) delete merged[k];
|
|
1518
1524
|
const issues = [];
|
|
1519
|
-
const line =
|
|
1525
|
+
const line = _chunkWRZ6C4TUcjs.normalizeChartReferenceLine.call(void 0, merged, "referenceLine", issues);
|
|
1520
1526
|
if (!line || issues.length) return this.reject(issues.map((i) => i.message).join(" "), issues);
|
|
1521
1527
|
const problem = this.referenceProblem(line.axis, [line.value]);
|
|
1522
1528
|
if (problem) return this.reject(problem);
|
|
@@ -1531,7 +1537,7 @@ var ChartController = (_class = class {
|
|
|
1531
1537
|
/** Adds a reference band (a target range). Returns its index. */
|
|
1532
1538
|
addReferenceBand(input) {
|
|
1533
1539
|
const issues = [];
|
|
1534
|
-
const band =
|
|
1540
|
+
const band = _chunkWRZ6C4TUcjs.normalizeChartReferenceBand.call(void 0, input, "referenceBand", issues);
|
|
1535
1541
|
if (!band || issues.length) return this.reject(issues.map((i) => i.message).join(" "), issues);
|
|
1536
1542
|
const problem = this.referenceProblem(band.axis, [band.from, band.to]);
|
|
1537
1543
|
if (problem) return this.reject(problem);
|
|
@@ -1546,7 +1552,7 @@ var ChartController = (_class = class {
|
|
|
1546
1552
|
const merged = { ...current, ...patch };
|
|
1547
1553
|
for (const [k, v] of Object.entries(patch)) if (v === null) delete merged[k];
|
|
1548
1554
|
const issues = [];
|
|
1549
|
-
const band =
|
|
1555
|
+
const band = _chunkWRZ6C4TUcjs.normalizeChartReferenceBand.call(void 0, merged, "referenceBand", issues);
|
|
1550
1556
|
if (!band || issues.length) return this.reject(issues.map((i) => i.message).join(" "), issues);
|
|
1551
1557
|
const problem = this.referenceProblem(band.axis, [band.from, band.to]);
|
|
1552
1558
|
if (problem) return this.reject(problem);
|
|
@@ -1569,7 +1575,7 @@ var ChartController = (_class = class {
|
|
|
1569
1575
|
const series = this.getSeries(seriesId);
|
|
1570
1576
|
if (!series) return this.unknownSeries(seriesId);
|
|
1571
1577
|
if (!Number.isInteger(index) || index < 0 || index >= this.spec.categories.length) return this.badIndex(index);
|
|
1572
|
-
const family =
|
|
1578
|
+
const family = _chunkWRZ6C4TUcjs.chartFamily.call(void 0, this.spec);
|
|
1573
1579
|
const text = label === null ? "" : String(label).trim();
|
|
1574
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.`);
|
|
1575
1581
|
if (text && (series.values[index] === null || series.values[index] === void 0))
|
|
@@ -1591,10 +1597,10 @@ var ChartController = (_class = class {
|
|
|
1591
1597
|
addTrendline(seriesId, input) {
|
|
1592
1598
|
const series = this.getSeries(seriesId);
|
|
1593
1599
|
if (!series) return this.unknownSeries(seriesId);
|
|
1594
|
-
if (!
|
|
1600
|
+
if (!_chunkN76AMOKEcjs.chartSupportsTrendlines.call(void 0, this.spec.type, this.spec.stacking))
|
|
1595
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.`);
|
|
1596
1602
|
const issues = [];
|
|
1597
|
-
const line =
|
|
1603
|
+
const line = _chunkWRZ6C4TUcjs.normalizeChartTrendline.call(void 0, input, "trendline", issues);
|
|
1598
1604
|
if (!line || issues.length) return this.reject(issues.map((i) => i.message).join(" ") || "The trendline is not valid.", issues);
|
|
1599
1605
|
const index = _nullishCoalesce(_optionalChain([series, 'access', _71 => _71.trendlines, 'optionalAccess', _72 => _72.length]), () => ( 0));
|
|
1600
1606
|
const next = this.edited((d) => {
|
|
@@ -1613,7 +1619,7 @@ var ChartController = (_class = class {
|
|
|
1613
1619
|
const issues = [];
|
|
1614
1620
|
const merged = { ...current, ...patch };
|
|
1615
1621
|
for (const [k, v] of Object.entries(patch)) if (v === null) delete merged[k];
|
|
1616
|
-
const line =
|
|
1622
|
+
const line = _chunkWRZ6C4TUcjs.normalizeChartTrendline.call(void 0, merged, "trendline", issues);
|
|
1617
1623
|
if (!line || issues.length) return this.reject(issues.map((i) => i.message).join(" "), issues);
|
|
1618
1624
|
this.commit(
|
|
1619
1625
|
"Change trendline",
|
|
@@ -1641,7 +1647,7 @@ var ChartController = (_class = class {
|
|
|
1641
1647
|
trendlinePoints(seriesId) {
|
|
1642
1648
|
const series = this.getSeries(seriesId);
|
|
1643
1649
|
if (!series) return [];
|
|
1644
|
-
const xy =
|
|
1650
|
+
const xy = _chunkWRZ6C4TUcjs.chartFamily.call(void 0, this.spec) === "xy";
|
|
1645
1651
|
const out = [];
|
|
1646
1652
|
series.values.forEach((v, i) => {
|
|
1647
1653
|
const x = xy ? _nullishCoalesce(_optionalChain([series, 'access', _79 => _79.x, 'optionalAccess', _80 => _80[i]]), () => ( (this.spec.type === "bubble" ? i + 1 : null))) : i + 1;
|
|
@@ -1653,13 +1659,13 @@ var ChartController = (_class = class {
|
|
|
1653
1659
|
trendlineFit(seriesId, index) {
|
|
1654
1660
|
const line = _optionalChain([this, 'access', _81 => _81.getSeries, 'call', _82 => _82(seriesId), 'optionalAccess', _83 => _83.trendlines, 'optionalAccess', _84 => _84[index]]);
|
|
1655
1661
|
if (!line) return null;
|
|
1656
|
-
return
|
|
1662
|
+
return _chunkN76AMOKEcjs.fitChartTrendline.call(void 0, line, this.trendlinePoints(seriesId));
|
|
1657
1663
|
}
|
|
1658
1664
|
/** The moving-average points of a trendline (empty for other kinds). */
|
|
1659
1665
|
trendlineMovingAverage(seriesId, index) {
|
|
1660
1666
|
const line = _optionalChain([this, 'access', _85 => _85.getSeries, 'call', _86 => _86(seriesId), 'optionalAccess', _87 => _87.trendlines, 'optionalAccess', _88 => _88[index]]);
|
|
1661
1667
|
if (!line || line.type !== "moving-average") return [];
|
|
1662
|
-
return
|
|
1668
|
+
return _chunkN76AMOKEcjs.chartMovingAverage.call(void 0, this.trendlinePoints(seriesId), _nullishCoalesce(line.period, () => ( 2)));
|
|
1663
1669
|
}
|
|
1664
1670
|
// -------------------------------------------------------------------------
|
|
1665
1671
|
// Reshaping
|
|
@@ -1680,7 +1686,7 @@ var ChartController = (_class = class {
|
|
|
1680
1686
|
used.add(id);
|
|
1681
1687
|
return { id, name, values: s.series.map((x) => _nullishCoalesce(x.values[i], () => ( null))) };
|
|
1682
1688
|
});
|
|
1683
|
-
const { spec } =
|
|
1689
|
+
const { spec } = _chunkWRZ6C4TUcjs.normalizeChartSpec.call(void 0, { ...s, categories: s.series.map((x) => x.name), series });
|
|
1684
1690
|
this.commit("Switch rows and columns", spec, null);
|
|
1685
1691
|
return { ok: true };
|
|
1686
1692
|
}
|
|
@@ -1739,7 +1745,7 @@ var ChartController = (_class = class {
|
|
|
1739
1745
|
/** Selects a chart element (view state; not an undo step). */
|
|
1740
1746
|
select(selection) {
|
|
1741
1747
|
const next = this.validSelection(selection, this.spec);
|
|
1742
|
-
if (
|
|
1748
|
+
if (_chunkN76AMOKEcjs.sameChartSelection.call(void 0, next, this.selection) || next === null && this.selection === null) return;
|
|
1743
1749
|
this.selection = next;
|
|
1744
1750
|
this.notify(false);
|
|
1745
1751
|
}
|
|
@@ -1816,14 +1822,14 @@ var ChartController = (_class = class {
|
|
|
1816
1822
|
// -------------------------------------------------------------------------
|
|
1817
1823
|
/** The spec, for saving (a copy). */
|
|
1818
1824
|
toJSON() {
|
|
1819
|
-
return
|
|
1825
|
+
return _chunkWRZ6C4TUcjs.cloneChartSpec.call(void 0, this.spec);
|
|
1820
1826
|
}
|
|
1821
1827
|
/**
|
|
1822
1828
|
* Replaces the chart without an undo step (e.g. when opening a document). Problems are
|
|
1823
1829
|
* fixed with defaults and reported in `state.issues` (and returned).
|
|
1824
1830
|
*/
|
|
1825
1831
|
load(input, options = {}) {
|
|
1826
|
-
const { spec, issues } =
|
|
1832
|
+
const { spec, issues } = _chunkWRZ6C4TUcjs.normalizeChartSpec.call(void 0, input);
|
|
1827
1833
|
this.spec = spec;
|
|
1828
1834
|
this.issues = issues;
|
|
1829
1835
|
this.selection = this.validSelection(this.selection, spec);
|
|
@@ -1843,7 +1849,7 @@ var ChartController = (_class = class {
|
|
|
1843
1849
|
* nothing changes and every problem is returned (and shown in `state.issues`).
|
|
1844
1850
|
*/
|
|
1845
1851
|
replace(input, options = {}) {
|
|
1846
|
-
const { spec, issues } =
|
|
1852
|
+
const { spec, issues } = _chunkWRZ6C4TUcjs.normalizeChartSpec.call(void 0, input);
|
|
1847
1853
|
if (issues.length) return this.reject(issues.map((i) => i.message).join(" "), issues);
|
|
1848
1854
|
this.commit(_nullishCoalesce(options.label, () => ( "Replace chart")), spec, this.validSelection(this.selection, spec));
|
|
1849
1855
|
return { ok: true };
|
|
@@ -1925,7 +1931,7 @@ function layoutSparkline(values, options) {
|
|
|
1925
1931
|
const h = Number.isFinite(options.height) ? Math.max(1, options.height) : 1;
|
|
1926
1932
|
const color = _nullishCoalesce(options.color, () => ( "#4269d0"));
|
|
1927
1933
|
const negative = _nullishCoalesce(options.negativeColor, () => ( "#e5484d"));
|
|
1928
|
-
const theme = { ...
|
|
1934
|
+
const theme = { ..._chunkWRZ6C4TUcjs.DEFAULT_CHART_THEME, background: "transparent" };
|
|
1929
1935
|
const marks = [];
|
|
1930
1936
|
const scene = { width: w, height: h, plot: { x: 0, y: 0, width: w, height: h }, marks, percent: false, theme, warnings: [] };
|
|
1931
1937
|
const vals = values.slice(0, MAX_POINTS).map((v) => v !== null && Number.isFinite(v) ? Math.max(-1e300, Math.min(1e300, v)) : null);
|
|
@@ -1958,7 +1964,7 @@ function layoutSparkline(values, options) {
|
|
|
1958
1964
|
const flush = () => {
|
|
1959
1965
|
if (run.length >= 2) {
|
|
1960
1966
|
const pts = run.length > 4e3 ? run.filter((_, i) => i % (Math.floor(run.length / 2e3) + 1) === 0) : run;
|
|
1961
|
-
d += pts.map(([x, y], i) => `${i ? "L" : "M"}${
|
|
1967
|
+
d += pts.map(([x, y], i) => `${i ? "L" : "M"}${_chunkN76AMOKEcjs.r2.call(void 0, x)},${_chunkN76AMOKEcjs.r2.call(void 0, y)}`).join("");
|
|
1962
1968
|
}
|
|
1963
1969
|
run = [];
|
|
1964
1970
|
};
|
|
@@ -426,7 +426,7 @@ function removeChartTreeRow(rows, row) {
|
|
|
426
426
|
}
|
|
427
427
|
|
|
428
428
|
// src/chart/spec.ts
|
|
429
|
-
var CHART_TYPES = ["bar", "line", "area", "scatter", "bubble", "pie", "donut", "radar", "waterfall", "histogram", "box", "funnel", "treemap", "sunburst", "sankey", "slope", "likert", "parliament", "barrace", "choropleth"];
|
|
429
|
+
var CHART_TYPES = ["bar", "line", "area", "scatter", "bubble", "pie", "donut", "radar", "waterfall", "histogram", "box", "funnel", "treemap", "sunburst", "sankey", "streamgraph", "slope", "likert", "parliament", "barrace", "choropleth"];
|
|
430
430
|
var CHART_MARKERS = ["circle", "square", "diamond", "triangle", "cross", "none"];
|
|
431
431
|
var CHART_TRENDLINE_TYPES = ["linear", "exponential", "logarithmic", "power", "polynomial", "moving-average"];
|
|
432
432
|
var CHART_LABEL_POSITIONS = ["auto", "inside", "outside", "center"];
|
|
@@ -462,6 +462,7 @@ var CHART_TYPE_LABELS = {
|
|
|
462
462
|
parliament: "Parliament",
|
|
463
463
|
sunburst: "Sunburst",
|
|
464
464
|
sankey: "Sankey",
|
|
465
|
+
streamgraph: "Streamgraph",
|
|
465
466
|
barrace: "Bar race",
|
|
466
467
|
choropleth: "Map"
|
|
467
468
|
};
|
|
@@ -515,6 +516,7 @@ function chartFamily(spec) {
|
|
|
515
516
|
case "parliament":
|
|
516
517
|
case "sunburst":
|
|
517
518
|
case "sankey":
|
|
519
|
+
case "streamgraph":
|
|
518
520
|
case "barrace":
|
|
519
521
|
case "choropleth":
|
|
520
522
|
return spec.type;
|