@pixerate/editor 0.166.0 → 0.167.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/THIRD_PARTY_NOTICES.md +11 -0
- package/dist/agent/index.cjs +34 -34
- package/dist/agent/index.js +5 -5
- package/dist/canvas/index.cjs +6 -6
- package/dist/canvas/index.js +2 -2
- package/dist/chart/index.cjs +236 -185
- package/dist/chart/index.d.cts +1 -0
- package/dist/chart/index.d.ts +1 -0
- package/dist/chart/index.js +57 -6
- package/dist/chart/layout-families.d.cts +8 -0
- package/dist/chart/layout-families.d.ts +8 -0
- package/dist/chart/maps.d.cts +43 -0
- package/dist/chart/maps.d.ts +43 -0
- package/dist/chart/spec.d.cts +1 -1
- package/dist/chart/spec.d.ts +1 -1
- package/dist/chart/types.d.cts +10 -2
- package/dist/chart/types.d.ts +10 -2
- package/dist/chart-maps/europe.d.cts +7 -0
- package/dist/chart-maps/europe.d.ts +7 -0
- package/dist/chart-maps/index.cjs +66 -0
- package/dist/chart-maps/index.d.cts +1 -0
- package/dist/chart-maps/index.d.ts +1 -0
- package/dist/chart-maps/index.js +66 -0
- package/dist/{chunk-V5L2G22R.cjs → chunk-2F4GAZL5.cjs} +109 -95
- package/dist/{chunk-5UNQDC3Q.js → chunk-34UCPHYO.js} +5 -2
- package/dist/{chunk-HXOBOHH2.cjs → chunk-E45AIIWY.cjs} +8 -8
- package/dist/{chunk-NQQDGGXY.js → chunk-FKYGM35R.js} +2 -2
- package/dist/{chunk-6FYIFGBW.cjs → chunk-GD34ICEX.cjs} +16 -16
- package/dist/{chunk-MZFZSVUJ.cjs → chunk-GTF4RYXJ.cjs} +25 -22
- package/dist/{chunk-ITANXMZD.js → chunk-M52UCHVZ.js} +127 -3
- package/dist/{chunk-YUFTVNLX.js → chunk-N3ACT6VJ.js} +16 -2
- package/dist/{chunk-XNU45TYA.js → chunk-OLCHKGGO.js} +4 -1
- package/dist/{chunk-FR432ROA.js → chunk-ORZF4JOO.js} +23 -4
- package/dist/{chunk-BPX4Z3N3.cjs → chunk-OUO3DSRT.cjs} +23 -4
- package/dist/{chunk-CHLV7UFP.cjs → chunk-SBAPXFPB.cjs} +51 -51
- package/dist/{chunk-VB2CY6EG.js → chunk-T62BRXMS.js} +3 -3
- package/dist/{chunk-SZWVMB3B.cjs → chunk-VKHJJUBK.cjs} +21 -18
- package/dist/{chunk-UUUTEVX6.cjs → chunk-WOIXNDHV.cjs} +172 -48
- package/dist/{chunk-DFCAR7AW.js → chunk-ZUPP4NKM.js} +3 -3
- package/dist/export/index.cjs +4 -4
- package/dist/export/index.js +3 -3
- package/dist/extensions/index.cjs +7 -7
- package/dist/extensions/index.js +6 -6
- package/dist/index.cjs +13 -13
- package/dist/index.js +7 -7
- package/package.json +11 -1
- package/skills/pixerate-chart/SKILL.md +18 -2
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkOUO3DSRTcjs = require('./chunk-OUO3DSRT.cjs');
|
|
12
12
|
|
|
13
13
|
// src/chart/ooxml.ts
|
|
14
14
|
var CHART_OOXML_NS = "http://schemas.openxmlformats.org/drawingml/2006/chart";
|
|
@@ -111,11 +111,11 @@ function chartFromOoxml(xml, options = {}) {
|
|
|
111
111
|
try {
|
|
112
112
|
doc = new (parser(options))().parseFromString(xml, "application/xml");
|
|
113
113
|
} catch (error) {
|
|
114
|
-
return { spec:
|
|
114
|
+
return { spec: _chunkOUO3DSRTcjs.normalizeChartSpec.call(void 0, {}).spec, issues: [{ path: "", message: `The chart XML could not be read: ${error.message}` }], unsupported, lossless: false };
|
|
115
115
|
}
|
|
116
116
|
const root = doc.documentElement;
|
|
117
117
|
if (!root || root.localName !== "chartSpace" || doc.getElementsByTagName("parsererror").length) {
|
|
118
|
-
return { spec:
|
|
118
|
+
return { spec: _chunkOUO3DSRTcjs.normalizeChartSpec.call(void 0, {}).spec, issues: [{ path: "", message: "This is not a chart part: expected a c:chartSpace (or cx:chartSpace) root element." }], unsupported, lossless: false };
|
|
119
119
|
}
|
|
120
120
|
if (_optionalChain([root, 'access', _14 => _14.namespaceURI, 'optionalAccess', _15 => _15.includes, 'call', _16 => _16("chartex")]) || kid(root, "chartData")) return readChartex(root, issues, unsupported);
|
|
121
121
|
const chart = kid(root, "chart");
|
|
@@ -280,7 +280,7 @@ function chartFromOoxml(xml, options = {}) {
|
|
|
280
280
|
}
|
|
281
281
|
if (!types.length) {
|
|
282
282
|
issues.push({ path: "plotArea", message: unsupported.length ? `The chart type is not supported: ${unsupported.join(", ")}.` : "The chart has no plot groups." });
|
|
283
|
-
return { spec:
|
|
283
|
+
return { spec: _chunkOUO3DSRTcjs.normalizeChartSpec.call(void 0, input).spec, issues, unsupported, lossless: false };
|
|
284
284
|
}
|
|
285
285
|
const first = types[0];
|
|
286
286
|
const combo = types.some((t) => t !== first);
|
|
@@ -290,14 +290,14 @@ function chartFromOoxml(xml, options = {}) {
|
|
|
290
290
|
if (!combo) {
|
|
291
291
|
for (const s of series) if (s.axis) issues.push({ path: "series", message: `"${s.name}" is on a second value axis.` });
|
|
292
292
|
}
|
|
293
|
-
if (types.some((t) => !
|
|
293
|
+
if (types.some((t) => !_chunkOUO3DSRTcjs.isCartesianChart.call(void 0, t)) && combo) unsupported.push("a pie or radar mixed with other chart types");
|
|
294
294
|
input.series = series;
|
|
295
295
|
input.categories = categories.length ? categories : Array.from({ length: Math.max(0, ...series.map((s) => s.values.length)) }, (_, i) => `${i + 1}`);
|
|
296
296
|
input.stacking = stacking;
|
|
297
297
|
input.orientation = orientation;
|
|
298
298
|
input.dataLabels = dataLabels;
|
|
299
299
|
input.points = points || first !== "line";
|
|
300
|
-
if (bool(val(groups[0], "varyColors")) && !combo &&
|
|
300
|
+
if (bool(val(groups[0], "varyColors")) && !combo && _chunkOUO3DSRTcjs.isCartesianChart.call(void 0, first) && series.length === 1) input.varyColors = true;
|
|
301
301
|
const readAxis = (a, fallback) => {
|
|
302
302
|
const axis = { ...fallback, format: {} };
|
|
303
303
|
if (!a) return axis;
|
|
@@ -324,12 +324,12 @@ function chartFromOoxml(xml, options = {}) {
|
|
|
324
324
|
};
|
|
325
325
|
const xy = first === "scatter" || first === "bubble";
|
|
326
326
|
const catAxis = _nullishCoalesce(_nullishCoalesce(kid(plot, "catAx"), () => ( kid(plot, "dateAx"))), () => ( (xy ? valAxes.find((a) => !vertical(a)) : void 0)));
|
|
327
|
-
input.xAxis = readAxis(catAxis,
|
|
327
|
+
input.xAxis = readAxis(catAxis, _chunkOUO3DSRTcjs.defaultChartAxis.call(void 0, false));
|
|
328
328
|
if (kid(plot, "dateAx")) input.xAxis.kind = "date";
|
|
329
|
-
input.yAxis = readAxis(_nullishCoalesce(_nullishCoalesce(primaryAxis, () => ( valAxes.find(vertical))), () => ( valAxes[0])),
|
|
329
|
+
input.yAxis = readAxis(_nullishCoalesce(_nullishCoalesce(primaryAxis, () => ( valAxes.find(vertical))), () => ( valAxes[0])), _chunkOUO3DSRTcjs.defaultChartAxis.call(void 0, true));
|
|
330
330
|
const secondaryAxis = valAxes.find((a) => a !== primaryAxis && (xy ? vertical(a) && a !== primaryAxis : true) && a !== catAxis);
|
|
331
|
-
if (series.some((s) => s.axis === "secondary") && secondaryAxis) input.yAxis2 = readAxis(secondaryAxis,
|
|
332
|
-
const { spec, issues: specIssues } =
|
|
331
|
+
if (series.some((s) => s.axis === "secondary") && secondaryAxis) input.yAxis2 = readAxis(secondaryAxis, _chunkOUO3DSRTcjs.defaultChartAxis.call(void 0, false));
|
|
332
|
+
const { spec, issues: specIssues } = _chunkOUO3DSRTcjs.normalizeChartSpec.call(void 0, input);
|
|
333
333
|
issues.push(...specIssues);
|
|
334
334
|
const uniq = [...new Set(unsupported)];
|
|
335
335
|
return { spec, issues, unsupported: uniq, lossless: uniq.length === 0 && specIssues.length === 0 };
|
|
@@ -382,7 +382,7 @@ function readChartex(root, issues, unsupported) {
|
|
|
382
382
|
const type = layouts[layout];
|
|
383
383
|
if (!type) {
|
|
384
384
|
issues.push({ path: "plotArea", message: `The chart layout "${layout || "unknown"}" is not supported.` });
|
|
385
|
-
return { spec:
|
|
385
|
+
return { spec: _chunkOUO3DSRTcjs.normalizeChartSpec.call(void 0, {}).spec, issues, unsupported: [layout || "unknown chartex layout"], lossless: false };
|
|
386
386
|
}
|
|
387
387
|
if (layout === "paretoLine") unsupported.push("pareto line");
|
|
388
388
|
const series = [];
|
|
@@ -409,18 +409,18 @@ function readChartex(root, issues, unsupported) {
|
|
|
409
409
|
const first = data.get(_nullishCoalesce(_optionalChain([kid, 'call', _35 => _35(seriesEls[0], "dataId"), 'optionalAccess', _36 => _36.getAttribute, 'call', _37 => _37("val")]), () => ( "0")));
|
|
410
410
|
if ((type === "treemap" || type === "sunburst") && _optionalChain([first, 'optionalAccess', _38 => _38.paths])) {
|
|
411
411
|
const treeIssues = [];
|
|
412
|
-
input.tree =
|
|
412
|
+
input.tree = _chunkOUO3DSRTcjs.chartTreeFromRows.call(void 0, first.paths.map((path2, i) => ({ path: path2, value: _nullishCoalesce(first.values[i], () => ( 0)) })), treeIssues);
|
|
413
413
|
for (const t of treeIssues) issues.push({ path: "chartData", message: t.message });
|
|
414
414
|
}
|
|
415
|
-
const { spec, issues: specIssues } =
|
|
415
|
+
const { spec, issues: specIssues } = _chunkOUO3DSRTcjs.normalizeChartSpec.call(void 0, input);
|
|
416
416
|
issues.push(...specIssues);
|
|
417
417
|
return { spec, issues, unsupported, lossless: unsupported.length === 0 && specIssues.length === 0 };
|
|
418
418
|
}
|
|
419
419
|
var esc = (s) => s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
420
420
|
var hex = (color) => {
|
|
421
421
|
if (!color) return null;
|
|
422
|
-
const rgb =
|
|
423
|
-
return rgb ?
|
|
422
|
+
const rgb = _chunkOUO3DSRTcjs.parseChartColor.call(void 0, color);
|
|
423
|
+
return rgb ? _chunkOUO3DSRTcjs.chartRgbToHex.call(void 0, rgb).slice(1).toUpperCase() : null;
|
|
424
424
|
};
|
|
425
425
|
var fillXml = (color, line = false) => {
|
|
426
426
|
const h = hex(color);
|
|
@@ -464,7 +464,7 @@ function errBarsXml(bars, dir) {
|
|
|
464
464
|
var MARKER_OUT = { circle: "circle", square: "square", diamond: "diamond", triangle: "triangle", cross: "x", none: "none" };
|
|
465
465
|
function chartToOoxml(spec) {
|
|
466
466
|
const issues = [];
|
|
467
|
-
const family =
|
|
467
|
+
const family = _chunkOUO3DSRTcjs.chartFamily.call(void 0, spec);
|
|
468
468
|
let type = spec.type;
|
|
469
469
|
if (family === "waterfall" || family === "histogram" || family === "box" || family === "funnel") {
|
|
470
470
|
issues.push(`${spec.type} charts are written as bar charts: DrawingML has no ${spec.type} type (Office 2016 stores it as chartex).`);
|
|
@@ -475,6 +475,9 @@ function chartToOoxml(spec) {
|
|
|
475
475
|
} else if (family === "sunburst") {
|
|
476
476
|
issues.push(`Sunburst charts are written as doughnut charts of the ${spec.tree.length ? "top-level group totals" : "values"}: DrawingML has no sunburst type (Office 2016 stores it as chartex).`);
|
|
477
477
|
type = "donut";
|
|
478
|
+
} else if (family === "choropleth") {
|
|
479
|
+
issues.push("Maps are written as bar charts of the values by region: DrawingML has no map chart (Office 2016 stores region maps as chartex with Bing geodata).");
|
|
480
|
+
type = "bar";
|
|
478
481
|
} else if (family === "barrace") {
|
|
479
482
|
issues.push("Bar chart races are written as clustered bar charts of every name at every time point: DrawingML has no animation.");
|
|
480
483
|
type = "bar";
|
|
@@ -505,7 +508,7 @@ function chartToOoxml(spec) {
|
|
|
505
508
|
const ids = { cat: 500000001, val: 500000002, cat2: 500000003, val2: 500000004 };
|
|
506
509
|
const xy = family === "xy" || type === "scatter" || type === "bubble";
|
|
507
510
|
const pieLike = type === "pie" || type === "donut";
|
|
508
|
-
const typed = (s) => pieLike || type === "radar" ? type : type === "bubble" ? "bubble" : xy ? "scatter" :
|
|
511
|
+
const typed = (s) => pieLike || type === "radar" ? type : type === "bubble" ? "bubble" : xy ? "scatter" : _chunkOUO3DSRTcjs.chartSeriesType.call(void 0, { type }, s);
|
|
509
512
|
const groups = [];
|
|
510
513
|
visible.forEach((s) => {
|
|
511
514
|
const kind = typed(s);
|
|
@@ -568,7 +571,7 @@ function chartToOoxml(spec) {
|
|
|
568
571
|
return `<c:ser>${parts.join("")}</c:ser>`;
|
|
569
572
|
};
|
|
570
573
|
const dLbls = `<c:dLbls><c:showLegendKey val="0"/><c:showVal val="${spec.dataLabels ? 1 : 0}"/><c:showCatName val="0"/><c:showSerName val="0"/><c:showPercent val="0"/><c:showBubbleSize val="0"/></c:dLbls>`;
|
|
571
|
-
const vary =
|
|
574
|
+
const vary = _chunkOUO3DSRTcjs.chartVariesColors.call(void 0, spec) ? 1 : 0;
|
|
572
575
|
const groupXml = groups.map((g) => {
|
|
573
576
|
const axes2 = g.secondary ? `<c:axId val="${ids.cat2}"/><c:axId val="${ids.val2}"/>` : `<c:axId val="${ids.cat}"/><c:axId val="${ids.val}"/>`;
|
|
574
577
|
const sers = g.series.map(({ s, index }) => serXml(g.kind, s, index)).join("");
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkOUO3DSRTcjs = require('./chunk-OUO3DSRT.cjs');
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
var _chunk55AKPTLMcjs = require('./chunk-55AKPTLM.cjs');
|
|
@@ -948,7 +948,7 @@ function drawCallouts(ctx, plot) {
|
|
|
948
948
|
}
|
|
949
949
|
if (unplaced) ctx.warn("annotations-skipped", `${unplaced} callout${unplaced === 1 ? " points" : "s point"} at a gap or a hidden value and ${unplaced === 1 ? "is" : "are"} not drawn.`);
|
|
950
950
|
}
|
|
951
|
-
var MUTED = /* @__PURE__ */ new Set(["node", "bar", "line", "area", "point", "slice", "cell", "box", "whisker", "outlier", "connector", "trendline", "trendline-label", "error-bar", "data-label", "legend-swatch", "legend-label"]);
|
|
951
|
+
var MUTED = /* @__PURE__ */ new Set(["node", "region", "bar", "line", "area", "point", "slice", "cell", "box", "whisker", "outlier", "connector", "trendline", "trendline-label", "error-bar", "data-label", "legend-swatch", "legend-label"]);
|
|
952
952
|
function applyHighlight(ctx) {
|
|
953
953
|
const { spec, marks } = ctx;
|
|
954
954
|
if (!spec.highlight.length) return;
|
|
@@ -1239,7 +1239,7 @@ function layoutCartesian(ctx, area, visible) {
|
|
|
1239
1239
|
const { spec, theme, marks, measure, fs } = ctx;
|
|
1240
1240
|
const horizontal = spec.orientation === "horizontal";
|
|
1241
1241
|
const n = spec.categories.length;
|
|
1242
|
-
const types = new Map(visible.map((s) => [s.id,
|
|
1242
|
+
const types = new Map(visible.map((s) => [s.id, _chunkOUO3DSRTcjs.chartSeriesType.call(void 0, spec, s)]));
|
|
1243
1243
|
const stacked = spec.stacking !== "none";
|
|
1244
1244
|
const percent = spec.stacking === "percent";
|
|
1245
1245
|
const onSecondary = (s) => s.axis === "secondary";
|
|
@@ -1276,7 +1276,7 @@ function layoutCartesian(ctx, area, visible) {
|
|
|
1276
1276
|
const stack = stacks.get(s.id);
|
|
1277
1277
|
errors.set(
|
|
1278
1278
|
s.id,
|
|
1279
|
-
|
|
1279
|
+
_chunkOUO3DSRTcjs.chartErrorAmounts.call(void 0, s.errorBars, s.values).map((e, i) => {
|
|
1280
1280
|
const raw = s.values[i];
|
|
1281
1281
|
const seg = _optionalChain([stack, 'optionalAccess', _11 => _11.segments, 'access', _12 => _12[i]]);
|
|
1282
1282
|
if (!e || raw === null || stack && !seg) return null;
|
|
@@ -1346,7 +1346,7 @@ function layoutCartesian(ctx, area, visible) {
|
|
|
1346
1346
|
const drawOrder = [...visible].sort((a, b) => order(types.get(a.id)) - order(types.get(b.id)));
|
|
1347
1347
|
for (const s of drawOrder) {
|
|
1348
1348
|
const si = spec.series.indexOf(s);
|
|
1349
|
-
const color =
|
|
1349
|
+
const color = _chunkOUO3DSRTcjs.chartSeriesColor.call(void 0, spec, si);
|
|
1350
1350
|
const type = types.get(s.id);
|
|
1351
1351
|
const stack = stacks.get(s.id);
|
|
1352
1352
|
const selSeries = ctx.seriesSelected(s.id);
|
|
@@ -1372,7 +1372,7 @@ function layoutCartesian(ctx, area, visible) {
|
|
|
1372
1372
|
const selected = ctx.isSelected(target);
|
|
1373
1373
|
const [x, y] = map({ c: c0, v: Math.min(a, b) });
|
|
1374
1374
|
const rect = horizontal ? { x: Math.min(a, b), y: c0, width: Math.abs(b - a), height: cw } : { x, y, width: cw, height: Math.abs(b - a) };
|
|
1375
|
-
const fill =
|
|
1375
|
+
const fill = _chunkOUO3DSRTcjs.chartPointColor.call(void 0, spec, si, i);
|
|
1376
1376
|
marks.push({
|
|
1377
1377
|
kind: "rect",
|
|
1378
1378
|
key: `bar-${s.id}-${i}`,
|
|
@@ -1451,7 +1451,7 @@ function layoutCartesian(ctx, area, visible) {
|
|
|
1451
1451
|
const target = { kind: "point", seriesId: s.id, index: i };
|
|
1452
1452
|
const selected = ctx.isSelected(target);
|
|
1453
1453
|
const r = type === "scatter" ? 4.5 : 3.5;
|
|
1454
|
-
const pointColor =
|
|
1454
|
+
const pointColor = _chunkOUO3DSRTcjs.chartPointColor.call(void 0, spec, si, i);
|
|
1455
1455
|
const fill = showDots ? type === "scatter" ? pointColor : theme.surface : "transparent";
|
|
1456
1456
|
marks.push(
|
|
1457
1457
|
pointMark({ key: `point-${s.id}-${i}`, target, selected: selected || selSeries, opacity: type === "scatter" ? 0.85 : void 0 }, showDots ? marker : "hit", cx, cy, showDots ? r : 6, fill, showDots ? pointColor : void 0, 2)
|
|
@@ -1524,8 +1524,8 @@ function layoutXy(ctx, area, visible) {
|
|
|
1524
1524
|
const yErrors = /* @__PURE__ */ new Map();
|
|
1525
1525
|
const xErrors = /* @__PURE__ */ new Map();
|
|
1526
1526
|
for (const { s } of all) {
|
|
1527
|
-
if (s.errorBars) yErrors.set(s.id,
|
|
1528
|
-
if (s.xErrorBars) xErrors.set(s.id,
|
|
1527
|
+
if (s.errorBars) yErrors.set(s.id, _chunkOUO3DSRTcjs.chartErrorAmounts.call(void 0, s.errorBars, s.values));
|
|
1528
|
+
if (s.xErrorBars) xErrors.set(s.id, _chunkOUO3DSRTcjs.chartErrorAmounts.call(void 0, s.xErrorBars, s.values.map((_, i) => _nullishCoalesce(_optionalChain([s, 'access', _29 => _29.x, 'optionalAccess', _30 => _30[i]]), () => ( (bubble || !s.x ? i + 1 : null))))));
|
|
1529
1529
|
}
|
|
1530
1530
|
let xlo = Infinity;
|
|
1531
1531
|
let xhi = -Infinity;
|
|
@@ -1608,8 +1608,8 @@ function layoutXy(ctx, area, visible) {
|
|
|
1608
1608
|
const trendLabels = [];
|
|
1609
1609
|
for (const { s, pts } of all) {
|
|
1610
1610
|
const si = spec.series.indexOf(s);
|
|
1611
|
-
const color =
|
|
1612
|
-
const type =
|
|
1611
|
+
const color = _chunkOUO3DSRTcjs.chartSeriesColor.call(void 0, spec, si);
|
|
1612
|
+
const type = _chunkOUO3DSRTcjs.chartSeriesType.call(void 0, spec, s);
|
|
1613
1613
|
const selSeries = ctx.seriesSelected(s.id);
|
|
1614
1614
|
const seriesTarget = { kind: "series", seriesId: s.id };
|
|
1615
1615
|
if (type === "line" || type === "area") {
|
|
@@ -1634,7 +1634,7 @@ function layoutXy(ctx, area, visible) {
|
|
|
1634
1634
|
}
|
|
1635
1635
|
const target = { kind: "point", seriesId: s.id, index: p.i };
|
|
1636
1636
|
const selected = ctx.isSelected(target);
|
|
1637
|
-
const pointColor =
|
|
1637
|
+
const pointColor = _chunkOUO3DSRTcjs.chartPointColor.call(void 0, spec, si, p.i);
|
|
1638
1638
|
const r = bubble ? maxSize > 0 && p.size !== null && p.size > 0 ? Math.max(2, Math.sqrt(p.size / maxSize) * maxR) : 2 : 4.5;
|
|
1639
1639
|
if (bubble) marks.push({ kind: "circle", key: `point-${s.id}-${p.i}`, role: "point", cx, cy, r, fill: pointColor, stroke: pointColor, strokeWidth: 1, opacity: 0.6, target, selected: selected || selSeries });
|
|
1640
1640
|
else marks.push(pointMark({ key: `point-${s.id}-${p.i}`, target, selected: selected || selSeries, opacity: 0.85 }, marker === "none" ? "hit" : marker, cx, cy, marker === "none" ? 6 : r, marker === "none" ? "transparent" : pointColor, marker === "none" ? void 0 : pointColor, 2));
|
|
@@ -1677,6 +1677,51 @@ function trendlineLegendItems(spec, color) {
|
|
|
1677
1677
|
);
|
|
1678
1678
|
}
|
|
1679
1679
|
|
|
1680
|
+
// src/chart/maps.ts
|
|
1681
|
+
var maps = /* @__PURE__ */ new Map();
|
|
1682
|
+
function registerChartMap(map) {
|
|
1683
|
+
maps.set(map.id, map);
|
|
1684
|
+
}
|
|
1685
|
+
function getChartMap(id) {
|
|
1686
|
+
return maps.get(id);
|
|
1687
|
+
}
|
|
1688
|
+
function listChartMaps() {
|
|
1689
|
+
return [...maps.values()];
|
|
1690
|
+
}
|
|
1691
|
+
var fold = (text) => text.normalize("NFKD").replace(/[̀-ͯ]/g, "").trim().toLowerCase();
|
|
1692
|
+
function matchChartMapRegions(map, categories) {
|
|
1693
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
1694
|
+
for (const r of map.regions) {
|
|
1695
|
+
byKey.set(fold(r.id), r);
|
|
1696
|
+
byKey.set(fold(r.name), r);
|
|
1697
|
+
}
|
|
1698
|
+
const taken = /* @__PURE__ */ new Set();
|
|
1699
|
+
return categories.map((c) => {
|
|
1700
|
+
const r = byKey.get(fold(c));
|
|
1701
|
+
if (!r || taken.has(r.id)) return null;
|
|
1702
|
+
taken.add(r.id);
|
|
1703
|
+
return r;
|
|
1704
|
+
});
|
|
1705
|
+
}
|
|
1706
|
+
function chartMapBreaks(values, steps, thresholds) {
|
|
1707
|
+
if (thresholds.length) return [...thresholds];
|
|
1708
|
+
if (!values.length) return [];
|
|
1709
|
+
const lo = Math.min(...values);
|
|
1710
|
+
const hi = Math.max(...values);
|
|
1711
|
+
if (!(hi > lo)) return [];
|
|
1712
|
+
const exact = Array.from({ length: steps - 1 }, (_, k) => lo + (hi - lo) * (k + 1) / steps);
|
|
1713
|
+
for (let digits = 2; digits <= 6; digits++) {
|
|
1714
|
+
const rounded = exact.map((b) => Number(b.toPrecision(digits)));
|
|
1715
|
+
if (rounded.every((b, i) => i === 0 || b > rounded[i - 1])) return rounded;
|
|
1716
|
+
}
|
|
1717
|
+
return exact;
|
|
1718
|
+
}
|
|
1719
|
+
var chartMapClass = (value, breaks) => breaks.filter((b) => value >= b).length;
|
|
1720
|
+
function chartMapRamp(base, count) {
|
|
1721
|
+
if (count <= 1) return [base];
|
|
1722
|
+
return Array.from({ length: count }, (_, k) => _chunkOUO3DSRTcjs.shadeChartColor.call(void 0, base, 0.82 - 1.17 * k / (count - 1)));
|
|
1723
|
+
}
|
|
1724
|
+
|
|
1680
1725
|
// src/chart/race.ts
|
|
1681
1726
|
function chartRaceValueAt(series, index) {
|
|
1682
1727
|
for (let i = Math.min(index, series.values.length - 1); i >= 0; i--) {
|
|
@@ -1710,7 +1755,7 @@ function chartRaceRanking(spec, frame) {
|
|
|
1710
1755
|
}
|
|
1711
1756
|
|
|
1712
1757
|
// src/chart/layout-families.ts
|
|
1713
|
-
var sliceColor = (ctx, series, i) => _optionalChain([series, 'access', _45 => _45.pointColors, 'optionalAccess', _46 => _46[i]]) ||
|
|
1758
|
+
var sliceColor = (ctx, series, i) => _optionalChain([series, 'access', _45 => _45.pointColors, 'optionalAccess', _46 => _46[i]]) || _chunkOUO3DSRTcjs.chartSliceColor.call(void 0, ctx.spec, i);
|
|
1714
1759
|
function layoutPie(ctx, area, series) {
|
|
1715
1760
|
const { spec, theme, marks, fs, selection } = ctx;
|
|
1716
1761
|
const values = spec.categories.map((_, i) => {
|
|
@@ -1826,7 +1871,7 @@ function layoutRadar(ctx, area, visible) {
|
|
|
1826
1871
|
});
|
|
1827
1872
|
for (const s of visible) {
|
|
1828
1873
|
const si = spec.series.indexOf(s);
|
|
1829
|
-
const color =
|
|
1874
|
+
const color = _chunkOUO3DSRTcjs.chartSeriesColor.call(void 0, spec, si);
|
|
1830
1875
|
const selSeries = ctx.seriesSelected(s.id);
|
|
1831
1876
|
const pts = s.values.map((v, i) => v !== null && Number.isFinite(v) ? at(i, rOf(v)) : null);
|
|
1832
1877
|
const present = pts.filter((p) => p !== null);
|
|
@@ -1876,7 +1921,7 @@ function layoutWaterfall(ctx, area, series) {
|
|
|
1876
1921
|
});
|
|
1877
1922
|
const { band, catCenter, map, value } = frame;
|
|
1878
1923
|
const w = band * (1 - spec.gapWidth);
|
|
1879
|
-
const color =
|
|
1924
|
+
const color = _chunkOUO3DSRTcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(series));
|
|
1880
1925
|
const format = _nullishCoalesce(series.format, () => ( spec.yAxis.format));
|
|
1881
1926
|
const labelsOn = _nullishCoalesce(series.dataLabels, () => ( spec.dataLabels));
|
|
1882
1927
|
let prevEnd = null;
|
|
@@ -1935,7 +1980,7 @@ function layoutHistogram(ctx, area, visible) {
|
|
|
1935
1980
|
const gap = k > 1 ? band * spec.gapWidth * 0.5 : 0;
|
|
1936
1981
|
const w = (band - gap) / k;
|
|
1937
1982
|
visible.forEach((s, si) => {
|
|
1938
|
-
const color =
|
|
1983
|
+
const color = _chunkOUO3DSRTcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(s));
|
|
1939
1984
|
const target = { kind: "series", seriesId: s.id };
|
|
1940
1985
|
const selected = ctx.seriesSelected(s.id);
|
|
1941
1986
|
counts[si].forEach((c, b) => {
|
|
@@ -1966,7 +2011,7 @@ function layoutBox(ctx, area, visible) {
|
|
|
1966
2011
|
visible.forEach((s, i) => {
|
|
1967
2012
|
const st = stats[i];
|
|
1968
2013
|
if (!st) return;
|
|
1969
|
-
const color =
|
|
2014
|
+
const color = _chunkOUO3DSRTcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(s));
|
|
1970
2015
|
const target = { kind: "series", seriesId: s.id };
|
|
1971
2016
|
const selected = ctx.seriesSelected(s.id);
|
|
1972
2017
|
const c = catCenter(i);
|
|
@@ -2185,7 +2230,7 @@ function layoutLikert(ctx, area, visible) {
|
|
|
2185
2230
|
if (x1 - x0 <= 0) return;
|
|
2186
2231
|
const target = { kind: "point", seriesId: s.id, index: i };
|
|
2187
2232
|
const selected = ctx.isSelected(target);
|
|
2188
|
-
const fill = _optionalChain([s, 'access', _48 => _48.pointColors, 'optionalAccess', _49 => _49[i]]) ||
|
|
2233
|
+
const fill = _optionalChain([s, 'access', _48 => _48.pointColors, 'optionalAccess', _49 => _49[i]]) || _chunkOUO3DSRTcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(s));
|
|
2189
2234
|
const rect = { x: x0, y, width: x1 - x0, height: barH };
|
|
2190
2235
|
marks.push({ kind: "rect", key, role: "bar", ...rect, fill, target, selected: selected || ctx.seriesSelected(s.id) || catSelected });
|
|
2191
2236
|
if (selected) ctx.outline(`${key}-selection`, { x: rect.x - 2, y: rect.y - 2, width: rect.width + 4, height: rect.height + 4 });
|
|
@@ -2284,8 +2329,8 @@ function layoutParliament(ctx, area, series) {
|
|
|
2284
2329
|
}
|
|
2285
2330
|
function treeColor(ctx, series, node, group, base, shade) {
|
|
2286
2331
|
if (node.color) return node.color;
|
|
2287
|
-
if (base === null) return _optionalChain([series, 'optionalAccess', _50 => _50.pointColors, 'optionalAccess', _51 => _51[group]]) ||
|
|
2288
|
-
return
|
|
2332
|
+
if (base === null) return _optionalChain([series, 'optionalAccess', _50 => _50.pointColors, 'optionalAccess', _51 => _51[group]]) || _chunkOUO3DSRTcjs.chartSliceColor.call(void 0, ctx.spec, group);
|
|
2333
|
+
return _chunkOUO3DSRTcjs.shadeChartColor.call(void 0, base, shade);
|
|
2289
2334
|
}
|
|
2290
2335
|
function layoutTreemapTree(ctx, area, series) {
|
|
2291
2336
|
const { spec, marks, theme, fs, measure } = ctx;
|
|
@@ -2293,7 +2338,7 @@ function layoutTreemapTree(ctx, area, series) {
|
|
|
2293
2338
|
const labelsOn = _nullishCoalesce(_optionalChain([series, 'optionalAccess', _53 => _53.dataLabels]), () => ( true));
|
|
2294
2339
|
let unlabelled = 0;
|
|
2295
2340
|
const draw = (nodes, rect, key, group, base) => {
|
|
2296
|
-
const rects = chartSquarify(nodes.map(
|
|
2341
|
+
const rects = chartSquarify(nodes.map(_chunkOUO3DSRTcjs.chartTreeTotal), rect);
|
|
2297
2342
|
nodes.forEach((node, k) => {
|
|
2298
2343
|
const r = rects[k];
|
|
2299
2344
|
if (r.width <= 0.5 || r.height <= 0.5) return;
|
|
@@ -2328,10 +2373,10 @@ function layoutTreemapTree(ctx, area, series) {
|
|
|
2328
2373
|
}
|
|
2329
2374
|
function layoutSunburst(ctx, area, series) {
|
|
2330
2375
|
const { spec, marks, theme, fs, measure } = ctx;
|
|
2331
|
-
const tree = spec.tree.length ? spec.tree :
|
|
2376
|
+
const tree = spec.tree.length ? spec.tree : _chunkOUO3DSRTcjs.chartTreeFromSeries.call(void 0, spec.categories, _nullishCoalesce(_optionalChain([series, 'optionalAccess', _55 => _55.values]), () => ( [])));
|
|
2332
2377
|
const indexOf = new Map(spec.categories.map((c, i) => [c.trim() || `${i + 1}`, i]));
|
|
2333
|
-
const depth =
|
|
2334
|
-
const total = tree.reduce((t, n) => t +
|
|
2378
|
+
const depth = _chunkOUO3DSRTcjs.chartTreeDepth.call(void 0, tree);
|
|
2379
|
+
const total = tree.reduce((t, n) => t + _chunkOUO3DSRTcjs.chartTreeTotal.call(void 0, n), 0);
|
|
2335
2380
|
const cx = area.x + area.width / 2;
|
|
2336
2381
|
const cy = area.y + area.height / 2;
|
|
2337
2382
|
const outer = Math.max(8, Math.min(area.width, area.height) / 2 - 4);
|
|
@@ -2345,10 +2390,10 @@ function layoutSunburst(ctx, area, series) {
|
|
|
2345
2390
|
const format = _nullishCoalesce(_optionalChain([series, 'optionalAccess', _56 => _56.format]), () => ( spec.yAxis.format));
|
|
2346
2391
|
let unlabelled = 0;
|
|
2347
2392
|
const walk = (nodes, start, sweep, level, key, group, base) => {
|
|
2348
|
-
const sum = nodes.reduce((t, n) => t +
|
|
2393
|
+
const sum = nodes.reduce((t, n) => t + _chunkOUO3DSRTcjs.chartTreeTotal.call(void 0, n), 0);
|
|
2349
2394
|
let at = start;
|
|
2350
2395
|
nodes.forEach((node, k) => {
|
|
2351
|
-
const value =
|
|
2396
|
+
const value = _chunkOUO3DSRTcjs.chartTreeTotal.call(void 0, node);
|
|
2352
2397
|
if (!(value > 0) || !sum) return;
|
|
2353
2398
|
const a0 = at;
|
|
2354
2399
|
const a1 = at + sweep * value / sum;
|
|
@@ -2420,7 +2465,7 @@ function layoutSankey(ctx, area, series) {
|
|
|
2420
2465
|
y += value[i] * ky + pad;
|
|
2421
2466
|
}
|
|
2422
2467
|
}
|
|
2423
|
-
const color = (i) => _optionalChain([series, 'optionalAccess', _61 => _61.pointColors, 'optionalAccess', _62 => _62[i]]) ||
|
|
2468
|
+
const color = (i) => _optionalChain([series, 'optionalAccess', _61 => _61.pointColors, 'optionalAccess', _62 => _62[i]]) || _chunkOUO3DSRTcjs.chartSliceColor.call(void 0, spec, i);
|
|
2424
2469
|
const named = new Set(spec.highlight);
|
|
2425
2470
|
const lit = nodes.map((n) => named.has(n));
|
|
2426
2471
|
const dimLinks = lit.some(Boolean);
|
|
@@ -2505,24 +2550,84 @@ function layoutBarRace(ctx, area, frame) {
|
|
|
2505
2550
|
const target = { kind: "point", seriesId: e.seriesId, index };
|
|
2506
2551
|
const selected = ctx.isSelected(target) || ctx.seriesSelected(e.seriesId);
|
|
2507
2552
|
const width = Math.max(0, xOf(e.value) - plot.x);
|
|
2508
|
-
marks.push({ kind: "rect", key: `bar-${e.seriesId}`, role: "bar", x: plot.x, y, width, height: barH, fill:
|
|
2553
|
+
marks.push({ kind: "rect", key: `bar-${e.seriesId}`, role: "bar", x: plot.x, y, width, height: barH, fill: _chunkOUO3DSRTcjs.chartSeriesColor.call(void 0, spec, si), radius: Math.min(3, barH / 4), target, selected, ...selected ? { stroke: theme.selection, strokeWidth: 1.5 } : {} });
|
|
2509
2554
|
marks.push({ kind: "text", key: `label-name-${e.seriesId}`, role: "tick-label", x: plot.x - 6, y: y + barH / 2, text: truncate(e.name, labelW - 8, fs, measure), anchor: "end", baseline: "middle", size: fs, fill: selected ? theme.selection : theme.text, target: { kind: "series", seriesId: e.seriesId } });
|
|
2510
2555
|
if (_nullishCoalesce(s.dataLabels, () => ( true))) marks.push({ kind: "text", key: `label-${e.seriesId}`, role: "data-label", x: plot.x + width + 5, y: y + barH / 2, text: formatChartNumber(e.value, _nullishCoalesce(s.format, () => ( format)), _nullishCoalesce((_nullishCoalesce(s.format, () => ( format))).decimals, () => ( (Math.abs(e.value) >= 100 ? 0 : void 0)))), anchor: "start", baseline: "middle", size: fs - 1, fill: theme.text, target });
|
|
2511
2556
|
}
|
|
2512
2557
|
if (ranking.length > top) ctx.warn("values-skipped", `The race shows the top ${top} of ${ranking.length} names at each moment (raceTopN).`);
|
|
2513
2558
|
return { plot, valueScale: { axis: "x", domain: [0, max], range: [plot.x, plot.x + plot.width], ticks } };
|
|
2514
2559
|
}
|
|
2560
|
+
function placePath(d, s, ox, oy) {
|
|
2561
|
+
return d.replace(/(-?\d+(?:\.\d+)?),(-?\d+(?:\.\d+)?)/g, (_, x, y) => `${r2(ox + Number(x) * s)},${r2(oy + Number(y) * s)}`);
|
|
2562
|
+
}
|
|
2563
|
+
function layoutChoropleth(ctx, area, series) {
|
|
2564
|
+
const { spec, theme, marks, fs, measure } = ctx;
|
|
2565
|
+
const map = getChartMap(spec.map);
|
|
2566
|
+
const matches = matchChartMapRegions(map, spec.categories);
|
|
2567
|
+
const unmatched = spec.categories.filter((_, i) => !matches[i]);
|
|
2568
|
+
if (unmatched.length)
|
|
2569
|
+
ctx.warn("values-skipped", `${unmatched.length} categor${unmatched.length === 1 ? "y names" : "ies name"} no region of ${map.name}: ${unmatched.slice(0, 8).map((c) => `"${c}"`).join(", ")}${unmatched.length > 8 ? ", \u2026" : ""}. Use codes (such as FRA) or names (France).`);
|
|
2570
|
+
const indexOf = /* @__PURE__ */ new Map();
|
|
2571
|
+
matches.forEach((r, i) => r && indexOf.set(r.id, i));
|
|
2572
|
+
const valueAt = (i) => {
|
|
2573
|
+
const v = series.values[i];
|
|
2574
|
+
return v !== null && v !== void 0 && Number.isFinite(v) ? v : null;
|
|
2575
|
+
};
|
|
2576
|
+
const present = [...indexOf.values()].map(valueAt).filter((v) => v !== null);
|
|
2577
|
+
const breaks = chartMapBreaks(present, spec.mapSteps, spec.mapThresholds);
|
|
2578
|
+
const ramp = chartMapRamp(_nullishCoalesce(series.color, () => ( _chunkOUO3DSRTcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(series)))), breaks.length + 1);
|
|
2579
|
+
const format = _nullishCoalesce(series.format, () => ( spec.yAxis.format));
|
|
2580
|
+
const legendH = fs * 2.2;
|
|
2581
|
+
const s = Math.max(1e-6, Math.min(area.width / map.width, (area.height - legendH) / map.height));
|
|
2582
|
+
const ox = area.x + (area.width - map.width * s) / 2;
|
|
2583
|
+
const oy = area.y;
|
|
2584
|
+
if (map.land) marks.push({ kind: "path", key: "map-land", role: "map-land", d: placePath(map.land, s, ox, oy), fill: theme.grid, opacity: 0.55 });
|
|
2585
|
+
const markers = [];
|
|
2586
|
+
const labels = [];
|
|
2587
|
+
for (const region of map.regions) {
|
|
2588
|
+
const i = indexOf.get(region.id);
|
|
2589
|
+
const value = i === void 0 ? null : valueAt(i);
|
|
2590
|
+
const fill = i !== void 0 && _optionalChain([series, 'access', _66 => _66.pointColors, 'optionalAccess', _67 => _67[i]]) ? series.pointColors[i] : value === null ? theme.grid : ramp[chartMapClass(value, breaks)];
|
|
2591
|
+
const target = i === void 0 ? void 0 : { kind: "category", index: i };
|
|
2592
|
+
const selected = target ? ctx.isSelected(target) || ctx.isSelected({ kind: "point", seriesId: series.id, index: i }) : false;
|
|
2593
|
+
const [cx, cy] = [ox + region.center[0] * s, oy + region.center[1] * s];
|
|
2594
|
+
if (region.d) marks.push({ kind: "path", key: `region-${region.id}`, role: "region", d: placePath(region.d, s, ox, oy), fill, stroke: selected ? theme.selection : theme.surface, strokeWidth: selected ? 2 : 0.6, ...target ? { target, selected } : {} });
|
|
2595
|
+
if (!region.d || region.area * s * s < 30)
|
|
2596
|
+
markers.push({ kind: "circle", key: `region-marker-${region.id}`, role: "region", cx, cy, r: 3.5, fill, stroke: selected ? theme.selection : theme.text, strokeWidth: selected ? 1.5 : 0.75, ...target ? { target, selected } : {} });
|
|
2597
|
+
if (value !== null && target && (_nullishCoalesce(series.dataLabels, () => ( spec.dataLabels))) && region.area * s * s > (fs * 3) ** 2) {
|
|
2598
|
+
const text = formatChartNumber(value, format);
|
|
2599
|
+
labels.push({ kind: "text", key: `label-${region.id}`, role: "data-label", x: cx, y: cy, text, anchor: "middle", baseline: "middle", size: fs - 1, weight: 600, fill: contrastingTextColor(fill), target });
|
|
2600
|
+
}
|
|
2601
|
+
}
|
|
2602
|
+
marks.push(...markers, ...labels);
|
|
2603
|
+
const fmt = (v) => formatChartNumber(v, format);
|
|
2604
|
+
const items = ramp.map((color, k) => ({
|
|
2605
|
+
color,
|
|
2606
|
+
text: breaks.length === 0 ? present.length ? fmt(present[0]) : "" : k === 0 ? `< ${fmt(breaks[0])}` : k === breaks.length ? `\u2265 ${fmt(breaks[k - 1])}` : `${fmt(breaks[k - 1])}\u2013${fmt(breaks[k])}`
|
|
2607
|
+
}));
|
|
2608
|
+
items.push({ color: theme.grid, text: "No data" });
|
|
2609
|
+
let x = area.x;
|
|
2610
|
+
const y = area.y + area.height - fs * 0.9;
|
|
2611
|
+
items.forEach((item, k) => {
|
|
2612
|
+
marks.push({ kind: "rect", key: `legend-swatch-${k}`, role: "legend-swatch", x, y: y - 5, width: 10, height: 10, radius: 2, fill: item.color });
|
|
2613
|
+
marks.push({ kind: "text", key: `legend-label-${k}`, role: "legend-label", x: x + 14, y, text: item.text, anchor: "start", baseline: "middle", size: fs - 1, fill: theme.text });
|
|
2614
|
+
x += 14 + measure(item.text, fs - 1) + 14;
|
|
2615
|
+
});
|
|
2616
|
+
if (x > area.x + area.width) ctx.warn("legend-truncated", "The map legend is wider than the chart; widen the chart or use fewer classes.");
|
|
2617
|
+
if (map.attribution) marks.push({ kind: "text", key: "map-attribution", role: "note", x: area.x + area.width, y, text: map.attribution, anchor: "end", baseline: "middle", size: Math.max(7, fs - 3), fill: theme.mutedText });
|
|
2618
|
+
return { plot: { x: ox, y: oy, width: map.width * s, height: map.height * s } };
|
|
2619
|
+
}
|
|
2515
2620
|
|
|
2516
2621
|
// src/chart/layout.ts
|
|
2517
2622
|
function legendItems(spec, ctx) {
|
|
2518
|
-
const family =
|
|
2519
|
-
if (spec.type === "funnel" || spec.type === "slope" || spec.type === "sankey" || spec.type === "barrace") return [];
|
|
2520
|
-
if (
|
|
2623
|
+
const family = _chunkOUO3DSRTcjs.chartFamily.call(void 0, spec);
|
|
2624
|
+
if (spec.type === "funnel" || spec.type === "slope" || spec.type === "sankey" || spec.type === "barrace" || spec.type === "choropleth") return [];
|
|
2625
|
+
if (_chunkOUO3DSRTcjs.chartSpecColorsByCategory.call(void 0, spec)) {
|
|
2521
2626
|
const first = spec.series.find((s) => !s.hidden);
|
|
2522
|
-
const seats = (i) => Math.max(0, Math.round(_nullishCoalesce(_optionalChain([first, 'optionalAccess',
|
|
2627
|
+
const seats = (i) => Math.max(0, Math.round(_nullishCoalesce(_optionalChain([first, 'optionalAccess', _68 => _68.values, 'access', _69 => _69[i]]), () => ( 0))));
|
|
2523
2628
|
return spec.categories.map((c, i) => ({
|
|
2524
2629
|
label: spec.type === "parliament" ? `${c} ${seats(i)}` : c,
|
|
2525
|
-
color: _optionalChain([first, 'optionalAccess',
|
|
2630
|
+
color: _optionalChain([first, 'optionalAccess', _70 => _70.pointColors, 'optionalAccess', _71 => _71[i]]) || _chunkOUO3DSRTcjs.chartSliceColor.call(void 0, spec, i),
|
|
2526
2631
|
target: { kind: "category", index: i },
|
|
2527
2632
|
faded: false,
|
|
2528
2633
|
selected: ctx.isSelected({ kind: "category", index: i }),
|
|
@@ -2536,17 +2641,17 @@ function legendItems(spec, ctx) {
|
|
|
2536
2641
|
return [
|
|
2537
2642
|
{ label: "Increase", color: ctx.theme.positive, target, faded: false, selected: false, shape: "square" },
|
|
2538
2643
|
{ label: "Decrease", color: ctx.theme.negative, target, faded: false, selected: false, shape: "square" },
|
|
2539
|
-
{ label: "Total", color:
|
|
2644
|
+
{ label: "Total", color: _chunkOUO3DSRTcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(first)), target, faded: false, selected: false, shape: "square" }
|
|
2540
2645
|
];
|
|
2541
2646
|
}
|
|
2542
2647
|
if (family === "box") return [];
|
|
2543
|
-
const trends = trendlineLegendItems(spec, (i) =>
|
|
2648
|
+
const trends = trendlineLegendItems(spec, (i) => _chunkOUO3DSRTcjs.chartSeriesColor.call(void 0, spec, i));
|
|
2544
2649
|
const items = [];
|
|
2545
2650
|
spec.series.forEach((s, i) => {
|
|
2546
|
-
const type =
|
|
2651
|
+
const type = _chunkOUO3DSRTcjs.chartSeriesType.call(void 0, spec, s);
|
|
2547
2652
|
items.push({
|
|
2548
2653
|
label: s.name,
|
|
2549
|
-
color:
|
|
2654
|
+
color: _chunkOUO3DSRTcjs.chartSeriesColor.call(void 0, spec, i),
|
|
2550
2655
|
target: { kind: "series", seriesId: s.id },
|
|
2551
2656
|
faded: !!s.hidden,
|
|
2552
2657
|
selected: ctx.seriesSelected(s.id),
|
|
@@ -2559,7 +2664,7 @@ function legendItems(spec, ctx) {
|
|
|
2559
2664
|
function layoutChart(spec, options) {
|
|
2560
2665
|
const width = Math.max(1, Number.isFinite(options.width) ? options.width : 1);
|
|
2561
2666
|
const height = Math.max(1, Number.isFinite(options.height) ? options.height : 1);
|
|
2562
|
-
const theme = { ...
|
|
2667
|
+
const theme = { ..._chunkOUO3DSRTcjs.DEFAULT_CHART_THEME, ...options.theme };
|
|
2563
2668
|
const selection = _nullishCoalesce(options.selection, () => ( null));
|
|
2564
2669
|
const marks = [];
|
|
2565
2670
|
const warnings = [];
|
|
@@ -2575,7 +2680,7 @@ function layoutChart(spec, options) {
|
|
|
2575
2680
|
warnings,
|
|
2576
2681
|
selection,
|
|
2577
2682
|
isSelected: (target) => sameChartSelection(selection, target),
|
|
2578
|
-
seriesSelected: (id) => _optionalChain([selection, 'optionalAccess',
|
|
2683
|
+
seriesSelected: (id) => _optionalChain([selection, 'optionalAccess', _72 => _72.kind]) === "series" && selection.seriesId === id,
|
|
2579
2684
|
outline: (key, box) => marks.push({ kind: "rect", key, role: "selection", ...box, fill: "none", stroke: theme.selection, strokeWidth: 1, radius: 3 }),
|
|
2580
2685
|
warn: (code, message) => {
|
|
2581
2686
|
if (!warnings.some((w) => w.code === code && w.message === message)) warnings.push({ code, message });
|
|
@@ -2598,17 +2703,17 @@ function layoutChart(spec, options) {
|
|
|
2598
2703
|
if (spec.title) titleMark("title", spec.title, theme.titleSize, 600, theme.text);
|
|
2599
2704
|
if (spec.subtitle) titleMark("subtitle", spec.subtitle, fs + 1, 400, theme.mutedText);
|
|
2600
2705
|
if (spec.title || spec.subtitle) top += 6;
|
|
2601
|
-
const family =
|
|
2706
|
+
const family = _chunkOUO3DSRTcjs.chartFamily.call(void 0, spec);
|
|
2602
2707
|
const visible = spec.series.filter((s) => !s.hidden);
|
|
2603
2708
|
const items = legendItems(spec, ctx);
|
|
2604
2709
|
let area = { x: pad, y: top, width: width - pad * 2, height: height - top - pad - noteHeight(spec, fs) };
|
|
2605
2710
|
const seriesLegend = family === "cartesian" || family === "xy" || family === "radar" || family === "histogram";
|
|
2606
2711
|
const hasTrend = items.some((i) => i.shape === "dash");
|
|
2607
|
-
const showLegend = spec.legend.show && items.length > 0 && (!seriesLegend ||
|
|
2712
|
+
const showLegend = spec.legend.show && items.length > 0 && (!seriesLegend || _chunkOUO3DSRTcjs.chartVariesColors.call(void 0, spec) || spec.series.length > 1 || spec.series.some((s) => s.hidden) || hasTrend);
|
|
2608
2713
|
if (showLegend) area = layoutLegend(items, spec.legend.position, area, ctx, ctx.isSelected({ kind: "legend" }));
|
|
2609
2714
|
const finish = (result) => {
|
|
2610
2715
|
if (result.plot.width > 0) {
|
|
2611
|
-
if (chartAnnotationFamily(
|
|
2716
|
+
if (chartAnnotationFamily(_chunkOUO3DSRTcjs.chartFamily.call(void 0, spec))) drawCallouts(ctx, result.plot);
|
|
2612
2717
|
else if (spec.referenceLines.length || spec.referenceBands.length || spec.series.some((s) => s.callouts))
|
|
2613
2718
|
ctx.warn("annotations-skipped", `Reference lines, bands and callouts are drawn on bar, line, area, scatter and bubble charts; this ${spec.type} chart leaves them out.`);
|
|
2614
2719
|
}
|
|
@@ -2656,6 +2761,18 @@ function layoutChart(spec, options) {
|
|
|
2656
2761
|
return finish(layoutFunnel(ctx, area, visible[0]));
|
|
2657
2762
|
case "treemap":
|
|
2658
2763
|
return finish(spec.tree.length ? layoutTreemapTree(ctx, area, spec.series[0]) : layoutTreemap(ctx, area, visible[0]));
|
|
2764
|
+
case "choropleth": {
|
|
2765
|
+
const map = getChartMap(spec.map);
|
|
2766
|
+
if (!map) {
|
|
2767
|
+
ctx.warn("type-fallback", `The map "${spec.map}" is not registered, so the values are drawn as bars: register it with registerChartMap (the Europe outlines are EUROPE_CHART_MAP in @pixerate/editor/chart-maps).`);
|
|
2768
|
+
return finish(layoutCartesian(ctx, area, visible));
|
|
2769
|
+
}
|
|
2770
|
+
if (!matchChartMapRegions(map, spec.categories).some(Boolean)) {
|
|
2771
|
+
ctx.warn("type-fallback", `No category names a region of ${map.name}, so the values are drawn as bars: use codes (such as FRA) or names (France) as categories.`);
|
|
2772
|
+
return finish(layoutCartesian(ctx, area, visible));
|
|
2773
|
+
}
|
|
2774
|
+
return finish(layoutChoropleth(ctx, area, visible[0]));
|
|
2775
|
+
}
|
|
2659
2776
|
case "barrace":
|
|
2660
2777
|
return finish(layoutBarRace(ctx, area, options.raceFrame));
|
|
2661
2778
|
case "sankey":
|
|
@@ -2759,9 +2876,9 @@ function layoutLegend(items, position, area, ctx, legendSelected) {
|
|
|
2759
2876
|
function addReadout(ctx, readout, plot) {
|
|
2760
2877
|
const { spec, marks, theme, fs, measure } = ctx;
|
|
2761
2878
|
const series = spec.series.find((s) => s.id === readout.seriesId);
|
|
2762
|
-
const value = _optionalChain([series, 'optionalAccess',
|
|
2879
|
+
const value = _optionalChain([series, 'optionalAccess', _73 => _73.values, 'access', _74 => _74[readout.index]]);
|
|
2763
2880
|
if (!series || value === null || value === void 0) return;
|
|
2764
|
-
const mark = marks.find((m) => (m.role === "point" || m.role === "bar") && _optionalChain([m, 'access',
|
|
2881
|
+
const mark = marks.find((m) => (m.role === "point" || m.role === "bar") && _optionalChain([m, 'access', _75 => _75.target, 'optionalAccess', _76 => _76.kind]) === "point" && m.target.seriesId === readout.seriesId && m.target.index === readout.index);
|
|
2765
2882
|
if (!mark) return;
|
|
2766
2883
|
let ax;
|
|
2767
2884
|
let ay;
|
|
@@ -2773,8 +2890,8 @@ function addReadout(ctx, readout, plot) {
|
|
|
2773
2890
|
ay = mark.cy - mark.r;
|
|
2774
2891
|
} else return;
|
|
2775
2892
|
const axis = series.axis === "secondary" ? spec.yAxis2 : spec.yAxis;
|
|
2776
|
-
const x = _optionalChain([series, 'access',
|
|
2777
|
-
const text = x !== null && x !== void 0 &&
|
|
2893
|
+
const x = _optionalChain([series, 'access', _77 => _77.x, 'optionalAccess', _78 => _78[readout.index]]);
|
|
2894
|
+
const text = x !== null && x !== void 0 && _chunkOUO3DSRTcjs.chartFamily.call(void 0, spec) === "xy" ? `${formatChartNumber(x, spec.xAxis.format)}, ${formatChartNumber(value, axis.format)}` : `${_nullishCoalesce(spec.categories[readout.index], () => ( ""))}: ${formatChartNumber(value, _nullishCoalesce(series.format, () => ( axis.format)))}`;
|
|
2778
2895
|
const w = measure(text, fs, 600) + 10;
|
|
2779
2896
|
const h = fs + 8;
|
|
2780
2897
|
const bx = Math.max(plot.x, Math.min(plot.x + plot.width - w, ax - w / 2));
|
|
@@ -2823,7 +2940,7 @@ function chartXAtPoint(scene, point) {
|
|
|
2823
2940
|
if (!scale) return void 0;
|
|
2824
2941
|
return chartScaleFromPixel(point.x, scale);
|
|
2825
2942
|
}
|
|
2826
|
-
function snapChartValue(scene, value, step, ticks = _nullishCoalesce(_optionalChain([scene, 'access',
|
|
2943
|
+
function snapChartValue(scene, value, step, ticks = _nullishCoalesce(_optionalChain([scene, 'access', _79 => _79.valueScale, 'optionalAccess', _80 => _80.ticks]), () => ( [])), logBase) {
|
|
2827
2944
|
if (logBase && step === void 0) return value > 0 && Number.isFinite(value) ? Number(value.toPrecision(2)) : value;
|
|
2828
2945
|
const unit = _nullishCoalesce(step, () => ( (ticks.length > 1 ? (ticks[1] - ticks[0]) / 10 : 1)));
|
|
2829
2946
|
if (!(unit > 0)) return value;
|
|
@@ -2874,4 +2991,11 @@ function snapChartValue(scene, value, step, ticks = _nullishCoalesce(_optionalCh
|
|
|
2874
2991
|
|
|
2875
2992
|
|
|
2876
2993
|
|
|
2877
|
-
|
|
2994
|
+
|
|
2995
|
+
|
|
2996
|
+
|
|
2997
|
+
|
|
2998
|
+
|
|
2999
|
+
|
|
3000
|
+
|
|
3001
|
+
exports.parseChartDate = parseChartDate; exports.CHART_DATE_STEPS = CHART_DATE_STEPS; exports.formatChartDate = formatChartDate; exports.chartDateLabels = chartDateLabels; exports.compileChartFormatCode = compileChartFormatCode; exports.formatChartValueWithCode = formatChartValueWithCode; exports.chartSerialToDate = chartSerialToDate; exports.chartDateToSerial = chartDateToSerial; exports.niceStep = niceStep; exports.niceScale = niceScale; exports.stepDecimals = stepDecimals; exports.formatChartNumber = formatChartNumber; exports.linearMap = linearMap; exports.niceLogScale = niceLogScale; exports.chartScaleToPixel = chartScaleToPixel; exports.chartScaleFromPixel = chartScaleFromPixel; exports.estimateChartTextWidth = estimateChartTextWidth; exports.sameChartSelection = sameChartSelection; exports.contrastingTextColor = contrastingTextColor; exports.r2 = r2; exports.chartHistogram = chartHistogram; exports.chartQuantile = chartQuantile; exports.suggestChartReferences = suggestChartReferences; exports.chartBoxStats = chartBoxStats; exports.chartSquarify = chartSquarify; exports.decimateChartPoints = decimateChartPoints; exports.summarizeChartSeries = summarizeChartSeries; exports.fitChartTrendline = fitChartTrendline; exports.trendNumberText = trendNumberText; exports.chartMovingAverage = chartMovingAverage; exports.chartTrendlineName = chartTrendlineName; exports.chartSupportsTrendlines = chartSupportsTrendlines; exports.MAX_CHART_DATA_LABELS = MAX_CHART_DATA_LABELS; exports.MAX_CHART_LINE_POINTS = MAX_CHART_LINE_POINTS; exports.MAX_CHART_MARKERS = MAX_CHART_MARKERS; exports.registerChartMap = registerChartMap; exports.getChartMap = getChartMap; exports.listChartMaps = listChartMaps; exports.matchChartMapRegions = matchChartMapRegions; exports.chartMapBreaks = chartMapBreaks; exports.chartMapClass = chartMapClass; exports.chartMapRamp = chartMapRamp; exports.chartRaceValueAt = chartRaceValueAt; exports.chartRaceMoment = chartRaceMoment; exports.chartRaceRanking = chartRaceRanking; exports.layoutChart = layoutChart; exports.chartValueAtPoint = chartValueAtPoint; exports.chartXAtPoint = chartXAtPoint; exports.snapChartValue = snapChartValue;
|
|
@@ -5,14 +5,14 @@ import {
|
|
|
5
5
|
chartToMermaid,
|
|
6
6
|
describeChart,
|
|
7
7
|
layoutSparkline
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-N3ACT6VJ.js";
|
|
9
9
|
import {
|
|
10
10
|
layoutChart
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-M52UCHVZ.js";
|
|
12
12
|
import {
|
|
13
13
|
DEFAULT_CHART_THEME,
|
|
14
14
|
normalizeChartSpec
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-ORZF4JOO.js";
|
|
16
16
|
import {
|
|
17
17
|
plainTextToSlice
|
|
18
18
|
} from "./chunk-2INPJDNY.js";
|