@blueprint-chart/lib 1.5.0 → 1.7.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/embed.js +2 -8
- package/dist/index.js +778 -1624
- package/dist/lib/lib.iife.js +28 -31
- package/dist/node-backend/browser.js +6 -6
- package/dist/node-backend/errors-DTQcjINA.js +8 -0
- package/dist/node-backend/index.js +7137 -5341
- package/dist/render-bpc-Bp2OTJmu.js +8028 -0
- package/dist/runtime/chart-css.d.ts +1 -1
- package/dist/runtime-BnrDRLyH.js +84 -0
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.js +48 -51
- package/package.json +12 -12
- package/src/charts/chart.scss +8 -2
- package/dist/embed-DxKuPk6P.js +0 -315
- package/dist/node-backend/errors-poq5BHAK.js +0 -8
- package/dist/render-bpc-CnZB0sa5.js +0 -6278
package/dist/index.js
CHANGED
|
@@ -1,1631 +1,785 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { $ as e, A as t, B as n, C as r, Ct as i, D as a, E as o, F as s, G as c, H as l, I as ee, J as te, K as ne, L as re, M as ie, N as ae, O as oe, P as se, Q as ce, R as le, S as ue, St as de, T as fe, Tt as pe, U as me, V as u, W as he, X as ge, Y as d, Z as f, _ as _e, _t as ve, a as ye, at as be, b as p, bt as xe, c as Se, ct as Ce, d as we, dt as Te, et as m, f as Ee, ft as De, g as Oe, gt as ke, h as Ae, ht as je, i as h, it as Me, j as Ne, k as Pe, l as Fe, lt as Ie, m as g, mt as _, n as v, nt as Le, o as Re, ot as ze, p as y, pt as Be, q as Ve, r as He, rt as Ue, s as We, st as Ge, t as Ke, tt as qe, u as Je, ut as Ye, v as Xe, vt as Ze, w as Qe, wt as $e, x as b, xt as et, y as tt, yt as nt, z as rt } from "./render-bpc-Bp2OTJmu.js";
|
|
2
|
+
import { t as it } from "./runtime-BnrDRLyH.js";
|
|
3
|
+
import x from "chroma-js";
|
|
4
|
+
//#region src/recommendations/intent.ts
|
|
5
|
+
var at = [
|
|
6
|
+
{
|
|
7
|
+
intent: "range",
|
|
8
|
+
pattern: /\b(range|high and low|high\/low|margin of error|confidence interval|confidence|interval|plus or minus|spread between)\b/i
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
intent: "composition-over-time",
|
|
12
|
+
pattern: /(composition|mix|stacked|breakdown)[^.]*\b(over time|by year|by quarter|by month|by decade)\b|\b(over time|by year|by quarter|by month)\b[^.]*(composition|mix|breakdown)/i
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
intent: "part-to-whole",
|
|
16
|
+
pattern: /\b(share|part[- ]to[- ]whole|proportion|percentage of (?:the )?total|% of (?:the )?total|makes? up|out of (?:the )?total|composition)\b/i
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
intent: "ranking",
|
|
20
|
+
pattern: /\b(rank|ranked|ranking|top \d+|most|largest|biggest|highest|leading|fewest|smallest)\b/i
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
intent: "trend",
|
|
24
|
+
pattern: /\b(over time|trend|grew|rose|fell|climbed|declined|increased?|decreased?|change over|year[- ]over[- ]year|overtak\w*|overtook|surpass\w*|crossover|diverg\w*)\b/i
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
intent: "comparison",
|
|
28
|
+
pattern: /\b(compares?|compared|comparison|versus|vs\.?|more than|difference between|across|than)\b/i
|
|
29
|
+
}
|
|
13
30
|
];
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
c("line", "best", "1 date + 1 numeric column — ideal for trend"),
|
|
87
|
-
c("area", "good", "Filled area emphasizes magnitude over time"),
|
|
88
|
-
c("bar-vertical", "alternative", "Can also show as bars")
|
|
89
|
-
],
|
|
90
|
-
comparison: () => [
|
|
91
|
-
c("bar-vertical", "best", "Bars for comparing discrete time points"),
|
|
92
|
-
c("line", "good", "Line if the trend matters more than the comparison")
|
|
93
|
-
],
|
|
94
|
-
ranking: () => [
|
|
95
|
-
c("bar-vertical", "best", "Bars for ranking discrete time points"),
|
|
96
|
-
c("line", "good", "Line for the underlying trend")
|
|
97
|
-
],
|
|
98
|
-
"part-to-whole": () => [
|
|
99
|
-
c("area", "best", "Filled area reads as magnitude/share over time"),
|
|
100
|
-
c("line", "good", "Line for the underlying trend")
|
|
101
|
-
],
|
|
102
|
-
"composition-over-time": () => [
|
|
103
|
-
c("area", "best", "Filled area shows magnitude over time"),
|
|
104
|
-
c("line", "good", "Line for the underlying trend")
|
|
105
|
-
]
|
|
106
|
-
},
|
|
107
|
-
"1date+Nnum": {
|
|
108
|
-
none: () => [
|
|
109
|
-
c("line-multi", "best", "1 date + multiple numeric columns — compare trends"),
|
|
110
|
-
c("bar-multi", "alternative", "Can also show as grouped bars")
|
|
111
|
-
],
|
|
112
|
-
trend: (e) => m["1date+Nnum"].none(e),
|
|
113
|
-
comparison: (e) => m["1date+Nnum"].none(e),
|
|
114
|
-
ranking: (e) => m["1date+Nnum"].none(e),
|
|
115
|
-
"composition-over-time": () => [
|
|
116
|
-
c("area-stacked", "best", "Stacked area shows composition over continuous time"),
|
|
117
|
-
c("column-stacked", "good", "Stacked columns for the same composition"),
|
|
118
|
-
c("line-multi", "alternative", "Multi-line if composition is not the point")
|
|
119
|
-
],
|
|
120
|
-
"part-to-whole": () => [
|
|
121
|
-
c("area-stacked", "best", "Stacked area shows share over time"),
|
|
122
|
-
c("line-multi", "good", "Multi-line if absolute trends matter more")
|
|
123
|
-
]
|
|
124
|
-
},
|
|
125
|
-
other: {
|
|
126
|
-
none: () => [
|
|
127
|
-
c("bar-vertical", "good", "Default bar chart recommendation")
|
|
128
|
-
]
|
|
129
|
-
}
|
|
31
|
+
function S(e) {
|
|
32
|
+
if (e === void 0 || e.trim() === "") return "none";
|
|
33
|
+
for (let t of at) if (t.pattern.test(e)) return t.intent;
|
|
34
|
+
return "none";
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/recommendations/decisionTable.ts
|
|
38
|
+
var C = (e, t, n) => ({
|
|
39
|
+
type: e,
|
|
40
|
+
fitness: t,
|
|
41
|
+
reason: n
|
|
42
|
+
}), w = {
|
|
43
|
+
"1cat+1num": {
|
|
44
|
+
none: (e) => {
|
|
45
|
+
let t = [C("bar-vertical", "best", "1 categorical + 1 numeric — classic bar chart"), C("bar-horizontal", "good", "Horizontal bars work well for long labels")];
|
|
46
|
+
return e <= 8 && (t.push(C("donut", "good", `${e} items — suitable for part-of-whole`)), t.push(C("pie", "alternative", "Pie chart for part-of-whole"))), t;
|
|
47
|
+
},
|
|
48
|
+
comparison: (e) => w["1cat+1num"].none(e),
|
|
49
|
+
ranking: () => [C("bar-horizontal", "best", "Ranked categories read best as horizontal bars"), C("bar-vertical", "good", "Vertical bars also work for ranking")],
|
|
50
|
+
"part-to-whole": (e) => e <= 5 ? [
|
|
51
|
+
C("pie", "best", `${e} slices — pie reads cleanly for very small N`),
|
|
52
|
+
C("donut", "good", "Donut for part-of-whole with a center label"),
|
|
53
|
+
C("bar-vertical", "alternative", "Bars if precise comparison matters")
|
|
54
|
+
] : e <= 8 ? [
|
|
55
|
+
C("donut", "best", `${e} slices — donut for part-of-whole`),
|
|
56
|
+
C("pie", "good", "Pie for part-of-whole"),
|
|
57
|
+
C("bar-vertical", "alternative", "Bars if precise comparison matters")
|
|
58
|
+
] : [C("bar-vertical", "best", `${e} categories — too many for a readable pie`), C("bar-horizontal", "good", "Horizontal bars for long labels")],
|
|
59
|
+
range: () => [C("bar-split", "best", "Diverging bars show a value against a shared baseline"), C("bar-vertical", "alternative", "Plain bars if the baseline is zero")]
|
|
60
|
+
},
|
|
61
|
+
"1cat+Nnum": {
|
|
62
|
+
none: () => [C("bar-multi", "best", "1 categorical + multiple numeric columns — compare groups"), C("line-multi", "good", "Can also show as a multi-line chart")],
|
|
63
|
+
comparison: (e) => w["1cat+Nnum"].none(e),
|
|
64
|
+
ranking: (e) => w["1cat+Nnum"].none(e),
|
|
65
|
+
trend: () => [C("line-multi", "best", "A trend or crossover story reads best as lines, even over categorical periods"), C("bar-multi", "alternative", "Grouped bars if per-period comparison matters more than the trend")],
|
|
66
|
+
"part-to-whole": () => [
|
|
67
|
+
C("bar-stacked", "best", "Stacked bars show composition within each category"),
|
|
68
|
+
C("column-stacked", "good", "Stacked columns for the same composition"),
|
|
69
|
+
C("bar-multi", "alternative", "Grouped bars if comparison beats composition")
|
|
70
|
+
],
|
|
71
|
+
"composition-over-time": () => [
|
|
72
|
+
C("column-stacked", "best", "Stacked columns show composition across discrete periods"),
|
|
73
|
+
C("bar-stacked", "good", "Stacked bars for the same composition"),
|
|
74
|
+
C("area-stacked", "alternative", "Stacked area if the periods are continuous time")
|
|
75
|
+
],
|
|
76
|
+
range: () => [C("bar-split", "best", "Diverging bars show values around a shared baseline"), C("bar-multi", "alternative", "Grouped bars if there is no shared baseline")]
|
|
77
|
+
},
|
|
78
|
+
"1date+1num": {
|
|
79
|
+
none: () => [C("line", "best", "1 date + 1 numeric column — ideal for trend"), C("bar-vertical", "alternative", "Can also show as bars")],
|
|
80
|
+
trend: () => [
|
|
81
|
+
C("line", "best", "1 date + 1 numeric column — ideal for trend"),
|
|
82
|
+
C("area", "good", "Filled area emphasizes magnitude over time"),
|
|
83
|
+
C("bar-vertical", "alternative", "Can also show as bars")
|
|
84
|
+
],
|
|
85
|
+
comparison: () => [C("bar-vertical", "best", "Bars for comparing discrete time points"), C("line", "good", "Line if the trend matters more than the comparison")],
|
|
86
|
+
ranking: () => [C("bar-vertical", "best", "Bars for ranking discrete time points"), C("line", "good", "Line for the underlying trend")],
|
|
87
|
+
"part-to-whole": () => [C("area", "best", "Filled area reads as magnitude/share over time"), C("line", "good", "Line for the underlying trend")],
|
|
88
|
+
"composition-over-time": () => [C("area", "best", "Filled area shows magnitude over time"), C("line", "good", "Line for the underlying trend")]
|
|
89
|
+
},
|
|
90
|
+
"1date+Nnum": {
|
|
91
|
+
none: () => [C("line-multi", "best", "1 date + multiple numeric columns — compare trends"), C("bar-multi", "alternative", "Can also show as grouped bars")],
|
|
92
|
+
trend: (e) => w["1date+Nnum"].none(e),
|
|
93
|
+
comparison: (e) => w["1date+Nnum"].none(e),
|
|
94
|
+
ranking: (e) => w["1date+Nnum"].none(e),
|
|
95
|
+
"composition-over-time": () => [
|
|
96
|
+
C("area-stacked", "best", "Stacked area shows composition over continuous time"),
|
|
97
|
+
C("column-stacked", "good", "Stacked columns for the same composition"),
|
|
98
|
+
C("line-multi", "alternative", "Multi-line if composition is not the point")
|
|
99
|
+
],
|
|
100
|
+
"part-to-whole": () => [C("area-stacked", "best", "Stacked area shows share over time"), C("line-multi", "good", "Multi-line if absolute trends matter more")]
|
|
101
|
+
},
|
|
102
|
+
other: { none: () => [C("bar-vertical", "good", "Default bar chart recommendation")] }
|
|
130
103
|
};
|
|
131
|
-
function
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
104
|
+
function ot(e, t, n) {
|
|
105
|
+
let r = w[e], i = r[t] ?? r.none;
|
|
106
|
+
return i ? i(n) : [C("bar-vertical", "good", "Default bar chart recommendation")];
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region src/recommendations/shape.ts
|
|
110
|
+
function T(e, t) {
|
|
111
|
+
let n = e.filter((e) => e === "string").length, r = e.filter((e) => e === "number").length, i = e.filter((e) => e === "date").length;
|
|
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
|
+
}
|
|
114
|
+
//#endregion
|
|
115
|
+
//#region src/recommendations/types.ts
|
|
116
|
+
var st = {
|
|
117
|
+
"bar-vertical": "Vertical Bar Chart",
|
|
118
|
+
"bar-horizontal": "Horizontal Bar Chart",
|
|
119
|
+
"bar-multi": "Grouped Bar Chart",
|
|
120
|
+
"bar-grouped": "Grouped Bar Chart",
|
|
121
|
+
"bar-stacked": "Stacked Bar Chart",
|
|
122
|
+
"bar-split": "Diverging Bar Chart",
|
|
123
|
+
"column-stacked": "Stacked Column Chart",
|
|
124
|
+
line: "Line Chart",
|
|
125
|
+
"line-multi": "Multi-Line Chart",
|
|
126
|
+
area: "Area Chart",
|
|
127
|
+
"area-stacked": "Stacked Area Chart",
|
|
128
|
+
pie: "Pie Chart",
|
|
129
|
+
donut: "Donut Chart"
|
|
153
130
|
};
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
131
|
+
//#endregion
|
|
132
|
+
//#region src/recommendations/recommend.ts
|
|
133
|
+
function ct(e, t, n) {
|
|
134
|
+
return e.length === 0 ? [] : ot(T(e, t), S(n), t).map((e) => ({
|
|
135
|
+
chartType: e.type,
|
|
136
|
+
label: st[e.type] ?? e.type,
|
|
137
|
+
fitness: e.fitness,
|
|
138
|
+
reason: e.reason
|
|
139
|
+
}));
|
|
140
|
+
}
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region src/charts/colorblind.ts
|
|
143
|
+
var lt = {
|
|
144
|
+
protanopia: "Protanopia (no red)",
|
|
145
|
+
deuteranopia: "Deuteranopia (no green)",
|
|
146
|
+
tritanopia: "Tritanopia (no blue)"
|
|
147
|
+
}, E = {
|
|
148
|
+
protanopia: [
|
|
149
|
+
.152286,
|
|
150
|
+
1.052583,
|
|
151
|
+
-.204868,
|
|
152
|
+
0,
|
|
153
|
+
0,
|
|
154
|
+
.114503,
|
|
155
|
+
.786281,
|
|
156
|
+
.099216,
|
|
157
|
+
0,
|
|
158
|
+
0,
|
|
159
|
+
-.003882,
|
|
160
|
+
-.048116,
|
|
161
|
+
1.051998,
|
|
162
|
+
0,
|
|
163
|
+
0,
|
|
164
|
+
0,
|
|
165
|
+
0,
|
|
166
|
+
0,
|
|
167
|
+
1,
|
|
168
|
+
0
|
|
169
|
+
],
|
|
170
|
+
deuteranopia: [
|
|
171
|
+
.367322,
|
|
172
|
+
.860646,
|
|
173
|
+
-.227968,
|
|
174
|
+
0,
|
|
175
|
+
0,
|
|
176
|
+
.280085,
|
|
177
|
+
.672501,
|
|
178
|
+
.047413,
|
|
179
|
+
0,
|
|
180
|
+
0,
|
|
181
|
+
-.01182,
|
|
182
|
+
.04294,
|
|
183
|
+
.968881,
|
|
184
|
+
0,
|
|
185
|
+
0,
|
|
186
|
+
0,
|
|
187
|
+
0,
|
|
188
|
+
0,
|
|
189
|
+
1,
|
|
190
|
+
0
|
|
191
|
+
],
|
|
192
|
+
tritanopia: [
|
|
193
|
+
1.255528,
|
|
194
|
+
-.076749,
|
|
195
|
+
-.178779,
|
|
196
|
+
0,
|
|
197
|
+
0,
|
|
198
|
+
-.078411,
|
|
199
|
+
.930809,
|
|
200
|
+
.147602,
|
|
201
|
+
0,
|
|
202
|
+
0,
|
|
203
|
+
.004733,
|
|
204
|
+
.691367,
|
|
205
|
+
.3039,
|
|
206
|
+
0,
|
|
207
|
+
0,
|
|
208
|
+
0,
|
|
209
|
+
0,
|
|
210
|
+
0,
|
|
211
|
+
1,
|
|
212
|
+
0
|
|
213
|
+
]
|
|
236
214
|
};
|
|
237
|
-
function
|
|
238
|
-
|
|
239
|
-
}
|
|
240
|
-
function
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
}
|
|
246
|
-
function
|
|
247
|
-
|
|
248
|
-
}
|
|
249
|
-
function
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
function
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
function
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
`);
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
`
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
`);
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
`);
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
`);
|
|
353
|
-
}
|
|
354
|
-
function
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
}
|
|
374
|
-
function
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
`
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
for (const t of e.scenes)
|
|
485
|
-
n.push(M(t, " "));
|
|
486
|
-
for (const t of e.transforms)
|
|
487
|
-
n.push($(t, " "));
|
|
488
|
-
return n.push("}"), n.join(`
|
|
489
|
-
`);
|
|
490
|
-
}
|
|
491
|
-
const U = /* @__PURE__ */ new Set([
|
|
492
|
-
"title",
|
|
493
|
-
"description",
|
|
494
|
-
"byline",
|
|
495
|
-
"note",
|
|
496
|
-
"source",
|
|
497
|
-
"sourceUrl",
|
|
498
|
-
"padding",
|
|
499
|
-
"transparentBackground",
|
|
500
|
-
"type",
|
|
501
|
-
"sort",
|
|
502
|
-
"sortMode",
|
|
503
|
-
"theme",
|
|
504
|
-
"heightMode",
|
|
505
|
-
"aspectRatio",
|
|
506
|
-
"fixedHeight"
|
|
507
|
-
]), A = /* @__PURE__ */ new Set(["sort"]), se = /* @__PURE__ */ new Set([
|
|
508
|
-
"text",
|
|
509
|
-
"repeat",
|
|
510
|
-
"textColor",
|
|
511
|
-
"maxWidth",
|
|
512
|
-
"textOutline",
|
|
513
|
-
"showLine",
|
|
514
|
-
"anchorDirection",
|
|
515
|
-
"textOffsetX",
|
|
516
|
-
"textOffsetY",
|
|
517
|
-
"lineStyle",
|
|
518
|
-
"lineWeight",
|
|
519
|
-
"showArrow",
|
|
520
|
-
"lineTargetDistance",
|
|
521
|
-
"showCircle",
|
|
522
|
-
"circleSize",
|
|
523
|
-
"circleStyle",
|
|
524
|
-
"circleColor"
|
|
525
|
-
]), le = /* @__PURE__ */ new Set([
|
|
526
|
-
"start",
|
|
527
|
-
"end",
|
|
528
|
-
"repeat",
|
|
529
|
-
"orientation",
|
|
530
|
-
"startAnchor",
|
|
531
|
-
"endAnchor",
|
|
532
|
-
"bgColor",
|
|
533
|
-
"bgOpacity",
|
|
534
|
-
"direction",
|
|
535
|
-
"text",
|
|
536
|
-
"textColor"
|
|
537
|
-
]), ce = /* @__PURE__ */ new Set([
|
|
538
|
-
"text",
|
|
539
|
-
"x",
|
|
540
|
-
"y",
|
|
541
|
-
"repeat",
|
|
542
|
-
"textColor",
|
|
543
|
-
"maxWidth",
|
|
544
|
-
"textOutline"
|
|
215
|
+
function D(e) {
|
|
216
|
+
return `bc-cvd-${e}`;
|
|
217
|
+
}
|
|
218
|
+
function ut(e) {
|
|
219
|
+
let t = "http://www.w3.org/2000/svg", n = document.createElementNS(t, "filter");
|
|
220
|
+
n.setAttribute("id", D(e)), n.setAttribute("color-interpolation-filters", "linearRGB");
|
|
221
|
+
let r = document.createElementNS(t, "feColorMatrix");
|
|
222
|
+
return r.setAttribute("type", "matrix"), r.setAttribute("values", E[e].join(" ")), n.appendChild(r), n;
|
|
223
|
+
}
|
|
224
|
+
function dt(e) {
|
|
225
|
+
return e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4;
|
|
226
|
+
}
|
|
227
|
+
function O(e) {
|
|
228
|
+
return e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055;
|
|
229
|
+
}
|
|
230
|
+
function k(e, t) {
|
|
231
|
+
let [n, r, i] = x(e).rgb().map((e) => dt(e / 255)), a = E[t], o = O(a[0] * n + a[1] * r + a[2] * i), s = O(a[5] * n + a[6] * r + a[7] * i), c = O(a[10] * n + a[11] * r + a[12] * i), l = (e) => Math.min(255, Math.max(0, Math.round(e * 255)));
|
|
232
|
+
return x(l(o), l(s), l(c)).hex();
|
|
233
|
+
}
|
|
234
|
+
var ft = 10;
|
|
235
|
+
function pt(e) {
|
|
236
|
+
if (e.length < 2) return [];
|
|
237
|
+
let t = [
|
|
238
|
+
"protanopia",
|
|
239
|
+
"deuteranopia",
|
|
240
|
+
"tritanopia"
|
|
241
|
+
], n = [];
|
|
242
|
+
for (let r of t) {
|
|
243
|
+
let t = e.map((e) => k(e, r)), i = [];
|
|
244
|
+
for (let n = 0; n < t.length; n++) for (let r = n + 1; r < t.length; r++) {
|
|
245
|
+
let a = x.deltaE(t[n], t[r]);
|
|
246
|
+
a < ft && i.push({
|
|
247
|
+
a: e[n],
|
|
248
|
+
b: e[r],
|
|
249
|
+
deltaE: a
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
i.length > 0 && n.push({
|
|
253
|
+
type: r,
|
|
254
|
+
label: lt[r],
|
|
255
|
+
pairs: i
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
return n;
|
|
259
|
+
}
|
|
260
|
+
//#endregion
|
|
261
|
+
//#region src/dsl/serializer.ts
|
|
262
|
+
function A(e, t) {
|
|
263
|
+
return (e ?? []).flatMap((e) => e.split("\n").map((e) => `${t}// ${e.trim()}`));
|
|
264
|
+
}
|
|
265
|
+
function j(e) {
|
|
266
|
+
return typeof e.value == "number" ? e.isPercentage ? `${e.value}%` : `${e.value}` : typeof e.value == "string" && e.value.startsWith("#") ? `"${e.value}"` : typeof e.value == "string" && /^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(e.value) ? e.value : `"${String(e.value).replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`;
|
|
267
|
+
}
|
|
268
|
+
function M(e, t) {
|
|
269
|
+
let n = `${t}${/^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(e.key) ? e.key : `"${e.key}"`} = ${j(e)}`;
|
|
270
|
+
return [...A(e.leadingComments, t), n].join("\n");
|
|
271
|
+
}
|
|
272
|
+
function mt(e, t) {
|
|
273
|
+
let n;
|
|
274
|
+
return n = e.key === "series" && e.quotedKey && !(e.values && e.values.length > 1) ? `${t}"series" = ${j(e)}` : e.values && e.values.length > 1 ? `${t}${e.key === "series" && !e.quotedKey ? e.key : `"${e.key}"`} = ${e.values.map((e) => typeof e == "number" ? `${e}` : `"${String(e).replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`).join(",")}` : `${t}${/^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(e.key) ? e.key : `"${e.key}"`} = ${j(e)}`, [...A(e.leadingComments, t), n].join("\n");
|
|
275
|
+
}
|
|
276
|
+
function N(e, t) {
|
|
277
|
+
let n = [...A(e.leadingComments, t), `${t}data {`];
|
|
278
|
+
for (let r of e.entries) n.push(mt(r, `${t} `));
|
|
279
|
+
return n.push(`${t}}`), n.join("\n");
|
|
280
|
+
}
|
|
281
|
+
function P(e, t) {
|
|
282
|
+
let n = e.fromHighlight ? "highlight" : "colorize", r = [...A(e.leadingComments, t), `${t}${n} "${e.target}" {`];
|
|
283
|
+
for (let n of e.properties) r.push(M(n, `${t} `));
|
|
284
|
+
return r.push(`${t}}`), r.join("\n");
|
|
285
|
+
}
|
|
286
|
+
function F(e, t) {
|
|
287
|
+
return [...A(e.leadingComments, t), `${t}highlight "${e.target}"`].join("\n");
|
|
288
|
+
}
|
|
289
|
+
function I(e, t) {
|
|
290
|
+
let n = [...A(e.leadingComments, t), `${t}area-fill "${e.from}" "${e.to}" {`];
|
|
291
|
+
for (let r of e.properties) n.push(M(r, `${t} `));
|
|
292
|
+
return n.push(`${t}}`), n.join("\n");
|
|
293
|
+
}
|
|
294
|
+
function L(e, t) {
|
|
295
|
+
let n = e.kind ?? f.Point;
|
|
296
|
+
if (n === f.Range) {
|
|
297
|
+
let n = [...A(e.leadingComments, t), `${t}range {`];
|
|
298
|
+
for (let r of e.properties) n.push(M(r, `${t} `));
|
|
299
|
+
return n.push(`${t}}`), n.join("\n");
|
|
300
|
+
}
|
|
301
|
+
if (n === f.Free) {
|
|
302
|
+
let n = [...A(e.leadingComments, t), `${t}note {`];
|
|
303
|
+
for (let r of e.properties) n.push(M(r, `${t} `));
|
|
304
|
+
return n.push(`${t}}`), n.join("\n");
|
|
305
|
+
}
|
|
306
|
+
let r = "target" in e ? e.target : "", i = [...A(e.leadingComments, t), `${t}annotation "${r}" {`];
|
|
307
|
+
for (let n of e.properties) i.push(M(n, `${t} `));
|
|
308
|
+
return i.push(`${t}}`), i.join("\n");
|
|
309
|
+
}
|
|
310
|
+
function R(e, t) {
|
|
311
|
+
let n = [...A(e.leadingComments, t), `${t}series "${e.name}" {`];
|
|
312
|
+
for (let r of e.properties) n.push(M(r, `${t} `));
|
|
313
|
+
return n.push(`${t}}`), n.join("\n");
|
|
314
|
+
}
|
|
315
|
+
function z(e, t) {
|
|
316
|
+
let n = e.name == null ? `${t}scene {` : `${t}scene "${e.name}" {`, r = [...A(e.leadingComments, t), n];
|
|
317
|
+
for (let n of e.properties) r.push(M(n, `${t} `));
|
|
318
|
+
e.data && r.push(N(e.data, `${t} `));
|
|
319
|
+
for (let n of e.colorizes) r.push(P(n, `${t} `));
|
|
320
|
+
for (let n of e.highlights) r.push(F(n, `${t} `));
|
|
321
|
+
for (let n of e.areaFills) r.push(I(n, `${t} `));
|
|
322
|
+
for (let n of e.annotations) r.push(L(n, `${t} `));
|
|
323
|
+
for (let n of e.series) r.push(R(n, `${t} `));
|
|
324
|
+
for (let n of e.transforms) r.push(B(n, `${t} `));
|
|
325
|
+
return r.push(`${t}}`), r.join("\n");
|
|
326
|
+
}
|
|
327
|
+
function B(e, t) {
|
|
328
|
+
let n = [...A(e.leadingComments, t), `${t}transform ${e.transformType} {`];
|
|
329
|
+
for (let r of e.properties) n.push(M(r, `${t} `));
|
|
330
|
+
return n.push(`${t}}`), n.join("\n");
|
|
331
|
+
}
|
|
332
|
+
function ht(e, t, n) {
|
|
333
|
+
let r = p(n).find((t) => t.key === e);
|
|
334
|
+
return !r || r.default === void 0 ? !1 : String(r.default) === String(t);
|
|
335
|
+
}
|
|
336
|
+
function gt(e) {
|
|
337
|
+
let t = [`chart ${e.chartType} {`];
|
|
338
|
+
for (let n of e.properties) t.push(M(n, " "));
|
|
339
|
+
e.data && t.push(N(e.data, " "));
|
|
340
|
+
for (let n of e.colorizes) t.push(P(n, " "));
|
|
341
|
+
for (let n of e.highlights) t.push(F(n, " "));
|
|
342
|
+
for (let n of e.areaFills) t.push(I(n, " "));
|
|
343
|
+
for (let n of e.annotations) t.push(L(n, " "));
|
|
344
|
+
for (let n of e.series) t.push(R(n, " "));
|
|
345
|
+
for (let n of e.scenes) t.push(z(n, " "));
|
|
346
|
+
for (let n of e.transforms) t.push(B(n, " "));
|
|
347
|
+
return t.push("}"), t.join("\n");
|
|
348
|
+
}
|
|
349
|
+
function _t(e) {
|
|
350
|
+
return new Map(e.map((e) => [e.key, e.value]));
|
|
351
|
+
}
|
|
352
|
+
function V(e, t, n, r) {
|
|
353
|
+
let i = p(n).find((t) => t.key === e);
|
|
354
|
+
return i ? r.has(e) ? String(r.get(e)) === String(t) : i.default !== void 0 && String(i.default) === String(t) : !1;
|
|
355
|
+
}
|
|
356
|
+
function H(e, t, n, r) {
|
|
357
|
+
let i = [...A(e.leadingComments, t), `${t}series "${e.name}" {`];
|
|
358
|
+
for (let a of e.properties) (a.isPercentage || !V(a.key, a.value, n, r)) && i.push(M(a, `${t} `));
|
|
359
|
+
return i.push(`${t}}`), i.join("\n");
|
|
360
|
+
}
|
|
361
|
+
function vt(e, t, n, r) {
|
|
362
|
+
let i = e.properties.find((e) => e.key === "type"), a = i ? String(i.value) : n, o = e.name == null ? `${t}scene {` : `${t}scene "${e.name}" {`, s = [...A(e.leadingComments, t), o], c = new Map(r);
|
|
363
|
+
for (let n of e.properties) {
|
|
364
|
+
if (n.key === "type") {
|
|
365
|
+
s.push(M(n, `${t} `));
|
|
366
|
+
continue;
|
|
367
|
+
}
|
|
368
|
+
c.set(n.key, n.value), (n.isPercentage || !V(n.key, n.value, a, r)) && s.push(M(n, `${t} `));
|
|
369
|
+
}
|
|
370
|
+
e.data && s.push(N(e.data, `${t} `));
|
|
371
|
+
for (let n of e.colorizes) s.push(P(n, `${t} `));
|
|
372
|
+
for (let n of e.highlights) s.push(F(n, `${t} `));
|
|
373
|
+
for (let n of e.areaFills) s.push(I(n, `${t} `));
|
|
374
|
+
for (let n of e.annotations) s.push(L(n, `${t} `));
|
|
375
|
+
for (let n of e.series) s.push(H(n, `${t} `, a, c));
|
|
376
|
+
for (let n of e.transforms) s.push(B(n, `${t} `));
|
|
377
|
+
return s.push(`${t}}`), s.join("\n");
|
|
378
|
+
}
|
|
379
|
+
function yt(e) {
|
|
380
|
+
let t = [`chart ${e.chartType} {`], n = /* @__PURE__ */ new Map();
|
|
381
|
+
for (let r of e.properties) (r.isPercentage || !V(r.key, r.value, e.chartType, n)) && t.push(M(r, " "));
|
|
382
|
+
e.data && t.push(N(e.data, " "));
|
|
383
|
+
for (let n of e.colorizes) t.push(P(n, " "));
|
|
384
|
+
for (let n of e.highlights) t.push(F(n, " "));
|
|
385
|
+
for (let n of e.areaFills) t.push(I(n, " "));
|
|
386
|
+
for (let n of e.annotations) t.push(L(n, " "));
|
|
387
|
+
let r = _t(e.properties);
|
|
388
|
+
for (let n of e.series) t.push(H(n, " ", e.chartType, r));
|
|
389
|
+
for (let n of e.scenes) t.push(vt(n, " ", e.chartType, r));
|
|
390
|
+
for (let n of e.transforms) t.push(B(n, " "));
|
|
391
|
+
return t.push("}"), t.join("\n");
|
|
392
|
+
}
|
|
393
|
+
function bt(e) {
|
|
394
|
+
let t = [`chart ${e.chartType} {`];
|
|
395
|
+
for (let n of e.properties) ht(n.key, n.value, e.chartType) || t.push(M(n, " "));
|
|
396
|
+
e.data && t.push(N(e.data, " "));
|
|
397
|
+
for (let n of e.colorizes) t.push(P(n, " "));
|
|
398
|
+
for (let n of e.highlights) t.push(F(n, " "));
|
|
399
|
+
for (let n of e.areaFills) t.push(I(n, " "));
|
|
400
|
+
for (let n of e.annotations) t.push(L(n, " "));
|
|
401
|
+
for (let n of e.series) t.push(R(n, " "));
|
|
402
|
+
for (let n of e.scenes) t.push(z(n, " "));
|
|
403
|
+
for (let n of e.transforms) t.push(B(n, " "));
|
|
404
|
+
return t.push("}"), t.join("\n");
|
|
405
|
+
}
|
|
406
|
+
//#endregion
|
|
407
|
+
//#region src/dsl/validate.ts
|
|
408
|
+
var U = /* @__PURE__ */ new Set([
|
|
409
|
+
"title",
|
|
410
|
+
"description",
|
|
411
|
+
"byline",
|
|
412
|
+
"note",
|
|
413
|
+
"source",
|
|
414
|
+
"sourceUrl",
|
|
415
|
+
"padding",
|
|
416
|
+
"transparentBackground",
|
|
417
|
+
"type",
|
|
418
|
+
"sort",
|
|
419
|
+
"sortMode",
|
|
420
|
+
"theme",
|
|
421
|
+
"heightMode",
|
|
422
|
+
"aspectRatio",
|
|
423
|
+
"fixedHeight"
|
|
424
|
+
]), W = /* @__PURE__ */ new Set(["sort"]), xt = /* @__PURE__ */ new Set([
|
|
425
|
+
"text",
|
|
426
|
+
"repeat",
|
|
427
|
+
"textColor",
|
|
428
|
+
"maxWidth",
|
|
429
|
+
"textOutline",
|
|
430
|
+
"showLine",
|
|
431
|
+
"anchorDirection",
|
|
432
|
+
"textOffsetX",
|
|
433
|
+
"textOffsetY",
|
|
434
|
+
"lineStyle",
|
|
435
|
+
"lineWeight",
|
|
436
|
+
"showArrow",
|
|
437
|
+
"lineTargetDistance",
|
|
438
|
+
"showCircle",
|
|
439
|
+
"circleSize",
|
|
440
|
+
"circleStyle",
|
|
441
|
+
"circleColor"
|
|
442
|
+
]), St = /* @__PURE__ */ new Set([
|
|
443
|
+
"start",
|
|
444
|
+
"end",
|
|
445
|
+
"repeat",
|
|
446
|
+
"orientation",
|
|
447
|
+
"startAnchor",
|
|
448
|
+
"endAnchor",
|
|
449
|
+
"bgColor",
|
|
450
|
+
"bgOpacity",
|
|
451
|
+
"direction",
|
|
452
|
+
"text",
|
|
453
|
+
"textColor"
|
|
454
|
+
]), Ct = /* @__PURE__ */ new Set([
|
|
455
|
+
"text",
|
|
456
|
+
"x",
|
|
457
|
+
"y",
|
|
458
|
+
"repeat",
|
|
459
|
+
"textColor",
|
|
460
|
+
"maxWidth",
|
|
461
|
+
"textOutline"
|
|
545
462
|
]);
|
|
546
|
-
function
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
}
|
|
574
|
-
function
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
}
|
|
622
|
-
function
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
463
|
+
function wt(e, t) {
|
|
464
|
+
let n = e.length, r = t.length;
|
|
465
|
+
if (n === 0) return r;
|
|
466
|
+
if (r === 0) return n;
|
|
467
|
+
let i = Array.from({ length: r + 1 }, (e, t) => t), a = Array(r + 1);
|
|
468
|
+
for (let o = 1; o <= n; o++) {
|
|
469
|
+
a[0] = o;
|
|
470
|
+
for (let n = 1; n <= r; n++) {
|
|
471
|
+
let r = e[o - 1] === t[n - 1] ? 0 : 1;
|
|
472
|
+
a[n] = Math.min(a[n - 1] + 1, i[n] + 1, i[n - 1] + r);
|
|
473
|
+
}
|
|
474
|
+
[i, a] = [a, i];
|
|
475
|
+
}
|
|
476
|
+
return i[r];
|
|
477
|
+
}
|
|
478
|
+
function G(e, t) {
|
|
479
|
+
let n, r = Infinity;
|
|
480
|
+
for (let i of t) {
|
|
481
|
+
let t = wt(e.toLowerCase(), i.toLowerCase());
|
|
482
|
+
t < r && (r = t, n = i);
|
|
483
|
+
}
|
|
484
|
+
if (n === void 0) return;
|
|
485
|
+
let i = Math.max(1, Math.min(3, Math.floor(e.length / 2)));
|
|
486
|
+
return r <= i ? n : void 0;
|
|
487
|
+
}
|
|
488
|
+
function Tt(e, t) {
|
|
489
|
+
return e.find((e) => e.key === t);
|
|
490
|
+
}
|
|
491
|
+
function Et(e, t, n, r) {
|
|
492
|
+
let i = t.value, a = String(i).toLowerCase();
|
|
493
|
+
if (e.type === m.Boolean) {
|
|
494
|
+
if (e.key === "valueLabels" && a === "percent" || i === !0 || i === !1 || a === "true" || a === "false") return;
|
|
495
|
+
r.push({
|
|
496
|
+
code: "invalid-boolean",
|
|
497
|
+
path: n,
|
|
498
|
+
message: `${e.key} expects true or false, got "${i}".`,
|
|
499
|
+
suggestion: a === "no" || a === "0" || a === "off" ? "false" : "true"
|
|
500
|
+
});
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
if (e.choices && e.choices.length > 0) {
|
|
504
|
+
let t = e.choices.map((e) => e.value);
|
|
505
|
+
if (t.includes(String(i)) || String(i) === "" && t.includes("")) return;
|
|
506
|
+
let a = G(String(i), t.filter((e) => e !== ""));
|
|
507
|
+
r.push({
|
|
508
|
+
code: "invalid-choice",
|
|
509
|
+
path: n,
|
|
510
|
+
message: `${e.key} must be one of: ${t.map((e) => `"${e}"`).join(", ")}; got "${i}".`,
|
|
511
|
+
suggestion: a
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
function K(e, t, n, r) {
|
|
516
|
+
let i = p(e), a = /* @__PURE__ */ new Set([...i.map((e) => e.key), ...U]);
|
|
517
|
+
for (let o of t) {
|
|
518
|
+
let t = `${n}.${o.key}`;
|
|
519
|
+
if (U.has(o.key)) continue;
|
|
520
|
+
let s = Tt(i, o.key);
|
|
521
|
+
if (!s) {
|
|
522
|
+
r.push({
|
|
523
|
+
code: "unknown-property",
|
|
524
|
+
path: t,
|
|
525
|
+
message: `Unknown property "${o.key}" for chart type "${e}".`,
|
|
526
|
+
suggestion: G(o.key, a)
|
|
527
|
+
});
|
|
528
|
+
continue;
|
|
529
|
+
}
|
|
530
|
+
Et(s, o, t, r);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
function Dt(e) {
|
|
534
|
+
return e === f.Range ? St : e === f.Free ? Ct : xt;
|
|
535
|
+
}
|
|
536
|
+
function Ot(e) {
|
|
537
|
+
return d[e];
|
|
538
|
+
}
|
|
539
|
+
function q(e, t, n) {
|
|
540
|
+
e.forEach((e, r) => {
|
|
541
|
+
let i = e.kind ?? f.Point, a = Dt(i), o = Ot(i);
|
|
542
|
+
for (let i of e.properties) a.has(i.key) || n.push({
|
|
543
|
+
code: "unknown-annotation-property",
|
|
544
|
+
path: `${t}.${o}[${r}].${i.key}`,
|
|
545
|
+
message: `Unknown ${o} property "${i.key}"; it will be silently ignored.`,
|
|
546
|
+
suggestion: G(i.key, a)
|
|
547
|
+
});
|
|
548
|
+
let s = y(e.properties).get("repeat");
|
|
549
|
+
s !== void 0 && (s === "true" || s === "false" || s === !0 || s === !1 || typeof s == "number" && Number.isInteger(s) && s >= 1 || n.push({
|
|
550
|
+
code: "invalid-annotation-repeat",
|
|
551
|
+
message: `repeat must be false, true, or a positive integer (got ${String(s)})`,
|
|
552
|
+
path: `${t}.${o}[${r}].repeat`
|
|
553
|
+
}));
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
function J(e, t, n) {
|
|
557
|
+
e.forEach((e, r) => {
|
|
558
|
+
W.has(e.transformType) || n.push({
|
|
559
|
+
code: "unknown-transform",
|
|
560
|
+
path: `${t}.transform[${r}]`,
|
|
561
|
+
message: `Unknown transform type "${e.transformType}". Known types: ${[...W].map((e) => `"${e}"`).join(", ")}.`,
|
|
562
|
+
suggestion: G(e.transformType, W)
|
|
563
|
+
});
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
function kt(e) {
|
|
567
|
+
let t = [], n = [], r = b(), i = r.includes(e.chartType);
|
|
568
|
+
i || t.push({
|
|
569
|
+
code: "unknown-chart-type",
|
|
570
|
+
path: "chartType",
|
|
571
|
+
message: `Unknown chart type "${e.chartType}".`,
|
|
572
|
+
suggestion: G(e.chartType, r)
|
|
573
|
+
}), i && K(e.chartType, e.properties, "chart", t), J(e.transforms, "chart", t), q(e.annotations, "chart", t);
|
|
574
|
+
let a = !!e.data && e.data.entries.length > 0, o = e.scenes.some((e) => !!e.data && e.data.entries.length > 0);
|
|
575
|
+
return !a && !o && t.push({
|
|
576
|
+
code: "missing-data",
|
|
577
|
+
path: "data",
|
|
578
|
+
message: e.data && e.data.entries.length === 0 ? "Data block is empty." : "Chart has no data."
|
|
579
|
+
}), e.data && At(e.data.entries, n), e.scenes.forEach((n, r) => {
|
|
580
|
+
jt(n, e.chartType, r, t);
|
|
581
|
+
}), {
|
|
582
|
+
valid: t.length === 0,
|
|
583
|
+
errors: t,
|
|
584
|
+
warnings: n
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
function At(e, t) {
|
|
588
|
+
let n = e.findIndex((e) => e.key === "series" && !e.quotedKey);
|
|
589
|
+
if (n === -1) return;
|
|
590
|
+
let r = e[n], i = r.values ?? [r.value];
|
|
591
|
+
i.every((e) => typeof e == "number") && t.push({
|
|
592
|
+
code: "numeric-series-meta-row",
|
|
593
|
+
path: "data.series",
|
|
594
|
+
message: "The unquoted `series` row names the chart columns, but its values are all numbers. If you meant a data category named series, quote the label.",
|
|
595
|
+
suggestion: `"series" = ${i.join(",")}`
|
|
596
|
+
}), n !== 0 && t.push({
|
|
597
|
+
code: "misplaced-series-meta-row",
|
|
598
|
+
path: "data.series",
|
|
599
|
+
message: "The `series` meta-row must be the first entry in the data block; later rows are ignored and the chart falls back to a single series.",
|
|
600
|
+
suggestion: "Move the series row to the top of the data block."
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
function jt(e, t, n, r) {
|
|
604
|
+
let i = `scene[${n}]`, a = e.properties.find((e) => e.key === "type")?.value, o = a == null ? t : String(a);
|
|
605
|
+
a != null && !b().includes(o) ? r.push({
|
|
606
|
+
code: "unknown-chart-type",
|
|
607
|
+
path: `${i}.type`,
|
|
608
|
+
message: `Unknown chart type "${o}".`,
|
|
609
|
+
suggestion: G(o, b())
|
|
610
|
+
}) : K(o, e.properties, i, r), J(e.transforms, i, r), q(e.annotations, i, r);
|
|
611
|
+
}
|
|
612
|
+
//#endregion
|
|
613
|
+
//#region src/samples/letter-frequency.bpc?raw
|
|
614
|
+
var Mt = "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", Nt = "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", Pt = "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", Ft = "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", It = "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", Lt = "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", Rt = "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", zt = "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", Bt = "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", Vt = "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", Ht = "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", Ut = "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", Wt = "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", Gt = "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", Kt = "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", qt = "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", Jt = "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", Yt = "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", Xt = "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";
|
|
615
|
+
//#endregion
|
|
616
|
+
//#region src/samples.ts
|
|
617
|
+
function Y(e, t) {
|
|
618
|
+
let n = e.properties.find((e) => e.key === t);
|
|
619
|
+
return n ? String(n.value) : "";
|
|
620
|
+
}
|
|
621
|
+
function Zt(e) {
|
|
622
|
+
if (!e.data) return "";
|
|
623
|
+
let t = e.data.entries, n = t.find((e) => e.key === "series" && !e.quotedKey);
|
|
624
|
+
return n ? [["category", ...String(n.value).split(",")].join(" "), ...t.filter((e) => !(e.key === "series" && !e.quotedKey)).map((e) => {
|
|
625
|
+
let t = String(e.value).split(",");
|
|
626
|
+
return [e.key, ...t].join(" ");
|
|
627
|
+
})].join("\n") : [["label", "value"].join(" "), ...t.map((e) => [e.key, String(e.value)].join(" "))].join("\n");
|
|
627
628
|
}
|
|
628
|
-
function
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
const r = e[t], o = r.values ?? [r.value];
|
|
678
|
-
o.every((a) => typeof a == "number") && n.push({
|
|
679
|
-
code: "numeric-series-meta-row",
|
|
680
|
-
path: "data.series",
|
|
681
|
-
message: "The unquoted `series` row names the chart columns, but its values are all numbers. If you meant a data category named series, quote the label.",
|
|
682
|
-
suggestion: `"series" = ${o.join(",")}`
|
|
683
|
-
}), t !== 0 && n.push({
|
|
684
|
-
code: "misplaced-series-meta-row",
|
|
685
|
-
path: "data.series",
|
|
686
|
-
message: "The `series` meta-row must be the first entry in the data block; later rows are ignored and the chart falls back to a single series.",
|
|
687
|
-
suggestion: "Move the series row to the top of the data block."
|
|
688
|
-
});
|
|
689
|
-
}
|
|
690
|
-
function ge(e, n, t, r) {
|
|
691
|
-
var l;
|
|
692
|
-
const o = `scene[${t}]`, a = (l = e.properties.find((i) => i.key === "type")) == null ? void 0 : l.value, s = a != null ? String(a) : n;
|
|
693
|
-
a != null && !T().includes(s) ? r.push({
|
|
694
|
-
code: "unknown-chart-type",
|
|
695
|
-
path: `${o}.type`,
|
|
696
|
-
message: `Unknown chart type "${s}".`,
|
|
697
|
-
suggestion: b(s, T())
|
|
698
|
-
}) : F(s, e.properties, o, r), j(e.transforms, o, r), R(e.annotations, o, r);
|
|
699
|
-
}
|
|
700
|
-
const be = `chart bar-vertical {
|
|
701
|
-
title = "E is the most frequent letter in English"
|
|
702
|
-
description = "How often each letter appears in typical English text"
|
|
703
|
-
byline = "Pierre Romera"
|
|
704
|
-
source = "Lewand, Cryptological Mathematics"
|
|
705
|
-
sourceUrl = "https://en.wikipedia.org/wiki/Letter_frequency"
|
|
706
|
-
note = "Based on analysis of 40,000 words from English prose"
|
|
707
|
-
colorPalette = "London"
|
|
708
|
-
sort = descending
|
|
709
|
-
|
|
710
|
-
highlight "E"
|
|
711
|
-
|
|
712
|
-
data {
|
|
713
|
-
"E" = 12.70
|
|
714
|
-
"T" = 9.06
|
|
715
|
-
"A" = 8.17
|
|
716
|
-
"O" = 7.51
|
|
717
|
-
"I" = 6.97
|
|
718
|
-
"N" = 6.75
|
|
719
|
-
"S" = 6.33
|
|
720
|
-
"H" = 6.09
|
|
721
|
-
"R" = 5.99
|
|
722
|
-
"D" = 4.25
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
`, ye = `chart bar-vertical {
|
|
726
|
-
// the headline above the chart
|
|
727
|
-
title = "China emits more CO₂ than the US and India combined"
|
|
728
|
-
description = "Annual emissions in billion tonnes, 2023"
|
|
729
|
-
source = "Our World in Data"
|
|
730
|
-
sourceUrl = "https://ourworldindata.org/co2-emissions"
|
|
731
|
-
|
|
732
|
-
// one row per country: "label" = value
|
|
733
|
-
data {
|
|
734
|
-
"China" = 12.17
|
|
735
|
-
"United States" = 4.92
|
|
736
|
-
"India" = 3.06
|
|
737
|
-
"Russia" = 1.73
|
|
738
|
-
"Japan" = 0.99
|
|
739
|
-
"Germany" = 0.59
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
// highlight pops one bar in the accent color
|
|
743
|
-
highlight "China"
|
|
744
|
-
|
|
745
|
-
// an annotation points a callout at a single bar
|
|
746
|
-
annotation "India" {
|
|
747
|
-
text = "Surpassed EU in 2023"
|
|
748
|
-
showLine = true
|
|
749
|
-
anchorDirection = N
|
|
750
|
-
textOffsetX = 66
|
|
751
|
-
textOffsetY = -41
|
|
752
|
-
lineStyle = curve-left
|
|
753
|
-
showArrow = true
|
|
754
|
-
lineTargetDistance = 26
|
|
755
|
-
showCircle = false
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
`, we = `chart bar-horizontal {
|
|
759
|
-
title = "Mandarin has nearly twice as many native speakers as Spanish"
|
|
760
|
-
description = "Number of native speakers worldwide, in millions"
|
|
761
|
-
source = "Ethnologue"
|
|
762
|
-
sourceUrl = "https://ethnologue.com"
|
|
763
|
-
byline = "Pierre Romera"
|
|
764
|
-
sort = descending
|
|
765
|
-
|
|
766
|
-
highlight "Mandarin"
|
|
767
|
-
|
|
768
|
-
data {
|
|
769
|
-
"Mandarin" = 988
|
|
770
|
-
"Spanish" = 487
|
|
771
|
-
"English" = 372
|
|
772
|
-
"Hindi" = 347
|
|
773
|
-
"Bengali" = 232
|
|
774
|
-
"Portuguese" = 252
|
|
775
|
-
"Russian" = 133
|
|
776
|
-
"Japanese" = 124
|
|
777
|
-
}
|
|
778
|
-
}
|
|
779
|
-
`, ve = `chart line-multi {
|
|
780
|
-
title = "China now buys more electric cars than the rest of the world combined"
|
|
781
|
-
description = "Electric car sales by region, millions per year"
|
|
782
|
-
source = "IEA Global EV Outlook 2024"
|
|
783
|
-
sourceUrl = "https://www.iea.org/reports/global-ev-outlook-2024"
|
|
784
|
-
colorPalette = "Maya"
|
|
785
|
-
tooltips = true
|
|
786
|
-
|
|
787
|
-
data {
|
|
788
|
-
series = "China","Europe","United States","Rest of world"
|
|
789
|
-
"2018" = 1.1,0.4,0.36,0.1
|
|
790
|
-
"2020" = 1.3,1.4,0.30,0.2
|
|
791
|
-
"2021" = 3.3,2.3,0.63,0.4
|
|
792
|
-
"2022" = 6.0,2.7,1.0,0.7
|
|
793
|
-
"2023" = 8.1,3.2,1.4,1.0
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
`, Se = `chart bar-multi {
|
|
797
|
-
title = "USA tops Paris 2024 with 126 medals across all categories"
|
|
798
|
-
description = "2024 Paris Summer Games — top six nations"
|
|
799
|
-
source = "Olympics.com"
|
|
800
|
-
sourceUrl = "https://olympics.com"
|
|
801
|
-
colors = "#eeca3b, #c0c0c0, #cd7f32"
|
|
802
|
-
sort = descending
|
|
803
|
-
|
|
804
|
-
data {
|
|
805
|
-
series = "Gold","Silver","Bronze"
|
|
806
|
-
"USA" = 40,44,42
|
|
807
|
-
"China" = 40,27,24
|
|
808
|
-
"Japan" = 20,12,13
|
|
809
|
-
"Great Britain" = 14,22,29
|
|
810
|
-
"Australia" = 18,19,16
|
|
811
|
-
"France" = 16,26,22
|
|
812
|
-
}
|
|
813
|
-
}
|
|
814
|
-
`, ke = `chart line {
|
|
815
|
-
title = "2024 was the hottest year on record"
|
|
816
|
-
description = "Deviation from the 1951–1980 average, in °C"
|
|
817
|
-
source = "NASA GISS"
|
|
818
|
-
sourceUrl = "https://data.giss.nasa.gov/gistemp/"
|
|
819
|
-
tooltips = true
|
|
820
|
-
crosshair = false
|
|
821
|
-
lineSymbols = true
|
|
822
|
-
|
|
823
|
-
data {
|
|
824
|
-
"1980" = 0.26
|
|
825
|
-
"1985" = 0.12
|
|
826
|
-
"1990" = 0.45
|
|
827
|
-
"1995" = 0.45
|
|
828
|
-
"2000" = 0.39
|
|
829
|
-
"2005" = 0.68
|
|
830
|
-
"2010" = 0.73
|
|
831
|
-
"2015" = 0.9
|
|
832
|
-
"2020" = 1.01
|
|
833
|
-
"2024" = 1.28
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
annotation "2015" {
|
|
837
|
-
text = "2015 Paris Agreement to limit global warming to 1.5°C "
|
|
838
|
-
maxWidth = 224
|
|
839
|
-
showLine = true
|
|
840
|
-
lineStyle = curve-right
|
|
841
|
-
showArrow = true
|
|
842
|
-
showCircle = true
|
|
843
|
-
}
|
|
844
|
-
}
|
|
845
|
-
`, $e = `chart line {
|
|
846
|
-
title = "Bitcoin surged past $90,000 in 2024"
|
|
847
|
-
description = "USD, year-end closing price"
|
|
848
|
-
source = "CoinGecko"
|
|
849
|
-
sourceUrl = "https://www.coingecko.com"
|
|
850
|
-
colors = "#f7931a"
|
|
851
|
-
lineSymbols = true
|
|
852
|
-
lineSymbolShowOn = "all"
|
|
853
|
-
lineSymbolShape = "diamond"
|
|
854
|
-
verticalNumberFormat = ",.0f"
|
|
855
|
-
tooltips = true
|
|
856
|
-
|
|
857
|
-
annotation "2021" {
|
|
858
|
-
text = "All-time high cycle"
|
|
859
|
-
textOffsetY = -12
|
|
860
|
-
showArrow = true
|
|
861
|
-
}
|
|
862
|
-
|
|
863
|
-
data {
|
|
864
|
-
"2016" = 963
|
|
865
|
-
"2017" = 14156
|
|
866
|
-
"2018" = 3742
|
|
867
|
-
"2019" = 7194
|
|
868
|
-
"2020" = 29080
|
|
869
|
-
"2021" = 46306
|
|
870
|
-
"2022" = 16547
|
|
871
|
-
"2023" = 42258
|
|
872
|
-
"2024" = 93429
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
`, Ce = `chart line-multi {
|
|
876
|
-
title = "The income share of the top 1% has surged since 1980"
|
|
877
|
-
description = "Pre-tax national income captured by the top 1%, percent"
|
|
878
|
-
source = "World Inequality Database"
|
|
879
|
-
sourceUrl = "https://wid.world"
|
|
880
|
-
colorPalette = "Egypt"
|
|
881
|
-
tooltips = true
|
|
882
|
-
lineSymbols = true
|
|
883
|
-
lineSymbolShowOn = "all"
|
|
884
|
-
|
|
885
|
-
data {
|
|
886
|
-
series = "United States","India","China","France"
|
|
887
|
-
"1980" = 10.4,7.5,6.6,7.5
|
|
888
|
-
"1990" = 14.7,10.7,8.3,9.0
|
|
889
|
-
"2000" = 17.3,10.5,10.5,11.3
|
|
890
|
-
"2010" = 17.9,16.4,15.2,11.0
|
|
891
|
-
"2021" = 19.9,22.1,15.7,12.7
|
|
892
|
-
}
|
|
893
|
-
|
|
894
|
-
scene "US doubles" {
|
|
895
|
-
title = "The US top 1% nearly doubled its income share since 1980"
|
|
896
|
-
highlight "United States"
|
|
897
|
-
}
|
|
898
|
-
|
|
899
|
-
scene "India overtakes" {
|
|
900
|
-
title = "India is now the most unequal of these major economies"
|
|
901
|
-
highlight "India"
|
|
902
|
-
}
|
|
903
|
-
|
|
904
|
-
scene "France's modest rise" {
|
|
905
|
-
title = "France's top 1% rose far less than the US or India"
|
|
906
|
-
highlight "France"
|
|
907
|
-
}
|
|
908
|
-
}
|
|
909
|
-
`, Ae = `chart pie {
|
|
910
|
-
title = "Asia is home to nearly 60% of the world's population"
|
|
911
|
-
description = "Estimated share, 2024"
|
|
912
|
-
source = "United Nations"
|
|
913
|
-
sourceUrl = "https://population.un.org"
|
|
914
|
-
colorPalette = "Klimt"
|
|
915
|
-
legendPosition = "right"
|
|
916
|
-
tooltips = true
|
|
917
|
-
|
|
918
|
-
data {
|
|
919
|
-
"Asia" = 58.9
|
|
920
|
-
"Africa" = 18.6
|
|
921
|
-
"Europe" = 9.1
|
|
922
|
-
"Latin America" = 8.1
|
|
923
|
-
"North America" = 4.7
|
|
924
|
-
}
|
|
925
|
-
}
|
|
926
|
-
`, Te = `chart bar-vertical {
|
|
927
|
-
title = "Brazil produces more coffee than the next three countries combined"
|
|
928
|
-
description = "Million 60-kg bags, 2023/24 crop year"
|
|
929
|
-
source = "USDA Foreign Agricultural Service"
|
|
930
|
-
sourceUrl = "https://www.fas.usda.gov/data/coffee-world-markets-and-trade"
|
|
931
|
-
colorPalette = "Harvey"
|
|
932
|
-
|
|
933
|
-
data {
|
|
934
|
-
"Brazil" = 66.4
|
|
935
|
-
"Vietnam" = 27.5
|
|
936
|
-
"Colombia" = 12.76
|
|
937
|
-
"Ethiopia" = 9.13
|
|
938
|
-
"Indonesia" = 7.65
|
|
939
|
-
"Honduras" = 5.5
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
highlight "Brazil"
|
|
943
|
-
|
|
944
|
-
transform sort {
|
|
945
|
-
column = "value"
|
|
946
|
-
direction = descending
|
|
947
|
-
}
|
|
948
|
-
}
|
|
949
|
-
`, Ee = `chart donut {
|
|
950
|
-
title = "The richest 1% own more wealth than the entire bottom 90% combined"
|
|
951
|
-
description = "Share of global wealth by group, 2021"
|
|
952
|
-
source = "World Inequality Report 2022"
|
|
953
|
-
sourceUrl = "https://wir2022.wid.world"
|
|
954
|
-
colorPalette = "Imperator"
|
|
955
|
-
legendPosition = "right"
|
|
956
|
-
displayAsPercentage = true
|
|
957
|
-
tooltips = true
|
|
958
|
-
|
|
959
|
-
data {
|
|
960
|
-
"Top 1%" = 38
|
|
961
|
-
"Next 9%" = 38
|
|
962
|
-
"Middle 40%" = 22
|
|
963
|
-
"Bottom 50%" = 2
|
|
964
|
-
}
|
|
965
|
-
|
|
966
|
-
scene "Top 1% spotlight" {
|
|
967
|
-
title = "The top 1% hold 38% of all global wealth"
|
|
968
|
-
description = "Share of global wealth by group, 2021"
|
|
969
|
-
highlight "Top 1%"
|
|
970
|
-
}
|
|
971
|
-
|
|
972
|
-
scene "Bottom half" {
|
|
973
|
-
title = "The bottom half of humanity owns just 2%"
|
|
974
|
-
description = "Share of global wealth by group, 2021"
|
|
975
|
-
highlight "Bottom 50%"
|
|
976
|
-
}
|
|
977
|
-
|
|
978
|
-
scene "Income tells a softer story" {
|
|
979
|
-
title = "Income is concentrated too — but less than wealth"
|
|
980
|
-
description = "Share of global income by the same groups, 2021"
|
|
981
|
-
highlight "Top 1%"
|
|
982
|
-
data {
|
|
983
|
-
"Top 1%" = 19
|
|
984
|
-
"Next 9%" = 33
|
|
985
|
-
"Middle 40%" = 39
|
|
986
|
-
"Bottom 50%" = 9
|
|
987
|
-
}
|
|
988
|
-
}
|
|
989
|
-
}
|
|
990
|
-
`, Be = `chart area {
|
|
991
|
-
title = "The US national debt has more than tripled since 2008"
|
|
992
|
-
description = "Total federal debt outstanding, trillions of dollars"
|
|
993
|
-
source = "U.S. Treasury, Fiscal Data"
|
|
994
|
-
sourceUrl = "https://fiscaldata.treasury.gov"
|
|
995
|
-
|
|
996
|
-
annotation "2008" {
|
|
997
|
-
text = "Financial crisis"
|
|
998
|
-
showArrow = true
|
|
999
|
-
textOffsetY = -14
|
|
1000
|
-
}
|
|
1001
|
-
|
|
1002
|
-
data {
|
|
1003
|
-
"2000" = 5.7
|
|
1004
|
-
"2004" = 7.4
|
|
1005
|
-
"2008" = 10.0
|
|
1006
|
-
"2012" = 16.1
|
|
1007
|
-
"2016" = 19.6
|
|
1008
|
-
"2020" = 26.9
|
|
1009
|
-
"2024" = 35.5
|
|
1010
|
-
}
|
|
1011
|
-
}
|
|
1012
|
-
`, Pe = `chart area-stacked {
|
|
1013
|
-
title = "Renewables' share of global energy has more than doubled since 2000"
|
|
1014
|
-
description = "Share of global primary energy by source, 2000–2023"
|
|
1015
|
-
source = "Our World in Data"
|
|
1016
|
-
sourceUrl = "https://ourworldindata.org/energy-mix"
|
|
1017
|
-
stackPercent = true
|
|
1018
|
-
areaSortMode = descending
|
|
1019
|
-
|
|
1020
|
-
data {
|
|
1021
|
-
series = "Coal","Oil","Gas","Renewables"
|
|
1022
|
-
"2000" = 27456,43017,23994,2997
|
|
1023
|
-
"2005" = 36201,47017,27439,3510
|
|
1024
|
-
"2010" = 42016,48193,31593,4868
|
|
1025
|
-
"2015" = 43695,51294,34780,6400
|
|
1026
|
-
"2020" = 42316,49101,38704,8569
|
|
1027
|
-
"2023" = 45319,54839,40151,10325
|
|
1028
|
-
}
|
|
1029
|
-
}
|
|
1030
|
-
`, xe = `chart column-stacked {
|
|
1031
|
-
title = "Natural gas and renewables pushed coal off the US power grid"
|
|
1032
|
-
description = "Share of US electricity generation by source, percent"
|
|
1033
|
-
source = "U.S. Energy Information Administration"
|
|
1034
|
-
sourceUrl = "https://www.eia.gov/electricity"
|
|
1035
|
-
stackMode = "percent"
|
|
1036
|
-
|
|
1037
|
-
data {
|
|
1038
|
-
series = "Coal","Natural gas","Nuclear","Renewables"
|
|
1039
|
-
"2010" = 45,24,20,10
|
|
1040
|
-
"2015" = 33,33,20,13
|
|
1041
|
-
"2020" = 19,39,20,20
|
|
1042
|
-
"2023" = 16,43,19,21
|
|
1043
|
-
}
|
|
1044
|
-
}
|
|
1045
|
-
`, De = `chart bar-stacked {
|
|
1046
|
-
title = "India has far more children than China, and a workforce nearly as large"
|
|
1047
|
-
description = "Millions of people, 2023"
|
|
1048
|
-
source = "UN Population Division"
|
|
1049
|
-
sourceUrl = "https://population.un.org"
|
|
1050
|
-
colorPalette = "London"
|
|
1051
|
-
|
|
1052
|
-
data {
|
|
1053
|
-
series = "0-14","15-64","65+"
|
|
1054
|
-
"China" = 232,988,200
|
|
1055
|
-
"India" = 354,978,97
|
|
1056
|
-
"USA" = 58,216,59
|
|
1057
|
-
"Indonesia" = 67,189,21
|
|
1058
|
-
"Brazil" = 43,148,24
|
|
1059
|
-
}
|
|
1060
|
-
}
|
|
1061
|
-
`, Ie = `chart area-stacked {
|
|
1062
|
-
title = "EU subsidies to new members surged after enlargement"
|
|
1063
|
-
description = "Agricultural subsidies to post-socialist EU members, million euros"
|
|
1064
|
-
source = "Eurostat"
|
|
1065
|
-
sourceUrl = "https://ec.europa.eu/eurostat"
|
|
1066
|
-
colorPalette = "Enara"
|
|
1067
|
-
interpolation = "linear"
|
|
1068
|
-
heightMode = "aspect-ratio"
|
|
1069
|
-
aspectRatio = "1:1"
|
|
1070
|
-
|
|
1071
|
-
data {
|
|
1072
|
-
series = "Indirect subsidies","Direct subsidies"
|
|
1073
|
-
"2000" = 370,800
|
|
1074
|
-
"2001" = 445,896
|
|
1075
|
-
"2002" = 567,816
|
|
1076
|
-
"2003" = 641,950
|
|
1077
|
-
"2004" = 1908,2434
|
|
1078
|
-
"2005" = 2234,3509
|
|
1079
|
-
"2006" = 2576,4356
|
|
1080
|
-
"2007" = 2467,5429
|
|
1081
|
-
"2008" = 2672,6655
|
|
1082
|
-
"2009" = 2474,7195
|
|
1083
|
-
"2010" = 2117,8207
|
|
1084
|
-
"2011" = 1863,9230
|
|
1085
|
-
"2012" = 1528,9191
|
|
1086
|
-
"2013" = 1251,10252
|
|
1087
|
-
"2014" = 1132,10987
|
|
1088
|
-
"2015" = 1687,10145
|
|
1089
|
-
}
|
|
1090
|
-
|
|
1091
|
-
scene "Indirect subsidies shrank" {
|
|
1092
|
-
title = "Indirect subsidies were cut under WTO pressure"
|
|
1093
|
-
description = "Subsidies tied to specific crops fell foul of World Trade Organization rules"
|
|
1094
|
-
|
|
1095
|
-
highlight "Indirect subsidies"
|
|
1096
|
-
}
|
|
1097
|
-
|
|
1098
|
-
scene "Direct subsidies dominate" {
|
|
1099
|
-
title = "Direct per-hectare payments now dominate"
|
|
1100
|
-
description = "The larger the fields, the more money farmers receive"
|
|
1101
|
-
|
|
1102
|
-
highlight "Direct subsidies"
|
|
1103
|
-
}
|
|
1104
|
-
|
|
1105
|
-
scene "Bulgaria: subsidies explode" {
|
|
1106
|
-
title = "Bulgarian farmers received almost nothing before 2007 accession"
|
|
1107
|
-
description = "More than three-quarters of Bulgarian subsidies are direct payments — the highest share among new members"
|
|
1108
|
-
|
|
1109
|
-
data {
|
|
1110
|
-
series = "Indirect subsidies","Direct subsidies"
|
|
1111
|
-
"2000" = 0,5
|
|
1112
|
-
"2001" = 0,33
|
|
1113
|
-
"2002" = 0,48
|
|
1114
|
-
"2003" = 0,69
|
|
1115
|
-
"2004" = 0,67
|
|
1116
|
-
"2005" = 0,87
|
|
1117
|
-
"2006" = 0,57
|
|
1118
|
-
"2007" = 59,250
|
|
1119
|
-
"2008" = 75,484
|
|
1120
|
-
"2009" = 97,415
|
|
1121
|
-
"2010" = 79,466
|
|
1122
|
-
"2011" = 94,458
|
|
1123
|
-
"2012" = 120,617
|
|
1124
|
-
"2013" = 132,852
|
|
1125
|
-
"2014" = 143,821
|
|
1126
|
-
"2015" = 213,677
|
|
1127
|
-
}
|
|
1128
|
-
|
|
1129
|
-
highlight "Direct subsidies"
|
|
1130
|
-
}
|
|
1131
|
-
|
|
1132
|
-
scene "Bulgarian farms grew" {
|
|
1133
|
-
title = "Average farm size in Bulgaria quadrupled"
|
|
1134
|
-
description = "Average farm size in hectares"
|
|
1135
|
-
type = line
|
|
1136
|
-
|
|
1137
|
-
data {
|
|
1138
|
-
"2005" = 5
|
|
1139
|
-
"2007" = 6
|
|
1140
|
-
"2010" = 12
|
|
1141
|
-
"2013" = 18
|
|
1142
|
-
}
|
|
1143
|
-
}
|
|
1144
|
-
|
|
1145
|
-
scene "Production rose" {
|
|
1146
|
-
title = "Bulgarian farm production rose from 3 to 4 billion euros"
|
|
1147
|
-
description = "Total production of Bulgarian farms, million euros"
|
|
1148
|
-
type = area
|
|
1149
|
-
|
|
1150
|
-
data {
|
|
1151
|
-
"2000" = 2933
|
|
1152
|
-
"2001" = 3240
|
|
1153
|
-
"2002" = 3051
|
|
1154
|
-
"2003" = 2816
|
|
1155
|
-
"2004" = 3049
|
|
1156
|
-
"2005" = 3011
|
|
1157
|
-
"2006" = 3111
|
|
1158
|
-
"2007" = 3038
|
|
1159
|
-
"2008" = 4148
|
|
1160
|
-
"2009" = 3437
|
|
1161
|
-
"2010" = 3486
|
|
1162
|
-
"2011" = 4038
|
|
1163
|
-
"2012" = 4161
|
|
1164
|
-
"2013" = 4115
|
|
1165
|
-
"2014" = 4138
|
|
1166
|
-
"2015" = 3915
|
|
1167
|
-
}
|
|
1168
|
-
}
|
|
1169
|
-
|
|
1170
|
-
scene "Cash crops replaced vegetables" {
|
|
1171
|
-
title = "Cash crops replaced vegetables in Bulgaria"
|
|
1172
|
-
description = "Production of Bulgarian farms, million euros"
|
|
1173
|
-
type = area-stacked
|
|
1174
|
-
|
|
1175
|
-
data {
|
|
1176
|
-
series = "Vegetables","Cash crops","Other production"
|
|
1177
|
-
"2000" = 464,615,1854
|
|
1178
|
-
"2001" = 458,777,2005
|
|
1179
|
-
"2002" = 577,850,1624
|
|
1180
|
-
"2003" = 539,818,1459
|
|
1181
|
-
"2004" = 483,1103,1463
|
|
1182
|
-
"2005" = 492,994,1525
|
|
1183
|
-
"2006" = 510,1083,1518
|
|
1184
|
-
"2007" = 436,936,1666
|
|
1185
|
-
"2008" = 541,2045,1563
|
|
1186
|
-
"2009" = 243,1553,1641
|
|
1187
|
-
"2010" = 184,2173,1128
|
|
1188
|
-
"2011" = 120,2853,1065
|
|
1189
|
-
"2012" = 117,2900,1144
|
|
1190
|
-
"2013" = 139,2802,1174
|
|
1191
|
-
"2014" = 143,3082,914
|
|
1192
|
-
"2015" = 144,2986,785
|
|
1193
|
-
}
|
|
1194
|
-
|
|
1195
|
-
highlight "Cash crops"
|
|
1196
|
-
}
|
|
1197
|
-
|
|
1198
|
-
scene "Vegetables collapsed" {
|
|
1199
|
-
title = "Vegetable production fell by a factor of three"
|
|
1200
|
-
description = "A traditional Bulgarian cultivation shrank as subsidies favoured large fields"
|
|
1201
|
-
|
|
1202
|
-
highlight "Vegetables"
|
|
1203
|
-
}
|
|
1204
|
-
|
|
1205
|
-
scene "Every vegetable declined" {
|
|
1206
|
-
title = "Bulgarian vegetable production collapsed across the board"
|
|
1207
|
-
description = "Production volume indexed to 2001 = 100"
|
|
1208
|
-
type = line-multi
|
|
1209
|
-
lineSymbols = false
|
|
1210
|
-
|
|
1211
|
-
data {
|
|
1212
|
-
series = "Cabbages","Tomatoes","Watermelons","Carrots","Onions","Garlic","Strawberries"
|
|
1213
|
-
"2001" = 100,100,100,100,100,100,100
|
|
1214
|
-
"2002" = 79,90,124,64,106,95,100
|
|
1215
|
-
"2003" = 100,157,177,142,118,98,72
|
|
1216
|
-
"2004" = 84,87,83,245,124,138,74
|
|
1217
|
-
"2005" = 50,46,62,30,40,93,42
|
|
1218
|
-
"2006" = 52,78,113,95,56,80,56
|
|
1219
|
-
"2007" = 36,49,64,74,29,30,38
|
|
1220
|
-
"2008" = 47,49,66,97,44,29,55
|
|
1221
|
-
"2009" = 28,38,74,105,23,39,55
|
|
1222
|
-
"2010" = 57,42,51,76,53,57,37
|
|
1223
|
-
"2011" = 32,38,56,86,47,43,45
|
|
1224
|
-
"2012" = 34,34,46,69,29,43,31
|
|
1225
|
-
"2013" = 33,43,53,39,36,40,24
|
|
1226
|
-
"2014" = 31,44,28,69,37,8,27
|
|
1227
|
-
"2015" = 31,45,50,57,25,18,32
|
|
1228
|
-
}
|
|
1229
|
-
}
|
|
1230
|
-
|
|
1231
|
-
scene "Jobs disappeared" {
|
|
1232
|
-
title = "Family farmers disappeared while salaried ag jobs held steady"
|
|
1233
|
-
description = "EU agricultural employment, thousands of full-time equivalents"
|
|
1234
|
-
type = line-multi
|
|
1235
|
-
lineSymbols = false
|
|
1236
|
-
|
|
1237
|
-
data {
|
|
1238
|
-
series = "Salaried workers","Non-salaried workers"
|
|
1239
|
-
"2000" = 2678,12194
|
|
1240
|
-
"2001" = 2598,11586
|
|
1241
|
-
"2002" = 2658,10795
|
|
1242
|
-
"2003" = 2563,10609
|
|
1243
|
-
"2004" = 2560,9999
|
|
1244
|
-
"2005" = 2501,10047
|
|
1245
|
-
"2006" = 2499,9782
|
|
1246
|
-
"2007" = 2437,9231
|
|
1247
|
-
"2008" = 2416,8971
|
|
1248
|
-
"2009" = 2348,8672
|
|
1249
|
-
"2010" = 2335,7808
|
|
1250
|
-
"2011" = 2322,7551
|
|
1251
|
-
"2012" = 2325,7501
|
|
1252
|
-
"2013" = 2297,7425
|
|
1253
|
-
"2014" = 2366,7183
|
|
1254
|
-
"2015" = 2413,6928
|
|
1255
|
-
"2016" = 2457,6741
|
|
1256
|
-
}
|
|
1257
|
-
|
|
1258
|
-
highlight "Non-salaried workers"
|
|
1259
|
-
}
|
|
1260
|
-
}
|
|
1261
|
-
`, Ue = `chart bar-horizontal {
|
|
1262
|
-
title = "China emits more CO₂ than the US and India combined"
|
|
1263
|
-
description = "Annual emissions in billion tonnes, 2023"
|
|
1264
|
-
source = "Our World in Data"
|
|
1265
|
-
sourceUrl = "https://ourworldindata.org/co2-emissions"
|
|
1266
|
-
byline = "Pierre Romera"
|
|
1267
|
-
|
|
1268
|
-
data {
|
|
1269
|
-
"China" = 12.17
|
|
1270
|
-
"United States" = 4.92
|
|
1271
|
-
"India" = 3.06
|
|
1272
|
-
"Russia" = 1.73
|
|
1273
|
-
"Japan" = 0.99
|
|
1274
|
-
"Germany" = 0.59
|
|
1275
|
-
}
|
|
1276
|
-
|
|
1277
|
-
scene "China spotlight" {
|
|
1278
|
-
title = "China alone emits more than the US and India together"
|
|
1279
|
-
highlight "China"
|
|
1280
|
-
}
|
|
1281
|
-
|
|
1282
|
-
scene "India rising" {
|
|
1283
|
-
title = "India passed the EU to become the third-largest emitter"
|
|
1284
|
-
highlight "India"
|
|
1285
|
-
}
|
|
1286
|
-
|
|
1287
|
-
scene "Japan declining" {
|
|
1288
|
-
title = "Japan's emissions have fallen since their 2013 peak"
|
|
1289
|
-
highlight "Japan"
|
|
1290
|
-
}
|
|
1291
|
-
|
|
1292
|
-
scene "Per capita reframe" {
|
|
1293
|
-
title = "Per person, Gulf states dwarf the biggest emitters"
|
|
1294
|
-
description = "CO₂ emissions per capita, tonnes per person, 2023"
|
|
1295
|
-
highlight "Qatar"
|
|
1296
|
-
data {
|
|
1297
|
-
"Qatar" = 40.13
|
|
1298
|
-
"United Arab Emirates" = 19.77
|
|
1299
|
-
"United States" = 14.32
|
|
1300
|
-
"China" = 8.56
|
|
1301
|
-
"India" = 2.13
|
|
1302
|
-
}
|
|
1303
|
-
}
|
|
1304
|
-
}
|
|
1305
|
-
`, ze = `chart bar-split {
|
|
1306
|
-
title = "CDU/CSU led German polls at 29 % ahead of the 2021 election"
|
|
1307
|
-
description = "How Germany would vote in the September 2021 federal election, according to polling in the previous June"
|
|
1308
|
-
source = "FG Wahlen"
|
|
1309
|
-
sourceUrl = "https://www.forschungsgruppe.de"
|
|
1310
|
-
note = "Margin of error at 10%: +/- 2 percentage points; at 40%: +/- 3 percentage points"
|
|
1311
|
-
|
|
1312
|
-
data {
|
|
1313
|
-
series = "Poll","High","Low"
|
|
1314
|
-
"CDU/CSU" = 29,32,27
|
|
1315
|
-
"Greens" = 22,25,20
|
|
1316
|
-
"SPD" = 14,16,12
|
|
1317
|
-
"AfD" = 10,12,8
|
|
1318
|
-
"FDP" = 10,12,8
|
|
1319
|
-
"Left" = 7,9,5
|
|
1320
|
-
}
|
|
1321
|
-
}
|
|
1322
|
-
`, Ne = `chart bar-grouped {
|
|
1323
|
-
title = "Asia Pacific holds more renewable capacity than all other regions combined"
|
|
1324
|
-
description = "Installed capacity in gigawatts (GW), 2023"
|
|
1325
|
-
source = "IRENA"
|
|
1326
|
-
sourceUrl = "https://www.irena.org/Publications/2024/Mar/Renewable-capacity-statistics-2024"
|
|
1327
|
-
colorPalette = "Folklore"
|
|
1328
|
-
|
|
1329
|
-
data {
|
|
1330
|
-
series = "Solar","Wind","Hydro"
|
|
1331
|
-
"Asia Pacific" = 870,520,650
|
|
1332
|
-
"Europe" = 290,260,230
|
|
1333
|
-
"North America" = 150,170,200
|
|
1334
|
-
"Latin America" = 50,40,190
|
|
1335
|
-
"Africa" = 12,9,40
|
|
1336
|
-
}
|
|
1337
|
-
}
|
|
1338
|
-
`;
|
|
1339
|
-
function z(e, n) {
|
|
1340
|
-
const t = e.properties.find((r) => r.key === n);
|
|
1341
|
-
return t ? String(t.value) : "";
|
|
1342
|
-
}
|
|
1343
|
-
function Oe(e) {
|
|
1344
|
-
if (!e.data)
|
|
1345
|
-
return "";
|
|
1346
|
-
const n = e.data.entries, t = n.find((a) => a.key === "series" && !a.quotedKey);
|
|
1347
|
-
if (t) {
|
|
1348
|
-
const s = ["category", ...String(t.value).split(",")].join(" "), l = n.filter((i) => !(i.key === "series" && !i.quotedKey)).map((i) => {
|
|
1349
|
-
const u = String(i.value).split(",");
|
|
1350
|
-
return [i.key, ...u].join(" ");
|
|
1351
|
-
});
|
|
1352
|
-
return [s, ...l].join(`
|
|
1353
|
-
`);
|
|
1354
|
-
}
|
|
1355
|
-
const r = ["label", "value"].join(" "), o = n.map((a) => [a.key, String(a.value)].join(" "));
|
|
1356
|
-
return [r, ...o].join(`
|
|
1357
|
-
`);
|
|
1358
|
-
}
|
|
1359
|
-
function Me(e) {
|
|
1360
|
-
if (!e.data)
|
|
1361
|
-
return "";
|
|
1362
|
-
const n = e.data.entries, t = n.find((r) => r.key === "series" && !r.quotedKey);
|
|
1363
|
-
if (t) {
|
|
1364
|
-
const r = `series = "${String(t.value)}"`, o = n.filter((a) => !(a.key === "series" && !a.quotedKey)).map((a) => `"${a.key}" = "${String(a.value)}"`);
|
|
1365
|
-
return [r, ...o].join(`
|
|
1366
|
-
`);
|
|
1367
|
-
}
|
|
1368
|
-
return n.map((r) => `"${r.key}" = ${String(r.value)}`).join(`
|
|
1369
|
-
`);
|
|
1370
|
-
}
|
|
1371
|
-
function h(e, n) {
|
|
1372
|
-
const t = N(n);
|
|
1373
|
-
return {
|
|
1374
|
-
id: e,
|
|
1375
|
-
title: z(t, "title"),
|
|
1376
|
-
description: z(t, "description"),
|
|
1377
|
-
chartType: t.chartType,
|
|
1378
|
-
tsvData: Oe(t),
|
|
1379
|
-
serializedData: Me(t),
|
|
1380
|
-
dsl: n
|
|
1381
|
-
};
|
|
1382
|
-
}
|
|
1383
|
-
const nn = [
|
|
1384
|
-
// Bar Vertical
|
|
1385
|
-
h("letter-frequency", be),
|
|
1386
|
-
h("co2-emissions", ye),
|
|
1387
|
-
h("coffee-production", Te),
|
|
1388
|
-
// Bar Horizontal
|
|
1389
|
-
h("spoken-languages", we),
|
|
1390
|
-
// Bar Multi
|
|
1391
|
-
h("quarterly-revenue", ve),
|
|
1392
|
-
h("medal-count", Se),
|
|
1393
|
-
// Line
|
|
1394
|
-
h("temperature-anomaly", ke),
|
|
1395
|
-
h("bitcoin-price", $e),
|
|
1396
|
-
// Line Multi
|
|
1397
|
-
h("unemployment-rates", Ce),
|
|
1398
|
-
// Donut
|
|
1399
|
-
h("browser-market", Ee),
|
|
1400
|
-
// Pie
|
|
1401
|
-
h("world-population", Ae),
|
|
1402
|
-
// Area
|
|
1403
|
-
h("stock-price-area", Be),
|
|
1404
|
-
// Area Stacked
|
|
1405
|
-
h("energy-mix-stacked-area", Pe),
|
|
1406
|
-
// Column Stacked
|
|
1407
|
-
h("quarterly-stacked-columns", xe),
|
|
1408
|
-
// Bar Stacked
|
|
1409
|
-
h("population-stacked-bar", De),
|
|
1410
|
-
// Bar Split
|
|
1411
|
-
h("election-polls", ze),
|
|
1412
|
-
// Bar Grouped
|
|
1413
|
-
h("renewable-capacity", Ne),
|
|
1414
|
-
// Story (multi-scene)
|
|
1415
|
-
h("farm-compass", Ie),
|
|
1416
|
-
h("co2-emissions-story", Ue)
|
|
1417
|
-
];
|
|
1418
|
-
class Le extends Error {
|
|
1419
|
-
constructor(n, t) {
|
|
1420
|
-
super(n, t), this.name = "ChartParseError";
|
|
1421
|
-
}
|
|
1422
|
-
}
|
|
1423
|
-
class Fe extends Error {
|
|
1424
|
-
constructor(n = "PNG export is only available in Node. Use toSvg() in the browser.") {
|
|
1425
|
-
super(n), this.name = "PngBrowserUnsupportedError";
|
|
1426
|
-
}
|
|
1427
|
-
}
|
|
1428
|
-
class tn extends Error {
|
|
1429
|
-
constructor(n) {
|
|
1430
|
-
super(n), this.name = "MissingNodeRenderDepsError";
|
|
1431
|
-
}
|
|
1432
|
-
}
|
|
1433
|
-
function Re() {
|
|
1434
|
-
return {
|
|
1435
|
-
kind: "dom",
|
|
1436
|
-
createContainer(e, n) {
|
|
1437
|
-
const t = document.createElement("div");
|
|
1438
|
-
return t.style.cssText = `position:absolute;left:-99999px;top:0;width:${e}px;height:${n}px`, document.body.appendChild(t), { container: t, cleanup: () => t.remove() };
|
|
1439
|
-
},
|
|
1440
|
-
renderToContainer(e, n, t) {
|
|
1441
|
-
H(e, n, {
|
|
1442
|
-
sceneIndex: t.sceneIndex,
|
|
1443
|
-
thumbnail: t.thumbnail ?? !1,
|
|
1444
|
-
transition: !1,
|
|
1445
|
-
theme: t.theme
|
|
1446
|
-
});
|
|
1447
|
-
},
|
|
1448
|
-
serializeSvg(e) {
|
|
1449
|
-
const n = e.querySelector(".bc-frame-body"), t = n ? n.querySelector("svg") : e.querySelector("svg"), r = (t == null ? void 0 : t.outerHTML) ?? "";
|
|
1450
|
-
if (!r)
|
|
1451
|
-
throw new Error("dom-backend: renderToContainer produced no SVG");
|
|
1452
|
-
return r.includes('xmlns="http://www.w3.org/2000/svg"') ? r : r.replace(/^<svg(?=\s|>)/, '<svg xmlns="http://www.w3.org/2000/svg"');
|
|
1453
|
-
},
|
|
1454
|
-
serializeFrame(e) {
|
|
1455
|
-
const n = e.querySelector(".bc-frame");
|
|
1456
|
-
if (n)
|
|
1457
|
-
return n.outerHTML;
|
|
1458
|
-
if (e.querySelector("svg"))
|
|
1459
|
-
return this.serializeSvg(e);
|
|
1460
|
-
throw new Error("dom-backend: renderToContainer produced no frame");
|
|
1461
|
-
},
|
|
1462
|
-
rasterizePng() {
|
|
1463
|
-
return Promise.reject(new Fe());
|
|
1464
|
-
}
|
|
1465
|
-
};
|
|
1466
|
-
}
|
|
1467
|
-
const je = 640, _e = 400;
|
|
1468
|
-
function qe() {
|
|
1469
|
-
return typeof document < "u" && typeof document.createElement == "function";
|
|
1470
|
-
}
|
|
1471
|
-
async function Ge() {
|
|
1472
|
-
return qe() ? Re() : (await import("@blueprint-chart/lib/internal/node-backend")).createNodeBackend();
|
|
1473
|
-
}
|
|
1474
|
-
async function rn(e, n = {}) {
|
|
1475
|
-
let t;
|
|
1476
|
-
try {
|
|
1477
|
-
t = K(N(e));
|
|
1478
|
-
} catch (i) {
|
|
1479
|
-
throw new Le(i instanceof Error ? i.message : String(i), { cause: i });
|
|
1480
|
-
}
|
|
1481
|
-
const r = await Ge(), o = n.frame ?? !0, a = {
|
|
1482
|
-
sceneIndex: n.scene,
|
|
1483
|
-
width: n.width ?? je,
|
|
1484
|
-
height: n.height ?? _e
|
|
1485
|
-
};
|
|
1486
|
-
function s(i) {
|
|
1487
|
-
r.renderToContainer(i, t, {
|
|
1488
|
-
sceneIndex: a.sceneIndex,
|
|
1489
|
-
thumbnail: !o,
|
|
1490
|
-
theme: n.theme
|
|
1491
|
-
});
|
|
1492
|
-
}
|
|
1493
|
-
const l = {
|
|
1494
|
-
async toSvg(i = {}) {
|
|
1495
|
-
const { container: u, cleanup: f } = r.createContainer(i.width ?? a.width, i.height ?? a.height);
|
|
1496
|
-
try {
|
|
1497
|
-
return s(u), r.serializeSvg(u);
|
|
1498
|
-
} finally {
|
|
1499
|
-
f();
|
|
1500
|
-
}
|
|
1501
|
-
},
|
|
1502
|
-
async toHtml(i = {}) {
|
|
1503
|
-
const { container: u, cleanup: f } = r.createContainer(i.width ?? a.width, i.height ?? a.height);
|
|
1504
|
-
try {
|
|
1505
|
-
return s(u), r.serializeFrame(u);
|
|
1506
|
-
} finally {
|
|
1507
|
-
f();
|
|
1508
|
-
}
|
|
1509
|
-
},
|
|
1510
|
-
async toPng(i = {}) {
|
|
1511
|
-
const { container: u, cleanup: f } = r.createContainer(i.width ?? a.width, i.height ?? a.height);
|
|
1512
|
-
let I;
|
|
1513
|
-
try {
|
|
1514
|
-
s(u), I = r.serializeSvg(u);
|
|
1515
|
-
} finally {
|
|
1516
|
-
f();
|
|
1517
|
-
}
|
|
1518
|
-
return r.rasterizePng(I, { width: i.width ?? a.width, height: i.height ?? a.height });
|
|
1519
|
-
},
|
|
1520
|
-
mount(i) {
|
|
1521
|
-
if (r.kind !== "dom")
|
|
1522
|
-
return console.warn("Blueprint Chart: mount() is a no-op outside a browser environment."), l;
|
|
1523
|
-
const u = typeof i == "string" ? document.querySelector(i) : i;
|
|
1524
|
-
if (!u)
|
|
1525
|
-
throw new Error(`Blueprint Chart: mount target "${String(i)}" not found`);
|
|
1526
|
-
return s(u), l;
|
|
1527
|
-
},
|
|
1528
|
-
scene(i) {
|
|
1529
|
-
return a.sceneIndex = i, l;
|
|
1530
|
-
}
|
|
1531
|
-
};
|
|
1532
|
-
return l;
|
|
1533
|
-
}
|
|
1534
|
-
export {
|
|
1535
|
-
G as ANNOTATION_KIND_KEYWORD,
|
|
1536
|
-
sn as Anchor,
|
|
1537
|
-
g as AnnotationKind,
|
|
1538
|
-
ln as AnnotationLineStyle,
|
|
1539
|
-
cn as AxisDirection,
|
|
1540
|
-
un as BC_TRANSITION_NAME,
|
|
1541
|
-
q as ChartOptionType,
|
|
1542
|
-
Le as ChartParseError,
|
|
1543
|
-
hn as ChartType,
|
|
1544
|
-
dn as CompassDirection,
|
|
1545
|
-
pn as CrosshairDirection,
|
|
1546
|
-
fn as CrosshairStyle,
|
|
1547
|
-
mn as DEFAULT_BAR_GAP,
|
|
1548
|
-
gn as DirectLabelMode,
|
|
1549
|
-
bn as DslNodeType,
|
|
1550
|
-
yn as FrameSizing,
|
|
1551
|
-
wn as GridStyle,
|
|
1552
|
-
vn as Interpolation,
|
|
1553
|
-
Sn as LabelPosition,
|
|
1554
|
-
kn as LabelRotation,
|
|
1555
|
-
$n as LegendPosition,
|
|
1556
|
-
Cn as LineStyle,
|
|
1557
|
-
tn as MissingNodeRenderDepsError,
|
|
1558
|
-
An as Orientation,
|
|
1559
|
-
Fe as PngBrowserUnsupportedError,
|
|
1560
|
-
Tn as RangeAnchor,
|
|
1561
|
-
En as ScaleType,
|
|
1562
|
-
Bn as SceneTransition,
|
|
1563
|
-
Pn as SortDirection,
|
|
1564
|
-
xn as SortMode,
|
|
1565
|
-
Dn as StackMode,
|
|
1566
|
-
In as StrokeStyle,
|
|
1567
|
-
Un as SymbolShape,
|
|
1568
|
-
zn as SymbolShowOn,
|
|
1569
|
-
Nn as SymbolStyle,
|
|
1570
|
-
On as TickPosition,
|
|
1571
|
-
Mn as ValueLabelPosition,
|
|
1572
|
-
Ln as adjustColorsForBackground,
|
|
1573
|
-
K as astToDefinition,
|
|
1574
|
-
Fn as buildChartOptions,
|
|
1575
|
-
Ct as buildSrcdoc,
|
|
1576
|
-
Ye as checkCvdColors,
|
|
1577
|
-
W as classifyIntent,
|
|
1578
|
-
Rn as commitFadeOut,
|
|
1579
|
-
Xe as compactSerialize,
|
|
1580
|
-
Qe as compactSerializeDeep,
|
|
1581
|
-
jn as convertAnnotations,
|
|
1582
|
-
_n as convertAreaFills,
|
|
1583
|
-
qn as convertColorizes,
|
|
1584
|
-
Gn as convertHighlights,
|
|
1585
|
-
Hn as convertSeriesOverrides,
|
|
1586
|
-
Kn as createCanvas,
|
|
1587
|
-
Je as createCvdSvgFilter,
|
|
1588
|
-
Vn as createFrame,
|
|
1589
|
-
Wn as dataEntriesToString,
|
|
1590
|
-
Jn as extractChartTypeOptions,
|
|
1591
|
-
Yn as extractSceneOverrides,
|
|
1592
|
-
Zn as fadeIn,
|
|
1593
|
-
Qn as featureJoin,
|
|
1594
|
-
Xn as getCachedChart,
|
|
1595
|
-
et as getChart,
|
|
1596
|
-
P as getChartOptions,
|
|
1597
|
-
nt as getChartTypeDefaults,
|
|
1598
|
-
X as getCvdFilterId,
|
|
1599
|
-
tt as getSceneTransition,
|
|
1600
|
-
rt as getTransitionDuration,
|
|
1601
|
-
ot as isSeriesHidden,
|
|
1602
|
-
T as listCharts,
|
|
1603
|
-
at as listPalettes,
|
|
1604
|
-
N as parse,
|
|
1605
|
-
it as parseData,
|
|
1606
|
-
_ as propertyMap,
|
|
1607
|
-
We as recommendCharts,
|
|
1608
|
-
st as registerChart,
|
|
1609
|
-
rn as render,
|
|
1610
|
-
lt as renderBpc,
|
|
1611
|
-
H as renderChart,
|
|
1612
|
-
ct as renderHorizontalAxis,
|
|
1613
|
-
ut as renderLegend,
|
|
1614
|
-
ht as renderVerticalAxis,
|
|
1615
|
-
dt as resolveBackgroundColor,
|
|
1616
|
-
pt as resolveBarGapPadding,
|
|
1617
|
-
ft as resolveChartTypeOptions,
|
|
1618
|
-
mt as resolvePalette,
|
|
1619
|
-
gt as resolveScene,
|
|
1620
|
-
bt as resolveSeriesColor,
|
|
1621
|
-
yt as resolveSeriesInterpolation,
|
|
1622
|
-
nn as samples,
|
|
1623
|
-
Ze as serialize,
|
|
1624
|
-
Y as shapeOf,
|
|
1625
|
-
ne as simulateCvdColor,
|
|
1626
|
-
wt as snapshotForFadeOut,
|
|
1627
|
-
vt as snapshotLiveAttrs,
|
|
1628
|
-
en as validateChart,
|
|
1629
|
-
St as wcagContrastRatio,
|
|
1630
|
-
kt as wcagLevel
|
|
629
|
+
function X(e) {
|
|
630
|
+
if (!e.data) return "";
|
|
631
|
+
let t = e.data.entries, n = t.find((e) => e.key === "series" && !e.quotedKey);
|
|
632
|
+
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");
|
|
633
|
+
}
|
|
634
|
+
function Z(e, t) {
|
|
635
|
+
let n = g(t);
|
|
636
|
+
return {
|
|
637
|
+
id: e,
|
|
638
|
+
title: Y(n, "title"),
|
|
639
|
+
description: Y(n, "description"),
|
|
640
|
+
chartType: n.chartType,
|
|
641
|
+
tsvData: Zt(n),
|
|
642
|
+
serializedData: X(n),
|
|
643
|
+
dsl: t
|
|
644
|
+
};
|
|
645
|
+
}
|
|
646
|
+
var Qt = [
|
|
647
|
+
Z("letter-frequency", Mt),
|
|
648
|
+
Z("co2-emissions", Nt),
|
|
649
|
+
Z("coffee-production", Vt),
|
|
650
|
+
Z("spoken-languages", Pt),
|
|
651
|
+
Z("quarterly-revenue", Ft),
|
|
652
|
+
Z("medal-count", It),
|
|
653
|
+
Z("temperature-anomaly", Lt),
|
|
654
|
+
Z("bitcoin-price", Rt),
|
|
655
|
+
Z("unemployment-rates", zt),
|
|
656
|
+
Z("browser-market", Ht),
|
|
657
|
+
Z("world-population", Bt),
|
|
658
|
+
Z("stock-price-area", Ut),
|
|
659
|
+
Z("energy-mix-stacked-area", Wt),
|
|
660
|
+
Z("quarterly-stacked-columns", Gt),
|
|
661
|
+
Z("population-stacked-bar", Kt),
|
|
662
|
+
Z("election-polls", Yt),
|
|
663
|
+
Z("renewable-capacity", Xt),
|
|
664
|
+
Z("farm-compass", qt),
|
|
665
|
+
Z("co2-emissions-story", Jt)
|
|
666
|
+
], Q = class extends Error {
|
|
667
|
+
constructor(e, t) {
|
|
668
|
+
super(e, t), this.name = "ChartParseError";
|
|
669
|
+
}
|
|
670
|
+
}, $ = class extends Error {
|
|
671
|
+
constructor(e = "PNG export is only available in Node. Use toSvg() in the browser.") {
|
|
672
|
+
super(e), this.name = "PngBrowserUnsupportedError";
|
|
673
|
+
}
|
|
674
|
+
}, $t = class extends Error {
|
|
675
|
+
constructor(e) {
|
|
676
|
+
super(e), this.name = "MissingNodeRenderDepsError";
|
|
677
|
+
}
|
|
1631
678
|
};
|
|
679
|
+
//#endregion
|
|
680
|
+
//#region src/render/backends/dom-backend.ts
|
|
681
|
+
function en() {
|
|
682
|
+
return {
|
|
683
|
+
kind: "dom",
|
|
684
|
+
createContainer(e, t) {
|
|
685
|
+
let n = document.createElement("div");
|
|
686
|
+
return n.style.cssText = `position:absolute;left:-99999px;top:0;width:${e}px;height:${t}px`, document.body.appendChild(n), {
|
|
687
|
+
container: n,
|
|
688
|
+
cleanup: () => n.remove()
|
|
689
|
+
};
|
|
690
|
+
},
|
|
691
|
+
renderToContainer(e, t, n) {
|
|
692
|
+
v(e, t, {
|
|
693
|
+
sceneIndex: n.sceneIndex,
|
|
694
|
+
thumbnail: n.thumbnail ?? !1,
|
|
695
|
+
transition: !1,
|
|
696
|
+
theme: n.theme
|
|
697
|
+
});
|
|
698
|
+
},
|
|
699
|
+
serializeSvg(e) {
|
|
700
|
+
let t = e.querySelector(".bc-frame-body"), n = (t ? t.querySelector("svg") : e.querySelector("svg"))?.outerHTML ?? "";
|
|
701
|
+
if (!n) throw Error("dom-backend: renderToContainer produced no SVG");
|
|
702
|
+
return n.includes("xmlns=\"http://www.w3.org/2000/svg\"") ? n : n.replace(/^<svg(?=\s|>)/, "<svg xmlns=\"http://www.w3.org/2000/svg\"");
|
|
703
|
+
},
|
|
704
|
+
serializeFrame(e) {
|
|
705
|
+
let t = e.querySelector(".bc-frame");
|
|
706
|
+
if (t) return t.outerHTML;
|
|
707
|
+
if (e.querySelector("svg")) return this.serializeSvg(e);
|
|
708
|
+
throw Error("dom-backend: renderToContainer produced no frame");
|
|
709
|
+
},
|
|
710
|
+
rasterizePng() {
|
|
711
|
+
return Promise.reject(new $());
|
|
712
|
+
}
|
|
713
|
+
};
|
|
714
|
+
}
|
|
715
|
+
//#endregion
|
|
716
|
+
//#region src/render/public-render.ts
|
|
717
|
+
var tn = 640, nn = 400;
|
|
718
|
+
function rn() {
|
|
719
|
+
return typeof document < "u" && typeof document.createElement == "function";
|
|
720
|
+
}
|
|
721
|
+
async function an() {
|
|
722
|
+
return rn() ? en() : (await import("@blueprint-chart/lib/internal/node-backend")).createNodeBackend();
|
|
723
|
+
}
|
|
724
|
+
async function on(e, t = {}) {
|
|
725
|
+
let n;
|
|
726
|
+
try {
|
|
727
|
+
n = h(g(e));
|
|
728
|
+
} catch (e) {
|
|
729
|
+
throw new Q(e instanceof Error ? e.message : String(e), { cause: e });
|
|
730
|
+
}
|
|
731
|
+
let r = await an(), i = t.frame ?? !0, a = {
|
|
732
|
+
sceneIndex: t.scene,
|
|
733
|
+
width: t.width ?? tn,
|
|
734
|
+
height: t.height ?? nn
|
|
735
|
+
};
|
|
736
|
+
function o(e) {
|
|
737
|
+
r.renderToContainer(e, n, {
|
|
738
|
+
sceneIndex: a.sceneIndex,
|
|
739
|
+
thumbnail: !i,
|
|
740
|
+
theme: t.theme
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
let s = {
|
|
744
|
+
async toSvg(e = {}) {
|
|
745
|
+
let { container: t, cleanup: n } = r.createContainer(e.width ?? a.width, e.height ?? a.height);
|
|
746
|
+
try {
|
|
747
|
+
return o(t), r.serializeSvg(t);
|
|
748
|
+
} finally {
|
|
749
|
+
n();
|
|
750
|
+
}
|
|
751
|
+
},
|
|
752
|
+
async toHtml(e = {}) {
|
|
753
|
+
let { container: t, cleanup: n } = r.createContainer(e.width ?? a.width, e.height ?? a.height);
|
|
754
|
+
try {
|
|
755
|
+
return o(t), r.serializeFrame(t);
|
|
756
|
+
} finally {
|
|
757
|
+
n();
|
|
758
|
+
}
|
|
759
|
+
},
|
|
760
|
+
async toPng(e = {}) {
|
|
761
|
+
let { container: t, cleanup: n } = r.createContainer(e.width ?? a.width, e.height ?? a.height), i;
|
|
762
|
+
try {
|
|
763
|
+
o(t), i = r.serializeSvg(t);
|
|
764
|
+
} finally {
|
|
765
|
+
n();
|
|
766
|
+
}
|
|
767
|
+
return r.rasterizePng(i, {
|
|
768
|
+
width: e.width ?? a.width,
|
|
769
|
+
height: e.height ?? a.height
|
|
770
|
+
});
|
|
771
|
+
},
|
|
772
|
+
mount(e) {
|
|
773
|
+
if (r.kind !== "dom") return console.warn("Blueprint Chart: mount() is a no-op outside a browser environment."), s;
|
|
774
|
+
let t = typeof e == "string" ? document.querySelector(e) : e;
|
|
775
|
+
if (!t) throw Error(`Blueprint Chart: mount target "${String(e)}" not found`);
|
|
776
|
+
return o(t), s;
|
|
777
|
+
},
|
|
778
|
+
scene(e) {
|
|
779
|
+
return a.sceneIndex = e, s;
|
|
780
|
+
}
|
|
781
|
+
};
|
|
782
|
+
return s;
|
|
783
|
+
}
|
|
784
|
+
//#endregion
|
|
785
|
+
export { d as ANNOTATION_KIND_KEYWORD, ge as Anchor, f as AnnotationKind, ce as AnnotationLineStyle, e as AxisDirection, t as BC_TRANSITION_NAME, m as ChartOptionType, Q as ChartParseError, qe as ChartType, Le as CompassDirection, Ue as CrosshairDirection, Me as CrosshairStyle, ie as DEFAULT_BAR_GAP, be as DirectLabelMode, ze as DslNodeType, Ge as FrameSizing, Ce as GridStyle, Ie as Interpolation, Ye as LabelPosition, Te as LabelRotation, De as LegendPosition, Be as LineStyle, $t as MissingNodeRenderDepsError, _ as Orientation, $ as PngBrowserUnsupportedError, je as RangeAnchor, ke as ScaleType, oe as SceneTransition, ve as SortDirection, Ze as SortMode, nt as StackMode, xe as StrokeStyle, et as SymbolShape, de as SymbolShowOn, i as SymbolStyle, $e as TickPosition, pe as ValueLabelPosition, he as adjustColorsForBackground, h as astToDefinition, _e as buildChartOptions, it as buildSrcdoc, pt as checkCvdColors, S as classifyIntent, rt as commitFadeOut, bt as compactSerialize, yt as compactSerializeDeep, ye as convertAnnotations, Re as convertAreaFills, We as convertColorizes, Se as convertHighlights, Fe as convertSeriesOverrides, me as createCanvas, ut as createCvdSvgFilter, te as createFrame, Je as dataEntriesToString, we as extractChartTypeOptions, Ee as extractSceneOverrides, n as fadeIn, o as featureJoin, Ne as getCachedChart, tt as getChart, p as getChartOptions, Ae as getChartTypeDefaults, D as getCvdFilterId, Pe as getSceneTransition, u as getTransitionDuration, r as isSeriesHidden, b as listCharts, se as listPalettes, g as parse, Xe as parseData, y as propertyMap, ct as recommendCharts, ue as registerChart, on as render, Ke as renderBpc, v as renderChart, re as renderHorizontalAxis, ee as renderLegend, le as renderVerticalAxis, c as resolveBackgroundColor, ae as resolveBarGapPadding, Oe as resolveChartTypeOptions, s as resolvePalette, He as resolveScene, Qe as resolveSeriesColor, fe as resolveSeriesInterpolation, Qt as samples, gt as serialize, T as shapeOf, k as simulateCvdColor, l as snapshotForFadeOut, a as snapshotLiveAttrs, kt as validateChart, ne as wcagContrastRatio, Ve as wcagLevel };
|