@blueprint-chart/lib 2.0.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/charts/axis/axis-service.d.ts +9 -0
- package/dist/charts/legend/legend-size.d.ts +13 -0
- package/dist/charts/plugins/annotations/shared.d.ts +13 -2
- package/dist/charts/plugins/arc-labels.d.ts +10 -1
- package/dist/charts/scale-helpers.d.ts +1 -1
- package/dist/charts/text-measure.d.ts +25 -0
- package/dist/charts/value-label-fit.d.ts +5 -0
- package/dist/embed.js +1 -1
- package/dist/enums.d.ts +18 -0
- package/dist/index.js +161 -157
- package/dist/lib/lib.iife.js +65 -15
- package/dist/node-backend/index.js +2065 -1928
- package/dist/{render-bpc-BWiUALXY.js → render-bpc-C4y50x4-.js} +2176 -2035
- package/dist/runtime/chart-css.d.ts +1 -1
- package/dist/runtime-gzeMNwqx.js +84 -0
- package/dist/runtime.js +2 -2
- package/dist/transforms/table.d.ts +0 -1
- package/package.json +1 -1
- package/src/charts/chart.scss +21 -0
- package/dist/runtime-DDhsXDn5.js +0 -84
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { $ as e, A as t, At as n, B as r, Bt as i, C as a, Ct as o, D as s, Dt as c, E as l, Et as u, F as d, Ft as f, G as p, Gt as m, H as h, Ht as
|
|
2
|
-
import { t as
|
|
3
|
-
import
|
|
1
|
+
import { $ as e, A as t, At as n, B as r, Bt as i, C as a, Ct as o, D as s, Dt as c, E as l, Et as u, F as d, Ft as f, G as p, Gt as m, H as h, Ht as g, I as _, It as v, J as y, Jt as ee, K as te, Kt as ne, L as re, Lt as ie, M as ae, Mt as oe, N as se, Nt as ce, O as le, Ot as ue, P as b, Pt as de, Q as fe, R as pe, Rt as me, S as he, St as ge, T as _e, Tt as ve, U as x, Ut as ye, V as be, Vt as xe, W as Se, Wt as Ce, X as we, Xt as Te, Y as Ee, Yt as De, Z as Oe, Zt as ke, _ as Ae, _t as je, a as Me, at as Ne, b as Pe, bt as S, c as Fe, ct as Ie, d as Le, dt as Re, et as ze, f as Be, ft as Ve, g as He, gt as Ue, h as We, ht as Ge, i as Ke, it as qe, j as Je, jt as Ye, k as Xe, kt as Ze, l as Qe, lt as $e, m as et, mt as tt, n as nt, nt as rt, o as it, ot as at, p as ot, pt as st, q as ct, qt as lt, r as ut, rt as dt, s as ft, st as pt, t as mt, tt as ht, u as gt, ut as _t, v as vt, vt as yt, w as bt, wt as xt, x as St, xt as Ct, y as wt, yt as Tt, z as C, zt as Et } from "./render-bpc-C4y50x4-.js";
|
|
2
|
+
import { t as Dt } from "./runtime-gzeMNwqx.js";
|
|
3
|
+
import w from "chroma-js";
|
|
4
4
|
//#region src/recommendations/intent.ts
|
|
5
|
-
var
|
|
5
|
+
var Ot = [
|
|
6
6
|
{
|
|
7
7
|
intent: "range",
|
|
8
8
|
pattern: /\b(range|high and low|high\/low|margin of error|confidence interval|confidence|interval|plus or minus|spread between)\b/i
|
|
@@ -28,86 +28,86 @@ var Dt = [
|
|
|
28
28
|
pattern: /\b(compares?|compared|comparison|versus|vs\.?|more than|difference between|across|than)\b/i
|
|
29
29
|
}
|
|
30
30
|
];
|
|
31
|
-
function
|
|
31
|
+
function T(e) {
|
|
32
32
|
if (e === void 0 || e.trim() === "") return "none";
|
|
33
|
-
for (let t of
|
|
33
|
+
for (let t of Ot) if (t.pattern.test(e)) return t.intent;
|
|
34
34
|
return "none";
|
|
35
35
|
}
|
|
36
36
|
//#endregion
|
|
37
37
|
//#region src/recommendations/decisionTable.ts
|
|
38
|
-
var
|
|
38
|
+
var E = (e, t, n) => ({
|
|
39
39
|
type: e,
|
|
40
40
|
fitness: t,
|
|
41
41
|
reason: n
|
|
42
|
-
}),
|
|
42
|
+
}), D = {
|
|
43
43
|
"1cat+1num": {
|
|
44
44
|
none: (e) => {
|
|
45
|
-
let t = [
|
|
46
|
-
return e <= 8 && (t.push(
|
|
45
|
+
let t = [E("bar-vertical", "best", "1 categorical + 1 numeric — classic bar chart"), E("bar-horizontal", "good", "Horizontal bars work well for long labels")];
|
|
46
|
+
return e <= 8 && (t.push(E("donut", "good", `${e} items — suitable for part-of-whole`)), t.push(E("pie", "alternative", "Pie chart for part-of-whole"))), t;
|
|
47
47
|
},
|
|
48
|
-
comparison: (e) =>
|
|
49
|
-
ranking: () => [
|
|
48
|
+
comparison: (e) => D["1cat+1num"].none(e),
|
|
49
|
+
ranking: () => [E("bar-horizontal", "best", "Ranked categories read best as horizontal bars"), E("bar-vertical", "good", "Vertical bars also work for ranking")],
|
|
50
50
|
"part-to-whole": (e) => e <= 5 ? [
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
E("pie", "best", `${e} slices — pie reads cleanly for very small N`),
|
|
52
|
+
E("donut", "good", "Donut for part-of-whole with a center label"),
|
|
53
|
+
E("bar-vertical", "alternative", "Bars if precise comparison matters")
|
|
54
54
|
] : e <= 8 ? [
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
] : [
|
|
59
|
-
range: () => [
|
|
55
|
+
E("donut", "best", `${e} slices — donut for part-of-whole`),
|
|
56
|
+
E("pie", "good", "Pie for part-of-whole"),
|
|
57
|
+
E("bar-vertical", "alternative", "Bars if precise comparison matters")
|
|
58
|
+
] : [E("bar-vertical", "best", `${e} categories — too many for a readable pie`), E("bar-horizontal", "good", "Horizontal bars for long labels")],
|
|
59
|
+
range: () => [E("bar-vertical", "best", "A single numeric column carries no range — plain bars read the value directly"), E("bar-horizontal", "good", "Horizontal bars work well for long labels")]
|
|
60
60
|
},
|
|
61
61
|
"1cat+Nnum": {
|
|
62
|
-
none: () => [
|
|
63
|
-
comparison: (e) =>
|
|
64
|
-
ranking: (e) =>
|
|
65
|
-
trend: () => [
|
|
62
|
+
none: () => [E("bar-multi", "best", "1 categorical + multiple numeric columns — compare groups"), E("line-multi", "good", "Can also show as a multi-line chart")],
|
|
63
|
+
comparison: (e) => D["1cat+Nnum"].none(e),
|
|
64
|
+
ranking: (e) => D["1cat+Nnum"].none(e),
|
|
65
|
+
trend: () => [E("line-multi", "best", "A trend or crossover story reads best as lines, even over categorical periods"), E("bar-multi", "alternative", "Grouped bars if per-period comparison matters more than the trend")],
|
|
66
66
|
"part-to-whole": () => [
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
E("bar-stacked", "best", "Stacked bars show composition within each category"),
|
|
68
|
+
E("column-stacked", "good", "Stacked columns for the same composition"),
|
|
69
|
+
E("bar-multi", "alternative", "Grouped bars if comparison beats composition")
|
|
70
70
|
],
|
|
71
71
|
"composition-over-time": () => [
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
E("column-stacked", "best", "Stacked columns show composition across discrete periods"),
|
|
73
|
+
E("bar-stacked", "good", "Stacked bars for the same composition"),
|
|
74
|
+
E("area-stacked", "alternative", "Stacked area if the periods are continuous time")
|
|
75
75
|
],
|
|
76
|
-
range: () => [
|
|
76
|
+
range: () => [E("bar-split", "best", "Diverging bars show values around a shared baseline"), E("bar-multi", "alternative", "Grouped bars if there is no shared baseline")]
|
|
77
77
|
},
|
|
78
78
|
"1date+1num": {
|
|
79
|
-
none: () => [
|
|
79
|
+
none: () => [E("line", "best", "1 date + 1 numeric column — ideal for trend"), E("bar-vertical", "alternative", "Can also show as bars")],
|
|
80
80
|
trend: () => [
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
E("line", "best", "1 date + 1 numeric column — ideal for trend"),
|
|
82
|
+
E("area", "good", "Filled area emphasizes magnitude over time"),
|
|
83
|
+
E("bar-vertical", "alternative", "Can also show as bars")
|
|
84
84
|
],
|
|
85
|
-
comparison: () => [
|
|
86
|
-
ranking: () => [
|
|
87
|
-
"part-to-whole": () => [
|
|
88
|
-
"composition-over-time": () => [
|
|
85
|
+
comparison: () => [E("bar-vertical", "best", "Bars for comparing discrete time points"), E("line", "good", "Line if the trend matters more than the comparison")],
|
|
86
|
+
ranking: () => [E("bar-vertical", "best", "Bars for ranking discrete time points"), E("line", "good", "Line for the underlying trend")],
|
|
87
|
+
"part-to-whole": () => [E("area", "best", "Filled area reads as magnitude/share over time"), E("line", "good", "Line for the underlying trend")],
|
|
88
|
+
"composition-over-time": () => [E("area", "best", "Filled area shows magnitude over time"), E("line", "good", "Line for the underlying trend")]
|
|
89
89
|
},
|
|
90
90
|
"1date+Nnum": {
|
|
91
|
-
none: () => [
|
|
92
|
-
trend: (e) =>
|
|
93
|
-
comparison: (e) =>
|
|
94
|
-
ranking: (e) =>
|
|
91
|
+
none: () => [E("line-multi", "best", "1 date + multiple numeric columns — compare trends"), E("bar-multi", "alternative", "Can also show as grouped bars")],
|
|
92
|
+
trend: (e) => D["1date+Nnum"].none(e),
|
|
93
|
+
comparison: (e) => D["1date+Nnum"].none(e),
|
|
94
|
+
ranking: (e) => D["1date+Nnum"].none(e),
|
|
95
95
|
"composition-over-time": () => [
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
E("area-stacked", "best", "Stacked area shows composition over continuous time"),
|
|
97
|
+
E("column-stacked", "good", "Stacked columns for the same composition"),
|
|
98
|
+
E("line-multi", "alternative", "Multi-line if composition is not the point")
|
|
99
99
|
],
|
|
100
|
-
"part-to-whole": () => [
|
|
100
|
+
"part-to-whole": () => [E("area-stacked", "best", "Stacked area shows share over time"), E("line-multi", "good", "Multi-line if absolute trends matter more")]
|
|
101
101
|
},
|
|
102
|
-
other: { none: () => [
|
|
102
|
+
other: { none: () => [E("bar-vertical", "good", "Default bar chart recommendation")] }
|
|
103
103
|
};
|
|
104
|
-
function
|
|
105
|
-
let r =
|
|
106
|
-
return i ? i(n) : [
|
|
104
|
+
function kt(e, t, n) {
|
|
105
|
+
let r = D[e], i = r[t] ?? r.none;
|
|
106
|
+
return i ? i(n) : [E("bar-vertical", "good", "Default bar chart recommendation")];
|
|
107
107
|
}
|
|
108
108
|
//#endregion
|
|
109
109
|
//#region src/recommendations/shape.ts
|
|
110
|
-
function
|
|
110
|
+
function O(e, t) {
|
|
111
111
|
let n = e.filter((e) => e === "string").length, r = e.filter((e) => e === "number").length, i = e.filter((e) => e === "date").length;
|
|
112
112
|
return i === 1 && n === 0 && r >= 1 ? r === 1 ? "1date+1num" : "1date+Nnum" : n === 1 && i === 0 && r >= 1 ? r === 1 ? "1cat+1num" : "1cat+Nnum" : "other";
|
|
113
113
|
}
|
|
@@ -131,7 +131,7 @@ var At = {
|
|
|
131
131
|
//#endregion
|
|
132
132
|
//#region src/recommendations/recommend.ts
|
|
133
133
|
function jt(e, t, n) {
|
|
134
|
-
return e.length === 0 ? [] :
|
|
134
|
+
return e.length === 0 ? [] : kt(O(e, t), T(n), t).map((e) => ({
|
|
135
135
|
chartType: e.type,
|
|
136
136
|
label: At[e.type] ?? e.type,
|
|
137
137
|
fitness: e.fitness,
|
|
@@ -250,8 +250,8 @@ function k(e) {
|
|
|
250
250
|
return e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055;
|
|
251
251
|
}
|
|
252
252
|
function zt(e, t) {
|
|
253
|
-
let [n, r, i] = (
|
|
254
|
-
return
|
|
253
|
+
let [n, r, i] = (w.valid(e) ? w(e) : w("#000")).rgb().map((e) => Rt(e / 255)), a = Ft[t], o = k(a[0] * n + a[1] * r + a[2] * i), s = k(a[5] * n + a[6] * r + a[7] * i), c = k(a[10] * n + a[11] * r + a[12] * i), l = (e) => Math.min(255, Math.max(0, Math.round(e * 255)));
|
|
254
|
+
return w(l(o), l(s), l(c)).hex();
|
|
255
255
|
}
|
|
256
256
|
var Bt = 10;
|
|
257
257
|
function Vt(e) {
|
|
@@ -264,7 +264,7 @@ function Vt(e) {
|
|
|
264
264
|
for (let r of t) {
|
|
265
265
|
let t = e.map((e) => zt(e, r)), i = [];
|
|
266
266
|
for (let n = 0; n < t.length; n++) for (let r = n + 1; r < t.length; r++) {
|
|
267
|
-
let a =
|
|
267
|
+
let a = w.deltaE(t[n], t[r]);
|
|
268
268
|
a < Bt && i.push({
|
|
269
269
|
a: e[n],
|
|
270
270
|
b: e[r],
|
|
@@ -291,10 +291,10 @@ function M(e, t) {
|
|
|
291
291
|
return [...A(e.trailingComments, `${t} `), j(`${t}}`, e.trailingComment)];
|
|
292
292
|
}
|
|
293
293
|
function N(e) {
|
|
294
|
-
return typeof e.value == "number" ? e.isPercentage ? `${e.value}%` : `${e.value}` : typeof e.value == "string" && e.value.startsWith("#") ?
|
|
294
|
+
return typeof e.value == "number" ? e.isPercentage ? `${e.value}%` : `${e.value}` : typeof e.value == "string" && e.value.startsWith("#") ? C(e.value) : typeof e.value == "string" && /^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(e.value) ? e.value : C(String(e.value));
|
|
295
295
|
}
|
|
296
296
|
function Ht(e) {
|
|
297
|
-
return /^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(e) ? e :
|
|
297
|
+
return /^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(e) ? e : C(e);
|
|
298
298
|
}
|
|
299
299
|
function P(e, t) {
|
|
300
300
|
let n = j(`${t}${Ht(e.key)} = ${N(e)}`, e.trailingComment);
|
|
@@ -302,7 +302,7 @@ function P(e, t) {
|
|
|
302
302
|
}
|
|
303
303
|
function Ut(e, t) {
|
|
304
304
|
let n;
|
|
305
|
-
return n = e.key === "series" && e.quotedKey && !(e.values && e.values.length > 1) ? `${t}"series" = ${N(e)}` : e.values && e.values.length > 1 ? `${t}${e.key === "series" && !e.quotedKey ? e.key :
|
|
305
|
+
return n = e.key === "series" && e.quotedKey && !(e.values && e.values.length > 1) ? `${t}"series" = ${N(e)}` : e.values && e.values.length > 1 ? `${t}${e.key === "series" && !e.quotedKey ? e.key : C(e.key)} = ${e.values.map((e) => typeof e == "number" ? `${e}` : C(String(e))).join(",")}` : `${t}${Ht(e.key)} = ${N(e)}`, [...A(e.leadingComments, t), j(n, e.trailingComment)].join("\n");
|
|
306
306
|
}
|
|
307
307
|
function F(e, t) {
|
|
308
308
|
let n = [...A(e.leadingComments, t), `${t}data {`];
|
|
@@ -310,41 +310,41 @@ function F(e, t) {
|
|
|
310
310
|
return n.push(...M(e, t)), n.join("\n");
|
|
311
311
|
}
|
|
312
312
|
function I(e, t) {
|
|
313
|
-
let n = e.fromHighlight ? "highlight" : "colorize", r = [...A(e.leadingComments, t), `${t}${n} ${
|
|
313
|
+
let n = e.fromHighlight ? "highlight" : "colorize", r = [...A(e.leadingComments, t), `${t}${n} ${C(e.target)} {`];
|
|
314
314
|
for (let n of e.properties) r.push(P(n, `${t} `));
|
|
315
315
|
return r.push(...M(e, t)), r.join("\n");
|
|
316
316
|
}
|
|
317
317
|
function L(e, t) {
|
|
318
|
-
return [...A(e.leadingComments, t), j(`${t}highlight ${
|
|
318
|
+
return [...A(e.leadingComments, t), j(`${t}highlight ${C(e.target)}`, e.trailingComment)].join("\n");
|
|
319
319
|
}
|
|
320
320
|
function R(e, t) {
|
|
321
|
-
let n = [...A(e.leadingComments, t), `${t}area-fill ${
|
|
321
|
+
let n = [...A(e.leadingComments, t), `${t}area-fill ${C(e.from)} ${C(e.to)} {`];
|
|
322
322
|
for (let r of e.properties) n.push(P(r, `${t} `));
|
|
323
323
|
return n.push(...M(e, t)), n.join("\n");
|
|
324
324
|
}
|
|
325
325
|
function z(e, t) {
|
|
326
|
-
let n = e.kind ??
|
|
327
|
-
if (n ===
|
|
326
|
+
let n = e.kind ?? S.Point;
|
|
327
|
+
if (n === S.Range) {
|
|
328
328
|
let n = [...A(e.leadingComments, t), `${t}range {`];
|
|
329
329
|
for (let r of e.properties) n.push(P(r, `${t} `));
|
|
330
330
|
return n.push(...M(e, t)), n.join("\n");
|
|
331
331
|
}
|
|
332
|
-
if (n ===
|
|
332
|
+
if (n === S.Free) {
|
|
333
333
|
let n = [...A(e.leadingComments, t), `${t}note {`];
|
|
334
334
|
for (let r of e.properties) n.push(P(r, `${t} `));
|
|
335
335
|
return n.push(...M(e, t)), n.join("\n");
|
|
336
336
|
}
|
|
337
|
-
let r = "target" in e ? e.target : "", i = [...A(e.leadingComments, t), `${t}annotation ${
|
|
337
|
+
let r = "target" in e ? e.target : "", i = [...A(e.leadingComments, t), `${t}annotation ${C(r)} {`];
|
|
338
338
|
for (let n of e.properties) i.push(P(n, `${t} `));
|
|
339
339
|
return i.push(...M(e, t)), i.join("\n");
|
|
340
340
|
}
|
|
341
341
|
function B(e, t) {
|
|
342
|
-
let n = [...A(e.leadingComments, t), `${t}series ${
|
|
342
|
+
let n = [...A(e.leadingComments, t), `${t}series ${C(e.name)} {`];
|
|
343
343
|
for (let r of e.properties) n.push(P(r, `${t} `));
|
|
344
344
|
return n.push(...M(e, t)), n.join("\n");
|
|
345
345
|
}
|
|
346
346
|
function Wt(e, t) {
|
|
347
|
-
let n = e.name == null ? `${t}scene {` : `${t}scene ${
|
|
347
|
+
let n = e.name == null ? `${t}scene {` : `${t}scene ${C(e.name)} {`, r = [...A(e.leadingComments, t), n];
|
|
348
348
|
for (let n of e.properties) r.push(P(n, `${t} `));
|
|
349
349
|
e.data && r.push(F(e.data, `${t} `));
|
|
350
350
|
for (let n of e.colorizes) r.push(I(n, `${t} `));
|
|
@@ -385,12 +385,12 @@ function H(e, t, n, r) {
|
|
|
385
385
|
return i ? r.has(e) ? String(r.get(e)) === String(t) : i.default !== void 0 && String(i.default) === String(t) : !1;
|
|
386
386
|
}
|
|
387
387
|
function Jt(e, t, n, r) {
|
|
388
|
-
let i = [...A(e.leadingComments, t), `${t}series ${
|
|
388
|
+
let i = [...A(e.leadingComments, t), `${t}series ${C(e.name)} {`];
|
|
389
389
|
for (let a of e.properties) (a.isPercentage || !H(a.key, a.value, n, r)) && i.push(P(a, `${t} `));
|
|
390
390
|
return i.push(...M(e, t)), i.join("\n");
|
|
391
391
|
}
|
|
392
392
|
function Yt(e, t, n, r) {
|
|
393
|
-
let i = e.properties.find((e) => e.key === "type"), a = i ? String(i.value) : n, o = e.name == null ? `${t}scene {` : `${t}scene ${
|
|
393
|
+
let i = e.properties.find((e) => e.key === "type"), a = i ? String(i.value) : n, o = e.name == null ? `${t}scene {` : `${t}scene ${C(e.name)} {`, s = [...A(e.leadingComments, t), o], c = new Map(r);
|
|
394
394
|
for (let n of e.properties) {
|
|
395
395
|
if (n.key === "type") {
|
|
396
396
|
s.push(P(n, `${t} `));
|
|
@@ -473,6 +473,7 @@ var Qt = /* @__PURE__ */ new Set([
|
|
|
473
473
|
]]
|
|
474
474
|
]), en = /* @__PURE__ */ new Set([
|
|
475
475
|
"lineSymbolSize",
|
|
476
|
+
"circleSize",
|
|
476
477
|
"fixedHeight",
|
|
477
478
|
"fixedWidth",
|
|
478
479
|
"maxWidth"
|
|
@@ -597,7 +598,7 @@ function un(e, t, n, r) {
|
|
|
597
598
|
G(e.key, i, t, n, r);
|
|
598
599
|
}
|
|
599
600
|
}
|
|
600
|
-
function
|
|
601
|
+
function dn(e, t, n, r) {
|
|
601
602
|
let i = h(e), a = /* @__PURE__ */ new Set([...i.map((e) => e.key), ...Qt]);
|
|
602
603
|
for (let o of t) {
|
|
603
604
|
let t = `${n}.${o.key}`;
|
|
@@ -617,22 +618,25 @@ function K(e, t, n, r) {
|
|
|
617
618
|
un(c, o, t, r);
|
|
618
619
|
}
|
|
619
620
|
}
|
|
620
|
-
function dn(e) {
|
|
621
|
-
return e === x.Range ? an : e === x.Free ? on : tn;
|
|
622
|
-
}
|
|
623
621
|
function fn(e) {
|
|
624
|
-
return
|
|
622
|
+
return e === S.Range ? an : e === S.Free ? on : tn;
|
|
625
623
|
}
|
|
626
|
-
function pn(e
|
|
624
|
+
function pn(e) {
|
|
625
|
+
return yt[e];
|
|
626
|
+
}
|
|
627
|
+
function mn(e, t, n) {
|
|
627
628
|
e.forEach((e, r) => {
|
|
628
|
-
let i = e.kind ??
|
|
629
|
-
for (let i of e.properties)
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
629
|
+
let i = e.kind ?? S.Point, a = fn(i), o = pn(i);
|
|
630
|
+
for (let i of e.properties) {
|
|
631
|
+
let e = `${t}.${o}[${r}].${i.key}`;
|
|
632
|
+
ln(i, e, n), !a.has(i.key) && n.push({
|
|
633
|
+
code: "unknown-annotation-property",
|
|
634
|
+
path: e,
|
|
635
|
+
message: `Unknown ${o} property "${i.key}"; it will be silently ignored.`,
|
|
636
|
+
suggestion: W(i.key, a)
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
let s = ae(e.properties).get("repeat");
|
|
636
640
|
if (s !== void 0) {
|
|
637
641
|
let e = String(s).toLowerCase();
|
|
638
642
|
e === "true" || e === "false" || typeof s == "number" && Number.isInteger(s) && s >= 1 || n.push({
|
|
@@ -643,7 +647,7 @@ function pn(e, t, n) {
|
|
|
643
647
|
}
|
|
644
648
|
});
|
|
645
649
|
}
|
|
646
|
-
function
|
|
650
|
+
function hn(e, t, n, r) {
|
|
647
651
|
let i = h(e);
|
|
648
652
|
t.forEach((e, t) => {
|
|
649
653
|
for (let a of e.properties) {
|
|
@@ -662,7 +666,7 @@ function mn(e, t, n, r) {
|
|
|
662
666
|
}
|
|
663
667
|
});
|
|
664
668
|
}
|
|
665
|
-
function
|
|
669
|
+
function gn(e, t, n) {
|
|
666
670
|
e.forEach((e, r) => {
|
|
667
671
|
U.has(e.transformType) || n.push({
|
|
668
672
|
code: "unknown-transform",
|
|
@@ -672,7 +676,7 @@ function hn(e, t, n) {
|
|
|
672
676
|
});
|
|
673
677
|
});
|
|
674
678
|
}
|
|
675
|
-
function
|
|
679
|
+
function _n(e) {
|
|
676
680
|
let t = /* @__PURE__ */ new Set();
|
|
677
681
|
for (let n of [e.data, ...e.scenes.map((e) => e.data)]) for (let e of n?.entries ?? []) {
|
|
678
682
|
if (e.key === "series" && !e.quotedKey) {
|
|
@@ -683,8 +687,8 @@ function gn(e) {
|
|
|
683
687
|
}
|
|
684
688
|
return t;
|
|
685
689
|
}
|
|
686
|
-
function
|
|
687
|
-
let n =
|
|
690
|
+
function vn(e, t) {
|
|
691
|
+
let n = _n(e);
|
|
688
692
|
if (n.size === 0) return;
|
|
689
693
|
let r = [
|
|
690
694
|
{
|
|
@@ -716,28 +720,28 @@ function _n(e, t) {
|
|
|
716
720
|
});
|
|
717
721
|
});
|
|
718
722
|
}
|
|
719
|
-
function
|
|
720
|
-
let t = [], n = [], r =
|
|
723
|
+
function yn(e) {
|
|
724
|
+
let t = [], n = [], r = x(), i = r.includes(e.chartType);
|
|
721
725
|
i || t.push({
|
|
722
726
|
code: "unknown-chart-type",
|
|
723
727
|
path: "chartType",
|
|
724
728
|
message: `Unknown chart type "${e.chartType}".`,
|
|
725
729
|
suggestion: W(e.chartType, r)
|
|
726
|
-
}), i &&
|
|
730
|
+
}), i && dn(e.chartType, e.properties, "chart", t), gn(e.transforms, "chart", t), mn(e.annotations, "chart", t), i && hn(e.chartType, e.series, "chart", t);
|
|
727
731
|
let a = !!e.data && e.data.entries.length > 0, o = e.scenes.some((e) => !!e.data && e.data.entries.length > 0);
|
|
728
732
|
return !a && !o && t.push({
|
|
729
733
|
code: "missing-data",
|
|
730
734
|
path: "data",
|
|
731
735
|
message: e.data && e.data.entries.length === 0 ? "Data block is empty." : "Chart has no data."
|
|
732
|
-
}), e.data &&
|
|
733
|
-
|
|
736
|
+
}), e.data && bn(e.data.entries, n), e.data && xn(e.data.entries, n), vn(e, n), e.scenes.forEach((n, r) => {
|
|
737
|
+
Sn(n, e.chartType, r, t);
|
|
734
738
|
}), {
|
|
735
739
|
valid: t.length === 0,
|
|
736
740
|
errors: t,
|
|
737
741
|
warnings: n
|
|
738
742
|
};
|
|
739
743
|
}
|
|
740
|
-
function
|
|
744
|
+
function bn(e, t) {
|
|
741
745
|
let n = e.findIndex((e) => e.key === "series" && !e.quotedKey);
|
|
742
746
|
if (n === -1) return;
|
|
743
747
|
let r = e[n], i = r.values ?? [r.value];
|
|
@@ -753,7 +757,7 @@ function yn(e, t) {
|
|
|
753
757
|
suggestion: "Move the series row to the top of the data block."
|
|
754
758
|
});
|
|
755
759
|
}
|
|
756
|
-
function
|
|
760
|
+
function xn(e, t) {
|
|
757
761
|
let n = /* @__PURE__ */ new Map();
|
|
758
762
|
for (let t of e) t.key === "series" && !t.quotedKey || n.set(t.key, (n.get(t.key) ?? 0) + 1);
|
|
759
763
|
for (let [e, r] of n) r > 1 && t.push({
|
|
@@ -763,25 +767,25 @@ function bn(e, t) {
|
|
|
763
767
|
suggestion: `"${e} (2)"`
|
|
764
768
|
});
|
|
765
769
|
}
|
|
766
|
-
function
|
|
770
|
+
function Sn(e, t, n, r) {
|
|
767
771
|
let i = `scene[${n}]`, a = e.properties.find((e) => e.key === "type")?.value, o = a == null ? t : String(a);
|
|
768
|
-
a != null && !
|
|
772
|
+
a != null && !x().includes(o) ? r.push({
|
|
769
773
|
code: "unknown-chart-type",
|
|
770
774
|
path: `${i}.type`,
|
|
771
775
|
message: `Unknown chart type "${o}".`,
|
|
772
|
-
suggestion: W(o,
|
|
773
|
-
}) : (
|
|
776
|
+
suggestion: W(o, x())
|
|
777
|
+
}) : (dn(o, e.properties, i, r), hn(o, e.series, i, r)), gn(e.transforms, i, r), mn(e.annotations, i, r);
|
|
774
778
|
}
|
|
775
779
|
//#endregion
|
|
776
780
|
//#region src/samples/letter-frequency.bpc?raw
|
|
777
|
-
var Sn = "chart bar-vertical {\n title = \"E is the most frequent letter in English\"\n description = \"How often each letter appears in typical English text\"\n byline = \"Pierre Romera\"\n source = \"Lewand, Cryptological Mathematics\"\n sourceUrl = \"https://en.wikipedia.org/wiki/Letter_frequency\"\n note = \"Based on analysis of 40,000 words from English prose\"\n colorPalette = \"London\"\n sort = descending\n\n highlight \"E\"\n\n data {\n \"E\" = 12.70\n \"T\" = 9.06\n \"A\" = 8.17\n \"O\" = 7.51\n \"I\" = 6.97\n \"N\" = 6.75\n \"S\" = 6.33\n \"H\" = 6.09\n \"R\" = 5.99\n \"D\" = 4.25\n }\n}\n", Cn = "chart bar-vertical {\n // the headline above the chart\n title = \"China emits more CO₂ than the US and India combined\"\n description = \"Annual emissions in billion tonnes, 2023\"\n source = \"Our World in Data\"\n sourceUrl = \"https://ourworldindata.org/co2-emissions\"\n\n // one row per country: \"label\" = value\n data {\n \"China\" = 12.17\n \"United States\" = 4.92\n \"India\" = 3.06\n \"Russia\" = 1.73\n \"Japan\" = 0.99\n \"Germany\" = 0.59\n }\n\n // highlight pops one bar in the accent color\n highlight \"China\"\n\n // an annotation points a callout at a single bar\n annotation \"India\" {\n text = \"Surpassed EU in 2023\"\n showLine = true\n anchorDirection = N\n textOffsetX = 66\n textOffsetY = -41\n lineStyle = curve-left\n showArrow = true\n lineTargetDistance = 26\n showCircle = false\n }\n}\n", wn = "chart bar-horizontal {\n title = \"Mandarin has nearly twice as many native speakers as Spanish\"\n description = \"Number of native speakers worldwide, in millions\"\n source = \"Ethnologue\"\n sourceUrl = \"https://ethnologue.com\"\n byline = \"Pierre Romera\"\n sort = descending\n\n highlight \"Mandarin\"\n\n data {\n \"Mandarin\" = 988\n \"Spanish\" = 487\n \"English\" = 372\n \"Hindi\" = 347\n \"Bengali\" = 232\n \"Portuguese\" = 252\n \"Russian\" = 133\n \"Japanese\" = 124\n }\n}\n", Tn = "chart line-multi {\n title = \"China now buys more electric cars than the rest of the world combined\"\n description = \"Electric car sales by region, millions per year\"\n source = \"IEA Global EV Outlook 2024\"\n sourceUrl = \"https://www.iea.org/reports/global-ev-outlook-2024\"\n colorPalette = \"Maya\"\n tooltips = true\n\n data {\n series = \"China\",\"Europe\",\"United States\",\"Rest of world\"\n \"2018\" = 1.1,0.4,0.36,0.1\n \"2020\" = 1.3,1.4,0.30,0.2\n \"2021\" = 3.3,2.3,0.63,0.4\n \"2022\" = 6.0,2.7,1.0,0.7\n \"2023\" = 8.1,3.2,1.4,1.0\n }\n}\n", En = "chart bar-multi {\n title = \"USA tops Paris 2024 with 126 medals across all categories\"\n description = \"2024 Paris Summer Games — top six nations\"\n source = \"Olympics.com\"\n sourceUrl = \"https://olympics.com\"\n colors = \"#eeca3b, #c0c0c0, #cd7f32\"\n sort = descending\n\n data {\n series = \"Gold\",\"Silver\",\"Bronze\"\n \"USA\" = 40,44,42\n \"China\" = 40,27,24\n \"Japan\" = 20,12,13\n \"Great Britain\" = 14,22,29\n \"Australia\" = 18,19,16\n \"France\" = 16,26,22\n }\n}\n", Dn = "chart line {\n title = \"2024 was the hottest year on record\"\n description = \"Deviation from the 1951–1980 average, in °C\"\n source = \"NASA GISS\"\n sourceUrl = \"https://data.giss.nasa.gov/gistemp/\"\n tooltips = true\n crosshair = false\n lineSymbols = true\n\n data {\n \"1980\" = 0.26\n \"1985\" = 0.12\n \"1990\" = 0.45\n \"1995\" = 0.45\n \"2000\" = 0.39\n \"2005\" = 0.68\n \"2010\" = 0.73\n \"2015\" = 0.9\n \"2020\" = 1.01\n \"2024\" = 1.28\n }\n\n annotation \"2015\" {\n text = \"2015 Paris Agreement to limit global warming to 1.5°C \"\n maxWidth = 224\n showLine = true\n lineStyle = curve-right\n showArrow = true\n showCircle = true\n }\n}\n", On = "chart line {\n title = \"Bitcoin surged past $90,000 in 2024\"\n description = \"USD, year-end closing price\"\n source = \"CoinGecko\"\n sourceUrl = \"https://www.coingecko.com\"\n colors = \"#f7931a\"\n lineSymbols = true\n lineSymbolShowOn = \"all\"\n lineSymbolShape = \"diamond\"\n verticalNumberFormat = \",.0f\"\n tooltips = true\n\n annotation \"2021\" {\n text = \"All-time high cycle\"\n textOffsetY = -12\n showArrow = true\n }\n\n data {\n \"2016\" = 963\n \"2017\" = 14156\n \"2018\" = 3742\n \"2019\" = 7194\n \"2020\" = 29080\n \"2021\" = 46306\n \"2022\" = 16547\n \"2023\" = 42258\n \"2024\" = 93429\n }\n}\n", kn = "chart line-multi {\n title = \"The income share of the top 1% has surged since 1980\"\n description = \"Pre-tax national income captured by the top 1%, percent\"\n source = \"World Inequality Database\"\n sourceUrl = \"https://wid.world\"\n colorPalette = \"Egypt\"\n tooltips = true\n lineSymbols = true\n lineSymbolShowOn = \"all\"\n\n data {\n series = \"United States\",\"India\",\"China\",\"France\"\n \"1980\" = 10.4,7.5,6.6,7.5\n \"1990\" = 14.7,10.7,8.3,9.0\n \"2000\" = 17.3,10.5,10.5,11.3\n \"2010\" = 17.9,16.4,15.2,11.0\n \"2021\" = 19.9,22.1,15.7,12.7\n }\n\n scene \"US doubles\" {\n title = \"The US top 1% nearly doubled its income share since 1980\"\n highlight \"United States\"\n }\n\n scene \"India overtakes\" {\n title = \"India is now the most unequal of these major economies\"\n highlight \"India\"\n }\n\n scene \"France's modest rise\" {\n title = \"France's top 1% rose far less than the US or India\"\n highlight \"France\"\n }\n}\n", An = "chart pie {\n title = \"Asia is home to nearly 60% of the world's population\"\n description = \"Estimated share, 2024\"\n source = \"United Nations\"\n sourceUrl = \"https://population.un.org\"\n colorPalette = \"Klimt\"\n legendPosition = \"right\"\n tooltips = true\n\n data {\n \"Asia\" = 58.9\n \"Africa\" = 18.6\n \"Europe\" = 9.1\n \"Latin America\" = 8.1\n \"North America\" = 4.7\n }\n}\n", jn = "chart bar-vertical {\n title = \"Brazil produces more coffee than the next three countries combined\"\n description = \"Million 60-kg bags, 2023/24 crop year\"\n source = \"USDA Foreign Agricultural Service\"\n sourceUrl = \"https://www.fas.usda.gov/data/coffee-world-markets-and-trade\"\n colorPalette = \"Harvey\"\n\n data {\n \"Brazil\" = 66.4\n \"Vietnam\" = 27.5\n \"Colombia\" = 12.76\n \"Ethiopia\" = 9.13\n \"Indonesia\" = 7.65\n \"Honduras\" = 5.5\n }\n\n highlight \"Brazil\"\n\n transform sort {\n column = \"value\"\n direction = descending\n }\n}\n", Mn = "chart donut {\n title = \"The richest 1% own more wealth than the entire bottom 90% combined\"\n description = \"Share of global wealth by group, 2021\"\n source = \"World Inequality Report 2022\"\n sourceUrl = \"https://wir2022.wid.world\"\n colorPalette = \"Imperator\"\n legendPosition = \"right\"\n displayAsPercentage = true\n tooltips = true\n\n data {\n \"Top 1%\" = 38\n \"Next 9%\" = 38\n \"Middle 40%\" = 22\n \"Bottom 50%\" = 2\n }\n\n scene \"Top 1% spotlight\" {\n title = \"The top 1% hold 38% of all global wealth\"\n description = \"Share of global wealth by group, 2021\"\n highlight \"Top 1%\"\n }\n\n scene \"Bottom half\" {\n title = \"The bottom half of humanity owns just 2%\"\n description = \"Share of global wealth by group, 2021\"\n highlight \"Bottom 50%\"\n }\n\n scene \"Income tells a softer story\" {\n title = \"Income is concentrated too — but less than wealth\"\n description = \"Share of global income by the same groups, 2021\"\n highlight \"Top 1%\"\n data {\n \"Top 1%\" = 19\n \"Next 9%\" = 33\n \"Middle 40%\" = 39\n \"Bottom 50%\" = 9\n }\n }\n}\n", Nn = "chart area {\n title = \"The US national debt has more than tripled since 2008\"\n description = \"Total federal debt outstanding, trillions of dollars\"\n source = \"U.S. Treasury, Fiscal Data\"\n sourceUrl = \"https://fiscaldata.treasury.gov\"\n\n annotation \"2008\" {\n text = \"Financial crisis\"\n showArrow = true\n textOffsetY = -14\n }\n\n data {\n \"2000\" = 5.7\n \"2004\" = 7.4\n \"2008\" = 10.0\n \"2012\" = 16.1\n \"2016\" = 19.6\n \"2020\" = 26.9\n \"2024\" = 35.5\n }\n}\n", Pn = "chart area-stacked {\n title = \"Renewables' share of global energy has more than doubled since 2000\"\n description = \"Share of global primary energy by source, 2000–2023\"\n source = \"Our World in Data\"\n sourceUrl = \"https://ourworldindata.org/energy-mix\"\n stackPercent = true\n areaSortMode = descending\n\n data {\n series = \"Coal\",\"Oil\",\"Gas\",\"Renewables\"\n \"2000\" = 27456,43017,23994,2997\n \"2005\" = 36201,47017,27439,3510\n \"2010\" = 42016,48193,31593,4868\n \"2015\" = 43695,51294,34780,6400\n \"2020\" = 42316,49101,38704,8569\n \"2023\" = 45319,54839,40151,10325\n }\n}\n", Fn = "chart column-stacked {\n title = \"Natural gas and renewables pushed coal off the US power grid\"\n description = \"Share of US electricity generation by source, percent\"\n source = \"U.S. Energy Information Administration\"\n sourceUrl = \"https://www.eia.gov/electricity\"\n stackMode = \"percent\"\n\n data {\n series = \"Coal\",\"Natural gas\",\"Nuclear\",\"Renewables\"\n \"2010\" = 45,24,20,10\n \"2015\" = 33,33,20,13\n \"2020\" = 19,39,20,20\n \"2023\" = 16,43,19,21\n }\n}\n", In = "chart bar-stacked {\n title = \"India has far more children than China, and a workforce nearly as large\"\n description = \"Millions of people, 2023\"\n source = \"UN Population Division\"\n sourceUrl = \"https://population.un.org\"\n colorPalette = \"London\"\n\n data {\n series = \"0-14\",\"15-64\",\"65+\"\n \"China\" = 232,988,200\n \"India\" = 354,978,97\n \"USA\" = 58,216,59\n \"Indonesia\" = 67,189,21\n \"Brazil\" = 43,148,24\n }\n}\n", Ln = "chart area-stacked {\n title = \"EU subsidies to new members surged after enlargement\"\n description = \"Agricultural subsidies to post-socialist EU members, million euros\"\n source = \"Eurostat\"\n sourceUrl = \"https://ec.europa.eu/eurostat\"\n colorPalette = \"Enara\"\n interpolation = \"linear\"\n heightMode = \"aspect-ratio\"\n aspectRatio = \"1:1\"\n\n data {\n series = \"Indirect subsidies\",\"Direct subsidies\"\n \"2000\" = 370,800\n \"2001\" = 445,896\n \"2002\" = 567,816\n \"2003\" = 641,950\n \"2004\" = 1908,2434\n \"2005\" = 2234,3509\n \"2006\" = 2576,4356\n \"2007\" = 2467,5429\n \"2008\" = 2672,6655\n \"2009\" = 2474,7195\n \"2010\" = 2117,8207\n \"2011\" = 1863,9230\n \"2012\" = 1528,9191\n \"2013\" = 1251,10252\n \"2014\" = 1132,10987\n \"2015\" = 1687,10145\n }\n\n scene \"Indirect subsidies shrank\" {\n title = \"Indirect subsidies were cut under WTO pressure\"\n description = \"Subsidies tied to specific crops fell foul of World Trade Organization rules\"\n\n highlight \"Indirect subsidies\"\n }\n\n scene \"Direct subsidies dominate\" {\n title = \"Direct per-hectare payments now dominate\"\n description = \"The larger the fields, the more money farmers receive\"\n\n highlight \"Direct subsidies\"\n }\n\n scene \"Bulgaria: subsidies explode\" {\n title = \"Bulgarian farmers received almost nothing before 2007 accession\"\n description = \"More than three-quarters of Bulgarian subsidies are direct payments — the highest share among new members\"\n\n data {\n series = \"Indirect subsidies\",\"Direct subsidies\"\n \"2000\" = 0,5\n \"2001\" = 0,33\n \"2002\" = 0,48\n \"2003\" = 0,69\n \"2004\" = 0,67\n \"2005\" = 0,87\n \"2006\" = 0,57\n \"2007\" = 59,250\n \"2008\" = 75,484\n \"2009\" = 97,415\n \"2010\" = 79,466\n \"2011\" = 94,458\n \"2012\" = 120,617\n \"2013\" = 132,852\n \"2014\" = 143,821\n \"2015\" = 213,677\n }\n\n highlight \"Direct subsidies\"\n }\n\n scene \"Bulgarian farms grew\" {\n title = \"Average farm size in Bulgaria quadrupled\"\n description = \"Average farm size in hectares\"\n type = line\n\n data {\n \"2005\" = 5\n \"2007\" = 6\n \"2010\" = 12\n \"2013\" = 18\n }\n }\n\n scene \"Production rose\" {\n title = \"Bulgarian farm production rose from 3 to 4 billion euros\"\n description = \"Total production of Bulgarian farms, million euros\"\n type = area\n\n data {\n \"2000\" = 2933\n \"2001\" = 3240\n \"2002\" = 3051\n \"2003\" = 2816\n \"2004\" = 3049\n \"2005\" = 3011\n \"2006\" = 3111\n \"2007\" = 3038\n \"2008\" = 4148\n \"2009\" = 3437\n \"2010\" = 3486\n \"2011\" = 4038\n \"2012\" = 4161\n \"2013\" = 4115\n \"2014\" = 4138\n \"2015\" = 3915\n }\n }\n\n scene \"Cash crops replaced vegetables\" {\n title = \"Cash crops replaced vegetables in Bulgaria\"\n description = \"Production of Bulgarian farms, million euros\"\n type = area-stacked\n\n data {\n series = \"Vegetables\",\"Cash crops\",\"Other production\"\n \"2000\" = 464,615,1854\n \"2001\" = 458,777,2005\n \"2002\" = 577,850,1624\n \"2003\" = 539,818,1459\n \"2004\" = 483,1103,1463\n \"2005\" = 492,994,1525\n \"2006\" = 510,1083,1518\n \"2007\" = 436,936,1666\n \"2008\" = 541,2045,1563\n \"2009\" = 243,1553,1641\n \"2010\" = 184,2173,1128\n \"2011\" = 120,2853,1065\n \"2012\" = 117,2900,1144\n \"2013\" = 139,2802,1174\n \"2014\" = 143,3082,914\n \"2015\" = 144,2986,785\n }\n\n highlight \"Cash crops\"\n }\n\n scene \"Vegetables collapsed\" {\n title = \"Vegetable production fell by a factor of three\"\n description = \"A traditional Bulgarian cultivation shrank as subsidies favoured large fields\"\n\n highlight \"Vegetables\"\n }\n\n scene \"Every vegetable declined\" {\n title = \"Bulgarian vegetable production collapsed across the board\"\n description = \"Production volume indexed to 2001 = 100\"\n type = line-multi\n lineSymbols = false\n\n data {\n series = \"Cabbages\",\"Tomatoes\",\"Watermelons\",\"Carrots\",\"Onions\",\"Garlic\",\"Strawberries\"\n \"2001\" = 100,100,100,100,100,100,100\n \"2002\" = 79,90,124,64,106,95,100\n \"2003\" = 100,157,177,142,118,98,72\n \"2004\" = 84,87,83,245,124,138,74\n \"2005\" = 50,46,62,30,40,93,42\n \"2006\" = 52,78,113,95,56,80,56\n \"2007\" = 36,49,64,74,29,30,38\n \"2008\" = 47,49,66,97,44,29,55\n \"2009\" = 28,38,74,105,23,39,55\n \"2010\" = 57,42,51,76,53,57,37\n \"2011\" = 32,38,56,86,47,43,45\n \"2012\" = 34,34,46,69,29,43,31\n \"2013\" = 33,43,53,39,36,40,24\n \"2014\" = 31,44,28,69,37,8,27\n \"2015\" = 31,45,50,57,25,18,32\n }\n }\n\n scene \"Jobs disappeared\" {\n title = \"Family farmers disappeared while salaried ag jobs held steady\"\n description = \"EU agricultural employment, thousands of full-time equivalents\"\n type = line-multi\n lineSymbols = false\n\n data {\n series = \"Salaried workers\",\"Non-salaried workers\"\n \"2000\" = 2678,12194\n \"2001\" = 2598,11586\n \"2002\" = 2658,10795\n \"2003\" = 2563,10609\n \"2004\" = 2560,9999\n \"2005\" = 2501,10047\n \"2006\" = 2499,9782\n \"2007\" = 2437,9231\n \"2008\" = 2416,8971\n \"2009\" = 2348,8672\n \"2010\" = 2335,7808\n \"2011\" = 2322,7551\n \"2012\" = 2325,7501\n \"2013\" = 2297,7425\n \"2014\" = 2366,7183\n \"2015\" = 2413,6928\n \"2016\" = 2457,6741\n }\n\n highlight \"Non-salaried workers\"\n }\n}\n", Rn = "chart bar-horizontal {\n title = \"China emits more CO₂ than the US and India combined\"\n description = \"Annual emissions in billion tonnes, 2023\"\n source = \"Our World in Data\"\n sourceUrl = \"https://ourworldindata.org/co2-emissions\"\n byline = \"Pierre Romera\"\n\n data {\n \"China\" = 12.17\n \"United States\" = 4.92\n \"India\" = 3.06\n \"Russia\" = 1.73\n \"Japan\" = 0.99\n \"Germany\" = 0.59\n }\n\n scene \"China spotlight\" {\n title = \"China alone emits more than the US and India together\"\n highlight \"China\"\n }\n\n scene \"India rising\" {\n title = \"India passed the EU to become the third-largest emitter\"\n highlight \"India\"\n }\n\n scene \"Japan declining\" {\n title = \"Japan's emissions have fallen since their 2013 peak\"\n highlight \"Japan\"\n }\n\n scene \"Per capita reframe\" {\n title = \"Per person, Gulf states dwarf the biggest emitters\"\n description = \"CO₂ emissions per capita, tonnes per person, 2023\"\n highlight \"Qatar\"\n data {\n \"Qatar\" = 40.13\n \"United Arab Emirates\" = 19.77\n \"United States\" = 14.32\n \"China\" = 8.56\n \"India\" = 2.13\n }\n }\n}\n", zn = "chart bar-split {\n title = \"CDU/CSU led German polls at 29 % ahead of the 2021 election\"\n description = \"How Germany would vote in the September 2021 federal election, according to polling in the previous June\"\n source = \"FG Wahlen\"\n sourceUrl = \"https://www.forschungsgruppe.de\"\n note = \"Margin of error at 10%: +/- 2 percentage points; at 40%: +/- 3 percentage points\"\n\n data {\n series = \"Poll\",\"High\",\"Low\"\n \"CDU/CSU\" = 29,32,27\n \"Greens\" = 22,25,20\n \"SPD\" = 14,16,12\n \"AfD\" = 10,12,8\n \"FDP\" = 10,12,8\n \"Left\" = 7,9,5\n }\n}\n", Bn = "chart bar-grouped {\n title = \"Asia Pacific holds more renewable capacity than all other regions combined\"\n description = \"Installed capacity in gigawatts (GW), 2023\"\n source = \"IRENA\"\n sourceUrl = \"https://www.irena.org/Publications/2024/Mar/Renewable-capacity-statistics-2024\"\n colorPalette = \"Folklore\"\n\n data {\n series = \"Solar\",\"Wind\",\"Hydro\"\n \"Asia Pacific\" = 870,520,650\n \"Europe\" = 290,260,230\n \"North America\" = 150,170,200\n \"Latin America\" = 50,40,190\n \"Africa\" = 12,9,40\n }\n}\n";
|
|
781
|
+
var Cn = "chart bar-vertical {\n title = \"E is the most frequent letter in English\"\n description = \"How often each letter appears in typical English text\"\n byline = \"Pierre Romera\"\n source = \"Lewand, Cryptological Mathematics\"\n sourceUrl = \"https://en.wikipedia.org/wiki/Letter_frequency\"\n note = \"Based on analysis of 40,000 words from English prose\"\n colorPalette = \"London\"\n sort = descending\n\n highlight \"E\"\n\n data {\n \"E\" = 12.70\n \"T\" = 9.06\n \"A\" = 8.17\n \"O\" = 7.51\n \"I\" = 6.97\n \"N\" = 6.75\n \"S\" = 6.33\n \"H\" = 6.09\n \"R\" = 5.99\n \"D\" = 4.25\n }\n}\n", wn = "chart bar-vertical {\n // the headline above the chart\n title = \"China emits more CO₂ than the US and India combined\"\n description = \"Annual emissions in billion tonnes, 2023\"\n source = \"Our World in Data\"\n sourceUrl = \"https://ourworldindata.org/co2-emissions\"\n\n // one row per country: \"label\" = value\n data {\n \"China\" = 12.17\n \"United States\" = 4.92\n \"India\" = 3.06\n \"Russia\" = 1.73\n \"Japan\" = 0.99\n \"Germany\" = 0.59\n }\n\n // highlight pops one bar in the accent color\n highlight \"China\"\n\n // an annotation points a callout at a single bar\n annotation \"India\" {\n text = \"Surpassed EU in 2023\"\n showLine = true\n anchorDirection = N\n textOffsetX = 66\n textOffsetY = -41\n lineStyle = curve-left\n showArrow = true\n lineTargetDistance = 26\n showCircle = false\n }\n}\n", Tn = "chart bar-horizontal {\n title = \"Mandarin has nearly twice as many native speakers as Spanish\"\n description = \"Number of native speakers worldwide, in millions\"\n source = \"Ethnologue\"\n sourceUrl = \"https://ethnologue.com\"\n byline = \"Pierre Romera\"\n sort = descending\n\n highlight \"Mandarin\"\n\n data {\n \"Mandarin\" = 988\n \"Spanish\" = 487\n \"English\" = 372\n \"Hindi\" = 347\n \"Bengali\" = 232\n \"Portuguese\" = 252\n \"Russian\" = 133\n \"Japanese\" = 124\n }\n}\n", En = "chart line-multi {\n title = \"China now buys more electric cars than the rest of the world combined\"\n description = \"Electric car sales by region, millions per year\"\n source = \"IEA Global EV Outlook 2024\"\n sourceUrl = \"https://www.iea.org/reports/global-ev-outlook-2024\"\n colorPalette = \"Maya\"\n tooltips = true\n\n data {\n series = \"China\",\"Europe\",\"United States\",\"Rest of world\"\n \"2018\" = 1.1,0.4,0.36,0.1\n \"2020\" = 1.3,1.4,0.30,0.2\n \"2021\" = 3.3,2.3,0.63,0.4\n \"2022\" = 6.0,2.7,1.0,0.7\n \"2023\" = 8.1,3.2,1.4,1.0\n }\n}\n", Dn = "chart bar-multi {\n title = \"USA tops Paris 2024 with 126 medals across all categories\"\n description = \"2024 Paris Summer Games — top six nations\"\n source = \"Olympics.com\"\n sourceUrl = \"https://olympics.com\"\n colors = \"#eeca3b, #c0c0c0, #cd7f32\"\n sort = descending\n\n data {\n series = \"Gold\",\"Silver\",\"Bronze\"\n \"USA\" = 40,44,42\n \"China\" = 40,27,24\n \"Japan\" = 20,12,13\n \"Great Britain\" = 14,22,29\n \"Australia\" = 18,19,16\n \"France\" = 16,26,22\n }\n}\n", On = "chart line {\n title = \"2024 was the hottest year on record\"\n description = \"Deviation from the 1951–1980 average, in °C\"\n source = \"NASA GISS\"\n sourceUrl = \"https://data.giss.nasa.gov/gistemp/\"\n tooltips = true\n crosshair = false\n lineSymbols = true\n\n data {\n \"1980\" = 0.26\n \"1985\" = 0.12\n \"1990\" = 0.45\n \"1995\" = 0.45\n \"2000\" = 0.39\n \"2005\" = 0.68\n \"2010\" = 0.73\n \"2015\" = 0.9\n \"2020\" = 1.01\n \"2024\" = 1.28\n }\n\n annotation \"2015\" {\n text = \"2015 Paris Agreement to limit global warming to 1.5°C \"\n maxWidth = 224\n showLine = true\n lineStyle = curve-right\n showArrow = true\n showCircle = true\n }\n}\n", kn = "chart line {\n title = \"Bitcoin surged past $90,000 in 2024\"\n description = \"USD, year-end closing price\"\n source = \"CoinGecko\"\n sourceUrl = \"https://www.coingecko.com\"\n colors = \"#f7931a\"\n lineSymbols = true\n lineSymbolShowOn = \"all\"\n lineSymbolShape = \"diamond\"\n verticalNumberFormat = \",.0f\"\n tooltips = true\n\n annotation \"2021\" {\n text = \"All-time high cycle\"\n textOffsetY = -12\n showArrow = true\n }\n\n data {\n \"2016\" = 963\n \"2017\" = 14156\n \"2018\" = 3742\n \"2019\" = 7194\n \"2020\" = 29080\n \"2021\" = 46306\n \"2022\" = 16547\n \"2023\" = 42258\n \"2024\" = 93429\n }\n}\n", An = "chart line-multi {\n title = \"The income share of the top 1% has surged since 1980\"\n description = \"Pre-tax national income captured by the top 1%, percent\"\n source = \"World Inequality Database\"\n sourceUrl = \"https://wid.world\"\n colorPalette = \"Egypt\"\n tooltips = true\n lineSymbols = true\n lineSymbolShowOn = \"all\"\n\n data {\n series = \"United States\",\"India\",\"China\",\"France\"\n \"1980\" = 10.4,7.5,6.6,7.5\n \"1990\" = 14.7,10.7,8.3,9.0\n \"2000\" = 17.3,10.5,10.5,11.3\n \"2010\" = 17.9,16.4,15.2,11.0\n \"2021\" = 19.9,22.1,15.7,12.7\n }\n\n scene \"US doubles\" {\n title = \"The US top 1% nearly doubled its income share since 1980\"\n highlight \"United States\"\n }\n\n scene \"India overtakes\" {\n title = \"India is now the most unequal of these major economies\"\n highlight \"India\"\n }\n\n scene \"France's modest rise\" {\n title = \"France's top 1% rose far less than the US or India\"\n highlight \"France\"\n }\n}\n", jn = "chart pie {\n title = \"Asia is home to nearly 60% of the world's population\"\n description = \"Estimated share, 2024\"\n source = \"United Nations\"\n sourceUrl = \"https://population.un.org\"\n colorPalette = \"Klimt\"\n legendPosition = \"right\"\n tooltips = true\n\n data {\n \"Asia\" = 58.9\n \"Africa\" = 18.6\n \"Europe\" = 9.1\n \"Latin America\" = 8.1\n \"North America\" = 4.7\n }\n}\n", Mn = "chart bar-vertical {\n title = \"Brazil produces more coffee than the next three countries combined\"\n description = \"Million 60-kg bags, 2023/24 crop year\"\n source = \"USDA Foreign Agricultural Service\"\n sourceUrl = \"https://www.fas.usda.gov/data/coffee-world-markets-and-trade\"\n colorPalette = \"Harvey\"\n\n data {\n \"Brazil\" = 66.4\n \"Vietnam\" = 27.5\n \"Colombia\" = 12.76\n \"Ethiopia\" = 9.13\n \"Indonesia\" = 7.65\n \"Honduras\" = 5.5\n }\n\n highlight \"Brazil\"\n\n transform sort {\n column = \"value\"\n direction = descending\n }\n}\n", Nn = "chart donut {\n title = \"The richest 1% own more wealth than the entire bottom 90% combined\"\n description = \"Share of global wealth by group, 2021\"\n source = \"World Inequality Report 2022\"\n sourceUrl = \"https://wir2022.wid.world\"\n colorPalette = \"Imperator\"\n legendPosition = \"right\"\n displayAsPercentage = true\n tooltips = true\n\n data {\n \"Top 1%\" = 38\n \"Next 9%\" = 38\n \"Middle 40%\" = 22\n \"Bottom 50%\" = 2\n }\n\n scene \"Top 1% spotlight\" {\n title = \"The top 1% hold 38% of all global wealth\"\n description = \"Share of global wealth by group, 2021\"\n highlight \"Top 1%\"\n }\n\n scene \"Bottom half\" {\n title = \"The bottom half of humanity owns just 2%\"\n description = \"Share of global wealth by group, 2021\"\n highlight \"Bottom 50%\"\n }\n\n scene \"Income tells a softer story\" {\n title = \"Income is concentrated too — but less than wealth\"\n description = \"Share of global income by the same groups, 2021\"\n highlight \"Top 1%\"\n data {\n \"Top 1%\" = 19\n \"Next 9%\" = 33\n \"Middle 40%\" = 39\n \"Bottom 50%\" = 9\n }\n }\n}\n", Pn = "chart area {\n title = \"The US national debt has more than tripled since 2008\"\n description = \"Total federal debt outstanding, trillions of dollars\"\n source = \"U.S. Treasury, Fiscal Data\"\n sourceUrl = \"https://fiscaldata.treasury.gov\"\n\n annotation \"2008\" {\n text = \"Financial crisis\"\n showArrow = true\n textOffsetY = -14\n }\n\n data {\n \"2000\" = 5.7\n \"2004\" = 7.4\n \"2008\" = 10.0\n \"2012\" = 16.1\n \"2016\" = 19.6\n \"2020\" = 26.9\n \"2024\" = 35.5\n }\n}\n", Fn = "chart area-stacked {\n title = \"Renewables' share of global energy has more than doubled since 2000\"\n description = \"Share of global primary energy by source, 2000–2023\"\n source = \"Our World in Data\"\n sourceUrl = \"https://ourworldindata.org/energy-mix\"\n stackPercent = true\n areaSortMode = descending\n\n data {\n series = \"Coal\",\"Oil\",\"Gas\",\"Renewables\"\n \"2000\" = 27456,43017,23994,2997\n \"2005\" = 36201,47017,27439,3510\n \"2010\" = 42016,48193,31593,4868\n \"2015\" = 43695,51294,34780,6400\n \"2020\" = 42316,49101,38704,8569\n \"2023\" = 45319,54839,40151,10325\n }\n}\n", In = "chart column-stacked {\n title = \"Natural gas and renewables pushed coal off the US power grid\"\n description = \"Share of US electricity generation by source, percent\"\n source = \"U.S. Energy Information Administration\"\n sourceUrl = \"https://www.eia.gov/electricity\"\n stackMode = \"percent\"\n\n data {\n series = \"Coal\",\"Natural gas\",\"Nuclear\",\"Renewables\"\n \"2010\" = 45,24,20,10\n \"2015\" = 33,33,20,13\n \"2020\" = 19,39,20,20\n \"2023\" = 16,43,19,21\n }\n}\n", Ln = "chart bar-stacked {\n title = \"India has far more children than China, and a workforce nearly as large\"\n description = \"Millions of people, 2023\"\n source = \"UN Population Division\"\n sourceUrl = \"https://population.un.org\"\n colorPalette = \"London\"\n\n data {\n series = \"0-14\",\"15-64\",\"65+\"\n \"China\" = 232,988,200\n \"India\" = 354,978,97\n \"USA\" = 58,216,59\n \"Indonesia\" = 67,189,21\n \"Brazil\" = 43,148,24\n }\n}\n", Rn = "chart area-stacked {\n title = \"EU subsidies to new members surged after enlargement\"\n description = \"Agricultural subsidies to post-socialist EU members, million euros\"\n source = \"Eurostat\"\n sourceUrl = \"https://ec.europa.eu/eurostat\"\n colorPalette = \"Enara\"\n interpolation = \"linear\"\n heightMode = \"aspect-ratio\"\n aspectRatio = \"1:1\"\n\n data {\n series = \"Indirect subsidies\",\"Direct subsidies\"\n \"2000\" = 370,800\n \"2001\" = 445,896\n \"2002\" = 567,816\n \"2003\" = 641,950\n \"2004\" = 1908,2434\n \"2005\" = 2234,3509\n \"2006\" = 2576,4356\n \"2007\" = 2467,5429\n \"2008\" = 2672,6655\n \"2009\" = 2474,7195\n \"2010\" = 2117,8207\n \"2011\" = 1863,9230\n \"2012\" = 1528,9191\n \"2013\" = 1251,10252\n \"2014\" = 1132,10987\n \"2015\" = 1687,10145\n }\n\n scene \"Indirect subsidies shrank\" {\n title = \"Indirect subsidies were cut under WTO pressure\"\n description = \"Subsidies tied to specific crops fell foul of World Trade Organization rules\"\n\n highlight \"Indirect subsidies\"\n }\n\n scene \"Direct subsidies dominate\" {\n title = \"Direct per-hectare payments now dominate\"\n description = \"The larger the fields, the more money farmers receive\"\n\n highlight \"Direct subsidies\"\n }\n\n scene \"Bulgaria: subsidies explode\" {\n title = \"Bulgarian farmers received almost nothing before 2007 accession\"\n description = \"More than three-quarters of Bulgarian subsidies are direct payments — the highest share among new members\"\n\n data {\n series = \"Indirect subsidies\",\"Direct subsidies\"\n \"2000\" = 0,5\n \"2001\" = 0,33\n \"2002\" = 0,48\n \"2003\" = 0,69\n \"2004\" = 0,67\n \"2005\" = 0,87\n \"2006\" = 0,57\n \"2007\" = 59,250\n \"2008\" = 75,484\n \"2009\" = 97,415\n \"2010\" = 79,466\n \"2011\" = 94,458\n \"2012\" = 120,617\n \"2013\" = 132,852\n \"2014\" = 143,821\n \"2015\" = 213,677\n }\n\n highlight \"Direct subsidies\"\n }\n\n scene \"Bulgarian farms grew\" {\n title = \"Average farm size in Bulgaria quadrupled\"\n description = \"Average farm size in hectares\"\n type = line\n\n data {\n \"2005\" = 5\n \"2007\" = 6\n \"2010\" = 12\n \"2013\" = 18\n }\n }\n\n scene \"Production rose\" {\n title = \"Bulgarian farm production rose from 3 to 4 billion euros\"\n description = \"Total production of Bulgarian farms, million euros\"\n type = area\n\n data {\n \"2000\" = 2933\n \"2001\" = 3240\n \"2002\" = 3051\n \"2003\" = 2816\n \"2004\" = 3049\n \"2005\" = 3011\n \"2006\" = 3111\n \"2007\" = 3038\n \"2008\" = 4148\n \"2009\" = 3437\n \"2010\" = 3486\n \"2011\" = 4038\n \"2012\" = 4161\n \"2013\" = 4115\n \"2014\" = 4138\n \"2015\" = 3915\n }\n }\n\n scene \"Cash crops replaced vegetables\" {\n title = \"Cash crops replaced vegetables in Bulgaria\"\n description = \"Production of Bulgarian farms, million euros\"\n type = area-stacked\n\n data {\n series = \"Vegetables\",\"Cash crops\",\"Other production\"\n \"2000\" = 464,615,1854\n \"2001\" = 458,777,2005\n \"2002\" = 577,850,1624\n \"2003\" = 539,818,1459\n \"2004\" = 483,1103,1463\n \"2005\" = 492,994,1525\n \"2006\" = 510,1083,1518\n \"2007\" = 436,936,1666\n \"2008\" = 541,2045,1563\n \"2009\" = 243,1553,1641\n \"2010\" = 184,2173,1128\n \"2011\" = 120,2853,1065\n \"2012\" = 117,2900,1144\n \"2013\" = 139,2802,1174\n \"2014\" = 143,3082,914\n \"2015\" = 144,2986,785\n }\n\n highlight \"Cash crops\"\n }\n\n scene \"Vegetables collapsed\" {\n title = \"Vegetable production fell by a factor of three\"\n description = \"A traditional Bulgarian cultivation shrank as subsidies favoured large fields\"\n\n highlight \"Vegetables\"\n }\n\n scene \"Every vegetable declined\" {\n title = \"Bulgarian vegetable production collapsed across the board\"\n description = \"Production volume indexed to 2001 = 100\"\n type = line-multi\n lineSymbols = false\n\n data {\n series = \"Cabbages\",\"Tomatoes\",\"Watermelons\",\"Carrots\",\"Onions\",\"Garlic\",\"Strawberries\"\n \"2001\" = 100,100,100,100,100,100,100\n \"2002\" = 79,90,124,64,106,95,100\n \"2003\" = 100,157,177,142,118,98,72\n \"2004\" = 84,87,83,245,124,138,74\n \"2005\" = 50,46,62,30,40,93,42\n \"2006\" = 52,78,113,95,56,80,56\n \"2007\" = 36,49,64,74,29,30,38\n \"2008\" = 47,49,66,97,44,29,55\n \"2009\" = 28,38,74,105,23,39,55\n \"2010\" = 57,42,51,76,53,57,37\n \"2011\" = 32,38,56,86,47,43,45\n \"2012\" = 34,34,46,69,29,43,31\n \"2013\" = 33,43,53,39,36,40,24\n \"2014\" = 31,44,28,69,37,8,27\n \"2015\" = 31,45,50,57,25,18,32\n }\n }\n\n scene \"Jobs disappeared\" {\n title = \"Family farmers disappeared while salaried ag jobs held steady\"\n description = \"EU agricultural employment, thousands of full-time equivalents\"\n type = line-multi\n lineSymbols = false\n\n data {\n series = \"Salaried workers\",\"Non-salaried workers\"\n \"2000\" = 2678,12194\n \"2001\" = 2598,11586\n \"2002\" = 2658,10795\n \"2003\" = 2563,10609\n \"2004\" = 2560,9999\n \"2005\" = 2501,10047\n \"2006\" = 2499,9782\n \"2007\" = 2437,9231\n \"2008\" = 2416,8971\n \"2009\" = 2348,8672\n \"2010\" = 2335,7808\n \"2011\" = 2322,7551\n \"2012\" = 2325,7501\n \"2013\" = 2297,7425\n \"2014\" = 2366,7183\n \"2015\" = 2413,6928\n \"2016\" = 2457,6741\n }\n\n highlight \"Non-salaried workers\"\n }\n}\n", zn = "chart bar-horizontal {\n title = \"China emits more CO₂ than the US and India combined\"\n description = \"Annual emissions in billion tonnes, 2023\"\n source = \"Our World in Data\"\n sourceUrl = \"https://ourworldindata.org/co2-emissions\"\n byline = \"Pierre Romera\"\n\n data {\n \"China\" = 12.17\n \"United States\" = 4.92\n \"India\" = 3.06\n \"Russia\" = 1.73\n \"Japan\" = 0.99\n \"Germany\" = 0.59\n }\n\n scene \"China spotlight\" {\n title = \"China alone emits more than the US and India together\"\n highlight \"China\"\n }\n\n scene \"India rising\" {\n title = \"India passed the EU to become the third-largest emitter\"\n highlight \"India\"\n }\n\n scene \"Japan declining\" {\n title = \"Japan's emissions have fallen since their 2013 peak\"\n highlight \"Japan\"\n }\n\n scene \"Per capita reframe\" {\n title = \"Per person, Gulf states dwarf the biggest emitters\"\n description = \"CO₂ emissions per capita, tonnes per person, 2023\"\n highlight \"Qatar\"\n data {\n \"Qatar\" = 40.13\n \"United Arab Emirates\" = 19.77\n \"United States\" = 14.32\n \"China\" = 8.56\n \"India\" = 2.13\n }\n }\n}\n", Bn = "chart bar-split {\n title = \"CDU/CSU led German polls at 29 % ahead of the 2021 election\"\n description = \"How Germany would vote in the September 2021 federal election, according to polling in the previous June\"\n source = \"FG Wahlen\"\n sourceUrl = \"https://www.forschungsgruppe.de\"\n note = \"Margin of error at 10%: +/- 2 percentage points; at 40%: +/- 3 percentage points\"\n\n data {\n series = \"Poll\",\"High\",\"Low\"\n \"CDU/CSU\" = 29,32,27\n \"Greens\" = 22,25,20\n \"SPD\" = 14,16,12\n \"AfD\" = 10,12,8\n \"FDP\" = 10,12,8\n \"Left\" = 7,9,5\n }\n}\n", Vn = "chart bar-grouped {\n title = \"Asia Pacific holds more renewable capacity than all other regions combined\"\n description = \"Installed capacity in gigawatts (GW), 2023\"\n source = \"IRENA\"\n sourceUrl = \"https://www.irena.org/Publications/2024/Mar/Renewable-capacity-statistics-2024\"\n colorPalette = \"Folklore\"\n\n data {\n series = \"Solar\",\"Wind\",\"Hydro\"\n \"Asia Pacific\" = 870,520,650\n \"Europe\" = 290,260,230\n \"North America\" = 150,170,200\n \"Latin America\" = 50,40,190\n \"Africa\" = 12,9,40\n }\n}\n";
|
|
778
782
|
//#endregion
|
|
779
783
|
//#region src/samples.ts
|
|
780
|
-
function
|
|
784
|
+
function Hn(e, t) {
|
|
781
785
|
let n = e.properties.find((e) => e.key === t);
|
|
782
786
|
return n ? String(n.value) : "";
|
|
783
787
|
}
|
|
784
|
-
function
|
|
788
|
+
function Un(e) {
|
|
785
789
|
if (!e.data) return "";
|
|
786
790
|
let t = e.data.entries, n = t.find((e) => e.key === "series" && !e.quotedKey);
|
|
787
791
|
return n ? [["category", ...String(n.value).split(",")].join(" "), ...t.filter((e) => !(e.key === "series" && !e.quotedKey)).map((e) => {
|
|
@@ -789,59 +793,59 @@ function Hn(e) {
|
|
|
789
793
|
return [e.key, ...t].join(" ");
|
|
790
794
|
})].join("\n") : [["label", "value"].join(" "), ...t.map((e) => [e.key, String(e.value)].join(" "))].join("\n");
|
|
791
795
|
}
|
|
792
|
-
function
|
|
796
|
+
function Wn(e) {
|
|
793
797
|
if (!e.data) return "";
|
|
794
798
|
let t = e.data.entries, n = t.find((e) => e.key === "series" && !e.quotedKey);
|
|
795
799
|
return n ? [`series = "${String(n.value)}"`, ...t.filter((e) => !(e.key === "series" && !e.quotedKey)).map((e) => `"${e.key}" = "${String(e.value)}"`)].join("\n") : t.map((e) => `"${e.key}" = ${String(e.value)}`).join("\n");
|
|
796
800
|
}
|
|
797
|
-
function
|
|
798
|
-
let n =
|
|
801
|
+
function K(e, t) {
|
|
802
|
+
let n = b(t);
|
|
799
803
|
return {
|
|
800
804
|
id: e,
|
|
801
|
-
title:
|
|
802
|
-
description:
|
|
805
|
+
title: Hn(n, "title"),
|
|
806
|
+
description: Hn(n, "description"),
|
|
803
807
|
chartType: n.chartType,
|
|
804
|
-
tsvData:
|
|
805
|
-
serializedData:
|
|
808
|
+
tsvData: Un(n),
|
|
809
|
+
serializedData: Wn(n),
|
|
806
810
|
dsl: t
|
|
807
811
|
};
|
|
808
812
|
}
|
|
809
|
-
var
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
],
|
|
813
|
+
var Gn = [
|
|
814
|
+
K("letter-frequency", Cn),
|
|
815
|
+
K("co2-emissions", wn),
|
|
816
|
+
K("coffee-production", Mn),
|
|
817
|
+
K("spoken-languages", Tn),
|
|
818
|
+
K("quarterly-revenue", En),
|
|
819
|
+
K("medal-count", Dn),
|
|
820
|
+
K("temperature-anomaly", On),
|
|
821
|
+
K("bitcoin-price", kn),
|
|
822
|
+
K("unemployment-rates", An),
|
|
823
|
+
K("browser-market", Nn),
|
|
824
|
+
K("world-population", jn),
|
|
825
|
+
K("stock-price-area", Pn),
|
|
826
|
+
K("energy-mix-stacked-area", Fn),
|
|
827
|
+
K("quarterly-stacked-columns", In),
|
|
828
|
+
K("population-stacked-bar", Ln),
|
|
829
|
+
K("election-polls", Bn),
|
|
830
|
+
K("renewable-capacity", Vn),
|
|
831
|
+
K("farm-compass", Rn),
|
|
832
|
+
K("co2-emissions-story", zn)
|
|
833
|
+
], Kn = class extends Error {
|
|
830
834
|
constructor(e, t) {
|
|
831
835
|
super(e, t), this.name = "ChartParseError";
|
|
832
836
|
}
|
|
833
|
-
},
|
|
837
|
+
}, qn = class extends Error {
|
|
834
838
|
constructor(e = "PNG export is only available in Node. Use toSvg() in the browser.") {
|
|
835
839
|
super(e), this.name = "PngBrowserUnsupportedError";
|
|
836
840
|
}
|
|
837
|
-
},
|
|
841
|
+
}, Jn = class extends Error {
|
|
838
842
|
constructor(e) {
|
|
839
843
|
super(e), this.name = "MissingNodeRenderDepsError";
|
|
840
844
|
}
|
|
841
845
|
};
|
|
842
846
|
//#endregion
|
|
843
847
|
//#region src/render/backends/dom-backend.ts
|
|
844
|
-
function
|
|
848
|
+
function Yn() {
|
|
845
849
|
return {
|
|
846
850
|
kind: "dom",
|
|
847
851
|
createContainer(e, t) {
|
|
@@ -871,21 +875,21 @@ function Jn() {
|
|
|
871
875
|
throw Error("dom-backend: renderToContainer produced no frame");
|
|
872
876
|
},
|
|
873
877
|
rasterizePng() {
|
|
874
|
-
return Promise.reject(new
|
|
878
|
+
return Promise.reject(new qn());
|
|
875
879
|
}
|
|
876
880
|
};
|
|
877
881
|
}
|
|
878
882
|
//#endregion
|
|
879
883
|
//#region src/render/frame-svg.ts
|
|
880
|
-
var
|
|
884
|
+
var Xn = {
|
|
881
885
|
background: "#ffffff",
|
|
882
886
|
color: "#333333"
|
|
883
|
-
},
|
|
887
|
+
}, Zn = {
|
|
884
888
|
background: "#1c1c1c",
|
|
885
889
|
color: "rgba(255, 255, 255, 0.9)"
|
|
886
|
-
},
|
|
890
|
+
}, Qn = "sans-serif", $n = 20, q = 14, J = 12, Y = 1.25, er = 4, tr = 8, nr = 12, rr = 40, ir = "16px", ar = "Blueprint Chart", or = "Source: ", sr = " · ", cr = .6;
|
|
887
891
|
function lr(e) {
|
|
888
|
-
return e === "dark" ? { ...
|
|
892
|
+
return e === "dark" ? { ...Zn } : { ...Xn };
|
|
889
893
|
}
|
|
890
894
|
function ur() {
|
|
891
895
|
if (typeof document > "u") return null;
|
|
@@ -899,7 +903,7 @@ function dr() {
|
|
|
899
903
|
let e = ur();
|
|
900
904
|
return (t, n, r) => {
|
|
901
905
|
let i = t.length * n * cr;
|
|
902
|
-
return e ? (e.font = `${r ? "bold " : ""}${n}px ${
|
|
906
|
+
return e ? (e.font = `${r ? "bold " : ""}${n}px ${Qn}`, Math.max(e.measureText(t).width, i)) : i;
|
|
903
907
|
};
|
|
904
908
|
}
|
|
905
909
|
function X(e, t, n, r, i) {
|
|
@@ -935,34 +939,34 @@ function fr(e) {
|
|
|
935
939
|
return /r?em$/.test(e) ? t * 16 : t;
|
|
936
940
|
}
|
|
937
941
|
function pr(e) {
|
|
938
|
-
let t = e.frame ?? {}, n = lr(e.theme), [r, i, a, o] =
|
|
939
|
-
t.title && (u = Z(l, X(t.title, s,
|
|
942
|
+
let t = e.frame ?? {}, n = lr(e.theme), [r, i, a, o] = je(t.padding ?? ir).map(fr), s = Math.max(e.width - o - i, 1), c = dr(), l = [], u = r;
|
|
943
|
+
t.title && (u = Z(l, X(t.title, s, $n, !0, c), {
|
|
940
944
|
x: o,
|
|
941
945
|
top: u,
|
|
942
|
-
fontSize:
|
|
946
|
+
fontSize: $n,
|
|
943
947
|
fontWeight: "bold",
|
|
944
948
|
fill: n.color
|
|
945
|
-
})), t.description && (u = Z(l, X(t.description, s,
|
|
949
|
+
})), t.description && (u = Z(l, X(t.description, s, q, !1, c), {
|
|
946
950
|
x: o,
|
|
947
951
|
top: t.title ? u + er : u,
|
|
948
|
-
fontSize:
|
|
952
|
+
fontSize: q,
|
|
949
953
|
fill: n.color
|
|
950
954
|
}));
|
|
951
|
-
let d = u, f = t.note ? X(t.note, s, J, !1, c) : [], p = c(ar, J, !1), m = [t.byline, t.source ? or + t.source : ""].filter(Boolean).join(sr), h = m ? X(m, Math.max(s - p - nr, 1), J, !1, c) : [],
|
|
952
|
-
return
|
|
955
|
+
let d = u, f = t.note ? X(t.note, s, J, !1, c) : [], p = c(ar, J, !1), m = [t.byline, t.source ? or + t.source : ""].filter(Boolean).join(sr), h = m ? X(m, Math.max(s - p - nr, 1), J, !1, c) : [], g = Math.max(h.length, 1), _ = f.length * J * Y + tr + g * J * Y + a, v = Math.max(e.height - d - _, rr), y = d + v;
|
|
956
|
+
return y = Z(l, f, {
|
|
953
957
|
x: o,
|
|
954
|
-
top:
|
|
958
|
+
top: y,
|
|
955
959
|
fontSize: J,
|
|
956
960
|
fontStyle: "italic",
|
|
957
961
|
fill: n.color
|
|
958
962
|
}) + tr, Z(l, h, {
|
|
959
963
|
x: o,
|
|
960
|
-
top:
|
|
964
|
+
top: y,
|
|
961
965
|
fontSize: J,
|
|
962
966
|
fill: n.color
|
|
963
967
|
}), Z(l, [ar], {
|
|
964
968
|
x: e.width - i,
|
|
965
|
-
top:
|
|
969
|
+
top: y,
|
|
966
970
|
fontSize: J,
|
|
967
971
|
fontWeight: "600",
|
|
968
972
|
fill: n.color,
|
|
@@ -974,12 +978,12 @@ function pr(e) {
|
|
|
974
978
|
x: o,
|
|
975
979
|
y: d,
|
|
976
980
|
width: s,
|
|
977
|
-
height:
|
|
981
|
+
height: v
|
|
978
982
|
},
|
|
979
983
|
blocks: l,
|
|
980
984
|
background: t.transparentBackground ? null : n.background,
|
|
981
985
|
color: n.color,
|
|
982
|
-
fontFamily:
|
|
986
|
+
fontFamily: Qn
|
|
983
987
|
};
|
|
984
988
|
}
|
|
985
989
|
function Q(e) {
|
|
@@ -1020,14 +1024,14 @@ function vr() {
|
|
|
1020
1024
|
return typeof document < "u" && typeof document.createElement == "function";
|
|
1021
1025
|
}
|
|
1022
1026
|
async function yr() {
|
|
1023
|
-
return vr() ?
|
|
1027
|
+
return vr() ? Yn() : (await import("@blueprint-chart/lib/internal/node-backend")).createNodeBackend();
|
|
1024
1028
|
}
|
|
1025
1029
|
async function br(e, t = {}) {
|
|
1026
1030
|
let n;
|
|
1027
1031
|
try {
|
|
1028
|
-
n = b(
|
|
1032
|
+
n = Me(b(e));
|
|
1029
1033
|
} catch (e) {
|
|
1030
|
-
throw new
|
|
1034
|
+
throw new Kn(e instanceof Error ? e.message : String(e), { cause: e });
|
|
1031
1035
|
}
|
|
1032
1036
|
let r = await yr(), i = t.frame ?? !0, a = {
|
|
1033
1037
|
sceneIndex: t.scene,
|
|
@@ -1046,7 +1050,7 @@ async function br(e, t = {}) {
|
|
|
1046
1050
|
});
|
|
1047
1051
|
}
|
|
1048
1052
|
function c(e) {
|
|
1049
|
-
let c = e.width ?? a.width, l = e.height ?? a.height, u =
|
|
1053
|
+
let c = e.width ?? a.width, l = e.height ?? a.height, u = Ke(n, a.sceneIndex), d = t.theme ?? u.theme;
|
|
1050
1054
|
if (!i) {
|
|
1051
1055
|
let { container: e, cleanup: t } = r.createContainer(c, l);
|
|
1052
1056
|
try {
|
|
@@ -1101,4 +1105,4 @@ async function br(e, t = {}) {
|
|
|
1101
1105
|
return l;
|
|
1102
1106
|
}
|
|
1103
1107
|
//#endregion
|
|
1104
|
-
export {
|
|
1108
|
+
export { yt as ANNOTATION_KIND_KEYWORD, Tt as Anchor, S as AnnotationKind, Ct as AnnotationLineStyle, ge as AxisDirection, fe as BC_TRANSITION_NAME, o as ChartOptionType, Kn as ChartParseError, xt as ChartType, ve as CompassDirection, u as CrosshairDirection, c as CrosshairStyle, tt as DEFAULT_BAR_GAP, ue as DirectLabelMode, Ze as DslNodeType, n as FilterCondition, Ye as FrameSizing, oe as GridStyle, ce as Interpolation, de as LabelPosition, f as LabelRotation, v as LegendPosition, ie as LineStyle, Jn as MissingNodeRenderDepsError, vt as NULL_VALUE, me as Orientation, Et as ParseOperationCategory, qn as PngBrowserUnsupportedError, i as RangeAnchor, xe as ScaleType, we as SceneTransition, g as SortDirection, ye as SortMode, Ce as StackMode, m as StrokeStyle, ne as SymbolShape, lt as SymbolShowOn, ee as SymbolStyle, it as TRANSFORM_TYPES, De as TickPosition, Te as TransformType, ke as ValueLabelPosition, _t as adjustColorsForBackground, ft as applyTransformNodes, Fe as applyTransformNodesToChartData, Qe as applyTransformSteps, Me as astToDefinition, re as buildChartOptions, hr as buildFrameSvg, Dt as buildSrcdoc, Le as chartDataToTable, Vt as checkCvdColors, T as classifyIntent, Be as cleanNumericValue, Ne as commitFadeOut, Zt as compactSerialize, Xt as compactSerializeDeep, bt as convertAnnotations, _e as convertAreaFills, l as convertColorizes, s as convertHighlights, le as convertSeriesOverrides, $e as createCanvas, Lt as createCvdSvgFilter, Ue as createFrame, Xe as dataEntriesToString, ot as detectColumnTypes, t as extractChartTypeOptions, Je as extractSceneOverrides, at as fadeIn, y as featureJoin, e as getCachedChart, be as getChart, h as getChartOptions, d as getChartTypeDefaults, It as getCvdFilterId, Pe as getOutputType, Oe as getSceneTransition, pt as getTransitionDuration, et as isDateValue, We as isNumberValue, p as isSeriesHidden, St as isTypeCompatible, x as listCharts, ze as listPalettes, Nt as listThemes, b as parse, He as parseBpcData, pe as parseData, he as parseOperationMap, a as parseOperations, ae as propertyMap, C as quoteDslString, jt as recommendCharts, Se as registerChart, br as render, mt as renderBpc, nt as renderChart, dt as renderHorizontalAxis, rt as renderLegend, qe as renderVerticalAxis, Re as resolveBackgroundColor, Ge as resolveBarGapPadding, _ as resolveChartTypeOptions, ht as resolvePalette, Ke as resolveScene, te as resolveSeriesColor, ct as resolveSeriesInterpolation, Gn as samples, Kt as serialize, Ae as serializeTableData, O as shapeOf, zt as simulateCvdColor, Ie as snapshotForFadeOut, Ee as snapshotLiveAttrs, r as stripDigitGroupSpaces, se as toBool, gt as transformNodesToSteps, wt as transformValue, yn as validateChart, Ve as wcagContrastRatio, st as wcagLevel };
|