@preschen/gen-vis 0.4.0 → 0.5.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/README.md +241 -0
- package/dist/gen-vis.js +1127 -0
- package/package.json +31 -21
- package/schema.json +370 -0
- package/dist/index.js +0 -2
package/package.json
CHANGED
|
@@ -1,14 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@preschen/gen-vis",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "A declarative d3 visualisation library",
|
|
5
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/gen-vis.js",
|
|
7
|
+
"module": "dist/gen-vis.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./dist/gen-vis.js",
|
|
10
|
+
"./schema.json": "./schema.json"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"schema.json"
|
|
15
|
+
],
|
|
6
16
|
"scripts": {
|
|
7
|
-
"dev": "
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
17
|
+
"dev": "vite",
|
|
18
|
+
"build": "vite build",
|
|
19
|
+
"watch": "vite build --watch",
|
|
20
|
+
"lib": "vite build --mode lib",
|
|
21
|
+
"test": "vitest run",
|
|
22
|
+
"upload": "rsync -arv dist-lib/ preschen@hades.wsr.ac.at:/usr/local/www/datascience/htdocs/gen-vis",
|
|
23
|
+
"deploy": "npm run lib && npm run upload",
|
|
24
|
+
"prepublishOnly": "npm test && npm run build"
|
|
12
25
|
},
|
|
13
26
|
"repository": {
|
|
14
27
|
"type": "git",
|
|
@@ -22,23 +35,20 @@
|
|
|
22
35
|
"url": "https://github.com/petres/gen-vis/issues"
|
|
23
36
|
},
|
|
24
37
|
"homepage": "https://github.com/petres/gen-vis",
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"vue": "^3"
|
|
40
|
+
},
|
|
25
41
|
"dependencies": {
|
|
26
|
-
"axios": "^1",
|
|
27
42
|
"d3": "^7",
|
|
28
|
-
"deepmerge": "^4"
|
|
29
|
-
"pinia": "^4",
|
|
30
|
-
"vue": "^3"
|
|
43
|
+
"deepmerge": "^4"
|
|
31
44
|
},
|
|
32
45
|
"devDependencies": {
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"vue-loader": "^17",
|
|
41
|
-
"webpack-cli": "^7",
|
|
42
|
-
"webpack-dev-server": "^6"
|
|
46
|
+
"@vitejs/plugin-vue": "^6.0.9",
|
|
47
|
+
"ajv": "^8.20.0",
|
|
48
|
+
"jsdom": "^30.1.1",
|
|
49
|
+
"sass": "^1.105.0",
|
|
50
|
+
"vite": "^8.3.1",
|
|
51
|
+
"vitest": "^5.0.2",
|
|
52
|
+
"vue": "^3.5.43"
|
|
43
53
|
}
|
|
44
54
|
}
|
package/schema.json
ADDED
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "https://unpkg.com/@preschen/gen-vis/schema.json",
|
|
4
|
+
"title": "gen-vis definition",
|
|
5
|
+
"description": "A chart of gen-vis, see https://github.com/petres/gen-vis. A definition can be a part which is merged into its parent, so no entry is required.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"properties": {
|
|
9
|
+
"$schema": { "type": "string" },
|
|
10
|
+
"parent": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "Url of the definition this one is deep merged into, relative to this definition. Arrays are replaced, not merged."
|
|
13
|
+
},
|
|
14
|
+
"data": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "Url of the CSV or JSON data, relative to the definition."
|
|
17
|
+
},
|
|
18
|
+
"options": { "$ref": "#/definitions/options" },
|
|
19
|
+
"globals": {
|
|
20
|
+
"type": "object",
|
|
21
|
+
"description": "Values changed by the form elements, e.g. the shared scales of the facets."
|
|
22
|
+
},
|
|
23
|
+
"mapping": {
|
|
24
|
+
"type": "object",
|
|
25
|
+
"description": "Maps columns of the data to named dimensions, the plots and all other parts of the definition refer to these names.",
|
|
26
|
+
"additionalProperties": { "$ref": "#/definitions/mapping" }
|
|
27
|
+
},
|
|
28
|
+
"plot": {
|
|
29
|
+
"description": "A plot or a list of plots, drawn in order.",
|
|
30
|
+
"oneOf": [
|
|
31
|
+
{ "$ref": "#/definitions/plot" },
|
|
32
|
+
{ "type": "array", "items": { "$ref": "#/definitions/plot" } }
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
"facets": { "$ref": "#/definitions/facets" },
|
|
36
|
+
"formElements": {
|
|
37
|
+
"type": "array",
|
|
38
|
+
"items": { "$ref": "#/definitions/formElement" }
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"definitions": {
|
|
42
|
+
"prop": {
|
|
43
|
+
"description": "A computed value: a reference, a ratio of a reference or steps based on a reference. The prop is required unless the object is merged into a prop of the parent definition.",
|
|
44
|
+
"type": "object",
|
|
45
|
+
"additionalProperties": false,
|
|
46
|
+
"properties": {
|
|
47
|
+
"prop": { "enum": ["fixed", "ref", "relative", "steps"] },
|
|
48
|
+
"ref": {
|
|
49
|
+
"type": "string",
|
|
50
|
+
"description": "e.g. totalWidth, innerWidth, innerHeight or a global"
|
|
51
|
+
},
|
|
52
|
+
"ratio": { "type": "number" },
|
|
53
|
+
"steps": {
|
|
54
|
+
"type": "array",
|
|
55
|
+
"description": "The value of the last step with a cut below the reference.",
|
|
56
|
+
"items": {
|
|
57
|
+
"type": "object",
|
|
58
|
+
"required": ["cut", "value"],
|
|
59
|
+
"additionalProperties": false,
|
|
60
|
+
"properties": {
|
|
61
|
+
"cut": { "type": "number" },
|
|
62
|
+
"value": {}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"value": { "description": "Used instead of the computed value." }
|
|
67
|
+
},
|
|
68
|
+
"allOf": [
|
|
69
|
+
{ "if": { "required": ["prop"], "properties": { "prop": { "const": "ref" } } }, "then": { "required": ["ref"] } },
|
|
70
|
+
{ "if": { "required": ["prop"], "properties": { "prop": { "const": "relative" } } }, "then": { "required": ["ref", "ratio"] } },
|
|
71
|
+
{ "if": { "required": ["prop"], "properties": { "prop": { "const": "steps" } } }, "then": { "required": ["ref", "steps"] } }
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
"value": {
|
|
75
|
+
"description": "A fixed value, a reference \"@name\" or a computed prop.",
|
|
76
|
+
"anyOf": [
|
|
77
|
+
{ "type": ["string", "number", "boolean", "null"] },
|
|
78
|
+
{ "$ref": "#/definitions/prop" }
|
|
79
|
+
]
|
|
80
|
+
},
|
|
81
|
+
"number": {
|
|
82
|
+
"description": "A number or a computed prop, e.g. based on totalWidth.",
|
|
83
|
+
"anyOf": [
|
|
84
|
+
{ "type": "number" },
|
|
85
|
+
{ "$ref": "#/definitions/prop" }
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
"props": {
|
|
89
|
+
"type": "object",
|
|
90
|
+
"description": "Svg attributes (and text), values are fixed, references \"@name\", computed props or nested props, e.g. d of a path.",
|
|
91
|
+
"additionalProperties": { "$ref": "#/definitions/propEntry" }
|
|
92
|
+
},
|
|
93
|
+
"propEntry": {
|
|
94
|
+
"anyOf": [
|
|
95
|
+
{ "$ref": "#/definitions/value" },
|
|
96
|
+
{
|
|
97
|
+
"type": "object",
|
|
98
|
+
"not": { "required": ["prop"] },
|
|
99
|
+
"additionalProperties": { "$ref": "#/definitions/propEntry" }
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
},
|
|
103
|
+
"pair": {
|
|
104
|
+
"type": "array",
|
|
105
|
+
"minItems": 2,
|
|
106
|
+
"maxItems": 2,
|
|
107
|
+
"items": { "type": ["number", "null"] }
|
|
108
|
+
},
|
|
109
|
+
"locale": {
|
|
110
|
+
"description": "Number and date formats, the name of a built-in locale or a d3 locale definition merged into one.",
|
|
111
|
+
"anyOf": [
|
|
112
|
+
{ "enum": ["de", "en"] },
|
|
113
|
+
{
|
|
114
|
+
"type": "object",
|
|
115
|
+
"additionalProperties": false,
|
|
116
|
+
"properties": {
|
|
117
|
+
"base": { "enum": ["de", "en"], "default": "de" },
|
|
118
|
+
"number": {
|
|
119
|
+
"type": "object",
|
|
120
|
+
"description": "See d3.formatLocale, e.g. decimal, thousands, grouping and currency ([prefix, suffix])."
|
|
121
|
+
},
|
|
122
|
+
"time": {
|
|
123
|
+
"type": "object",
|
|
124
|
+
"description": "See d3.timeFormatLocale, e.g. date, months and shortMonths."
|
|
125
|
+
},
|
|
126
|
+
"timeTicks": {
|
|
127
|
+
"type": "object",
|
|
128
|
+
"description": "The formats of the ticks of time axes without format, by the interval of the date.",
|
|
129
|
+
"additionalProperties": false,
|
|
130
|
+
"properties": {
|
|
131
|
+
"millisecond": { "type": "string" },
|
|
132
|
+
"second": { "type": "string" },
|
|
133
|
+
"minute": { "type": "string" },
|
|
134
|
+
"hour": { "type": "string" },
|
|
135
|
+
"day": { "type": "string" },
|
|
136
|
+
"week": { "type": "string" },
|
|
137
|
+
"month": { "type": "string" },
|
|
138
|
+
"year": { "type": "string" }
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
]
|
|
144
|
+
},
|
|
145
|
+
"options": {
|
|
146
|
+
"type": "object",
|
|
147
|
+
"additionalProperties": false,
|
|
148
|
+
"properties": {
|
|
149
|
+
"title": { "type": "string" },
|
|
150
|
+
"subtitle": { "type": "string" },
|
|
151
|
+
"footer": { "type": "string", "description": "HTML" },
|
|
152
|
+
"width": { "type": "number", "description": "The width of the container if not given." },
|
|
153
|
+
"height": { "$ref": "#/definitions/number" },
|
|
154
|
+
"margins": {
|
|
155
|
+
"type": "object",
|
|
156
|
+
"additionalProperties": false,
|
|
157
|
+
"properties": {
|
|
158
|
+
"top": { "type": "number" },
|
|
159
|
+
"right": { "type": "number" },
|
|
160
|
+
"bottom": { "type": "number" },
|
|
161
|
+
"left": { "type": "number" }
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
"locale": { "$ref": "#/definitions/locale" },
|
|
165
|
+
"fontFamily": {
|
|
166
|
+
"type": "string",
|
|
167
|
+
"description": "Css font-family, by default the css variable --gen-vis-font-family or Century Gothic."
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
"scale": {
|
|
172
|
+
"type": "object",
|
|
173
|
+
"additionalProperties": false,
|
|
174
|
+
"properties": {
|
|
175
|
+
"type": {
|
|
176
|
+
"enum": ["linear", "log", "pow", "sqrt", "symlog", "time", "utc", "point", "band"],
|
|
177
|
+
"default": "linear",
|
|
178
|
+
"description": "A d3 scale, continuous scales need a numeric or date mapping, point and band a categorical one."
|
|
179
|
+
},
|
|
180
|
+
"orientation": {
|
|
181
|
+
"enum": ["horizontal", "vertical"],
|
|
182
|
+
"description": "Places the scale on the plot."
|
|
183
|
+
},
|
|
184
|
+
"domain": {
|
|
185
|
+
"$ref": "#/definitions/pair",
|
|
186
|
+
"description": "Fixes the domain, null entries are taken from the data."
|
|
187
|
+
},
|
|
188
|
+
"domainRel": {
|
|
189
|
+
"$ref": "#/definitions/pair",
|
|
190
|
+
"description": "Extends the domain relative to its size."
|
|
191
|
+
},
|
|
192
|
+
"domainAbs": {
|
|
193
|
+
"$ref": "#/definitions/pair",
|
|
194
|
+
"description": "Extends the domain by absolute values."
|
|
195
|
+
},
|
|
196
|
+
"range": {
|
|
197
|
+
"type": "array",
|
|
198
|
+
"items": { "type": ["number", "string"] },
|
|
199
|
+
"description": "By default the width or height of the plot."
|
|
200
|
+
},
|
|
201
|
+
"padding": { "type": "number", "description": "For categorical scales." }
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
"axis": {
|
|
205
|
+
"type": "object",
|
|
206
|
+
"additionalProperties": false,
|
|
207
|
+
"properties": {
|
|
208
|
+
"position": { "enum": ["top", "bottom", "left", "right"] },
|
|
209
|
+
"ticks": { "$ref": "#/definitions/number" },
|
|
210
|
+
"values": { "type": "array", "description": "Fixed ticks." },
|
|
211
|
+
"format": { "type": "string", "description": "A d3 number or time format." },
|
|
212
|
+
"rotate": {
|
|
213
|
+
"type": "number",
|
|
214
|
+
"description": "The angle of the labels in degrees, positive counterclockwise, negative clockwise."
|
|
215
|
+
},
|
|
216
|
+
"grid": { "type": "boolean", "description": "Lines at the ticks." },
|
|
217
|
+
"title": {
|
|
218
|
+
"type": "object",
|
|
219
|
+
"additionalProperties": false,
|
|
220
|
+
"properties": {
|
|
221
|
+
"name": { "type": "string" },
|
|
222
|
+
"offset": { "type": "number" }
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
"padding": { "type": "number" }
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
"mapping": {
|
|
229
|
+
"type": "object",
|
|
230
|
+
"additionalProperties": false,
|
|
231
|
+
"properties": {
|
|
232
|
+
"column": { "type": "string" },
|
|
233
|
+
"type": {
|
|
234
|
+
"enum": ["numeric", "date", "categorical"],
|
|
235
|
+
"description": "Missing and invalid numeric and date values are null, dates are parsed with Date.parse or are timestamps."
|
|
236
|
+
},
|
|
237
|
+
"stacked": { "type": "boolean", "description": "Stacks the values of a vertical axis." },
|
|
238
|
+
"scale": { "$ref": "#/definitions/scale" },
|
|
239
|
+
"axis": { "$ref": "#/definitions/axis" },
|
|
240
|
+
"hover": {
|
|
241
|
+
"type": "object",
|
|
242
|
+
"additionalProperties": false,
|
|
243
|
+
"properties": {
|
|
244
|
+
"format": { "type": "string", "description": "By default the format of the axis." },
|
|
245
|
+
"props": {
|
|
246
|
+
"type": "object",
|
|
247
|
+
"description": "The columns of the entries of a categorical mapping, name by default.",
|
|
248
|
+
"additionalProperties": { "$ref": "#/definitions/value" }
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
"legend": {
|
|
253
|
+
"type": "object",
|
|
254
|
+
"additionalProperties": false,
|
|
255
|
+
"properties": {
|
|
256
|
+
"symbol": {
|
|
257
|
+
"type": "object",
|
|
258
|
+
"additionalProperties": false,
|
|
259
|
+
"properties": {
|
|
260
|
+
"size": { "type": "number" },
|
|
261
|
+
"elements": {
|
|
262
|
+
"type": "array",
|
|
263
|
+
"items": {
|
|
264
|
+
"type": "object",
|
|
265
|
+
"required": ["type"],
|
|
266
|
+
"additionalProperties": false,
|
|
267
|
+
"properties": {
|
|
268
|
+
"type": { "type": "string", "description": "An svg element, e.g. line or circle." },
|
|
269
|
+
"props": { "$ref": "#/definitions/props" }
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
"props": {
|
|
276
|
+
"type": "object",
|
|
277
|
+
"additionalProperties": { "$ref": "#/definitions/value" }
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
"props": {
|
|
282
|
+
"type": "object",
|
|
283
|
+
"description": "The categories and their props, e.g. colors. Only visible categories are shown.",
|
|
284
|
+
"additionalProperties": false,
|
|
285
|
+
"properties": {
|
|
286
|
+
"common": { "$ref": "#/definitions/categoryProps" },
|
|
287
|
+
"manual": {
|
|
288
|
+
"type": "object",
|
|
289
|
+
"additionalProperties": { "$ref": "#/definitions/categoryProps" }
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
"categoryProps": {
|
|
296
|
+
"type": "object",
|
|
297
|
+
"properties": {
|
|
298
|
+
"name": { "type": "string", "description": "The key by default." },
|
|
299
|
+
"visible": { "type": "boolean", "default": true }
|
|
300
|
+
}
|
|
301
|
+
},
|
|
302
|
+
"plot": {
|
|
303
|
+
"type": "object",
|
|
304
|
+
"additionalProperties": false,
|
|
305
|
+
"properties": {
|
|
306
|
+
"type": {
|
|
307
|
+
"enum": ["svg:path", "svg:circle", "svg:line", "svg:rect", "svg:text", "base:area", "bar", "stackedBar"],
|
|
308
|
+
"description": "svg:path and base:area draw a path per group, the others an element per row."
|
|
309
|
+
},
|
|
310
|
+
"id": { "type": "string", "description": "The class of the plot group, plot-<index> by default." },
|
|
311
|
+
"categories": {
|
|
312
|
+
"type": "array",
|
|
313
|
+
"items": { "type": "string" },
|
|
314
|
+
"description": "The rows are grouped by these mappings, the props of their categories are available in the props."
|
|
315
|
+
},
|
|
316
|
+
"props": { "$ref": "#/definitions/props" }
|
|
317
|
+
}
|
|
318
|
+
},
|
|
319
|
+
"facets": {
|
|
320
|
+
"type": "object",
|
|
321
|
+
"additionalProperties": false,
|
|
322
|
+
"properties": {
|
|
323
|
+
"dim": {
|
|
324
|
+
"description": "A plot for every category of this mapping.",
|
|
325
|
+
"anyOf": [
|
|
326
|
+
{ "type": "string" },
|
|
327
|
+
{ "type": "array", "items": { "type": "string" }, "minItems": 1, "maxItems": 1 }
|
|
328
|
+
]
|
|
329
|
+
},
|
|
330
|
+
"cols": { "$ref": "#/definitions/number" },
|
|
331
|
+
"scales": {
|
|
332
|
+
"description": "The mappings which share their scale across all facets, or a reference to a global.",
|
|
333
|
+
"anyOf": [
|
|
334
|
+
{ "type": "array", "items": { "type": "string" } },
|
|
335
|
+
{ "$ref": "#/definitions/prop" }
|
|
336
|
+
]
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
},
|
|
340
|
+
"formElement": {
|
|
341
|
+
"type": "object",
|
|
342
|
+
"required": ["id", "ref", "type", "values"],
|
|
343
|
+
"additionalProperties": false,
|
|
344
|
+
"properties": {
|
|
345
|
+
"id": { "type": "string" },
|
|
346
|
+
"name": { "type": "string" },
|
|
347
|
+
"ref": { "type": "string", "description": "The global which is changed." },
|
|
348
|
+
"type": { "enum": ["switch"] },
|
|
349
|
+
"values": {
|
|
350
|
+
"type": "array",
|
|
351
|
+
"items": {
|
|
352
|
+
"type": "object",
|
|
353
|
+
"required": ["id", "value"],
|
|
354
|
+
"additionalProperties": false,
|
|
355
|
+
"properties": {
|
|
356
|
+
"id": { "type": "string" },
|
|
357
|
+
"name": { "type": "string" },
|
|
358
|
+
"value": {},
|
|
359
|
+
"mapping": {
|
|
360
|
+
"type": "object",
|
|
361
|
+
"description": "Patches the mappings while the entry is selected.",
|
|
362
|
+
"additionalProperties": { "$ref": "#/definitions/mapping" }
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|