@pixerate/editor 0.165.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/controller.d.cts +29 -0
- package/dist/chart/controller.d.ts +29 -0
- package/dist/chart/index.cjs +352 -179
- package/dist/chart/index.d.cts +2 -0
- package/dist/chart/index.d.ts +2 -0
- package/dist/chart/index.js +183 -10
- package/dist/chart/layout-families.d.cts +15 -0
- package/dist/chart/layout-families.d.ts +15 -0
- package/dist/chart/layout-shared.d.cts +5 -0
- package/dist/chart/layout-shared.d.ts +5 -0
- package/dist/chart/maps.d.cts +43 -0
- package/dist/chart/maps.d.ts +43 -0
- package/dist/chart/race.d.cts +26 -0
- package/dist/chart/race.d.ts +26 -0
- package/dist/chart/schemas.d.cts +2 -0
- package/dist/chart/schemas.d.ts +2 -0
- package/dist/chart/spec.d.cts +1 -1
- package/dist/chart/spec.d.ts +1 -1
- package/dist/chart/types.d.cts +14 -2
- package/dist/chart/types.d.ts +14 -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-IMRXC7OA.cjs → chunk-2F4GAZL5.cjs} +186 -96
- package/dist/{chunk-FEU2XVQH.js → chunk-34UCPHYO.js} +8 -2
- package/dist/{chunk-ODFCS7HF.cjs → chunk-E45AIIWY.cjs} +8 -8
- package/dist/{chunk-N7NBGT2Y.js → chunk-FKYGM35R.js} +2 -2
- package/dist/{chunk-64VWWR5U.cjs → chunk-GD34ICEX.cjs} +16 -16
- package/dist/{chunk-TVQW26AV.cjs → chunk-GTF4RYXJ.cjs} +29 -23
- package/dist/{chunk-V5GSY3NC.js → chunk-M52UCHVZ.js} +203 -3
- package/dist/{chunk-FRBRLKNQ.js → chunk-N3ACT6VJ.js} +92 -2
- package/dist/{chunk-CRFSQWKQ.js → chunk-OLCHKGGO.js} +7 -1
- package/dist/{chunk-2ZRN43IN.js → chunk-ORZF4JOO.js} +32 -4
- package/dist/{chunk-UVXTOZ2B.cjs → chunk-OUO3DSRT.cjs} +32 -4
- package/dist/{chunk-MKXK6E4O.cjs → chunk-SBAPXFPB.cjs} +51 -51
- package/dist/{chunk-2J5VLJHC.js → chunk-T62BRXMS.js} +3 -3
- package/dist/{chunk-Q25WAFTD.cjs → chunk-VKHJJUBK.cjs} +24 -18
- package/dist/{chunk-QO2T6KA5.cjs → chunk-WOIXNDHV.cjs} +247 -47
- package/dist/{chunk-X5W645RI.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 +36 -2
|
@@ -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,8 +1677,85 @@ 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
|
+
|
|
1725
|
+
// src/chart/race.ts
|
|
1726
|
+
function chartRaceValueAt(series, index) {
|
|
1727
|
+
for (let i = Math.min(index, series.values.length - 1); i >= 0; i--) {
|
|
1728
|
+
const v = series.values[i];
|
|
1729
|
+
if (v !== null && v !== void 0 && Number.isFinite(v)) return v;
|
|
1730
|
+
}
|
|
1731
|
+
return 0;
|
|
1732
|
+
}
|
|
1733
|
+
function chartRaceMoment(count, frame) {
|
|
1734
|
+
const last = Math.max(0, count - 1);
|
|
1735
|
+
const at = frame === null || frame === void 0 || !Number.isFinite(frame) ? last : Math.max(0, Math.min(last, frame));
|
|
1736
|
+
const from = Math.floor(at);
|
|
1737
|
+
const to = Math.min(last, from + 1);
|
|
1738
|
+
return { from, to, t: at - from, at };
|
|
1739
|
+
}
|
|
1740
|
+
function chartRaceRanking(spec, frame) {
|
|
1741
|
+
const visible = spec.series.filter((s) => !s.hidden);
|
|
1742
|
+
const { from, to, t } = chartRaceMoment(spec.categories.length, frame);
|
|
1743
|
+
const rankAt = (i) => {
|
|
1744
|
+
const order2 = visible.map((s, k) => ({ id: s.id, v: chartRaceValueAt(s, i), k })).sort((a, b) => b.v - a.v || a.k - b.k);
|
|
1745
|
+
return new Map(order2.map((o, r) => [o.id, r]));
|
|
1746
|
+
};
|
|
1747
|
+
const r0 = rankAt(from);
|
|
1748
|
+
const r1 = rankAt(to);
|
|
1749
|
+
const near = t < 0.5 ? r0 : r1;
|
|
1750
|
+
return visible.map((s) => {
|
|
1751
|
+
const a = chartRaceValueAt(s, from);
|
|
1752
|
+
const b = chartRaceValueAt(s, to);
|
|
1753
|
+
return { seriesId: s.id, name: s.name, value: a + (b - a) * t, position: r0.get(s.id) + (r1.get(s.id) - r0.get(s.id)) * t, rank: near.get(s.id) };
|
|
1754
|
+
}).sort((a, b) => a.position - b.position || b.value - a.value);
|
|
1755
|
+
}
|
|
1756
|
+
|
|
1680
1757
|
// src/chart/layout-families.ts
|
|
1681
|
-
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);
|
|
1682
1759
|
function layoutPie(ctx, area, series) {
|
|
1683
1760
|
const { spec, theme, marks, fs, selection } = ctx;
|
|
1684
1761
|
const values = spec.categories.map((_, i) => {
|
|
@@ -1794,7 +1871,7 @@ function layoutRadar(ctx, area, visible) {
|
|
|
1794
1871
|
});
|
|
1795
1872
|
for (const s of visible) {
|
|
1796
1873
|
const si = spec.series.indexOf(s);
|
|
1797
|
-
const color =
|
|
1874
|
+
const color = _chunkOUO3DSRTcjs.chartSeriesColor.call(void 0, spec, si);
|
|
1798
1875
|
const selSeries = ctx.seriesSelected(s.id);
|
|
1799
1876
|
const pts = s.values.map((v, i) => v !== null && Number.isFinite(v) ? at(i, rOf(v)) : null);
|
|
1800
1877
|
const present = pts.filter((p) => p !== null);
|
|
@@ -1844,7 +1921,7 @@ function layoutWaterfall(ctx, area, series) {
|
|
|
1844
1921
|
});
|
|
1845
1922
|
const { band, catCenter, map, value } = frame;
|
|
1846
1923
|
const w = band * (1 - spec.gapWidth);
|
|
1847
|
-
const color =
|
|
1924
|
+
const color = _chunkOUO3DSRTcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(series));
|
|
1848
1925
|
const format = _nullishCoalesce(series.format, () => ( spec.yAxis.format));
|
|
1849
1926
|
const labelsOn = _nullishCoalesce(series.dataLabels, () => ( spec.dataLabels));
|
|
1850
1927
|
let prevEnd = null;
|
|
@@ -1903,7 +1980,7 @@ function layoutHistogram(ctx, area, visible) {
|
|
|
1903
1980
|
const gap = k > 1 ? band * spec.gapWidth * 0.5 : 0;
|
|
1904
1981
|
const w = (band - gap) / k;
|
|
1905
1982
|
visible.forEach((s, si) => {
|
|
1906
|
-
const color =
|
|
1983
|
+
const color = _chunkOUO3DSRTcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(s));
|
|
1907
1984
|
const target = { kind: "series", seriesId: s.id };
|
|
1908
1985
|
const selected = ctx.seriesSelected(s.id);
|
|
1909
1986
|
counts[si].forEach((c, b) => {
|
|
@@ -1934,7 +2011,7 @@ function layoutBox(ctx, area, visible) {
|
|
|
1934
2011
|
visible.forEach((s, i) => {
|
|
1935
2012
|
const st = stats[i];
|
|
1936
2013
|
if (!st) return;
|
|
1937
|
-
const color =
|
|
2014
|
+
const color = _chunkOUO3DSRTcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(s));
|
|
1938
2015
|
const target = { kind: "series", seriesId: s.id };
|
|
1939
2016
|
const selected = ctx.seriesSelected(s.id);
|
|
1940
2017
|
const c = catCenter(i);
|
|
@@ -2153,7 +2230,7 @@ function layoutLikert(ctx, area, visible) {
|
|
|
2153
2230
|
if (x1 - x0 <= 0) return;
|
|
2154
2231
|
const target = { kind: "point", seriesId: s.id, index: i };
|
|
2155
2232
|
const selected = ctx.isSelected(target);
|
|
2156
|
-
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));
|
|
2157
2234
|
const rect = { x: x0, y, width: x1 - x0, height: barH };
|
|
2158
2235
|
marks.push({ kind: "rect", key, role: "bar", ...rect, fill, target, selected: selected || ctx.seriesSelected(s.id) || catSelected });
|
|
2159
2236
|
if (selected) ctx.outline(`${key}-selection`, { x: rect.x - 2, y: rect.y - 2, width: rect.width + 4, height: rect.height + 4 });
|
|
@@ -2252,8 +2329,8 @@ function layoutParliament(ctx, area, series) {
|
|
|
2252
2329
|
}
|
|
2253
2330
|
function treeColor(ctx, series, node, group, base, shade) {
|
|
2254
2331
|
if (node.color) return node.color;
|
|
2255
|
-
if (base === null) return _optionalChain([series, 'optionalAccess', _50 => _50.pointColors, 'optionalAccess', _51 => _51[group]]) ||
|
|
2256
|
-
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);
|
|
2257
2334
|
}
|
|
2258
2335
|
function layoutTreemapTree(ctx, area, series) {
|
|
2259
2336
|
const { spec, marks, theme, fs, measure } = ctx;
|
|
@@ -2261,7 +2338,7 @@ function layoutTreemapTree(ctx, area, series) {
|
|
|
2261
2338
|
const labelsOn = _nullishCoalesce(_optionalChain([series, 'optionalAccess', _53 => _53.dataLabels]), () => ( true));
|
|
2262
2339
|
let unlabelled = 0;
|
|
2263
2340
|
const draw = (nodes, rect, key, group, base) => {
|
|
2264
|
-
const rects = chartSquarify(nodes.map(
|
|
2341
|
+
const rects = chartSquarify(nodes.map(_chunkOUO3DSRTcjs.chartTreeTotal), rect);
|
|
2265
2342
|
nodes.forEach((node, k) => {
|
|
2266
2343
|
const r = rects[k];
|
|
2267
2344
|
if (r.width <= 0.5 || r.height <= 0.5) return;
|
|
@@ -2296,10 +2373,10 @@ function layoutTreemapTree(ctx, area, series) {
|
|
|
2296
2373
|
}
|
|
2297
2374
|
function layoutSunburst(ctx, area, series) {
|
|
2298
2375
|
const { spec, marks, theme, fs, measure } = ctx;
|
|
2299
|
-
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]), () => ( [])));
|
|
2300
2377
|
const indexOf = new Map(spec.categories.map((c, i) => [c.trim() || `${i + 1}`, i]));
|
|
2301
|
-
const depth =
|
|
2302
|
-
const total = tree.reduce((t, n) => t +
|
|
2378
|
+
const depth = _chunkOUO3DSRTcjs.chartTreeDepth.call(void 0, tree);
|
|
2379
|
+
const total = tree.reduce((t, n) => t + _chunkOUO3DSRTcjs.chartTreeTotal.call(void 0, n), 0);
|
|
2303
2380
|
const cx = area.x + area.width / 2;
|
|
2304
2381
|
const cy = area.y + area.height / 2;
|
|
2305
2382
|
const outer = Math.max(8, Math.min(area.width, area.height) / 2 - 4);
|
|
@@ -2313,10 +2390,10 @@ function layoutSunburst(ctx, area, series) {
|
|
|
2313
2390
|
const format = _nullishCoalesce(_optionalChain([series, 'optionalAccess', _56 => _56.format]), () => ( spec.yAxis.format));
|
|
2314
2391
|
let unlabelled = 0;
|
|
2315
2392
|
const walk = (nodes, start, sweep, level, key, group, base) => {
|
|
2316
|
-
const sum = nodes.reduce((t, n) => t +
|
|
2393
|
+
const sum = nodes.reduce((t, n) => t + _chunkOUO3DSRTcjs.chartTreeTotal.call(void 0, n), 0);
|
|
2317
2394
|
let at = start;
|
|
2318
2395
|
nodes.forEach((node, k) => {
|
|
2319
|
-
const value =
|
|
2396
|
+
const value = _chunkOUO3DSRTcjs.chartTreeTotal.call(void 0, node);
|
|
2320
2397
|
if (!(value > 0) || !sum) return;
|
|
2321
2398
|
const a0 = at;
|
|
2322
2399
|
const a1 = at + sweep * value / sum;
|
|
@@ -2388,7 +2465,7 @@ function layoutSankey(ctx, area, series) {
|
|
|
2388
2465
|
y += value[i] * ky + pad;
|
|
2389
2466
|
}
|
|
2390
2467
|
}
|
|
2391
|
-
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);
|
|
2392
2469
|
const named = new Set(spec.highlight);
|
|
2393
2470
|
const lit = nodes.map((n) => named.has(n));
|
|
2394
2471
|
const dimLinks = lit.some(Boolean);
|
|
@@ -2441,17 +2518,116 @@ function layoutSankey(ctx, area, series) {
|
|
|
2441
2518
|
if (hidden) ctx.warn("labels-truncated", `${hidden} node label${hidden === 1 ? " was" : "s were"} shortened to fit between the columns.`);
|
|
2442
2519
|
return { plot: area };
|
|
2443
2520
|
}
|
|
2521
|
+
function layoutBarRace(ctx, area, frame) {
|
|
2522
|
+
const { spec, theme, marks, fs, measure } = ctx;
|
|
2523
|
+
const top = spec.raceTopN;
|
|
2524
|
+
const moment = chartRaceMoment(spec.categories.length, frame);
|
|
2525
|
+
const ranking = chartRaceRanking(spec, frame);
|
|
2526
|
+
const shown = ranking.filter((e) => e.position < top);
|
|
2527
|
+
const labelW = Math.min(area.width * 0.3, Math.max(0, ...ranking.map((e) => measure(e.name, fs)))) + 8;
|
|
2528
|
+
const tickH = spec.yAxis.show ? fs * 1.6 : 4;
|
|
2529
|
+
const plot = { x: area.x + labelW, y: area.y + tickH, width: Math.max(1, area.width - labelW - fs * 4), height: Math.max(1, area.height - tickH) };
|
|
2530
|
+
const lead = Math.max(1e-9, ...shown.map((e) => e.value));
|
|
2531
|
+
const max = spec.yAxis.max !== null && spec.yAxis.max > 0 ? spec.yAxis.max : lead * 1.08;
|
|
2532
|
+
const xOf = (v) => plot.x + Math.max(0, Math.min(max, v)) / max * plot.width;
|
|
2533
|
+
const ticks = niceScale(0, max, 5).ticks.filter((t) => t <= max);
|
|
2534
|
+
const axisTarget = { kind: "axis", axis: "y" };
|
|
2535
|
+
const format = spec.yAxis.format;
|
|
2536
|
+
ticks.forEach((t, k) => {
|
|
2537
|
+
if (spec.yAxis.gridlines) marks.push({ kind: "line", key: `grid-y-${k}`, role: "grid", x1: xOf(t), y1: plot.y, x2: xOf(t), y2: plot.y + plot.height, stroke: theme.grid, strokeWidth: 1 });
|
|
2538
|
+
if (spec.yAxis.show) marks.push({ kind: "text", key: `tick-y-${k}`, role: "tick-label", x: xOf(t), y: area.y, text: formatChartNumber(t, format, _nullishCoalesce(format.decimals, () => ( stepDecimals(ticks[1] - ticks[0] || 1)))), anchor: "middle", baseline: "top", size: fs - 1, fill: theme.mutedText, target: axisTarget });
|
|
2539
|
+
});
|
|
2540
|
+
const label = _nullishCoalesce(spec.categories[moment.t < 0.5 ? moment.from : moment.to], () => ( ""));
|
|
2541
|
+
const timeSize = Math.min(theme.titleSize * 3, plot.height * 0.2, plot.width * 0.5 / Math.max(1, label.length * 0.6));
|
|
2542
|
+
marks.push({ kind: "text", key: "race-time", role: "race-time", x: plot.x + plot.width, y: plot.y + plot.height - 4, text: label, anchor: "end", baseline: "bottom", size: timeSize, weight: 700, fill: theme.mutedText, opacity: 0.55, target: { kind: "category", index: moment.t < 0.5 ? moment.from : moment.to } });
|
|
2543
|
+
const band = plot.height / top;
|
|
2544
|
+
const barH = Math.max(2, band * (1 - Math.min(0.8, spec.gapWidth)));
|
|
2545
|
+
const index = Math.round(moment.at);
|
|
2546
|
+
for (const e of shown) {
|
|
2547
|
+
const si = spec.series.findIndex((s2) => s2.id === e.seriesId);
|
|
2548
|
+
const s = spec.series[si];
|
|
2549
|
+
const y = plot.y + e.position * band + (band - barH) / 2;
|
|
2550
|
+
const target = { kind: "point", seriesId: e.seriesId, index };
|
|
2551
|
+
const selected = ctx.isSelected(target) || ctx.seriesSelected(e.seriesId);
|
|
2552
|
+
const width = Math.max(0, xOf(e.value) - plot.x);
|
|
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 } : {} });
|
|
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 } });
|
|
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 });
|
|
2556
|
+
}
|
|
2557
|
+
if (ranking.length > top) ctx.warn("values-skipped", `The race shows the top ${top} of ${ranking.length} names at each moment (raceTopN).`);
|
|
2558
|
+
return { plot, valueScale: { axis: "x", domain: [0, max], range: [plot.x, plot.x + plot.width], ticks } };
|
|
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
|
+
}
|
|
2444
2620
|
|
|
2445
2621
|
// src/chart/layout.ts
|
|
2446
2622
|
function legendItems(spec, ctx) {
|
|
2447
|
-
const family =
|
|
2448
|
-
if (spec.type === "funnel" || spec.type === "slope" || spec.type === "sankey") return [];
|
|
2449
|
-
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)) {
|
|
2450
2626
|
const first = spec.series.find((s) => !s.hidden);
|
|
2451
|
-
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))));
|
|
2452
2628
|
return spec.categories.map((c, i) => ({
|
|
2453
2629
|
label: spec.type === "parliament" ? `${c} ${seats(i)}` : c,
|
|
2454
|
-
color: _optionalChain([first, 'optionalAccess',
|
|
2630
|
+
color: _optionalChain([first, 'optionalAccess', _70 => _70.pointColors, 'optionalAccess', _71 => _71[i]]) || _chunkOUO3DSRTcjs.chartSliceColor.call(void 0, spec, i),
|
|
2455
2631
|
target: { kind: "category", index: i },
|
|
2456
2632
|
faded: false,
|
|
2457
2633
|
selected: ctx.isSelected({ kind: "category", index: i }),
|
|
@@ -2465,17 +2641,17 @@ function legendItems(spec, ctx) {
|
|
|
2465
2641
|
return [
|
|
2466
2642
|
{ label: "Increase", color: ctx.theme.positive, target, faded: false, selected: false, shape: "square" },
|
|
2467
2643
|
{ label: "Decrease", color: ctx.theme.negative, target, faded: false, selected: false, shape: "square" },
|
|
2468
|
-
{ label: "Total", color:
|
|
2644
|
+
{ label: "Total", color: _chunkOUO3DSRTcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(first)), target, faded: false, selected: false, shape: "square" }
|
|
2469
2645
|
];
|
|
2470
2646
|
}
|
|
2471
2647
|
if (family === "box") return [];
|
|
2472
|
-
const trends = trendlineLegendItems(spec, (i) =>
|
|
2648
|
+
const trends = trendlineLegendItems(spec, (i) => _chunkOUO3DSRTcjs.chartSeriesColor.call(void 0, spec, i));
|
|
2473
2649
|
const items = [];
|
|
2474
2650
|
spec.series.forEach((s, i) => {
|
|
2475
|
-
const type =
|
|
2651
|
+
const type = _chunkOUO3DSRTcjs.chartSeriesType.call(void 0, spec, s);
|
|
2476
2652
|
items.push({
|
|
2477
2653
|
label: s.name,
|
|
2478
|
-
color:
|
|
2654
|
+
color: _chunkOUO3DSRTcjs.chartSeriesColor.call(void 0, spec, i),
|
|
2479
2655
|
target: { kind: "series", seriesId: s.id },
|
|
2480
2656
|
faded: !!s.hidden,
|
|
2481
2657
|
selected: ctx.seriesSelected(s.id),
|
|
@@ -2488,7 +2664,7 @@ function legendItems(spec, ctx) {
|
|
|
2488
2664
|
function layoutChart(spec, options) {
|
|
2489
2665
|
const width = Math.max(1, Number.isFinite(options.width) ? options.width : 1);
|
|
2490
2666
|
const height = Math.max(1, Number.isFinite(options.height) ? options.height : 1);
|
|
2491
|
-
const theme = { ...
|
|
2667
|
+
const theme = { ..._chunkOUO3DSRTcjs.DEFAULT_CHART_THEME, ...options.theme };
|
|
2492
2668
|
const selection = _nullishCoalesce(options.selection, () => ( null));
|
|
2493
2669
|
const marks = [];
|
|
2494
2670
|
const warnings = [];
|
|
@@ -2504,7 +2680,7 @@ function layoutChart(spec, options) {
|
|
|
2504
2680
|
warnings,
|
|
2505
2681
|
selection,
|
|
2506
2682
|
isSelected: (target) => sameChartSelection(selection, target),
|
|
2507
|
-
seriesSelected: (id) => _optionalChain([selection, 'optionalAccess',
|
|
2683
|
+
seriesSelected: (id) => _optionalChain([selection, 'optionalAccess', _72 => _72.kind]) === "series" && selection.seriesId === id,
|
|
2508
2684
|
outline: (key, box) => marks.push({ kind: "rect", key, role: "selection", ...box, fill: "none", stroke: theme.selection, strokeWidth: 1, radius: 3 }),
|
|
2509
2685
|
warn: (code, message) => {
|
|
2510
2686
|
if (!warnings.some((w) => w.code === code && w.message === message)) warnings.push({ code, message });
|
|
@@ -2527,17 +2703,17 @@ function layoutChart(spec, options) {
|
|
|
2527
2703
|
if (spec.title) titleMark("title", spec.title, theme.titleSize, 600, theme.text);
|
|
2528
2704
|
if (spec.subtitle) titleMark("subtitle", spec.subtitle, fs + 1, 400, theme.mutedText);
|
|
2529
2705
|
if (spec.title || spec.subtitle) top += 6;
|
|
2530
|
-
const family =
|
|
2706
|
+
const family = _chunkOUO3DSRTcjs.chartFamily.call(void 0, spec);
|
|
2531
2707
|
const visible = spec.series.filter((s) => !s.hidden);
|
|
2532
2708
|
const items = legendItems(spec, ctx);
|
|
2533
2709
|
let area = { x: pad, y: top, width: width - pad * 2, height: height - top - pad - noteHeight(spec, fs) };
|
|
2534
2710
|
const seriesLegend = family === "cartesian" || family === "xy" || family === "radar" || family === "histogram";
|
|
2535
2711
|
const hasTrend = items.some((i) => i.shape === "dash");
|
|
2536
|
-
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);
|
|
2537
2713
|
if (showLegend) area = layoutLegend(items, spec.legend.position, area, ctx, ctx.isSelected({ kind: "legend" }));
|
|
2538
2714
|
const finish = (result) => {
|
|
2539
2715
|
if (result.plot.width > 0) {
|
|
2540
|
-
if (chartAnnotationFamily(
|
|
2716
|
+
if (chartAnnotationFamily(_chunkOUO3DSRTcjs.chartFamily.call(void 0, spec))) drawCallouts(ctx, result.plot);
|
|
2541
2717
|
else if (spec.referenceLines.length || spec.referenceBands.length || spec.series.some((s) => s.callouts))
|
|
2542
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.`);
|
|
2543
2719
|
}
|
|
@@ -2585,6 +2761,20 @@ function layoutChart(spec, options) {
|
|
|
2585
2761
|
return finish(layoutFunnel(ctx, area, visible[0]));
|
|
2586
2762
|
case "treemap":
|
|
2587
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
|
+
}
|
|
2776
|
+
case "barrace":
|
|
2777
|
+
return finish(layoutBarRace(ctx, area, options.raceFrame));
|
|
2588
2778
|
case "sankey":
|
|
2589
2779
|
if (!spec.links.length) {
|
|
2590
2780
|
ctx.warn("type-fallback", "A Sankey diagram needs flows (set_chart_links); it is drawn as a bar chart until then.");
|
|
@@ -2686,9 +2876,9 @@ function layoutLegend(items, position, area, ctx, legendSelected) {
|
|
|
2686
2876
|
function addReadout(ctx, readout, plot) {
|
|
2687
2877
|
const { spec, marks, theme, fs, measure } = ctx;
|
|
2688
2878
|
const series = spec.series.find((s) => s.id === readout.seriesId);
|
|
2689
|
-
const value = _optionalChain([series, 'optionalAccess',
|
|
2879
|
+
const value = _optionalChain([series, 'optionalAccess', _73 => _73.values, 'access', _74 => _74[readout.index]]);
|
|
2690
2880
|
if (!series || value === null || value === void 0) return;
|
|
2691
|
-
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);
|
|
2692
2882
|
if (!mark) return;
|
|
2693
2883
|
let ax;
|
|
2694
2884
|
let ay;
|
|
@@ -2700,8 +2890,8 @@ function addReadout(ctx, readout, plot) {
|
|
|
2700
2890
|
ay = mark.cy - mark.r;
|
|
2701
2891
|
} else return;
|
|
2702
2892
|
const axis = series.axis === "secondary" ? spec.yAxis2 : spec.yAxis;
|
|
2703
|
-
const x = _optionalChain([series, 'access',
|
|
2704
|
-
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)))}`;
|
|
2705
2895
|
const w = measure(text, fs, 600) + 10;
|
|
2706
2896
|
const h = fs + 8;
|
|
2707
2897
|
const bx = Math.max(plot.x, Math.min(plot.x + plot.width - w, ax - w / 2));
|
|
@@ -2750,7 +2940,7 @@ function chartXAtPoint(scene, point) {
|
|
|
2750
2940
|
if (!scale) return void 0;
|
|
2751
2941
|
return chartScaleFromPixel(point.x, scale);
|
|
2752
2942
|
}
|
|
2753
|
-
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) {
|
|
2754
2944
|
if (logBase && step === void 0) return value > 0 && Number.isFinite(value) ? Number(value.toPrecision(2)) : value;
|
|
2755
2945
|
const unit = _nullishCoalesce(step, () => ( (ticks.length > 1 ? (ticks[1] - ticks[0]) / 10 : 1)));
|
|
2756
2946
|
if (!(unit > 0)) return value;
|
|
@@ -2798,4 +2988,14 @@ function snapChartValue(scene, value, step, ticks = _nullishCoalesce(_optionalCh
|
|
|
2798
2988
|
|
|
2799
2989
|
|
|
2800
2990
|
|
|
2801
|
-
|
|
2991
|
+
|
|
2992
|
+
|
|
2993
|
+
|
|
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";
|
package/dist/export/index.cjs
CHANGED
|
@@ -12,14 +12,14 @@
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkE45AIIWYcjs = require('../chunk-E45AIIWY.cjs');
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
var _chunkJLWLX52Lcjs = require('../chunk-JLWLX52L.cjs');
|
|
20
20
|
require('../chunk-YN6JKAUE.cjs');
|
|
21
|
-
require('../chunk-
|
|
22
|
-
require('../chunk-
|
|
21
|
+
require('../chunk-VKHJJUBK.cjs');
|
|
22
|
+
require('../chunk-OUO3DSRT.cjs');
|
|
23
23
|
require('../chunk-ALNIFK5G.cjs');
|
|
24
24
|
require('../chunk-2BSBFBOA.cjs');
|
|
25
25
|
require('../chunk-EUIDTZNQ.cjs');
|
|
@@ -42,4 +42,4 @@ require('../chunk-IPJ3TEYR.cjs');
|
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
|
|
45
|
-
exports.DOCX_ANONYMOUS_AUTHOR =
|
|
45
|
+
exports.DOCX_ANONYMOUS_AUTHOR = _chunkE45AIIWYcjs.DOCX_ANONYMOUS_AUTHOR; exports.DOCX_EXPORT_MIME_TYPE = _chunkE45AIIWYcjs.DOCX_EXPORT_MIME_TYPE; exports.DocxExportController = _chunkE45AIIWYcjs.DocxExportController; exports.XmlWriter = _chunkE45AIIWYcjs.XmlWriter; exports.createDocxExportController = _chunkE45AIIWYcjs.createDocxExportController; exports.createDocxParts = _chunkE45AIIWYcjs.createDocxParts; exports.deflateRaw = _chunkJLWLX52Lcjs.deflateRaw; exports.docxFileName = _chunkE45AIIWYcjs.docxFileName; exports.downloadBlob = _chunkE45AIIWYcjs.downloadBlob; exports.escapeXmlAttr = _chunkE45AIIWYcjs.escapeXmlAttr; exports.escapeXmlText = _chunkE45AIIWYcjs.escapeXmlText; exports.exportDocx = _chunkE45AIIWYcjs.exportDocx; exports.exportDocxBlob = _chunkE45AIIWYcjs.exportDocxBlob; exports.stripInvalidXmlChars = _chunkE45AIIWYcjs.stripInvalidXmlChars; exports.writeZip = _chunkJLWLX52Lcjs.writeZip;
|
package/dist/export/index.js
CHANGED
|
@@ -12,14 +12,14 @@ import {
|
|
|
12
12
|
exportDocx,
|
|
13
13
|
exportDocxBlob,
|
|
14
14
|
stripInvalidXmlChars
|
|
15
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-FKYGM35R.js";
|
|
16
16
|
import {
|
|
17
17
|
deflateRaw,
|
|
18
18
|
writeZip
|
|
19
19
|
} from "../chunk-AZCODQO5.js";
|
|
20
20
|
import "../chunk-CXXKJBQZ.js";
|
|
21
|
-
import "../chunk-
|
|
22
|
-
import "../chunk-
|
|
21
|
+
import "../chunk-OLCHKGGO.js";
|
|
22
|
+
import "../chunk-ORZF4JOO.js";
|
|
23
23
|
import "../chunk-CIQIM2IP.js";
|
|
24
24
|
import "../chunk-HF5QZS7Z.js";
|
|
25
25
|
import "../chunk-7272D3K2.js";
|