@opendata-ai/openchart-core 9.0.0-rc.2 → 9.0.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/index.d.ts +125 -23
- package/dist/index.js +63 -23
- package/dist/index.js.map +1 -1
- package/dist/styles.css.map +1 -1
- package/package.json +1 -1
- package/schema/chart.schema.json +414 -31
- package/schema/table.schema.json +3 -3
- package/schema/vizspec.schema.json +1133 -143
package/dist/index.js
CHANGED
|
@@ -130,15 +130,28 @@ function optional(...types) {
|
|
|
130
130
|
return { required: false, allowedTypes: types };
|
|
131
131
|
}
|
|
132
132
|
var MARK_ENCODING_RULES = {
|
|
133
|
+
errorbar: {
|
|
134
|
+
x: required("quantitative", "nominal", "ordinal", "temporal"),
|
|
135
|
+
y: required("quantitative", "nominal", "ordinal", "temporal"),
|
|
136
|
+
x2: optional("quantitative"),
|
|
137
|
+
y2: optional("quantitative"),
|
|
138
|
+
color: optional(),
|
|
139
|
+
size: optional(),
|
|
140
|
+
opacity: optional(),
|
|
141
|
+
detail: optional(),
|
|
142
|
+
description: optional(),
|
|
143
|
+
tooltip: optional()
|
|
144
|
+
},
|
|
133
145
|
bar: {
|
|
134
146
|
x: required("quantitative", "nominal", "ordinal", "temporal"),
|
|
135
|
-
y: required("quantitative", "nominal", "ordinal"),
|
|
147
|
+
y: required("quantitative", "nominal", "ordinal", "temporal"),
|
|
136
148
|
x2: optional("quantitative"),
|
|
137
149
|
y2: optional("quantitative"),
|
|
138
150
|
color: optional("nominal", "ordinal", "quantitative"),
|
|
139
151
|
size: optional(),
|
|
140
152
|
opacity: optional("quantitative"),
|
|
141
153
|
tooltip: optional(),
|
|
154
|
+
description: optional(),
|
|
142
155
|
detail: optional("nominal")
|
|
143
156
|
},
|
|
144
157
|
line: {
|
|
@@ -149,6 +162,7 @@ var MARK_ENCODING_RULES = {
|
|
|
149
162
|
opacity: optional("quantitative"),
|
|
150
163
|
strokeDash: optional("nominal", "ordinal"),
|
|
151
164
|
tooltip: optional(),
|
|
165
|
+
description: optional(),
|
|
152
166
|
detail: optional("nominal")
|
|
153
167
|
},
|
|
154
168
|
area: {
|
|
@@ -161,6 +175,7 @@ var MARK_ENCODING_RULES = {
|
|
|
161
175
|
size: optional(),
|
|
162
176
|
opacity: optional("quantitative"),
|
|
163
177
|
tooltip: optional(),
|
|
178
|
+
description: optional(),
|
|
164
179
|
detail: optional("nominal")
|
|
165
180
|
},
|
|
166
181
|
point: {
|
|
@@ -170,6 +185,7 @@ var MARK_ENCODING_RULES = {
|
|
|
170
185
|
size: optional("quantitative"),
|
|
171
186
|
opacity: optional("quantitative"),
|
|
172
187
|
tooltip: optional(),
|
|
188
|
+
description: optional(),
|
|
173
189
|
detail: optional("nominal")
|
|
174
190
|
},
|
|
175
191
|
circle: {
|
|
@@ -179,6 +195,7 @@ var MARK_ENCODING_RULES = {
|
|
|
179
195
|
size: optional("quantitative"),
|
|
180
196
|
opacity: optional("quantitative"),
|
|
181
197
|
tooltip: optional(),
|
|
198
|
+
description: optional(),
|
|
182
199
|
detail: optional("nominal")
|
|
183
200
|
},
|
|
184
201
|
lollipop: {
|
|
@@ -188,6 +205,7 @@ var MARK_ENCODING_RULES = {
|
|
|
188
205
|
size: optional("quantitative"),
|
|
189
206
|
opacity: optional("quantitative"),
|
|
190
207
|
tooltip: optional(),
|
|
208
|
+
description: optional(),
|
|
191
209
|
detail: optional("nominal")
|
|
192
210
|
},
|
|
193
211
|
beeswarm: {
|
|
@@ -197,6 +215,7 @@ var MARK_ENCODING_RULES = {
|
|
|
197
215
|
size: optional("quantitative"),
|
|
198
216
|
opacity: optional("quantitative"),
|
|
199
217
|
tooltip: optional(),
|
|
218
|
+
description: optional(),
|
|
200
219
|
detail: optional("nominal")
|
|
201
220
|
},
|
|
202
221
|
// Range: x+x2 with nominal y (horizontal) or y+y2 with nominal x (vertical).
|
|
@@ -211,6 +230,7 @@ var MARK_ENCODING_RULES = {
|
|
|
211
230
|
size: optional(),
|
|
212
231
|
opacity: optional("quantitative"),
|
|
213
232
|
tooltip: optional(),
|
|
233
|
+
description: optional(),
|
|
214
234
|
detail: optional("nominal")
|
|
215
235
|
},
|
|
216
236
|
arc: {
|
|
@@ -221,6 +241,7 @@ var MARK_ENCODING_RULES = {
|
|
|
221
241
|
size: optional(),
|
|
222
242
|
opacity: optional("quantitative"),
|
|
223
243
|
tooltip: optional(),
|
|
244
|
+
description: optional(),
|
|
224
245
|
detail: optional("nominal")
|
|
225
246
|
},
|
|
226
247
|
waffle: {
|
|
@@ -231,6 +252,7 @@ var MARK_ENCODING_RULES = {
|
|
|
231
252
|
opacity: optional("quantitative"),
|
|
232
253
|
tooltip: optional(),
|
|
233
254
|
theta: optional("quantitative"),
|
|
255
|
+
description: optional(),
|
|
234
256
|
detail: optional("nominal")
|
|
235
257
|
},
|
|
236
258
|
// parliament: hemicycle seat chart. Like arc/waffle, no positional axes;
|
|
@@ -245,6 +267,7 @@ var MARK_ENCODING_RULES = {
|
|
|
245
267
|
opacity: optional("quantitative"),
|
|
246
268
|
tooltip: optional(),
|
|
247
269
|
theta: optional("quantitative"),
|
|
270
|
+
description: optional(),
|
|
248
271
|
detail: optional("nominal")
|
|
249
272
|
},
|
|
250
273
|
text: {
|
|
@@ -255,6 +278,7 @@ var MARK_ENCODING_RULES = {
|
|
|
255
278
|
opacity: optional("quantitative"),
|
|
256
279
|
text: required(),
|
|
257
280
|
tooltip: optional(),
|
|
281
|
+
description: optional(),
|
|
258
282
|
detail: optional("nominal")
|
|
259
283
|
},
|
|
260
284
|
rule: {
|
|
@@ -267,6 +291,7 @@ var MARK_ENCODING_RULES = {
|
|
|
267
291
|
opacity: optional("quantitative"),
|
|
268
292
|
strokeDash: optional("nominal", "ordinal"),
|
|
269
293
|
tooltip: optional(),
|
|
294
|
+
description: optional(),
|
|
270
295
|
detail: optional("nominal")
|
|
271
296
|
},
|
|
272
297
|
tick: {
|
|
@@ -276,6 +301,7 @@ var MARK_ENCODING_RULES = {
|
|
|
276
301
|
size: optional(),
|
|
277
302
|
opacity: optional("quantitative"),
|
|
278
303
|
tooltip: optional(),
|
|
304
|
+
description: optional(),
|
|
279
305
|
detail: optional("nominal")
|
|
280
306
|
},
|
|
281
307
|
rect: {
|
|
@@ -287,6 +313,7 @@ var MARK_ENCODING_RULES = {
|
|
|
287
313
|
size: optional(),
|
|
288
314
|
opacity: optional("quantitative"),
|
|
289
315
|
tooltip: optional(),
|
|
316
|
+
description: optional(),
|
|
290
317
|
detail: optional("nominal")
|
|
291
318
|
},
|
|
292
319
|
// calendar: x is the daily date (temporal), color the per-day value
|
|
@@ -300,6 +327,7 @@ var MARK_ENCODING_RULES = {
|
|
|
300
327
|
size: optional(),
|
|
301
328
|
opacity: optional("quantitative"),
|
|
302
329
|
tooltip: optional(),
|
|
330
|
+
description: optional(),
|
|
303
331
|
detail: optional("nominal")
|
|
304
332
|
},
|
|
305
333
|
// histogram: x is the raw quantitative field to bin. y is optional because
|
|
@@ -313,6 +341,7 @@ var MARK_ENCODING_RULES = {
|
|
|
313
341
|
size: optional(),
|
|
314
342
|
opacity: optional("quantitative"),
|
|
315
343
|
tooltip: optional(),
|
|
344
|
+
description: optional(),
|
|
316
345
|
detail: optional("nominal")
|
|
317
346
|
},
|
|
318
347
|
// density: x is the raw quantitative field to estimate over. y is computed
|
|
@@ -325,6 +354,7 @@ var MARK_ENCODING_RULES = {
|
|
|
325
354
|
size: optional(),
|
|
326
355
|
opacity: optional("quantitative"),
|
|
327
356
|
tooltip: optional(),
|
|
357
|
+
description: optional(),
|
|
328
358
|
detail: optional("nominal")
|
|
329
359
|
}
|
|
330
360
|
};
|
|
@@ -396,6 +426,7 @@ var MARK_TYPES = /* @__PURE__ */ new Set([
|
|
|
396
426
|
"lollipop",
|
|
397
427
|
"beeswarm",
|
|
398
428
|
"range",
|
|
429
|
+
"errorbar",
|
|
399
430
|
"waffle",
|
|
400
431
|
"calendar",
|
|
401
432
|
"parliament",
|
|
@@ -459,6 +490,7 @@ var MARK_DISPLAY_NAMES = {
|
|
|
459
490
|
lollipop: "Lollipop chart",
|
|
460
491
|
beeswarm: "Beeswarm chart",
|
|
461
492
|
range: "Range plot",
|
|
493
|
+
errorbar: "Error bar plot",
|
|
462
494
|
waffle: "Waffle chart",
|
|
463
495
|
calendar: "Calendar heatmap",
|
|
464
496
|
parliament: "Parliament chart",
|
|
@@ -932,32 +964,32 @@ var ACHROMATIC_RAMP = {
|
|
|
932
964
|
// canvas
|
|
933
965
|
};
|
|
934
966
|
var CATEGORICAL_PALETTE = [
|
|
935
|
-
"#
|
|
936
|
-
// cyan — oklch(0.
|
|
937
|
-
"#
|
|
938
|
-
// ochre — oklch(0.
|
|
967
|
+
"#0a879e",
|
|
968
|
+
// cyan — oklch(0.575 0.100 216)
|
|
969
|
+
"#bf7e1f",
|
|
970
|
+
// ochre — oklch(0.646 0.130 70)
|
|
939
971
|
"#4170cb",
|
|
940
972
|
// blue — oklch(0.559 0.150 262)
|
|
941
973
|
"#b2417f",
|
|
942
974
|
// rose — oklch(0.550 0.161 350)
|
|
943
975
|
"#3ca368",
|
|
944
976
|
// green — oklch(0.640 0.130 155)
|
|
945
|
-
"#
|
|
946
|
-
// violet — oklch(0.
|
|
977
|
+
"#9c7bd2"
|
|
978
|
+
// violet — oklch(0.650 0.130 300)
|
|
947
979
|
];
|
|
948
980
|
var CATEGORICAL_FILL_PALETTE = [
|
|
949
|
-
"#
|
|
950
|
-
// cyan — oklch(0.
|
|
951
|
-
"#
|
|
952
|
-
// ochre — oklch(0.
|
|
981
|
+
"#1390a0",
|
|
982
|
+
// cyan — oklch(0.599 0.100 209)
|
|
983
|
+
"#b58245",
|
|
984
|
+
// ochre — oklch(0.645 0.100 69)
|
|
953
985
|
"#587fc8",
|
|
954
986
|
// blue — oklch(0.601 0.120 262)
|
|
955
987
|
"#bf6291",
|
|
956
988
|
// rose — oklch(0.619 0.131 350)
|
|
957
|
-
"#
|
|
958
|
-
// green — oklch(0.
|
|
959
|
-
"#
|
|
960
|
-
// violet — oklch(0.
|
|
989
|
+
"#57a072",
|
|
990
|
+
// green — oklch(0.645 0.101 155)
|
|
991
|
+
"#9981c3"
|
|
992
|
+
// violet — oklch(0.651 0.100 300)
|
|
961
993
|
];
|
|
962
994
|
var CATEGORICAL_PALETTE_DARK = [
|
|
963
995
|
"#22d3ee",
|
|
@@ -1772,12 +1804,12 @@ function adaptTheme(theme) {
|
|
|
1772
1804
|
const darkGridline = pairs?.["colors.gridline"] ? pairs["colors.gridline"].dark : overridden(theme.colors.gridline, light.gridline, "rgba(255,255,255,0.06)");
|
|
1773
1805
|
const darkHairline = pairs?.["colors.hairline"] ? pairs["colors.hairline"].dark : overridden(theme.colors.hairline, light.hairline, "rgba(255,255,255,0.14)");
|
|
1774
1806
|
const darkAxis = pairs?.["colors.axis"] ? pairs["colors.axis"].dark : overridden(theme.colors.axis, light.axis, "#a1a1aa");
|
|
1775
|
-
const
|
|
1776
|
-
...
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1807
|
+
const paletteForDark = (field, defaults) => {
|
|
1808
|
+
const palette = overridden(theme.colors[field], light[field], [...defaults]);
|
|
1809
|
+
return palette.map((color, index) => pairs?.[`colors.${field}.${index}`]?.dark ?? color);
|
|
1810
|
+
};
|
|
1811
|
+
const categorical = paletteForDark("categorical", CATEGORICAL_PALETTE_DARK);
|
|
1812
|
+
const categoricalFill = paletteForDark("categoricalFill", CATEGORICAL_FILL_PALETTE_DARK);
|
|
1781
1813
|
const neutral = deriveNeutralRamp(darkText, darkBg, true);
|
|
1782
1814
|
const authoredColors = theme._authored?.colors && !Array.isArray(theme._authored.colors) ? theme._authored.colors : {};
|
|
1783
1815
|
const authoredColor = (key, fallback) => pairs?.[`colors.${key}`]?.dark ?? (authoredColors[key] !== void 0 ? theme.colors[key] ?? fallback : fallback);
|
|
@@ -2015,8 +2047,10 @@ function themeConfigToPartial(config, base) {
|
|
|
2015
2047
|
if (Array.isArray(config.colors)) {
|
|
2016
2048
|
colors.categorical = config.colors;
|
|
2017
2049
|
} else {
|
|
2018
|
-
if (config.colors.categorical)
|
|
2019
|
-
|
|
2050
|
+
if (config.colors.categorical)
|
|
2051
|
+
colors.categorical = config.colors.categorical.map(resolveTokenLight);
|
|
2052
|
+
if (config.colors.categoricalFill)
|
|
2053
|
+
colors.categoricalFill = config.colors.categoricalFill.map(resolveTokenLight);
|
|
2020
2054
|
if (config.colors.sequential) colors.sequential = config.colors.sequential;
|
|
2021
2055
|
if (config.colors.diverging) colors.diverging = config.colors.diverging;
|
|
2022
2056
|
if (config.colors.background) colors.background = resolveTokenLight(config.colors.background);
|
|
@@ -2124,6 +2158,12 @@ function themeConfigToPartial(config, base) {
|
|
|
2124
2158
|
function collectTokenPairs(config) {
|
|
2125
2159
|
const pairs = {};
|
|
2126
2160
|
if (config.colors && !Array.isArray(config.colors)) {
|
|
2161
|
+
for (const field of ["categorical", "categoricalFill"]) {
|
|
2162
|
+
const palette = config.colors[field] ?? (field === "categoricalFill" ? config.colors.categorical : void 0);
|
|
2163
|
+
palette?.forEach((value, index) => {
|
|
2164
|
+
if (typeof value === "object") pairs[`colors.${field}.${index}`] = value;
|
|
2165
|
+
});
|
|
2166
|
+
}
|
|
2127
2167
|
const colorFields = [
|
|
2128
2168
|
"background",
|
|
2129
2169
|
"text",
|