@pixerate/editor 0.51.0 → 0.53.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 +23 -23
- package/dist/agent/index.js +4 -4
- package/dist/chart/index.cjs +475 -124
- package/dist/chart/index.cjs.map +1 -1
- package/dist/chart/index.d.cts +174 -25
- package/dist/chart/index.d.ts +174 -25
- package/dist/chart/index.js +375 -24
- package/dist/chart/index.js.map +1 -1
- package/dist/{chunk-GJBIVWB2.js → chunk-3S72F46R.js} +387 -9
- package/dist/chunk-3S72F46R.js.map +1 -0
- package/dist/{chunk-5TWIN7ZJ.js → chunk-47WWV3LI.js} +34 -4
- package/dist/chunk-47WWV3LI.js.map +1 -0
- package/dist/{chunk-OV7UAKIY.js → chunk-633QC34G.js} +172 -1
- package/dist/chunk-633QC34G.js.map +1 -0
- package/dist/{chunk-MR2764X2.js → chunk-AGGUNWT6.js} +2 -322
- package/dist/chunk-AGGUNWT6.js.map +1 -0
- package/dist/{chunk-T6XU4B54.js → chunk-BQQZ6MOI.js} +7 -7
- package/dist/{chunk-LNKZPIQD.cjs → chunk-C3JHII3M.cjs} +67 -67
- package/dist/{chunk-LNKZPIQD.cjs.map → chunk-C3JHII3M.cjs.map} +1 -1
- package/dist/{chunk-JOX6MJW4.cjs → chunk-CKRNELPO.cjs} +176 -5
- package/dist/chunk-CKRNELPO.cjs.map +1 -0
- package/dist/{chunk-TGBCBQFV.cjs → chunk-DK6QBGCS.cjs} +45 -15
- package/dist/chunk-DK6QBGCS.cjs.map +1 -0
- package/dist/{chunk-GTZXF4BI.cjs → chunk-NK3WL5TJ.cjs} +298 -133
- package/dist/chunk-NK3WL5TJ.cjs.map +1 -0
- package/dist/{chunk-3JNRQVTS.cjs → chunk-NN3JGUSX.cjs} +402 -24
- package/dist/chunk-NN3JGUSX.cjs.map +1 -0
- package/dist/{chunk-3CC7OPUQ.cjs → chunk-O6FO6VI3.cjs} +3 -323
- package/dist/chunk-O6FO6VI3.cjs.map +1 -0
- package/dist/{chunk-DQPBQXKG.js → chunk-OIKYP7XC.js} +8 -8
- package/dist/{chunk-FEMIVHN3.cjs → chunk-P43HUQRX.cjs} +16 -16
- package/dist/{chunk-FEMIVHN3.cjs.map → chunk-P43HUQRX.cjs.map} +1 -1
- package/dist/{chunk-QFTVLEVN.js → chunk-RIXTW3C4.js} +3 -3
- package/dist/{chunk-WBOAXDKD.js → chunk-VODBAO32.js} +222 -57
- package/dist/chunk-VODBAO32.js.map +1 -0
- package/dist/{chunk-2Q46FKZK.cjs → chunk-YZZMX6V7.cjs} +25 -25
- package/dist/{chunk-2Q46FKZK.cjs.map → chunk-YZZMX6V7.cjs.map} +1 -1
- package/dist/{controller-DS3drIvy.d.cts → controller-CX0QfSv0.d.cts} +53 -2
- package/dist/{controller-BdKzaxs2.d.ts → controller-DscWQbjO.d.ts} +53 -2
- package/dist/export/index.cjs +5 -5
- package/dist/export/index.js +4 -4
- package/dist/extensions/index.cjs +7 -7
- package/dist/extensions/index.d.cts +2 -2
- package/dist/extensions/index.d.ts +2 -2
- package/dist/extensions/index.js +6 -6
- package/dist/{index-Dt9lzydb.d.ts → index-CALDD35B.d.ts} +1 -1
- package/dist/{index-DOy9HzfC.d.cts → index-DIWB6xMf.d.cts} +1 -1
- package/dist/index.cjs +15 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -113
- package/dist/index.d.ts +6 -113
- package/dist/index.js +13 -12
- package/dist/index.js.map +1 -1
- package/dist/zip-4nG0YAH7.d.cts +110 -0
- package/dist/zip-4nG0YAH7.d.ts +110 -0
- package/package.json +1 -1
- package/dist/chunk-3CC7OPUQ.cjs.map +0 -1
- package/dist/chunk-3JNRQVTS.cjs.map +0 -1
- package/dist/chunk-5TWIN7ZJ.js.map +0 -1
- package/dist/chunk-GJBIVWB2.js.map +0 -1
- package/dist/chunk-GTZXF4BI.cjs.map +0 -1
- package/dist/chunk-JOX6MJW4.cjs.map +0 -1
- package/dist/chunk-MR2764X2.js.map +0 -1
- package/dist/chunk-OV7UAKIY.js.map +0 -1
- package/dist/chunk-TGBCBQFV.cjs.map +0 -1
- package/dist/chunk-WBOAXDKD.js.map +0 -1
- /package/dist/{chunk-T6XU4B54.js.map → chunk-BQQZ6MOI.js.map} +0 -0
- /package/dist/{chunk-DQPBQXKG.js.map → chunk-OIKYP7XC.js.map} +0 -0
- /package/dist/{chunk-QFTVLEVN.js.map → chunk-RIXTW3C4.js.map} +0 -0
package/dist/chart/index.cjs
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkDK6QBGCScjs = require('../chunk-DK6QBGCS.cjs');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
@@ -15,8 +15,8 @@ var _chunkTGBCBQFVcjs = require('../chunk-TGBCBQFV.cjs');
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
var _chunk3JNRQVTScjs = require('../chunk-3JNRQVTS.cjs');
|
|
19
18
|
|
|
19
|
+
var _chunkNN3JGUSXcjs = require('../chunk-NN3JGUSX.cjs');
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
@@ -71,11 +71,11 @@ var _chunk3JNRQVTScjs = require('../chunk-3JNRQVTS.cjs');
|
|
|
71
71
|
|
|
72
72
|
|
|
73
73
|
|
|
74
|
-
var _chunkGTZXF4BIcjs = require('../chunk-GTZXF4BI.cjs');
|
|
75
74
|
|
|
76
75
|
|
|
77
76
|
|
|
78
77
|
|
|
78
|
+
var _chunkNK3WL5TJcjs = require('../chunk-NK3WL5TJ.cjs');
|
|
79
79
|
|
|
80
80
|
|
|
81
81
|
|
|
@@ -121,7 +121,22 @@ var _chunkGTZXF4BIcjs = require('../chunk-GTZXF4BI.cjs');
|
|
|
121
121
|
|
|
122
122
|
|
|
123
123
|
|
|
124
|
-
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
var _chunkCKRNELPOcjs = require('../chunk-CKRNELPO.cjs');
|
|
125
140
|
require('../chunk-XP5IUZUO.cjs');
|
|
126
141
|
|
|
127
142
|
|
|
@@ -135,9 +150,9 @@ function chartRasterSize(width, height, scale = 2, maxSize = CHART_RASTER_MAX_SI
|
|
|
135
150
|
const factor = Math.min(scale > 0 ? scale : 1, maxSize / Math.max(width, height));
|
|
136
151
|
return { width: Math.max(1, Math.round(width * factor)), height: Math.max(1, Math.round(height * factor)), scale: factor };
|
|
137
152
|
}
|
|
138
|
-
function closingParen(text,
|
|
153
|
+
function closingParen(text, open2) {
|
|
139
154
|
let depth = 0;
|
|
140
|
-
for (let i =
|
|
155
|
+
for (let i = open2; i < text.length; i++) {
|
|
141
156
|
if (text[i] === "(") depth++;
|
|
142
157
|
else if (text[i] === ")" && --depth === 0) return i + 1;
|
|
143
158
|
}
|
|
@@ -236,7 +251,7 @@ function chartFileName(spec, extension) {
|
|
|
236
251
|
}
|
|
237
252
|
async function downloadChartPng(spec, options = {}) {
|
|
238
253
|
const { width = 800, height = 450, filename = chartFileName(spec, "png"), theme, ...raster } = options;
|
|
239
|
-
const svg =
|
|
254
|
+
const svg = _chunkNK3WL5TJcjs.chartToSvg.call(void 0, spec, { width, height, theme });
|
|
240
255
|
const { url, width: w, height: h } = await svgToPngDataUrl(svg, { ...raster, width, height });
|
|
241
256
|
const doc = _nullishCoalesce(raster.document, () => ( globalThis.document));
|
|
242
257
|
const link = doc.createElement("a");
|
|
@@ -251,7 +266,7 @@ async function downloadChartPng(spec, options = {}) {
|
|
|
251
266
|
|
|
252
267
|
// src/chart/recommend.ts
|
|
253
268
|
var blank = (c) => c === null || c === void 0 || String(c).trim() === "";
|
|
254
|
-
var isText = (c) => blank(c) ||
|
|
269
|
+
var isText = (c) => blank(c) || _chunkCKRNELPOcjs.parseChartValue.call(void 0, c) === void 0;
|
|
255
270
|
function analyzeChartTable(rows) {
|
|
256
271
|
const grid = rows.filter((r) => r.some((c) => !blank(c)));
|
|
257
272
|
const height = grid.length;
|
|
@@ -269,7 +284,7 @@ function analyzeChartTable(rows) {
|
|
|
269
284
|
let anyPositive = false;
|
|
270
285
|
for (let r = headerRow ? 1 : 0; r < height; r++)
|
|
271
286
|
for (let c = labelColumn ? 1 : 0; c < width; c++) {
|
|
272
|
-
const v =
|
|
287
|
+
const v = _chunkCKRNELPOcjs.parseChartValue.call(void 0, cell(r, c));
|
|
273
288
|
if (typeof v !== "number") continue;
|
|
274
289
|
anyNumber = true;
|
|
275
290
|
if (v < 0) {
|
|
@@ -278,7 +293,7 @@ function analyzeChartTable(rows) {
|
|
|
278
293
|
} else if (v > 0) anyPositive = true;
|
|
279
294
|
}
|
|
280
295
|
const labels = byRows ? _nullishCoalesce(_optionalChain([grid, 'access', _20 => _20[0], 'optionalAccess', _21 => _21.slice, 'call', _22 => _22(labelColumn ? 1 : 0)]), () => ( [])) : grid.slice(headerRow ? 1 : 0).map((r) => r[0]);
|
|
281
|
-
const dates = (byRows ? headerRow : labelColumn) && labels.length > 1 && labels.filter((l) => !blank(l) &&
|
|
296
|
+
const dates = (byRows ? headerRow : labelColumn) && labels.length > 1 && labels.filter((l) => !blank(l) && _chunkNK3WL5TJcjs.parseChartDate.call(void 0, String(l)) !== null).length >= labels.length * 0.8;
|
|
282
297
|
return {
|
|
283
298
|
headerRow,
|
|
284
299
|
labelColumn,
|
|
@@ -365,7 +380,7 @@ function chartFromTable(rows, options = {}) {
|
|
|
365
380
|
if (xFromFirst) {
|
|
366
381
|
table = table.map((r) => [r[1], ...r.slice(2)]);
|
|
367
382
|
}
|
|
368
|
-
const data =
|
|
383
|
+
const data = _chunkCKRNELPOcjs.chartDataFromTable.call(void 0, table, { seriesIn: shape.byRows ? "rows" : "columns", header: true, xFromFirstColumn: xFromFirst });
|
|
369
384
|
return { type, stacking, categories: data.categories, series: data.series, issues: data.issues, shape };
|
|
370
385
|
}
|
|
371
386
|
|
|
@@ -401,10 +416,10 @@ function createChartCommands(controller, options = {}) {
|
|
|
401
416
|
readOnly: true,
|
|
402
417
|
keywords: ["chart", "data", "spec", "get", "summary"],
|
|
403
418
|
description: "Returns the chart spec, its data as a table (series names in the header row) and a summary: per-series min / max / mean / trend, axes as drawn, layout warnings and a colour check.",
|
|
404
|
-
params: object({ width:
|
|
419
|
+
params: object({ width: _chunkDK6QBGCScjs.WIDTH, height: _chunkDK6QBGCScjs.HEIGHT }),
|
|
405
420
|
run: (_ctx, params = {}) => {
|
|
406
421
|
const spec = controller.getSpec();
|
|
407
|
-
return { spec: controller.toJSON(), table:
|
|
422
|
+
return { spec: controller.toJSON(), table: _chunkCKRNELPOcjs.chartDataToTable.call(void 0, spec), summary: _chunkNK3WL5TJcjs.summarizeChart.call(void 0, controller.toJSON(), { width: _nullishCoalesce(_optionalChain([params, 'optionalAccess', _25 => _25.width]), () => ( 640)), height: _nullishCoalesce(_optionalChain([params, 'optionalAccess', _26 => _26.height]), () => ( 400)) }), issues: controller.getState().issues };
|
|
408
423
|
}
|
|
409
424
|
},
|
|
410
425
|
{
|
|
@@ -412,8 +427,8 @@ function createChartCommands(controller, options = {}) {
|
|
|
412
427
|
id: `${prefix}update`,
|
|
413
428
|
label: "Change Chart\u2026",
|
|
414
429
|
keywords: ["chart", "title", "axis", "legend", "stack", "style", "format", "type"],
|
|
415
|
-
description:
|
|
416
|
-
params: object(
|
|
430
|
+
description: 'Changes chart presentation as one undo step: type, titles, axes (xAxis = categories, yAxis = values, yAxis2 = secondary values; reverse, and scale "log" on value axes), legend, stacking, orientation, curve, points, data labels, palette, donut hole, bar spacing, histogram bins or waterfall total. Invalid values change nothing and return why.',
|
|
431
|
+
params: object(_chunkDK6QBGCScjs.CHART_UPDATE_PROPERTIES),
|
|
417
432
|
run: (_ctx, params) => {
|
|
418
433
|
check(controller.update(params));
|
|
419
434
|
return { spec: controller.toJSON() };
|
|
@@ -427,11 +442,11 @@ function createChartCommands(controller, options = {}) {
|
|
|
427
442
|
description: "Replaces the categories and series as one undo step. Each series has one value per category (padded with gaps).",
|
|
428
443
|
params: object({
|
|
429
444
|
categories: { type: "array", items: { type: "string" }, description: "Category labels in order." },
|
|
430
|
-
series: { type: "array", description: "The new series.", items: object({ id: { type: "string", description: "Stable id (optional)." }, ...
|
|
445
|
+
series: { type: "array", description: "The new series.", items: object({ id: { type: "string", description: "Stable id (optional)." }, ..._chunkDK6QBGCScjs.SERIES_PROPS }, ["name", "values"]) }
|
|
431
446
|
}),
|
|
432
447
|
run: (_ctx, params) => {
|
|
433
448
|
check(controller.setData(params));
|
|
434
|
-
return { table:
|
|
449
|
+
return { table: _chunkCKRNELPOcjs.chartDataToTable.call(void 0, controller.getSpec()) };
|
|
435
450
|
}
|
|
436
451
|
},
|
|
437
452
|
{
|
|
@@ -440,10 +455,10 @@ function createChartCommands(controller, options = {}) {
|
|
|
440
455
|
label: "Set Chart Values\u2026",
|
|
441
456
|
keywords: ["chart", "value", "cell", "edit"],
|
|
442
457
|
description: "Sets individual values as one undo step. Series by id or name; category by index or label.",
|
|
443
|
-
params: object({ cells: { type: "array", minItems: 1, description: "Values to set.", items: object({ series:
|
|
458
|
+
params: object({ cells: { type: "array", minItems: 1, description: "Values to set.", items: object({ series: _chunkDK6QBGCScjs.SERIES_REF, category: _chunkDK6QBGCScjs.CATEGORY_REF, value: _chunkDK6QBGCScjs.VALUE }, ["series", "category", "value"]) } }, ["cells"]),
|
|
444
459
|
run: (_ctx, params) => {
|
|
445
460
|
check(controller.setValues(params.cells.map((c) => ({ seriesId: resolveSeries(c.series).id, index: resolveCategory(c.category), value: c.value }))));
|
|
446
|
-
return { table:
|
|
461
|
+
return { table: _chunkCKRNELPOcjs.chartDataToTable.call(void 0, controller.getSpec()) };
|
|
447
462
|
}
|
|
448
463
|
},
|
|
449
464
|
{
|
|
@@ -452,7 +467,7 @@ function createChartCommands(controller, options = {}) {
|
|
|
452
467
|
label: "Add Series",
|
|
453
468
|
keywords: ["chart", "series", "new"],
|
|
454
469
|
description: "Adds a series (default: an empty one at the end). Returns its id.",
|
|
455
|
-
params: object({ ...
|
|
470
|
+
params: object({ ..._chunkDK6QBGCScjs.SERIES_PROPS, id: { type: "string", description: "Id to use (default series-N)." }, at: { type: "integer", minimum: 0, description: "Position (default: last)." } }),
|
|
456
471
|
run: (_ctx, params = {}) => {
|
|
457
472
|
const { at, ...input } = _nullishCoalesce(params, () => ( {}));
|
|
458
473
|
const clean = Object.fromEntries(Object.entries(input).filter(([, v]) => v !== null));
|
|
@@ -466,8 +481,8 @@ function createChartCommands(controller, options = {}) {
|
|
|
466
481
|
id: `${prefix}updateSeries`,
|
|
467
482
|
label: "Change Series\u2026",
|
|
468
483
|
keywords: ["chart", "series", "rename", "colour", "color", "hide", "axis", "marker"],
|
|
469
|
-
description: "Renames, recolours, hides, moves to the secondary axis or changes how a series is drawn (null resets a field).",
|
|
470
|
-
params: object({ series:
|
|
484
|
+
description: "Renames, recolours, hides, moves to the secondary axis or changes how a series is drawn, including error bars (null resets a field).",
|
|
485
|
+
params: object({ series: _chunkDK6QBGCScjs.SERIES_REF, ...Object.fromEntries(Object.entries(_chunkDK6QBGCScjs.SERIES_PROPS).filter(([k]) => k !== "values")) }, ["series"]),
|
|
471
486
|
run: (_ctx, params) => {
|
|
472
487
|
const { series, ...patch } = params;
|
|
473
488
|
const id = resolveSeries(series).id;
|
|
@@ -481,7 +496,7 @@ function createChartCommands(controller, options = {}) {
|
|
|
481
496
|
label: "Delete Series",
|
|
482
497
|
keywords: ["chart", "series", "remove"],
|
|
483
498
|
description: "Deletes a series by id or name.",
|
|
484
|
-
params: object({ series:
|
|
499
|
+
params: object({ series: _chunkDK6QBGCScjs.SERIES_REF }, ["series"]),
|
|
485
500
|
run: (_ctx, params) => {
|
|
486
501
|
check(controller.removeSeries(resolveSeries(params.series).id));
|
|
487
502
|
return { series: seriesIds() };
|
|
@@ -502,7 +517,7 @@ function createChartCommands(controller, options = {}) {
|
|
|
502
517
|
label: "Delete Category",
|
|
503
518
|
keywords: ["chart", "category", "row", "remove"],
|
|
504
519
|
description: "Deletes a category (and its values) by index or label.",
|
|
505
|
-
params: object({ category:
|
|
520
|
+
params: object({ category: _chunkDK6QBGCScjs.CATEGORY_REF }, ["category"]),
|
|
506
521
|
run: (_ctx, params) => {
|
|
507
522
|
check(controller.removeCategory(resolveCategory(params.category)));
|
|
508
523
|
return { categories: controller.getSpec().categories };
|
|
@@ -514,7 +529,7 @@ function createChartCommands(controller, options = {}) {
|
|
|
514
529
|
label: "Add Trendline\u2026",
|
|
515
530
|
keywords: ["chart", "trend", "regression", "fit", "forecast", "moving average"],
|
|
516
531
|
description: "Fits a trendline to a series (linear, exponential, logarithmic, power, polynomial or moving average). Returns its index and the fit.",
|
|
517
|
-
params: object({ series:
|
|
532
|
+
params: object({ series: _chunkDK6QBGCScjs.SERIES_REF, ..._chunkDK6QBGCScjs.TRENDLINE_PROPS }, ["series", "type"]),
|
|
518
533
|
run: (_ctx, params) => {
|
|
519
534
|
const { series, ...line } = params;
|
|
520
535
|
const result = controller.addTrendline(resolveSeries(series).id, line);
|
|
@@ -529,7 +544,7 @@ function createChartCommands(controller, options = {}) {
|
|
|
529
544
|
label: "Delete Trendline",
|
|
530
545
|
keywords: ["chart", "trend", "remove"],
|
|
531
546
|
description: "Deletes a trendline from a series.",
|
|
532
|
-
params: object({ series:
|
|
547
|
+
params: object({ series: _chunkDK6QBGCScjs.SERIES_REF, index: { type: "integer", minimum: 0, description: "Trendline index (0 = first)." } }, ["series", "index"]),
|
|
533
548
|
run: (_ctx, params) => {
|
|
534
549
|
check(controller.removeTrendline(resolveSeries(params.series).id, params.index));
|
|
535
550
|
return { trendlines: _nullishCoalesce(_optionalChain([controller, 'access', _29 => _29.getSeries, 'call', _30 => _30(resolveSeries(params.series).id), 'optionalAccess', _31 => _31.trendlines]), () => ( [])) };
|
|
@@ -542,8 +557,8 @@ function createChartCommands(controller, options = {}) {
|
|
|
542
557
|
keywords: ["chart", "quick layout", "style", "colours", "colors", "monochrome", "theme"],
|
|
543
558
|
description: "Applies a quick layout and / or colour scheme as one undo step.",
|
|
544
559
|
params: object({
|
|
545
|
-
layout: { type: "string", enum:
|
|
546
|
-
colors: { type: "string", enum:
|
|
560
|
+
layout: { type: "string", enum: _chunkNK3WL5TJcjs.CHART_LAYOUT_PRESETS.map((p) => p.id), description: "Quick layout id." },
|
|
561
|
+
colors: { type: "string", enum: _chunkNK3WL5TJcjs.CHART_COLOR_SCHEMES.map((p) => p.id), description: "Colour scheme id." }
|
|
547
562
|
}),
|
|
548
563
|
run: (_ctx, params = {}) => {
|
|
549
564
|
check(controller.applyPreset(_nullishCoalesce(params, () => ( {}))));
|
|
@@ -558,7 +573,7 @@ function createChartCommands(controller, options = {}) {
|
|
|
558
573
|
description: "Swaps series and categories as one undo step.",
|
|
559
574
|
run: () => {
|
|
560
575
|
check(controller.transpose());
|
|
561
|
-
return { table:
|
|
576
|
+
return { table: _chunkCKRNELPOcjs.chartDataToTable.call(void 0, controller.getSpec()) };
|
|
562
577
|
}
|
|
563
578
|
},
|
|
564
579
|
{
|
|
@@ -578,7 +593,7 @@ function createChartCommands(controller, options = {}) {
|
|
|
578
593
|
run: (_ctx, params) => {
|
|
579
594
|
const result = controller.importCsv(params.csv, { seriesIn: params.seriesIn, header: params.header });
|
|
580
595
|
check(result);
|
|
581
|
-
return { table:
|
|
596
|
+
return { table: _chunkCKRNELPOcjs.chartDataToTable.call(void 0, controller.getSpec()), issues: _nullishCoalesce(result.issues, () => ( [])) };
|
|
582
597
|
}
|
|
583
598
|
},
|
|
584
599
|
{
|
|
@@ -589,7 +604,7 @@ function createChartCommands(controller, options = {}) {
|
|
|
589
604
|
description: "Replaces the chart with Mermaid xychart-beta, pie or radar-beta text (one undo step). Unreadable lines are listed with line numbers.",
|
|
590
605
|
params: object({ mermaid: { type: "string", description: "Mermaid text." } }, ["mermaid"]),
|
|
591
606
|
run: (_ctx, params) => {
|
|
592
|
-
const read =
|
|
607
|
+
const read = _chunkNK3WL5TJcjs.chartFromMermaid.call(void 0, params.mermaid);
|
|
593
608
|
if (!read.family) fail(read.issues.map((i) => i.message).join(" ") || "Expected Mermaid starting with xychart-beta, pie or radar-beta.");
|
|
594
609
|
check(controller.update({ ...read.spec }, { label: "Import Mermaid chart" }));
|
|
595
610
|
return { spec: controller.toJSON(), issues: read.issues };
|
|
@@ -603,7 +618,7 @@ function createChartCommands(controller, options = {}) {
|
|
|
603
618
|
keywords: ["chart", "mermaid", "markdown", "export"],
|
|
604
619
|
description: "Returns the chart as Mermaid text (with a round-trip comment unless meta is false).",
|
|
605
620
|
params: object({ meta: { type: "boolean", description: "Include the %% @pixerate round-trip comment (default true)." } }),
|
|
606
|
-
run: (_ctx, params = {}) => ({ mermaid:
|
|
621
|
+
run: (_ctx, params = {}) => ({ mermaid: _chunkNK3WL5TJcjs.chartToMermaid.call(void 0, controller.toJSON(), { meta: _optionalChain([params, 'optionalAccess', _32 => _32.meta]) }) })
|
|
607
622
|
},
|
|
608
623
|
{
|
|
609
624
|
...base,
|
|
@@ -612,7 +627,7 @@ function createChartCommands(controller, options = {}) {
|
|
|
612
627
|
readOnly: true,
|
|
613
628
|
keywords: ["chart", "office", "word", "powerpoint", "docx", "pptx", "xml", "export"],
|
|
614
629
|
description: "Returns the chart as a DrawingML chart part (c:chartSpace) and what could not be written.",
|
|
615
|
-
run: () =>
|
|
630
|
+
run: () => _chunkNN3JGUSXcjs.chartToOoxml.call(void 0, controller.toJSON())
|
|
616
631
|
},
|
|
617
632
|
{
|
|
618
633
|
...base,
|
|
@@ -621,9 +636,9 @@ function createChartCommands(controller, options = {}) {
|
|
|
621
636
|
readOnly: true,
|
|
622
637
|
keywords: ["chart", "svg", "export", "image"],
|
|
623
638
|
description: "Returns the chart drawn as a standalone, accessible SVG string (with <title> and <desc>).",
|
|
624
|
-
params: object({ width:
|
|
639
|
+
params: object({ width: _chunkDK6QBGCScjs.WIDTH, height: _chunkDK6QBGCScjs.HEIGHT }),
|
|
625
640
|
run: (_ctx, params = {}) => ({
|
|
626
|
-
svg:
|
|
641
|
+
svg: _chunkNK3WL5TJcjs.chartToSvg.call(void 0, controller.toJSON(), { width: _nullishCoalesce(_optionalChain([params, 'optionalAccess', _33 => _33.width]), () => ( 640)), height: _nullishCoalesce(_optionalChain([params, 'optionalAccess', _34 => _34.height]), () => ( 400)) })
|
|
627
642
|
})
|
|
628
643
|
},
|
|
629
644
|
{
|
|
@@ -635,7 +650,7 @@ function createChartCommands(controller, options = {}) {
|
|
|
635
650
|
description: "Suggests chart types for the current data (or CSV), best first, each with a reason.",
|
|
636
651
|
params: object({ csv: { type: "string", description: "CSV text to analyse instead of the current data." } }),
|
|
637
652
|
run: (_ctx, params = {}) => ({
|
|
638
|
-
recommendations: recommendChartTypes(_optionalChain([params, 'optionalAccess', _35 => _35.csv]) !== void 0 ? _chunkTNNJXF46cjs.parseCsv.call(void 0, params.csv) :
|
|
653
|
+
recommendations: recommendChartTypes(_optionalChain([params, 'optionalAccess', _35 => _35.csv]) !== void 0 ? _chunkTNNJXF46cjs.parseCsv.call(void 0, params.csv) : _chunkCKRNELPOcjs.chartDataToTable.call(void 0, controller.getSpec()))
|
|
639
654
|
})
|
|
640
655
|
},
|
|
641
656
|
{
|
|
@@ -648,8 +663,8 @@ function createChartCommands(controller, options = {}) {
|
|
|
648
663
|
run: () => {
|
|
649
664
|
const s = controller.getSpec();
|
|
650
665
|
const visible = s.series.filter((x) => !x.hidden);
|
|
651
|
-
const colors =
|
|
652
|
-
return { colors, ...
|
|
666
|
+
const colors = _chunkCKRNELPOcjs.chartColorsByCategory.call(void 0, s.type) ? s.categories.map((_, i) => _optionalChain([visible, 'access', _36 => _36[0], 'optionalAccess', _37 => _37.pointColors, 'optionalAccess', _38 => _38[i]]) || _chunkCKRNELPOcjs.chartSliceColor.call(void 0, s, i)) : visible.map((x) => _chunkCKRNELPOcjs.chartSeriesColor.call(void 0, s, s.series.indexOf(x)));
|
|
667
|
+
return { colors, ..._chunkCKRNELPOcjs.checkChartColors.call(void 0, colors) };
|
|
653
668
|
}
|
|
654
669
|
},
|
|
655
670
|
{
|
|
@@ -680,7 +695,7 @@ function chartClientToScene(scene, box, clientX, clientY) {
|
|
|
680
695
|
function canDragChartPoint(controller, scene, target) {
|
|
681
696
|
if (_optionalChain([target, 'optionalAccess', _39 => _39.kind]) !== "point" || !scene.valueScale || scene.percent) return false;
|
|
682
697
|
const spec = controller.getSpec();
|
|
683
|
-
const family =
|
|
698
|
+
const family = _chunkCKRNELPOcjs.chartFamily.call(void 0, spec);
|
|
684
699
|
if (family !== "cartesian" && family !== "xy" && family !== "waterfall") return false;
|
|
685
700
|
const series = controller.getSeries(target.seriesId);
|
|
686
701
|
return !!series && !series.hidden && series.values[target.index] !== null;
|
|
@@ -689,13 +704,14 @@ function snapChartDragValue(scene, value, options = {}) {
|
|
|
689
704
|
const scale = _nullishCoalesce(options.scale, () => ( scene.valueScale));
|
|
690
705
|
const tolerance = _nullishCoalesce(options.tolerancePx, () => ( 6));
|
|
691
706
|
if (scale) {
|
|
692
|
-
const px = (v) =>
|
|
707
|
+
const px = (v) => _chunkNK3WL5TJcjs.chartScaleToPixel.call(void 0, v, scale);
|
|
693
708
|
const at = px(value);
|
|
694
709
|
let best = null;
|
|
695
710
|
let bestDist = tolerance;
|
|
696
711
|
for (const c of [..._nullishCoalesce(options.candidates, () => ( [])), ...scale.ticks]) {
|
|
697
712
|
if (!Number.isFinite(c)) continue;
|
|
698
713
|
const d = Math.abs(px(c) - at);
|
|
714
|
+
if (!Number.isFinite(d)) continue;
|
|
699
715
|
if (d <= bestDist) {
|
|
700
716
|
best = c;
|
|
701
717
|
bestDist = d;
|
|
@@ -703,7 +719,7 @@ function snapChartDragValue(scene, value, options = {}) {
|
|
|
703
719
|
}
|
|
704
720
|
if (best !== null) return best;
|
|
705
721
|
}
|
|
706
|
-
return
|
|
722
|
+
return _chunkNK3WL5TJcjs.snapChartValue.call(void 0, scene, value, options.step, _optionalChain([scale, 'optionalAccess', _40 => _40.ticks]), _optionalChain([scale, 'optionalAccess', _41 => _41.logBase]));
|
|
707
723
|
}
|
|
708
724
|
function startChartPointDrag(controller, scene, target, start, options = {}) {
|
|
709
725
|
if (!canDragChartPoint(controller, scene, target)) return null;
|
|
@@ -712,11 +728,11 @@ function startChartPointDrag(controller, scene, target, start, options = {}) {
|
|
|
712
728
|
const series = controller.getSeries(seriesId);
|
|
713
729
|
const secondary = series.axis === "secondary" && !!scene.valueScale2;
|
|
714
730
|
const scale = secondary ? scene.valueScale2 : scene.valueScale;
|
|
715
|
-
const xy =
|
|
731
|
+
const xy = _chunkCKRNELPOcjs.chartFamily.call(void 0, spec) === "xy" && !!scene.xScale;
|
|
716
732
|
const startValue = _nullishCoalesce(series.values[index], () => ( 0));
|
|
717
|
-
const startX = _nullishCoalesce(_optionalChain([series, 'access',
|
|
718
|
-
const startAt =
|
|
719
|
-
const startAtX = xy ?
|
|
733
|
+
const startX = _nullishCoalesce(_optionalChain([series, 'access', _42 => _42.x, 'optionalAccess', _43 => _43[index]]), () => ( null));
|
|
734
|
+
const startAt = _chunkNK3WL5TJcjs.chartValueAtPoint.call(void 0, scene, start, secondary);
|
|
735
|
+
const startAtX = xy ? _chunkNK3WL5TJcjs.chartXAtPoint.call(void 0, scene, start) : void 0;
|
|
720
736
|
if (startAt === void 0) return null;
|
|
721
737
|
const candidates = [0, startValue];
|
|
722
738
|
if (!xy) {
|
|
@@ -734,34 +750,38 @@ function startChartPointDrag(controller, scene, target, start, options = {}) {
|
|
|
734
750
|
target: { seriesId, index },
|
|
735
751
|
move(point, moveOptions = {}) {
|
|
736
752
|
if (ended) return;
|
|
737
|
-
const at =
|
|
753
|
+
const at = _chunkNK3WL5TJcjs.chartValueAtPoint.call(void 0, scene, point, secondary);
|
|
738
754
|
if (at === void 0) return;
|
|
739
755
|
const factor = moveOptions.fine ? 0.1 : 1;
|
|
740
|
-
|
|
741
|
-
let
|
|
756
|
+
const moved = (from, to, s, value) => s.logBase && value > 0 && from > 0 && to > 0 ? value * Math.pow(to / from, factor) : value + (to - from) * factor;
|
|
757
|
+
let moveY = true;
|
|
758
|
+
let moveX = false;
|
|
759
|
+
let atX;
|
|
742
760
|
if (xy && startX !== null && startAtX !== void 0) {
|
|
743
|
-
|
|
744
|
-
|
|
761
|
+
atX = _chunkNK3WL5TJcjs.chartXAtPoint.call(void 0, scene, point);
|
|
762
|
+
moveX = atX !== void 0;
|
|
745
763
|
if (moveOptions.lockAxis) {
|
|
746
|
-
if (Math.abs(point.x - start.x) >= Math.abs(point.y - start.y))
|
|
747
|
-
else
|
|
764
|
+
if (Math.abs(point.x - start.x) >= Math.abs(point.y - start.y)) moveY = false;
|
|
765
|
+
else moveX = false;
|
|
748
766
|
}
|
|
749
767
|
}
|
|
750
768
|
const snap = (v, s, c) => {
|
|
751
769
|
if (moveOptions.noSnap) return Number(v.toPrecision(12));
|
|
752
770
|
if (moveOptions.fine) {
|
|
771
|
+
if (s.logBase && !options.step) return v > 0 ? Number(v.toPrecision(3)) : v;
|
|
753
772
|
const unit = options.step ? options.step / 10 : s.ticks.length > 1 ? (s.ticks[1] - s.ticks[0]) / 100 : void 0;
|
|
754
|
-
return
|
|
773
|
+
return _chunkNK3WL5TJcjs.snapChartValue.call(void 0, scene, v, unit, s.ticks);
|
|
755
774
|
}
|
|
756
775
|
return snapChartDragValue(scene, v, { candidates: c, tolerancePx: options.tolerancePx, step: options.step, scale: s });
|
|
757
776
|
};
|
|
758
|
-
const y = snap(
|
|
777
|
+
const y = moveY ? snap(moved(startAt, at, scale, startValue), scale, candidates) : startValue;
|
|
759
778
|
if (xy && startX !== null) {
|
|
760
|
-
const
|
|
779
|
+
const nextX = moveX ? moved(startAtX, atX, scene.xScale, startX) : startX;
|
|
780
|
+
const x = nextX !== startX ? snap(nextX, scene.xScale, [0, startX]) : startX;
|
|
761
781
|
const xs = [..._nullishCoalesce(series.x, () => ( []))];
|
|
762
782
|
xs[index] = x;
|
|
763
783
|
controller.setValue(seriesId, index, y, { label });
|
|
764
|
-
if (x !== _optionalChain([controller, 'access',
|
|
784
|
+
if (x !== _optionalChain([controller, 'access', _44 => _44.getSeries, 'call', _45 => _45(seriesId), 'optionalAccess', _46 => _46.x, 'optionalAccess', _47 => _47[index]])) controller.updateSeries(seriesId, { x: xs });
|
|
765
785
|
} else controller.setValue(seriesId, index, y, { label });
|
|
766
786
|
},
|
|
767
787
|
end() {
|
|
@@ -795,7 +815,7 @@ function handleChartKey(controller, scene, event) {
|
|
|
795
815
|
return true;
|
|
796
816
|
case "ArrowLeft":
|
|
797
817
|
case "ArrowRight": {
|
|
798
|
-
if (event.altKey || _optionalChain([selection, 'optionalAccess',
|
|
818
|
+
if (event.altKey || _optionalChain([selection, 'optionalAccess', _48 => _48.kind]) !== "point" && _optionalChain([selection, 'optionalAccess', _49 => _49.kind]) !== "category") return false;
|
|
799
819
|
const n = spec.categories.length;
|
|
800
820
|
const index = Math.max(0, Math.min(n - 1, selection.index + (event.key === "ArrowRight" ? 1 : -1)));
|
|
801
821
|
controller.select({ ...selection, index });
|
|
@@ -803,12 +823,22 @@ function handleChartKey(controller, scene, event) {
|
|
|
803
823
|
}
|
|
804
824
|
case "ArrowUp":
|
|
805
825
|
case "ArrowDown": {
|
|
806
|
-
if (_optionalChain([selection, 'optionalAccess',
|
|
807
|
-
const
|
|
808
|
-
const
|
|
826
|
+
if (_optionalChain([selection, 'optionalAccess', _50 => _50.kind]) !== "point" || _optionalChain([scene, 'optionalAccess', _51 => _51.percent])) return false;
|
|
827
|
+
const series = controller.getSeries(selection.seriesId);
|
|
828
|
+
const secondary = _optionalChain([series, 'optionalAccess', _52 => _52.axis]) === "secondary";
|
|
829
|
+
const scale = _nullishCoalesce((secondary ? _optionalChain([scene, 'optionalAccess', _53 => _53.valueScale2]) : null), () => ( _optionalChain([scene, 'optionalAccess', _54 => _54.valueScale])));
|
|
830
|
+
const ticks = _nullishCoalesce(_optionalChain([scale, 'optionalAccess', _55 => _55.ticks]), () => ( []));
|
|
831
|
+
const up = event.key === "ArrowUp";
|
|
832
|
+
const current = _nullishCoalesce(_optionalChain([series, 'optionalAccess', _56 => _56.values, 'access', _57 => _57[selection.index]]), () => ( null));
|
|
833
|
+
if (_optionalChain([scale, 'optionalAccess', _58 => _58.logBase]) && current !== null && current > 0) {
|
|
834
|
+
const power = event.shiftKey ? 1 : event.altKey ? 0.01 : 0.1;
|
|
835
|
+
const next = Number((current * Math.pow(scale.logBase, up ? power : -power)).toPrecision(event.altKey ? 4 : 3));
|
|
836
|
+
controller.nudgeValue(selection.seriesId, selection.index, next - current);
|
|
837
|
+
return true;
|
|
838
|
+
}
|
|
809
839
|
const step = ticks.length > 1 ? ticks[1] - ticks[0] : 1;
|
|
810
840
|
const amount = event.shiftKey ? step : event.altKey ? step / 100 : step / 10;
|
|
811
|
-
controller.nudgeValue(selection.seriesId, selection.index, amount * (
|
|
841
|
+
controller.nudgeValue(selection.seriesId, selection.index, amount * (up ? 1 : -1));
|
|
812
842
|
return true;
|
|
813
843
|
}
|
|
814
844
|
default:
|
|
@@ -828,22 +858,22 @@ function describeChartSelection(controller, selection = controller.getState().se
|
|
|
828
858
|
case "legend":
|
|
829
859
|
return "Legend";
|
|
830
860
|
case "axis":
|
|
831
|
-
return selection.axis === "x" ?
|
|
861
|
+
return selection.axis === "x" ? _chunkCKRNELPOcjs.chartFamily.call(void 0, spec) === "xy" ? "X axis" : "Category axis" : selection.axis === "y" ? "Value axis" : "Secondary value axis";
|
|
832
862
|
case "series":
|
|
833
|
-
return `Series "${_nullishCoalesce(_optionalChain([controller, 'access',
|
|
863
|
+
return `Series "${_nullishCoalesce(_optionalChain([controller, 'access', _59 => _59.getSeries, 'call', _60 => _60(selection.seriesId), 'optionalAccess', _61 => _61.name]), () => ( selection.seriesId))}"`;
|
|
834
864
|
case "category":
|
|
835
865
|
return `Category "${_nullishCoalesce(spec.categories[selection.index], () => ( selection.index))}"`;
|
|
836
866
|
case "trendline": {
|
|
837
867
|
const series = controller.getSeries(selection.seriesId);
|
|
838
|
-
const line = _optionalChain([series, 'optionalAccess',
|
|
839
|
-
return `${line ? line.type.replace("-", " ") : "Trendline"} trendline on "${_nullishCoalesce(_optionalChain([series, 'optionalAccess',
|
|
868
|
+
const line = _optionalChain([series, 'optionalAccess', _62 => _62.trendlines, 'optionalAccess', _63 => _63[selection.index]]);
|
|
869
|
+
return `${line ? line.type.replace("-", " ") : "Trendline"} trendline on "${_nullishCoalesce(_optionalChain([series, 'optionalAccess', _64 => _64.name]), () => ( selection.seriesId))}"`;
|
|
840
870
|
}
|
|
841
871
|
case "point": {
|
|
842
872
|
const series = controller.getSeries(selection.seriesId);
|
|
843
|
-
const value = _optionalChain([series, 'optionalAccess',
|
|
844
|
-
const x = _optionalChain([series, 'optionalAccess',
|
|
845
|
-
if (x !== void 0 && x !== null &&
|
|
846
|
-
return `${_nullishCoalesce(_optionalChain([series, 'optionalAccess',
|
|
873
|
+
const value = _optionalChain([series, 'optionalAccess', _65 => _65.values, 'access', _66 => _66[selection.index]]);
|
|
874
|
+
const x = _optionalChain([series, 'optionalAccess', _67 => _67.x, 'optionalAccess', _68 => _68[selection.index]]);
|
|
875
|
+
if (x !== void 0 && x !== null && _chunkCKRNELPOcjs.chartFamily.call(void 0, spec) === "xy") return `${_nullishCoalesce(_optionalChain([series, 'optionalAccess', _69 => _69.name]), () => ( selection.seriesId))}: (${x}, ${_nullishCoalesce(value, () => ( "blank"))})`;
|
|
876
|
+
return `${_nullishCoalesce(_optionalChain([series, 'optionalAccess', _70 => _70.name]), () => ( selection.seriesId))} \xB7 ${_nullishCoalesce(spec.categories[selection.index], () => ( selection.index))}: ${_nullishCoalesce(value, () => ( "blank"))}`;
|
|
847
877
|
}
|
|
848
878
|
}
|
|
849
879
|
}
|
|
@@ -916,13 +946,13 @@ function createChartToolProvider(controller, options = {}) {
|
|
|
916
946
|
fail2(`There is no category ${JSON.stringify(ref)}; expected an index from 0 to ${categories.length - 1} or one of ${categories.slice(0, 20).map((c) => JSON.stringify(c)).join(", ")}.`);
|
|
917
947
|
return index;
|
|
918
948
|
};
|
|
919
|
-
const table = () =>
|
|
949
|
+
const table = () => _chunkCKRNELPOcjs.chartDataToTable.call(void 0, spec());
|
|
920
950
|
const Parser = () => _nullishCoalesce(options.DOMParser, () => ( globalThis.DOMParser));
|
|
921
951
|
const getChart = {
|
|
922
952
|
name: "get_chart",
|
|
923
953
|
title: "Read the chart",
|
|
924
954
|
description: "Returns the chart spec (type, titles, axes, legend, series with ids and settings), its data as a table (header row of series names, then one row per category), the current selection, and a summary at the given size: per-series min / max / mean / trend, the axes as drawn, layout warnings (hidden labels, thinned lines), a colour check and a plain-language description. Use the series ids and category indexes it returns with the write tools.",
|
|
925
|
-
inputSchema: { type: "object", properties: { width:
|
|
955
|
+
inputSchema: { type: "object", properties: { width: _chunkDK6QBGCScjs.WIDTH, height: _chunkDK6QBGCScjs.HEIGHT }, additionalProperties: false },
|
|
926
956
|
annotations: { title: "Read the chart", ...READ },
|
|
927
957
|
handler: ({ width = size.width, height = size.height }) => {
|
|
928
958
|
const reason = readOnlyReason();
|
|
@@ -930,7 +960,7 @@ function createChartToolProvider(controller, options = {}) {
|
|
|
930
960
|
spec: controller.toJSON(),
|
|
931
961
|
table: table(),
|
|
932
962
|
selection: controller.getState().selection,
|
|
933
|
-
summary:
|
|
963
|
+
summary: _chunkNK3WL5TJcjs.summarizeChart.call(void 0, controller.toJSON(), { width, height }),
|
|
934
964
|
issues: controller.getState().issues,
|
|
935
965
|
...reason ? { readOnly: reason } : {}
|
|
936
966
|
};
|
|
@@ -943,8 +973,8 @@ function createChartToolProvider(controller, options = {}) {
|
|
|
943
973
|
inputSchema: {
|
|
944
974
|
type: "object",
|
|
945
975
|
properties: {
|
|
946
|
-
width:
|
|
947
|
-
height:
|
|
976
|
+
width: _chunkDK6QBGCScjs.WIDTH,
|
|
977
|
+
height: _chunkDK6QBGCScjs.HEIGHT,
|
|
948
978
|
format: { type: "string", enum: ["svg", "png"], description: "svg (default): the SVG document as text. png: an image to look at (only when the host can rasterize; costs image tokens)." }
|
|
949
979
|
},
|
|
950
980
|
additionalProperties: false
|
|
@@ -952,8 +982,8 @@ function createChartToolProvider(controller, options = {}) {
|
|
|
952
982
|
annotations: { title: "Render the chart", ...READ },
|
|
953
983
|
handler: async ({ width = size.width, height = size.height, format = "svg" }) => {
|
|
954
984
|
const json = controller.toJSON();
|
|
955
|
-
const scene =
|
|
956
|
-
const svg =
|
|
985
|
+
const scene = _chunkNK3WL5TJcjs.layoutChart.call(void 0, json, { width, height, selection: null });
|
|
986
|
+
const svg = _chunkNK3WL5TJcjs.chartSceneToSvg.call(void 0, scene, { ariaLabel: json.title || void 0, description: _chunkNK3WL5TJcjs.describeChart.call(void 0, json) });
|
|
957
987
|
const warnings = scene.warnings;
|
|
958
988
|
if (format === "png") {
|
|
959
989
|
if (!options.rasterize) fail2('This host cannot rasterize charts; call render_chart with format "svg", or get_chart for the layout warnings.');
|
|
@@ -987,8 +1017,8 @@ function createChartToolProvider(controller, options = {}) {
|
|
|
987
1017
|
handler: ({ colors, surface }) => {
|
|
988
1018
|
const s = spec();
|
|
989
1019
|
const visible = s.series.filter((x) => !x.hidden);
|
|
990
|
-
const own =
|
|
991
|
-
return { colors: _nullishCoalesce(colors, () => ( own)), ...
|
|
1020
|
+
const own = _chunkCKRNELPOcjs.chartColorsByCategory.call(void 0, s.type) ? s.categories.map((_, i) => _optionalChain([visible, 'access', _71 => _71[0], 'optionalAccess', _72 => _72.pointColors, 'optionalAccess', _73 => _73[i]]) || _chunkCKRNELPOcjs.chartSliceColor.call(void 0, s, i)) : visible.map((x) => _chunkCKRNELPOcjs.chartSeriesColor.call(void 0, s, s.series.indexOf(x)));
|
|
1021
|
+
return { colors: _nullishCoalesce(colors, () => ( own)), ..._chunkCKRNELPOcjs.checkChartColors.call(void 0, _nullishCoalesce(colors, () => ( own)), { surface }) };
|
|
992
1022
|
}
|
|
993
1023
|
};
|
|
994
1024
|
const recommend = {
|
|
@@ -1010,15 +1040,15 @@ function createChartToolProvider(controller, options = {}) {
|
|
|
1010
1040
|
description: "Returns a trendline's fitted coefficients (in x for category charts, x = 1, 2, 3, \u2026), R\xB2, equation and the number of points, or the moving-average points.",
|
|
1011
1041
|
inputSchema: {
|
|
1012
1042
|
type: "object",
|
|
1013
|
-
properties: { series:
|
|
1043
|
+
properties: { series: _chunkDK6QBGCScjs.SERIES_REF, index: { type: "integer", minimum: 0, description: "Trendline index on the series (0 = first)." } },
|
|
1014
1044
|
required: ["series", "index"],
|
|
1015
1045
|
additionalProperties: false
|
|
1016
1046
|
},
|
|
1017
1047
|
annotations: { title: "Read a trendline fit", ...READ },
|
|
1018
1048
|
handler: ({ series, index }) => {
|
|
1019
1049
|
const s = seriesById(series);
|
|
1020
|
-
const line = _optionalChain([s, 'access',
|
|
1021
|
-
if (!line) fail2(`"${s.name}" has no trendline ${index}; it has ${_nullishCoalesce(_optionalChain([s, 'access',
|
|
1050
|
+
const line = _optionalChain([s, 'access', _74 => _74.trendlines, 'optionalAccess', _75 => _75[index]]);
|
|
1051
|
+
if (!line) fail2(`"${s.name}" has no trendline ${index}; it has ${_nullishCoalesce(_optionalChain([s, 'access', _76 => _76.trendlines, 'optionalAccess', _77 => _77.length]), () => ( 0))}.`);
|
|
1022
1052
|
if (line.type === "moving-average") return { trendline: line, points: controller.trendlineMovingAverage(s.id, index) };
|
|
1023
1053
|
const fit = controller.trendlineFit(s.id, index);
|
|
1024
1054
|
if (!fit) fail2(`The ${line.type} trendline on "${s.name}" cannot be fitted: it needs more points (and positive values for log, exponential and power fits).`);
|
|
@@ -1032,8 +1062,8 @@ function createChartToolProvider(controller, options = {}) {
|
|
|
1032
1062
|
inputSchema: { type: "object", properties: {}, additionalProperties: false },
|
|
1033
1063
|
annotations: { title: "List chart presets", ...READ },
|
|
1034
1064
|
handler: () => ({
|
|
1035
|
-
layouts:
|
|
1036
|
-
colorSchemes:
|
|
1065
|
+
layouts: _chunkNK3WL5TJcjs.CHART_LAYOUT_PRESETS.map(({ id, label, description }) => ({ id, label, description })),
|
|
1066
|
+
colorSchemes: _chunkNK3WL5TJcjs.CHART_COLOR_SCHEMES.map(({ id, label, description, palette }) => ({ id, label, description, palette }))
|
|
1037
1067
|
})
|
|
1038
1068
|
};
|
|
1039
1069
|
const exportMermaid = {
|
|
@@ -1042,7 +1072,7 @@ function createChartToolProvider(controller, options = {}) {
|
|
|
1042
1072
|
description: 'Returns the chart as Mermaid text (xychart-beta, pie or radar-beta) for Markdown or chat. With meta (default true) one "%% @pixerate {\u2026}" comment keeps what Mermaid cannot express, so import_chart_mermaid gets the chart back exactly.',
|
|
1043
1073
|
inputSchema: { type: "object", properties: { meta: { type: "boolean", description: "Include the round-trip comment (default true)." } }, additionalProperties: false },
|
|
1044
1074
|
annotations: { title: "Export chart as Mermaid", ...READ },
|
|
1045
|
-
handler: ({ meta = true }) => ({ mermaid:
|
|
1075
|
+
handler: ({ meta = true }) => ({ mermaid: _chunkNK3WL5TJcjs.chartToMermaid.call(void 0, controller.toJSON(), { meta }) })
|
|
1046
1076
|
};
|
|
1047
1077
|
const exportOoxml = {
|
|
1048
1078
|
name: "export_chart_ooxml",
|
|
@@ -1050,15 +1080,15 @@ function createChartToolProvider(controller, options = {}) {
|
|
|
1050
1080
|
description: "Returns the chart as a DrawingML chart part (c:chartSpace) for Word or PowerPoint files, with what could not be written as sentences.",
|
|
1051
1081
|
inputSchema: { type: "object", properties: {}, additionalProperties: false },
|
|
1052
1082
|
annotations: { title: "Export chart as Office XML", ...READ },
|
|
1053
|
-
handler: () =>
|
|
1083
|
+
handler: () => _chunkNN3JGUSXcjs.chartToOoxml.call(void 0, controller.toJSON())
|
|
1054
1084
|
};
|
|
1055
1085
|
const updateChart = {
|
|
1056
1086
|
name: "update_chart",
|
|
1057
1087
|
title: "Change chart presentation",
|
|
1058
|
-
description:
|
|
1088
|
+
description: 'Changes how the chart looks, as one undo step: type, titles, axes (xAxis = categories or numeric x, yAxis = values, yAxis2 = secondary values; each can be reversed, and value axes can be logarithmic with scale "log"), legend, stacking, orientation, curve, points, data labels and their position, palette, donut hole, bar spacing, histogram bins, waterfall total. All-or-nothing: invalid values change nothing and come back as sentences. Returns the new spec.',
|
|
1059
1089
|
inputSchema: {
|
|
1060
1090
|
type: "object",
|
|
1061
|
-
properties:
|
|
1091
|
+
properties: _chunkDK6QBGCScjs.CHART_UPDATE_PROPERTIES,
|
|
1062
1092
|
additionalProperties: false
|
|
1063
1093
|
},
|
|
1064
1094
|
annotations: { title: "Change chart presentation", ...WRITE_IDEMPOTENT },
|
|
@@ -1079,7 +1109,7 @@ function createChartToolProvider(controller, options = {}) {
|
|
|
1079
1109
|
series: {
|
|
1080
1110
|
type: "array",
|
|
1081
1111
|
description: "The new series (replaces all).",
|
|
1082
|
-
items: { type: "object", properties: { id: { type: "string", description: "Stable id (optional)." }, ...
|
|
1112
|
+
items: { type: "object", properties: { id: { type: "string", description: "Stable id (optional)." }, ..._chunkDK6QBGCScjs.SERIES_PROPS }, required: ["name", "values"], additionalProperties: false }
|
|
1083
1113
|
}
|
|
1084
1114
|
},
|
|
1085
1115
|
additionalProperties: false
|
|
@@ -1102,7 +1132,7 @@ function createChartToolProvider(controller, options = {}) {
|
|
|
1102
1132
|
type: "array",
|
|
1103
1133
|
minItems: 1,
|
|
1104
1134
|
description: "Values to set.",
|
|
1105
|
-
items: { type: "object", properties: { series:
|
|
1135
|
+
items: { type: "object", properties: { series: _chunkDK6QBGCScjs.SERIES_REF, category: _chunkDK6QBGCScjs.CATEGORY_REF, value: _chunkDK6QBGCScjs.VALUE }, required: ["series", "category", "value"], additionalProperties: false }
|
|
1106
1136
|
}
|
|
1107
1137
|
},
|
|
1108
1138
|
required: ["cells"],
|
|
@@ -1111,7 +1141,7 @@ function createChartToolProvider(controller, options = {}) {
|
|
|
1111
1141
|
annotations: { title: "Set chart values", ...WRITE_IDEMPOTENT },
|
|
1112
1142
|
handler: async ({ cells }) => {
|
|
1113
1143
|
const resolved = cells.map((c) => ({ seriesId: seriesById(c.series).id, index: categoryIndex(c.category), value: c.value }));
|
|
1114
|
-
const parsed = resolved.map((c) =>
|
|
1144
|
+
const parsed = resolved.map((c) => _chunkCKRNELPOcjs.parseChartValue.call(void 0, c.value));
|
|
1115
1145
|
const bad = resolved.find((_, i) => parsed[i] === void 0);
|
|
1116
1146
|
if (bad) fail2(`"${String(bad.value)}" is not a number; pass a number, numeric text or null for a gap. Nothing was changed.`);
|
|
1117
1147
|
if (options.director && parsed.every((v) => typeof v === "number")) {
|
|
@@ -1128,7 +1158,7 @@ function createChartToolProvider(controller, options = {}) {
|
|
|
1128
1158
|
description: "Adds a series (values padded to the categories) and selects it. Returns its id and stored values.",
|
|
1129
1159
|
inputSchema: {
|
|
1130
1160
|
type: "object",
|
|
1131
|
-
properties: { ...
|
|
1161
|
+
properties: { ..._chunkDK6QBGCScjs.SERIES_PROPS, id: { type: "string", description: "Id to use (default: series-N)." }, at: { type: "integer", minimum: 0, description: "Position (default: last)." } },
|
|
1132
1162
|
required: ["name"],
|
|
1133
1163
|
additionalProperties: false
|
|
1134
1164
|
},
|
|
@@ -1143,10 +1173,10 @@ function createChartToolProvider(controller, options = {}) {
|
|
|
1143
1173
|
const updateSeries = {
|
|
1144
1174
|
name: "update_chart_series",
|
|
1145
1175
|
title: "Change a series",
|
|
1146
|
-
description: "Renames, recolours, hides, moves to the secondary axis or changes how a series is drawn (marker, curve, labels, format, x values, bubble sizes, point colours). null resets a field. Values change with set_chart_values. Returns the series.",
|
|
1176
|
+
description: "Renames, recolours, hides, moves to the secondary axis or changes how a series is drawn (marker, curve, labels, format, x values, bubble sizes, point colours, error bars). null resets a field. Values change with set_chart_values. Returns the series.",
|
|
1147
1177
|
inputSchema: {
|
|
1148
1178
|
type: "object",
|
|
1149
|
-
properties: { series:
|
|
1179
|
+
properties: { series: _chunkDK6QBGCScjs.SERIES_REF, ...Object.fromEntries(Object.entries(_chunkDK6QBGCScjs.SERIES_PROPS).filter(([k]) => k !== "values")) },
|
|
1150
1180
|
required: ["series"],
|
|
1151
1181
|
additionalProperties: false
|
|
1152
1182
|
},
|
|
@@ -1162,7 +1192,7 @@ function createChartToolProvider(controller, options = {}) {
|
|
|
1162
1192
|
name: "remove_chart_series",
|
|
1163
1193
|
title: "Delete a series",
|
|
1164
1194
|
description: "Deletes a series and its values. Returns the remaining series ids.",
|
|
1165
|
-
inputSchema: { type: "object", properties: { series:
|
|
1195
|
+
inputSchema: { type: "object", properties: { series: _chunkDK6QBGCScjs.SERIES_REF }, required: ["series"], additionalProperties: false },
|
|
1166
1196
|
annotations: { title: "Delete a series", ...DESTRUCTIVE },
|
|
1167
1197
|
handler: ({ series }) => {
|
|
1168
1198
|
resolve(controller.removeSeries(seriesById(series).id));
|
|
@@ -1188,7 +1218,7 @@ function createChartToolProvider(controller, options = {}) {
|
|
|
1188
1218
|
name: "remove_chart_category",
|
|
1189
1219
|
title: "Delete a category",
|
|
1190
1220
|
description: "Deletes a category and its value in every series. Returns the remaining categories.",
|
|
1191
|
-
inputSchema: { type: "object", properties: { category:
|
|
1221
|
+
inputSchema: { type: "object", properties: { category: _chunkDK6QBGCScjs.CATEGORY_REF }, required: ["category"], additionalProperties: false },
|
|
1192
1222
|
annotations: { title: "Delete a category", ...DESTRUCTIVE },
|
|
1193
1223
|
handler: ({ category }) => {
|
|
1194
1224
|
resolve(controller.removeCategory(categoryIndex(category)));
|
|
@@ -1231,7 +1261,7 @@ function createChartToolProvider(controller, options = {}) {
|
|
|
1231
1261
|
annotations: { title: "Import a Mermaid chart", ...DESTRUCTIVE },
|
|
1232
1262
|
handler: ({ mermaid }) => {
|
|
1233
1263
|
const fenced = /```(?:mermaid)?\s*\n([\s\S]*?)```/.exec(mermaid);
|
|
1234
|
-
const read =
|
|
1264
|
+
const read = _chunkNK3WL5TJcjs.chartFromMermaid.call(void 0, fenced ? fenced[1] : mermaid);
|
|
1235
1265
|
if (!read.family) fail2(read.issues.map((i) => i.message).join(" ") || "Expected Mermaid starting with xychart-beta, pie or radar-beta.");
|
|
1236
1266
|
resolve(controller.update({ ...read.spec }, { label: "Import Mermaid chart" }));
|
|
1237
1267
|
return { spec: controller.toJSON(), issues: read.issues };
|
|
@@ -1244,7 +1274,7 @@ function createChartToolProvider(controller, options = {}) {
|
|
|
1244
1274
|
inputSchema: { type: "object", properties: { xml: { type: "string", description: "The chart part XML, e.g. word/charts/chart1.xml." } }, required: ["xml"], additionalProperties: false },
|
|
1245
1275
|
annotations: { title: "Import an Office chart", ...DESTRUCTIVE },
|
|
1246
1276
|
handler: ({ xml }) => {
|
|
1247
|
-
const read =
|
|
1277
|
+
const read = _chunkNN3JGUSXcjs.chartFromOoxml.call(void 0, xml, { DOMParser: Parser() });
|
|
1248
1278
|
if (read.issues.some((i) => i.path === "" || i.path === "plotArea")) fail2(read.issues.map((i) => i.message).join(" "));
|
|
1249
1279
|
resolve(controller.update({ ...read.spec }, { label: "Import Office chart" }));
|
|
1250
1280
|
return { spec: controller.toJSON(), issues: read.issues.map((i) => i.message), unsupported: read.unsupported, lossless: read.lossless };
|
|
@@ -1254,7 +1284,7 @@ function createChartToolProvider(controller, options = {}) {
|
|
|
1254
1284
|
name: "add_chart_trendline",
|
|
1255
1285
|
title: "Add a trendline",
|
|
1256
1286
|
description: "Fits a trendline to a series and draws it (unstacked bar, line, area, scatter and bubble charts). Returns its index and the fit: coefficients, R\xB2 and equation.",
|
|
1257
|
-
inputSchema: { type: "object", properties: { series:
|
|
1287
|
+
inputSchema: { type: "object", properties: { series: _chunkDK6QBGCScjs.SERIES_REF, ..._chunkDK6QBGCScjs.TRENDLINE_PROPS }, required: ["series", "type"], additionalProperties: false },
|
|
1258
1288
|
annotations: { title: "Add a trendline", ...WRITE },
|
|
1259
1289
|
handler: ({ series, ...line }) => {
|
|
1260
1290
|
const s = seriesById(series);
|
|
@@ -1268,7 +1298,7 @@ function createChartToolProvider(controller, options = {}) {
|
|
|
1268
1298
|
description: "Deletes a trendline from a series. Returns the series' remaining trendlines.",
|
|
1269
1299
|
inputSchema: {
|
|
1270
1300
|
type: "object",
|
|
1271
|
-
properties: { series:
|
|
1301
|
+
properties: { series: _chunkDK6QBGCScjs.SERIES_REF, index: { type: "integer", minimum: 0, description: "Trendline index on the series (0 = first)." } },
|
|
1272
1302
|
required: ["series", "index"],
|
|
1273
1303
|
additionalProperties: false
|
|
1274
1304
|
},
|
|
@@ -1276,7 +1306,7 @@ function createChartToolProvider(controller, options = {}) {
|
|
|
1276
1306
|
handler: ({ series, index }) => {
|
|
1277
1307
|
const s = seriesById(series);
|
|
1278
1308
|
resolve(controller.removeTrendline(s.id, index));
|
|
1279
|
-
return { series: s.id, trendlines: _nullishCoalesce(_optionalChain([controller, 'access',
|
|
1309
|
+
return { series: s.id, trendlines: _nullishCoalesce(_optionalChain([controller, 'access', _78 => _78.getSeries, 'call', _79 => _79(s.id), 'optionalAccess', _80 => _80.trendlines]), () => ( [])) };
|
|
1280
1310
|
}
|
|
1281
1311
|
};
|
|
1282
1312
|
const applyPreset = {
|
|
@@ -1286,8 +1316,8 @@ function createChartToolProvider(controller, options = {}) {
|
|
|
1286
1316
|
inputSchema: {
|
|
1287
1317
|
type: "object",
|
|
1288
1318
|
properties: {
|
|
1289
|
-
layout: { type: "string", enum:
|
|
1290
|
-
colors: { type: "string", enum:
|
|
1319
|
+
layout: { type: "string", enum: _chunkNK3WL5TJcjs.CHART_LAYOUT_PRESETS.map((p) => p.id), description: "Quick layout id." },
|
|
1320
|
+
colors: { type: "string", enum: _chunkNK3WL5TJcjs.CHART_COLOR_SCHEMES.map((p) => p.id), description: "Colour scheme id." }
|
|
1291
1321
|
},
|
|
1292
1322
|
additionalProperties: false
|
|
1293
1323
|
},
|
|
@@ -1316,8 +1346,8 @@ function createChartToolProvider(controller, options = {}) {
|
|
|
1316
1346
|
type: "object",
|
|
1317
1347
|
properties: {
|
|
1318
1348
|
kind: { type: "string", enum: ["none", "chart", "title", "subtitle", "legend", "axis", "series", "point", "category", "trendline"], description: "What to select." },
|
|
1319
|
-
series: { ...
|
|
1320
|
-
category: { ...
|
|
1349
|
+
series: { ..._chunkDK6QBGCScjs.SERIES_REF, description: "Series id or name (series, point, trendline)." },
|
|
1350
|
+
category: { ..._chunkDK6QBGCScjs.CATEGORY_REF, description: "Category index or label (point, category)." },
|
|
1321
1351
|
axis: { type: "string", enum: ["x", "y", "y2"], description: "Axis (axis)." },
|
|
1322
1352
|
index: { type: "integer", minimum: 0, description: "Trendline index (trendline)." }
|
|
1323
1353
|
},
|
|
@@ -1375,20 +1405,20 @@ function createChartToolProvider(controller, options = {}) {
|
|
|
1375
1405
|
to: { type: "object", description: "End, as fractions of the chart.", properties: { x: { type: "number", minimum: 0, maximum: 1, description: "Fraction of the width." }, y: { type: "number", minimum: 0, maximum: 1, description: "Fraction of the height." } }, required: ["x", "y"], additionalProperties: false },
|
|
1376
1406
|
fine: { type: "boolean", description: "Move a tenth as far (Alt)." },
|
|
1377
1407
|
lockAxis: { type: "boolean", description: "Scatter charts: change only the axis moved along most (Shift)." },
|
|
1378
|
-
width:
|
|
1379
|
-
height:
|
|
1408
|
+
width: _chunkDK6QBGCScjs.WIDTH,
|
|
1409
|
+
height: _chunkDK6QBGCScjs.HEIGHT
|
|
1380
1410
|
},
|
|
1381
1411
|
required: ["from", "to"],
|
|
1382
1412
|
additionalProperties: false
|
|
1383
1413
|
},
|
|
1384
1414
|
annotations: { title: "Drag a chart point", ...WRITE },
|
|
1385
1415
|
handler: ({ from, to, fine, lockAxis, width = size.width, height = size.height }) => {
|
|
1386
|
-
const scene =
|
|
1416
|
+
const scene = _chunkNK3WL5TJcjs.layoutChart.call(void 0, controller.toJSON(), { width, height });
|
|
1387
1417
|
const start = { x: from.x * width, y: from.y * height };
|
|
1388
1418
|
const target = chartHitTest(scene, start);
|
|
1389
|
-
if (_optionalChain([target, 'optionalAccess',
|
|
1419
|
+
if (_optionalChain([target, 'optionalAccess', _81 => _81.kind]) !== "point") fail2(`There is no bar or point at (${from.x}, ${from.y}); ${target ? `that is the ${target.kind}` : "that is outside the chart"}. Use render_chart to find marks.`);
|
|
1390
1420
|
const t = target;
|
|
1391
|
-
const before = _nullishCoalesce(_optionalChain([controller, 'access',
|
|
1421
|
+
const before = _nullishCoalesce(_optionalChain([controller, 'access', _82 => _82.getSeries, 'call', _83 => _83(t.seriesId), 'optionalAccess', _84 => _84.values, 'access', _85 => _85[t.index]]), () => ( null));
|
|
1392
1422
|
const session = startChartPointDrag(controller, scene, t, start);
|
|
1393
1423
|
if (!session) fail2("That point cannot be dragged here (percent-stacked charts, pies and gaps cannot be dragged).");
|
|
1394
1424
|
session.move({ x: to.x * width, y: to.y * height }, { fine, lockAxis });
|
|
@@ -1413,10 +1443,10 @@ function createChartToolProvider(controller, options = {}) {
|
|
|
1413
1443
|
},
|
|
1414
1444
|
annotations: { title: "Press a key on the chart", ...DESTRUCTIVE },
|
|
1415
1445
|
handler: ({ key: k, shift, alt }) => {
|
|
1416
|
-
const scene =
|
|
1446
|
+
const scene = _chunkNK3WL5TJcjs.layoutChart.call(void 0, controller.toJSON(), size);
|
|
1417
1447
|
const used = handleChartKey(controller, scene, { key: k, shiftKey: shift, altKey: alt });
|
|
1418
1448
|
const sel = controller.getState().selection;
|
|
1419
|
-
const value = _optionalChain([sel, 'optionalAccess',
|
|
1449
|
+
const value = _optionalChain([sel, 'optionalAccess', _86 => _86.kind]) === "point" ? _nullishCoalesce(_optionalChain([controller, 'access', _87 => _87.getSeries, 'call', _88 => _88(sel.seriesId), 'optionalAccess', _89 => _89.values, 'access', _90 => _90[sel.index]]), () => ( null)) : void 0;
|
|
1420
1450
|
return { used, selection: sel, ...value !== void 0 ? { value } : {} };
|
|
1421
1451
|
}
|
|
1422
1452
|
};
|
|
@@ -1521,12 +1551,12 @@ var ChartStream = (_class = class {
|
|
|
1521
1551
|
if (format === "json") {
|
|
1522
1552
|
const value = complete ? safeParse(text) : parsePartialChartJson(text);
|
|
1523
1553
|
if (value !== void 0) {
|
|
1524
|
-
const read =
|
|
1554
|
+
const read = _chunkCKRNELPOcjs.normalizeChartSpec.call(void 0, value);
|
|
1525
1555
|
spec = read.spec;
|
|
1526
1556
|
issues = complete ? read.issues : [];
|
|
1527
1557
|
}
|
|
1528
1558
|
} else {
|
|
1529
|
-
const read =
|
|
1559
|
+
const read = _chunkNK3WL5TJcjs.chartFromMermaid.call(void 0, text, { partial: !complete });
|
|
1530
1560
|
if (read.family) {
|
|
1531
1561
|
spec = read.spec;
|
|
1532
1562
|
issues = complete ? read.issues : [];
|
|
@@ -1638,7 +1668,7 @@ function createInstantChartClock(start = 0) {
|
|
|
1638
1668
|
};
|
|
1639
1669
|
}
|
|
1640
1670
|
function chartPointAnchor(scene, seriesId, index) {
|
|
1641
|
-
const mark = scene.marks.find((m) => (m.role === "bar" || m.role === "point") && _optionalChain([m, 'access',
|
|
1671
|
+
const mark = scene.marks.find((m) => (m.role === "bar" || m.role === "point") && _optionalChain([m, 'access', _91 => _91.target, 'optionalAccess', _92 => _92.kind]) === "point" && m.target.seriesId === seriesId && m.target.index === index);
|
|
1642
1672
|
if (!mark) return null;
|
|
1643
1673
|
if (mark.kind === "rect") return { x: mark.x + mark.width / 2, y: mark.y };
|
|
1644
1674
|
if (mark.kind === "circle") return { x: mark.cx, y: mark.cy };
|
|
@@ -1664,10 +1694,10 @@ function planChartCommand(spec, scene, command, speed = 1) {
|
|
|
1664
1694
|
case "setValue": {
|
|
1665
1695
|
const at = chartPointAnchor(scene, command.seriesId, command.index);
|
|
1666
1696
|
const series = spec.series.find((s) => s.id === command.seriesId);
|
|
1667
|
-
const from = _nullishCoalesce(_optionalChain([series, 'optionalAccess',
|
|
1668
|
-
const scale = _optionalChain([series, 'optionalAccess',
|
|
1697
|
+
const from = _nullishCoalesce(_optionalChain([series, 'optionalAccess', _93 => _93.values, 'access', _94 => _94[command.index]]), () => ( 0));
|
|
1698
|
+
const scale = _optionalChain([series, 'optionalAccess', _95 => _95.axis]) === "secondary" ? _nullishCoalesce(scene.valueScale2, () => ( scene.valueScale)) : scene.valueScale;
|
|
1669
1699
|
if (at && scale) {
|
|
1670
|
-
const px =
|
|
1700
|
+
const px = _chunkNK3WL5TJcjs.linearMap.call(void 0, command.value, scale.domain, scale.range);
|
|
1671
1701
|
const to = scale.axis === "y" ? { x: at.x, y: px } : { x: px, y: at.y };
|
|
1672
1702
|
steps.push({ type: "move", to: at, ms: ms(380) }, { type: "press" }, { type: "drag", to, ms: ms(520), from, value: command.value }, { type: "release" });
|
|
1673
1703
|
} else steps.push({ type: "drag", to: { x: scene.plot.x + scene.plot.width / 2, y: scene.plot.y + scene.plot.height / 2 }, ms: ms(200), from, value: command.value });
|
|
@@ -1677,12 +1707,12 @@ function planChartCommand(spec, scene, command, speed = 1) {
|
|
|
1677
1707
|
case "select": {
|
|
1678
1708
|
const sel = command.selection;
|
|
1679
1709
|
let to = null;
|
|
1680
|
-
if (_optionalChain([sel, 'optionalAccess',
|
|
1710
|
+
if (_optionalChain([sel, 'optionalAccess', _96 => _96.kind]) === "point") to = chartPointAnchor(scene, sel.seriesId, sel.index);
|
|
1681
1711
|
else if (sel) {
|
|
1682
1712
|
const m = scene.marks.find((x) => x.target && JSON.stringify(x.target) === JSON.stringify(sel));
|
|
1683
|
-
if (_optionalChain([m, 'optionalAccess',
|
|
1684
|
-
else if (_optionalChain([m, 'optionalAccess',
|
|
1685
|
-
else if (_optionalChain([m, 'optionalAccess',
|
|
1713
|
+
if (_optionalChain([m, 'optionalAccess', _97 => _97.kind]) === "text") to = { x: m.x, y: m.y };
|
|
1714
|
+
else if (_optionalChain([m, 'optionalAccess', _98 => _98.kind]) === "rect") to = { x: m.x + m.width / 2, y: m.y + m.height / 2 };
|
|
1715
|
+
else if (_optionalChain([m, 'optionalAccess', _99 => _99.kind]) === "circle") to = { x: m.cx, y: m.cy };
|
|
1686
1716
|
}
|
|
1687
1717
|
if (to) steps.push({ type: "move", to, ms: ms(380) }, { type: "press" }, { type: "release" });
|
|
1688
1718
|
steps.push({ type: "commit" });
|
|
@@ -1749,7 +1779,7 @@ var ChartDirector = (_class3 = class {
|
|
|
1749
1779
|
const t = f / frames;
|
|
1750
1780
|
const e = 1 - Math.pow(1 - t, 3);
|
|
1751
1781
|
this.presence.set({ id, x: from.x + (to.x - from.x) * e, y: from.y + (to.y - from.y) * e });
|
|
1752
|
-
_optionalChain([each, 'optionalCall',
|
|
1782
|
+
_optionalChain([each, 'optionalCall', _100 => _100(e)]);
|
|
1753
1783
|
await this.clock.wait(ms / frames);
|
|
1754
1784
|
}
|
|
1755
1785
|
}
|
|
@@ -1781,7 +1811,7 @@ var ChartDirector = (_class3 = class {
|
|
|
1781
1811
|
if (command.kind !== "setValue") break;
|
|
1782
1812
|
const stale2 = this.stale(command);
|
|
1783
1813
|
if (stale2) return { ok: false, command, message: stale2 };
|
|
1784
|
-
const label = `${_nullishCoalesce(_optionalChain([this, 'access',
|
|
1814
|
+
const label = `${_nullishCoalesce(_optionalChain([this, 'access', _101 => _101.presence, 'access', _102 => _102.getState, 'call', _103 => _103(), 'access', _104 => _104.actors, 'access', _105 => _105.find, 'call', _106 => _106((a) => a.id === id), 'optionalAccess', _107 => _107.name]), () => ( "Agent"))}: edit value`;
|
|
1785
1815
|
await this.move(id, where(), step.to, step.ms, (e) => {
|
|
1786
1816
|
const v = step.from + (step.value - step.from) * e;
|
|
1787
1817
|
this.controller.setValue(command.seriesId, command.index, Number(v.toPrecision(12)), { label });
|
|
@@ -1804,6 +1834,327 @@ var ChartDirector = (_class3 = class {
|
|
|
1804
1834
|
}
|
|
1805
1835
|
}, _class3);
|
|
1806
1836
|
|
|
1837
|
+
// src/chart/office-files.ts
|
|
1838
|
+
var OfficeChartsError = class extends Error {
|
|
1839
|
+
constructor(message, options) {
|
|
1840
|
+
super(message, options);
|
|
1841
|
+
this.name = "OfficeChartsError";
|
|
1842
|
+
}
|
|
1843
|
+
};
|
|
1844
|
+
var CHARTEX_NS = "http://schemas.microsoft.com/office/drawing/2014/chartex";
|
|
1845
|
+
var STRICT_CHART_NS = "http://purl.oclc.org/ooxml/drawingml/chart";
|
|
1846
|
+
var dirname = (path) => path.slice(0, path.lastIndexOf("/") + 1);
|
|
1847
|
+
function resolvePartPath(baseDir, target) {
|
|
1848
|
+
const out = [];
|
|
1849
|
+
for (const segment of (target.startsWith("/") ? target.slice(1) : baseDir + target).split("/")) {
|
|
1850
|
+
if (segment === "" || segment === ".") continue;
|
|
1851
|
+
if (segment === "..") out.pop();
|
|
1852
|
+
else out.push(segment);
|
|
1853
|
+
}
|
|
1854
|
+
return out.join("/");
|
|
1855
|
+
}
|
|
1856
|
+
var relsPathFor = (partPath) => `${dirname(partPath)}_rels/${partPath.slice(dirname(partPath).length)}.rels`;
|
|
1857
|
+
function elements(root, localName) {
|
|
1858
|
+
return Array.from(root.getElementsByTagNameNS("*", localName));
|
|
1859
|
+
}
|
|
1860
|
+
function relId(el, localName = "id") {
|
|
1861
|
+
for (const a of Array.from(el.attributes)) {
|
|
1862
|
+
if (a.localName === localName && (_optionalChain([a, 'access', _108 => _108.namespaceURI, 'optionalAccess', _109 => _109.includes, 'call', _110 => _110("relationships")]) || a.prefix === "r")) return a.value;
|
|
1863
|
+
}
|
|
1864
|
+
return void 0;
|
|
1865
|
+
}
|
|
1866
|
+
var firstChild = (el, localName) => el ? Array.from(_nullishCoalesce(el.children, () => ( el.childNodes))).find((n) => n.nodeType === 1 && n.localName === localName) : void 0;
|
|
1867
|
+
async function readXml(r, path) {
|
|
1868
|
+
const entry = _nullishCoalesce(r.zip.get(path), () => ( r.zip.entries.find((e) => e.name.toLowerCase() === path.toLowerCase())));
|
|
1869
|
+
if (!entry) return null;
|
|
1870
|
+
const doc = new r.Parser().parseFromString(await r.zip.readText(entry), "application/xml");
|
|
1871
|
+
return doc.getElementsByTagName("parsererror").length ? null : doc;
|
|
1872
|
+
}
|
|
1873
|
+
async function readRels(r, partPath) {
|
|
1874
|
+
const rels = /* @__PURE__ */ new Map();
|
|
1875
|
+
const doc = await readXml(r, relsPathFor(partPath));
|
|
1876
|
+
if (!doc) return rels;
|
|
1877
|
+
for (const rel of elements(doc, "Relationship")) {
|
|
1878
|
+
const id = rel.getAttribute("Id");
|
|
1879
|
+
if (!id) continue;
|
|
1880
|
+
const target = _nullishCoalesce(rel.getAttribute("Target"), () => ( ""));
|
|
1881
|
+
const external = _optionalChain([rel, 'access', _111 => _111.getAttribute, 'call', _112 => _112("TargetMode"), 'optionalAccess', _113 => _113.toLowerCase, 'call', _114 => _114()]) === "external";
|
|
1882
|
+
rels.set(id, { type: _nullishCoalesce(rel.getAttribute("Type"), () => ( "")), target: external ? target : resolvePartPath(dirname(partPath), target), external });
|
|
1883
|
+
}
|
|
1884
|
+
return rels;
|
|
1885
|
+
}
|
|
1886
|
+
var isChartRef = (el) => el.localName === "chart" && (el.namespaceURI === _chunkNN3JGUSXcjs.CHART_OOXML_NS || el.namespaceURI === STRICT_CHART_NS || el.namespaceURI === CHARTEX_NS);
|
|
1887
|
+
function frameName(ref) {
|
|
1888
|
+
for (let el = ref.parentElement; el; el = el.parentElement) {
|
|
1889
|
+
if (el.localName === "graphicFrame") {
|
|
1890
|
+
const nv = elements(el, "cNvPr")[0];
|
|
1891
|
+
return _optionalChain([nv, 'optionalAccess', _115 => _115.getAttribute, 'call', _116 => _116("name")]) || void 0;
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1894
|
+
return void 0;
|
|
1895
|
+
}
|
|
1896
|
+
async function chartsInPart(r, root, rels, place) {
|
|
1897
|
+
for (const ref of elements(root, "chart")) {
|
|
1898
|
+
if (r.charts.length >= r.max) return;
|
|
1899
|
+
if (!isChartRef(ref)) continue;
|
|
1900
|
+
const rel = rels.get(_nullishCoalesce(relId(ref), () => ( "")));
|
|
1901
|
+
if (!rel || rel.external || r.seen.has(rel.target)) continue;
|
|
1902
|
+
const entry = r.zip.get(rel.target);
|
|
1903
|
+
if (!entry) continue;
|
|
1904
|
+
r.seen.add(rel.target);
|
|
1905
|
+
const read = _chunkNN3JGUSXcjs.chartFromOoxml.call(void 0, await r.zip.readText(entry), { DOMParser: r.Parser });
|
|
1906
|
+
const name = frameName(ref);
|
|
1907
|
+
r.charts.push({
|
|
1908
|
+
id: `chart-${r.charts.length + 1}`,
|
|
1909
|
+
path: rel.target,
|
|
1910
|
+
partKind: ref.namespaceURI === CHARTEX_NS ? "chartex" : "chart",
|
|
1911
|
+
...place(ref),
|
|
1912
|
+
...name ? { name } : {},
|
|
1913
|
+
title: read.spec.title,
|
|
1914
|
+
spec: read.spec,
|
|
1915
|
+
issues: read.issues.map((i) => i.message),
|
|
1916
|
+
unsupported: read.unsupported,
|
|
1917
|
+
lossless: read.lossless
|
|
1918
|
+
});
|
|
1919
|
+
}
|
|
1920
|
+
}
|
|
1921
|
+
function columnName(index) {
|
|
1922
|
+
let name = "";
|
|
1923
|
+
for (let n = index + 1; n > 0; n = Math.floor((n - 1) / 26)) name = String.fromCharCode(65 + (n - 1) % 26) + name;
|
|
1924
|
+
return name;
|
|
1925
|
+
}
|
|
1926
|
+
function anchorCell(marker) {
|
|
1927
|
+
const col = Number(_optionalChain([firstChild, 'call', _117 => _117(marker, "col"), 'optionalAccess', _118 => _118.textContent]));
|
|
1928
|
+
const row = Number(_optionalChain([firstChild, 'call', _119 => _119(marker, "row"), 'optionalAccess', _120 => _120.textContent]));
|
|
1929
|
+
return Number.isInteger(col) && Number.isInteger(row) && col >= 0 && row >= 0 ? `${columnName(col)}${row + 1}` : void 0;
|
|
1930
|
+
}
|
|
1931
|
+
function drawingPlace(ref) {
|
|
1932
|
+
for (let el = ref.parentElement; el; el = el.parentElement) {
|
|
1933
|
+
if (el.localName === "twoCellAnchor" || el.localName === "oneCellAnchor") {
|
|
1934
|
+
const anchor = anchorCell(firstChild(el, "from"));
|
|
1935
|
+
const to = el.localName === "twoCellAnchor" ? anchorCell(firstChild(el, "to")) : void 0;
|
|
1936
|
+
return { ...anchor ? { anchor } : {}, ...anchor && to ? { range: `${anchor}:${to}` } : {} };
|
|
1937
|
+
}
|
|
1938
|
+
if (el.localName === "absoluteAnchor") return {};
|
|
1939
|
+
}
|
|
1940
|
+
return {};
|
|
1941
|
+
}
|
|
1942
|
+
async function readMainPart(r) {
|
|
1943
|
+
const rootRels = await readRels(r, "");
|
|
1944
|
+
const main = [...rootRels.values()].find((rel) => /\/officeDocument$/.test(rel.type) && !rel.external);
|
|
1945
|
+
const doc = main ? await readXml(r, main.target) : null;
|
|
1946
|
+
if (!main || !doc) throw new OfficeChartsError("This is not an Office file: _rels/.rels names no main part (expected an .xlsx, .pptx or .docx file).");
|
|
1947
|
+
return { path: main.target, doc };
|
|
1948
|
+
}
|
|
1949
|
+
async function readXlsx(r, main) {
|
|
1950
|
+
const rels = await readRels(r, main.path);
|
|
1951
|
+
for (const sheet of elements(main.doc, "sheet")) {
|
|
1952
|
+
const rel = rels.get(_nullishCoalesce(relId(sheet), () => ( "")));
|
|
1953
|
+
if (!rel || rel.external) continue;
|
|
1954
|
+
const doc = await readXml(r, rel.target);
|
|
1955
|
+
if (!doc) continue;
|
|
1956
|
+
const sheetName = _nullishCoalesce(sheet.getAttribute("name"), () => ( rel.target));
|
|
1957
|
+
const sheetRels = await readRels(r, rel.target);
|
|
1958
|
+
for (const drawingRef of elements(doc, "drawing")) {
|
|
1959
|
+
const drawingRel = sheetRels.get(_nullishCoalesce(relId(drawingRef), () => ( "")));
|
|
1960
|
+
if (!drawingRel || drawingRel.external) continue;
|
|
1961
|
+
const drawing = await readXml(r, drawingRel.target);
|
|
1962
|
+
if (!drawing) continue;
|
|
1963
|
+
const drawingRels = await readRels(r, drawingRel.target);
|
|
1964
|
+
await chartsInPart(r, drawing, drawingRels, (ref) => ({ sheet: sheetName, ...drawingPlace(ref) }));
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1968
|
+
async function readPptx(r, main) {
|
|
1969
|
+
const rels = await readRels(r, main.path);
|
|
1970
|
+
const slides = elements(main.doc, "sldId");
|
|
1971
|
+
for (let i = 0; i < slides.length; i++) {
|
|
1972
|
+
const rel = rels.get(_nullishCoalesce(relId(slides[i]), () => ( "")));
|
|
1973
|
+
if (!rel || rel.external) continue;
|
|
1974
|
+
const doc = await readXml(r, rel.target);
|
|
1975
|
+
if (!doc) continue;
|
|
1976
|
+
await chartsInPart(r, doc, await readRels(r, rel.target), () => ({ slide: i + 1 }));
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1979
|
+
async function readDocx(r, main) {
|
|
1980
|
+
await chartsInPart(r, main.doc, await readRels(r, main.path), () => ({}));
|
|
1981
|
+
}
|
|
1982
|
+
async function open(bytes, options) {
|
|
1983
|
+
const Parser = _nullishCoalesce(options.DOMParser, () => ( globalThis.DOMParser));
|
|
1984
|
+
if (!Parser) throw new OfficeChartsError("Reading Office files needs a DOMParser. In Node, pass one (e.g. from jsdom or @xmldom/xmldom) as { DOMParser }.");
|
|
1985
|
+
let zip;
|
|
1986
|
+
try {
|
|
1987
|
+
zip = await _chunkNN3JGUSXcjs.readZip.call(void 0, bytes, options);
|
|
1988
|
+
} catch (error) {
|
|
1989
|
+
throw new OfficeChartsError(`This is not an Office file: ${error.message}`, { cause: error });
|
|
1990
|
+
}
|
|
1991
|
+
const r = { zip, Parser, max: _nullishCoalesce(options.maxCharts, () => ( 500)), charts: [], seen: /* @__PURE__ */ new Set() };
|
|
1992
|
+
const main = await readMainPart(r);
|
|
1993
|
+
const root = main.doc.documentElement.localName;
|
|
1994
|
+
const format = root === "workbook" ? "xlsx" : root === "presentation" ? "pptx" : root === "document" ? "docx" : void 0;
|
|
1995
|
+
if (!format) throw new OfficeChartsError(`The main part ${main.path} is a <${root}>; expected an Excel workbook, PowerPoint presentation or Word document.`);
|
|
1996
|
+
return { r, main, format };
|
|
1997
|
+
}
|
|
1998
|
+
var READERS = { xlsx: readXlsx, pptx: readPptx, docx: readDocx };
|
|
1999
|
+
async function extractOfficeCharts(bytes, options = {}) {
|
|
2000
|
+
const { r, main, format } = await open(bytes, options);
|
|
2001
|
+
await READERS[format](r, main);
|
|
2002
|
+
return { format, charts: r.charts };
|
|
2003
|
+
}
|
|
2004
|
+
async function extractAs(format, bytes, options) {
|
|
2005
|
+
const result = await extractOfficeCharts(bytes, options);
|
|
2006
|
+
if (result.format !== format) throw new OfficeChartsError(`This is a .${result.format} file, not a .${format} file.`);
|
|
2007
|
+
return result.charts;
|
|
2008
|
+
}
|
|
2009
|
+
var extractXlsxCharts = (bytes, options = {}) => extractAs("xlsx", bytes, options);
|
|
2010
|
+
var extractPptxCharts = (bytes, options = {}) => extractAs("pptx", bytes, options);
|
|
2011
|
+
var extractDocxCharts = (bytes, options = {}) => extractAs("docx", bytes, options);
|
|
2012
|
+
function describeOfficeChartPlace(chart) {
|
|
2013
|
+
if (chart.sheet !== void 0) return chart.anchor ? `${chart.sheet}!${chart.anchor}` : chart.sheet;
|
|
2014
|
+
if (chart.slide !== void 0) return `Slide ${chart.slide}`;
|
|
2015
|
+
return "Document";
|
|
2016
|
+
}
|
|
2017
|
+
|
|
2018
|
+
// src/chart/file-tools.ts
|
|
2019
|
+
var READ2 = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
|
|
2020
|
+
var DESTRUCTIVE2 = { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false };
|
|
2021
|
+
var fail3 = (message) => {
|
|
2022
|
+
throw new Error(message);
|
|
2023
|
+
};
|
|
2024
|
+
function fromBase64(data) {
|
|
2025
|
+
const clean = data.replace(/^data:[^,]*,/, "").replace(/\s+/g, "");
|
|
2026
|
+
let binary;
|
|
2027
|
+
try {
|
|
2028
|
+
binary = atob(clean);
|
|
2029
|
+
} catch (e6) {
|
|
2030
|
+
return fail3('"data" is not valid base64. Pass the whole .xlsx, .pptx or .docx file encoded as base64 (a data: URL prefix is fine).');
|
|
2031
|
+
}
|
|
2032
|
+
const out = new Uint8Array(binary.length);
|
|
2033
|
+
for (let i = 0; i < binary.length; i++) out[i] = binary.charCodeAt(i);
|
|
2034
|
+
return out;
|
|
2035
|
+
}
|
|
2036
|
+
function chartSummary(chart) {
|
|
2037
|
+
return {
|
|
2038
|
+
id: chart.id,
|
|
2039
|
+
place: describeOfficeChartPlace(chart),
|
|
2040
|
+
...chart.sheet !== void 0 ? { sheet: chart.sheet } : {},
|
|
2041
|
+
...chart.slide !== void 0 ? { slide: chart.slide } : {},
|
|
2042
|
+
...chart.anchor ? { anchor: chart.anchor } : {},
|
|
2043
|
+
...chart.range ? { range: chart.range } : {},
|
|
2044
|
+
...chart.name ? { name: chart.name } : {},
|
|
2045
|
+
path: chart.path,
|
|
2046
|
+
partKind: chart.partKind,
|
|
2047
|
+
title: chart.title,
|
|
2048
|
+
type: chart.spec.type,
|
|
2049
|
+
series: chart.spec.series.map((s) => s.name),
|
|
2050
|
+
categories: chart.spec.categories.length,
|
|
2051
|
+
issues: chart.issues,
|
|
2052
|
+
unsupported: chart.unsupported,
|
|
2053
|
+
lossless: chart.lossless
|
|
2054
|
+
};
|
|
2055
|
+
}
|
|
2056
|
+
function createOfficeChartToolProvider(options = {}) {
|
|
2057
|
+
const cache = /* @__PURE__ */ new WeakMap();
|
|
2058
|
+
const readOnlyReason = () => {
|
|
2059
|
+
const r = typeof options.readOnly === "function" ? options.readOnly() : options.readOnly;
|
|
2060
|
+
if (!r) return null;
|
|
2061
|
+
return typeof r === "string" ? r : "This chart is read-only.";
|
|
2062
|
+
};
|
|
2063
|
+
const source = options.files ? { file: { type: "string", description: "Name of an open file, as list_open_files returns it." } } : { data: { type: "string", description: "The whole .xlsx, .pptx or .docx file as base64 (a data: URL prefix is allowed)." } };
|
|
2064
|
+
const sourceKey = options.files ? "file" : "data";
|
|
2065
|
+
const read = (args) => {
|
|
2066
|
+
if (!options.files) return extractOfficeCharts(fromBase64(String(args.data)), { DOMParser: options.DOMParser });
|
|
2067
|
+
const files = options.files();
|
|
2068
|
+
const file = files.find((f) => f.name === args.file);
|
|
2069
|
+
if (!file) return fail3(`There is no open file "${String(args.file)}"; expected one of ${files.map((f) => JSON.stringify(f.name)).join(", ") || "(none; ask the user to open an .xlsx, .pptx or .docx file)"}.`);
|
|
2070
|
+
let result = cache.get(file);
|
|
2071
|
+
if (!result) {
|
|
2072
|
+
result = extractOfficeCharts(file.data, { DOMParser: options.DOMParser });
|
|
2073
|
+
cache.set(file, result);
|
|
2074
|
+
result.catch(() => cache.delete(file));
|
|
2075
|
+
}
|
|
2076
|
+
return result;
|
|
2077
|
+
};
|
|
2078
|
+
const chartById = async (args) => {
|
|
2079
|
+
const { charts } = await read(args);
|
|
2080
|
+
const chart = charts.find((c) => c.id === args.chartId);
|
|
2081
|
+
if (!chart) fail3(`There is no chart "${String(args.chartId)}" in this file; expected one of ${charts.map((c) => `"${c.id}" (${describeOfficeChartPlace(c)})`).join(", ") || "(none: the file has no charts)"}.`);
|
|
2082
|
+
return chart;
|
|
2083
|
+
};
|
|
2084
|
+
const CHART_ID = { type: "string", description: 'Chart id from list_file_charts, e.g. "chart-1".' };
|
|
2085
|
+
const listOpenFiles = {
|
|
2086
|
+
name: "list_open_files",
|
|
2087
|
+
title: "List open files",
|
|
2088
|
+
description: "Lists the Office files the user opened that charts can be read from. Returns their names and sizes in bytes.",
|
|
2089
|
+
inputSchema: { type: "object", properties: {}, additionalProperties: false },
|
|
2090
|
+
annotations: { title: "List open files", ...READ2 },
|
|
2091
|
+
handler: () => ({ files: (_nullishCoalesce(_optionalChain([options, 'access', _121 => _121.files, 'optionalCall', _122 => _122()]), () => ( []))).map((f) => ({ name: f.name, bytes: f.data.byteLength })) })
|
|
2092
|
+
};
|
|
2093
|
+
const listCharts = {
|
|
2094
|
+
name: "list_file_charts",
|
|
2095
|
+
title: "List the charts in an Office file",
|
|
2096
|
+
description: "Reads an Excel workbook, PowerPoint deck or Word document and lists its charts in file order: id, where it sits (sheet name and anchor cell, or slide number), title, type, series names, number of categories, read problems, features the chart editor cannot hold, and whether it reads losslessly. Pass an id to get_file_chart or load_file_chart.",
|
|
2097
|
+
inputSchema: { type: "object", properties: { ...source }, required: [sourceKey], additionalProperties: false },
|
|
2098
|
+
annotations: { title: "List the charts in an Office file", ...READ2 },
|
|
2099
|
+
handler: async (args) => {
|
|
2100
|
+
const result = await read(args);
|
|
2101
|
+
return { format: result.format, charts: result.charts.map(chartSummary) };
|
|
2102
|
+
}
|
|
2103
|
+
};
|
|
2104
|
+
const getChart = {
|
|
2105
|
+
name: "get_file_chart",
|
|
2106
|
+
title: "Get a chart from an Office file",
|
|
2107
|
+
description: "Returns one chart of an Office file with its full chart spec (data, axes, series styles), where it sits and its read problems.",
|
|
2108
|
+
inputSchema: { type: "object", properties: { ...source, chartId: CHART_ID }, required: [sourceKey, "chartId"], additionalProperties: false },
|
|
2109
|
+
annotations: { title: "Get a chart from an Office file", ...READ2 },
|
|
2110
|
+
handler: async (args) => {
|
|
2111
|
+
const chart = await chartById(args);
|
|
2112
|
+
return { ...chartSummary(chart), spec: chart.spec };
|
|
2113
|
+
}
|
|
2114
|
+
};
|
|
2115
|
+
const loadChart = {
|
|
2116
|
+
name: "load_file_chart",
|
|
2117
|
+
title: "Load a chart from an Office file",
|
|
2118
|
+
description: "Replaces the chart in the editor with a chart from an Office file, as one undo step. Returns the new spec, read problems and features the editor could not keep.",
|
|
2119
|
+
inputSchema: { type: "object", properties: { ...source, chartId: CHART_ID }, required: [sourceKey, "chartId"], additionalProperties: false },
|
|
2120
|
+
annotations: { title: "Load a chart from an Office file", ...DESTRUCTIVE2 },
|
|
2121
|
+
handler: async (args) => {
|
|
2122
|
+
const reason = readOnlyReason();
|
|
2123
|
+
if (reason) fail3(reason);
|
|
2124
|
+
const chart = await chartById(args);
|
|
2125
|
+
const result = options.controller.update({ ...chart.spec }, { label: "Load chart from file" });
|
|
2126
|
+
if (!result.ok) fail3(_nullishCoalesce(result.message, () => ( "The chart could not be loaded.")));
|
|
2127
|
+
return { id: chart.id, place: describeOfficeChartPlace(chart), spec: options.controller.toJSON(), issues: chart.issues, unsupported: chart.unsupported, lossless: chart.lossless };
|
|
2128
|
+
}
|
|
2129
|
+
};
|
|
2130
|
+
return {
|
|
2131
|
+
id: _nullishCoalesce(options.id, () => ( "office-charts")),
|
|
2132
|
+
...options.namespace ? { namespace: options.namespace } : {},
|
|
2133
|
+
tools: () => [...options.files ? [listOpenFiles] : [], listCharts, getChart, ...options.controller && !readOnlyReason() ? [loadChart] : []]
|
|
2134
|
+
};
|
|
2135
|
+
}
|
|
2136
|
+
|
|
2137
|
+
|
|
2138
|
+
|
|
2139
|
+
|
|
2140
|
+
|
|
2141
|
+
|
|
2142
|
+
|
|
2143
|
+
|
|
2144
|
+
|
|
2145
|
+
|
|
2146
|
+
|
|
2147
|
+
|
|
2148
|
+
|
|
2149
|
+
|
|
2150
|
+
|
|
2151
|
+
|
|
2152
|
+
|
|
2153
|
+
|
|
2154
|
+
|
|
2155
|
+
|
|
2156
|
+
|
|
2157
|
+
|
|
1807
2158
|
|
|
1808
2159
|
|
|
1809
2160
|
|
|
@@ -1944,5 +2295,5 @@ var ChartDirector = (_class3 = class {
|
|
|
1944
2295
|
|
|
1945
2296
|
|
|
1946
2297
|
|
|
1947
|
-
exports.CHART_AXIS_KINDS =
|
|
2298
|
+
exports.CHART_AXIS_KINDS = _chunkCKRNELPOcjs.CHART_AXIS_KINDS; exports.CHART_AXIS_SCALES = _chunkCKRNELPOcjs.CHART_AXIS_SCALES; exports.CHART_COLOR_SCHEMES = _chunkNK3WL5TJcjs.CHART_COLOR_SCHEMES; exports.CHART_CURVES = _chunkCKRNELPOcjs.CHART_CURVES; exports.CHART_DATE_STEPS = _chunkNK3WL5TJcjs.CHART_DATE_STEPS; exports.CHART_ERROR_BAR_DIRECTIONS = _chunkCKRNELPOcjs.CHART_ERROR_BAR_DIRECTIONS; exports.CHART_ERROR_BAR_LABELS = _chunkCKRNELPOcjs.CHART_ERROR_BAR_LABELS; exports.CHART_ERROR_BAR_TYPES = _chunkCKRNELPOcjs.CHART_ERROR_BAR_TYPES; exports.CHART_LABEL_POSITIONS = _chunkCKRNELPOcjs.CHART_LABEL_POSITIONS; exports.CHART_LAYOUT_PRESETS = _chunkNK3WL5TJcjs.CHART_LAYOUT_PRESETS; exports.CHART_LEGEND_POSITIONS = _chunkCKRNELPOcjs.CHART_LEGEND_POSITIONS; exports.CHART_MARKERS = _chunkCKRNELPOcjs.CHART_MARKERS; exports.CHART_MERMAID_META_PREFIX = _chunkNK3WL5TJcjs.CHART_MERMAID_META_PREFIX; exports.CHART_NUMBER_STYLES = _chunkCKRNELPOcjs.CHART_NUMBER_STYLES; exports.CHART_OOXML_CONTENT_TYPE = _chunkNN3JGUSXcjs.CHART_OOXML_CONTENT_TYPE; exports.CHART_OOXML_NS = _chunkNN3JGUSXcjs.CHART_OOXML_NS; exports.CHART_OOXML_RELATIONSHIP = _chunkNN3JGUSXcjs.CHART_OOXML_RELATIONSHIP; exports.CHART_ORIENTATIONS = _chunkCKRNELPOcjs.CHART_ORIENTATIONS; exports.CHART_PALETTE_SHADES = _chunkCKRNELPOcjs.CHART_PALETTE_SHADES; exports.CHART_PRESENCE_COLORS = CHART_PRESENCE_COLORS; exports.CHART_RASTER_MAX_SIZE = CHART_RASTER_MAX_SIZE; exports.CHART_SERIES_TYPES = _chunkCKRNELPOcjs.CHART_SERIES_TYPES; exports.CHART_STACKINGS = _chunkCKRNELPOcjs.CHART_STACKINGS; exports.CHART_TRENDLINE_TYPES = _chunkCKRNELPOcjs.CHART_TRENDLINE_TYPES; exports.CHART_TYPES = _chunkCKRNELPOcjs.CHART_TYPES; exports.CHART_TYPE_LABELS = _chunkCKRNELPOcjs.CHART_TYPE_LABELS; exports.CSS_VARIABLE_CHART_THEME = _chunkCKRNELPOcjs.CSS_VARIABLE_CHART_THEME; exports.ChartController = _chunkNK3WL5TJcjs.ChartController; exports.ChartDirector = ChartDirector; exports.ChartPresence = ChartPresence; exports.ChartStream = ChartStream; exports.DEFAULT_CHART_PALETTE = _chunkCKRNELPOcjs.DEFAULT_CHART_PALETTE; exports.DEFAULT_CHART_THEME = _chunkCKRNELPOcjs.DEFAULT_CHART_THEME; exports.MAX_CHART_DATA_LABELS = _chunkNK3WL5TJcjs.MAX_CHART_DATA_LABELS; exports.MAX_CHART_LINE_POINTS = _chunkNK3WL5TJcjs.MAX_CHART_LINE_POINTS; exports.MAX_CHART_MARKERS = _chunkNK3WL5TJcjs.MAX_CHART_MARKERS; exports.OfficeChartsError = OfficeChartsError; exports.RENDER_CHART_INSTRUCTIONS = RENDER_CHART_INSTRUCTIONS; exports.analyzeChartTable = analyzeChartTable; exports.blendChartScenes = blendChartScenes; exports.canDragChartPoint = canDragChartPoint; exports.chartBoxStats = _chunkNK3WL5TJcjs.chartBoxStats; exports.chartClientToScene = chartClientToScene; exports.chartColorDistance = _chunkCKRNELPOcjs.chartColorDistance; exports.chartColorInputValue = _chunkCKRNELPOcjs.chartColorInputValue; exports.chartColorsByCategory = _chunkCKRNELPOcjs.chartColorsByCategory; exports.chartContrastRatio = _chunkCKRNELPOcjs.chartContrastRatio; exports.chartDataFromTable = _chunkCKRNELPOcjs.chartDataFromTable; exports.chartDataToTable = _chunkCKRNELPOcjs.chartDataToTable; exports.chartDateLabels = _chunkNK3WL5TJcjs.chartDateLabels; exports.chartDateToSerial = _chunkNK3WL5TJcjs.chartDateToSerial; exports.chartErrorAmounts = _chunkCKRNELPOcjs.chartErrorAmounts; exports.chartErrorBarsOfType = _chunkCKRNELPOcjs.chartErrorBarsOfType; exports.chartFamily = _chunkCKRNELPOcjs.chartFamily; exports.chartFileName = chartFileName; exports.chartFormatToCode = _chunkNN3JGUSXcjs.chartFormatToCode; exports.chartFromMermaid = _chunkNK3WL5TJcjs.chartFromMermaid; exports.chartFromOoxml = _chunkNN3JGUSXcjs.chartFromOoxml; exports.chartFromTable = chartFromTable; exports.chartHistogram = _chunkNK3WL5TJcjs.chartHistogram; exports.chartHitTest = chartHitTest; exports.chartLuminance = _chunkCKRNELPOcjs.chartLuminance; exports.chartMermaidFamily = _chunkNK3WL5TJcjs.chartMermaidFamily; exports.chartMovingAverage = _chunkNK3WL5TJcjs.chartMovingAverage; exports.chartPointAnchor = chartPointAnchor; exports.chartPointColor = _chunkCKRNELPOcjs.chartPointColor; exports.chartPresetPatch = _chunkNK3WL5TJcjs.chartPresetPatch; exports.chartQuantile = _chunkNK3WL5TJcjs.chartQuantile; exports.chartRasterSize = chartRasterSize; exports.chartRgbToHex = _chunkCKRNELPOcjs.chartRgbToHex; exports.chartRgbToOklab = _chunkCKRNELPOcjs.chartRgbToOklab; exports.chartScaleFromPixel = _chunkNK3WL5TJcjs.chartScaleFromPixel; exports.chartScaleToPixel = _chunkNK3WL5TJcjs.chartScaleToPixel; exports.chartSceneToDomSpec = _chunkNK3WL5TJcjs.chartSceneToDomSpec; exports.chartSceneToSvg = _chunkNK3WL5TJcjs.chartSceneToSvg; exports.chartSerialToDate = _chunkNK3WL5TJcjs.chartSerialToDate; exports.chartSeriesColor = _chunkCKRNELPOcjs.chartSeriesColor; exports.chartSeriesType = _chunkCKRNELPOcjs.chartSeriesType; exports.chartSliceColor = _chunkCKRNELPOcjs.chartSliceColor; exports.chartSquarify = _chunkNK3WL5TJcjs.chartSquarify; exports.chartSupportsTrendlines = _chunkNK3WL5TJcjs.chartSupportsTrendlines; exports.chartTextBaseline = _chunkNK3WL5TJcjs.chartTextBaseline; exports.chartTextOn = _chunkCKRNELPOcjs.chartTextOn; exports.chartTextTransform = _chunkNK3WL5TJcjs.chartTextTransform; exports.chartToMermaid = _chunkNK3WL5TJcjs.chartToMermaid; exports.chartToOoxml = _chunkNN3JGUSXcjs.chartToOoxml; exports.chartToSvg = _chunkNK3WL5TJcjs.chartToSvg; exports.chartTrendlineName = _chunkNK3WL5TJcjs.chartTrendlineName; exports.chartValueAtPoint = _chunkNK3WL5TJcjs.chartValueAtPoint; exports.chartXAtPoint = _chunkNK3WL5TJcjs.chartXAtPoint; exports.checkChartColors = _chunkCKRNELPOcjs.checkChartColors; exports.cloneChartSeries = _chunkCKRNELPOcjs.cloneChartSeries; exports.cloneChartSpec = _chunkCKRNELPOcjs.cloneChartSpec; exports.compileChartFormatCode = _chunkNK3WL5TJcjs.compileChartFormatCode; exports.contrastingTextColor = _chunkNK3WL5TJcjs.contrastingTextColor; exports.createChartCommands = createChartCommands; exports.createChartController = _chunkNK3WL5TJcjs.createChartController; exports.createChartRasterizer = createChartRasterizer; exports.createChartSpec = _chunkCKRNELPOcjs.createChartSpec; exports.createChartToolProvider = createChartToolProvider; exports.createInstantChartClock = createInstantChartClock; exports.createOfficeChartToolProvider = createOfficeChartToolProvider; exports.cyclePaletteColor = _chunkCKRNELPOcjs.cyclePaletteColor; exports.decimateChartPoints = _chunkNK3WL5TJcjs.decimateChartPoints; exports.defaultChartAxis = _chunkCKRNELPOcjs.defaultChartAxis; exports.defaultChartErrorBarValue = _chunkCKRNELPOcjs.defaultChartErrorBarValue; exports.describeChart = _chunkNK3WL5TJcjs.describeChart; exports.describeChartErrorBars = _chunkCKRNELPOcjs.describeChartErrorBars; exports.describeChartSelection = describeChartSelection; exports.describeOfficeChartPlace = describeOfficeChartPlace; exports.downloadChartPng = downloadChartPng; exports.easeChartTween = easeChartTween; exports.estimateChartTextWidth = _chunkNK3WL5TJcjs.estimateChartTextWidth; exports.extractDocxCharts = extractDocxCharts; exports.extractOfficeCharts = extractOfficeCharts; exports.extractPptxCharts = extractPptxCharts; exports.extractXlsxCharts = extractXlsxCharts; exports.findMermaidCharts = _chunkNK3WL5TJcjs.findMermaidCharts; exports.fitChartTrendline = _chunkNK3WL5TJcjs.fitChartTrendline; exports.formatChartAmountList = _chunkCKRNELPOcjs.formatChartAmountList; exports.formatChartDate = _chunkNK3WL5TJcjs.formatChartDate; exports.formatChartNumber = _chunkNK3WL5TJcjs.formatChartNumber; exports.formatChartValueWithCode = _chunkNK3WL5TJcjs.formatChartValueWithCode; exports.handleChartKey = handleChartKey; exports.isCartesianChart = _chunkCKRNELPOcjs.isCartesianChart; exports.isXyChart = _chunkCKRNELPOcjs.isXyChart; exports.layoutChart = _chunkNK3WL5TJcjs.layoutChart; exports.layoutSparkline = _chunkNK3WL5TJcjs.layoutSparkline; exports.linearMap = _chunkNK3WL5TJcjs.linearMap; exports.monochromeChartPalette = _chunkNK3WL5TJcjs.monochromeChartPalette; exports.niceLogScale = _chunkNK3WL5TJcjs.niceLogScale; exports.niceScale = _chunkNK3WL5TJcjs.niceScale; exports.niceStep = _chunkNK3WL5TJcjs.niceStep; exports.normalizeChartAxis = _chunkCKRNELPOcjs.normalizeChartAxis; exports.normalizeChartErrorBars = _chunkCKRNELPOcjs.normalizeChartErrorBars; exports.normalizeChartSpec = _chunkCKRNELPOcjs.normalizeChartSpec; exports.normalizeChartTrendline = _chunkCKRNELPOcjs.normalizeChartTrendline; exports.normalizeChartValues = _chunkCKRNELPOcjs.normalizeChartValues; exports.parseChartAmountList = _chunkCKRNELPOcjs.parseChartAmountList; exports.parseChartColor = _chunkCKRNELPOcjs.parseChartColor; exports.parseChartDate = _chunkNK3WL5TJcjs.parseChartDate; exports.parseChartValue = _chunkCKRNELPOcjs.parseChartValue; exports.parsePartialChartJson = parsePartialChartJson; exports.planChartCommand = planChartCommand; exports.rasterizeChartSvg = rasterizeChartSvg; exports.realChartClock = realChartClock; exports.recommendChartTypes = recommendChartTypes; exports.recommendForShape = recommendForShape; exports.resolveChartSvgPaints = resolveChartSvgPaints; exports.sameChartSelection = _chunkNK3WL5TJcjs.sameChartSelection; exports.shadeChartColor = _chunkCKRNELPOcjs.shadeChartColor; exports.simulateChartVision = _chunkCKRNELPOcjs.simulateChartVision; exports.snapChartDragValue = snapChartDragValue; exports.snapChartValue = _chunkNK3WL5TJcjs.snapChartValue; exports.sparklineToSvg = _chunkNK3WL5TJcjs.sparklineToSvg; exports.startChartPointDrag = startChartPointDrag; exports.stepDecimals = _chunkNK3WL5TJcjs.stepDecimals; exports.summarizeChart = _chunkNK3WL5TJcjs.summarizeChart; exports.summarizeChartSeries = _chunkNK3WL5TJcjs.summarizeChartSeries; exports.trendNumberText = _chunkNK3WL5TJcjs.trendNumberText; exports.uniqueChartSeriesId = _chunkCKRNELPOcjs.uniqueChartSeriesId;
|
|
1948
2299
|
//# sourceMappingURL=index.cjs.map
|