@liggi/figkit 0.5.0 → 0.6.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/GUIDE.md +61 -6
- package/THIRD_PARTY_NOTICES.md +48 -1
- package/bin/fig.mjs +5 -3
- package/dist/viz.iife.js +47 -42
- package/examples/charts/map.json +269 -0
- package/package.json +2 -1
- package/runtime/fig.css +17 -0
- package/runtime/fig.js +146 -18
- package/viz/draw.js +13 -0
- package/viz/map-spec.js +121 -0
- package/viz/map.js +513 -0
- package/viz/spec.js +8 -3
package/viz/spec.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { sequenceShape, sequenceChecks } from './sequence-spec.js';
|
|
4
4
|
import { statesShape, statesChecks } from './states-spec.js';
|
|
5
|
+
import { mapShape, mapChecks } from './map-spec.js';
|
|
5
6
|
|
|
6
7
|
const TONE = z.enum(['accent', 'second', 'good', 'bad']);
|
|
7
8
|
const label = z.string({ error: 'needs a label' }).trim().min(1, 'needs a label').max(40, 'keep labels to 40 characters');
|
|
@@ -287,11 +288,14 @@ export const SequenceSpec = z.object({ type: z.literal('sequence'), title, note:
|
|
|
287
288
|
/** The states one thing moves through and the moves between them, with optional counts on the moves. */
|
|
288
289
|
export const StatesSpec = z.object({ type: z.literal('states'), title, note: common.note, source: common.source, style: common.style, ...statesShape }).strict();
|
|
289
290
|
|
|
290
|
-
|
|
291
|
-
export const
|
|
291
|
+
/** A whole system: parts grouped by subsystem and the links between them, laid out by figkit. */
|
|
292
|
+
export const MapSpec = z.object({ type: z.literal('map'), title, note: common.note, source: common.source, style: common.style, ...mapShape }).strict();
|
|
292
293
|
|
|
294
|
+
export const Spec = z.discriminatedUnion('type', [SplitSpec, BarsSpec, EstimatesSpec, BeforeAfterSpec, DumbbellSpec, SeriesSpec, EntitiesSpec, GroupsSpec, LinesSpec, PanelsSpec, HeatmapSpec, DotsSpec, ScatterSpec, UnitsSpec, SequenceSpec, StatesSpec, MapSpec]);
|
|
295
|
+
export const TYPES = { split: SplitSpec, bars: BarsSpec, estimates: EstimatesSpec, 'before-after': BeforeAfterSpec, dumbbell: DumbbellSpec, series: SeriesSpec, entities: EntitiesSpec, groups: GroupsSpec, lines: LinesSpec, panels: PanelsSpec, heatmap: HeatmapSpec, dots: DotsSpec, scatter: ScatterSpec, units: UnitsSpec, sequence: SequenceSpec, states: StatesSpec, map: MapSpec };
|
|
293
296
|
|
|
294
|
-
|
|
297
|
+
|
|
298
|
+
const items = (s) => s.parts ?? s.bars ?? s.rows ?? s.records ?? s.messages ?? (s.type === 'states' ? [...s.states, ...s.moves] : s.type === 'map' ? [...s.parts, ...s.links] : null) ?? (s.type === 'scatter' ? s.points : s.type === 'dots' ? s.groups : (s.after ? [s.after] : []));
|
|
295
299
|
const kind = (v) => (typeof v === 'number' ? 'number' : 'date');
|
|
296
300
|
|
|
297
301
|
|
|
@@ -342,6 +346,7 @@ function linesChecks(s, at = '') {
|
|
|
342
346
|
function crossChecks(s) {
|
|
343
347
|
if (s.type === 'sequence') return sequenceChecks(s);
|
|
344
348
|
if (s.type === 'states') return statesChecks(s);
|
|
349
|
+
if (s.type === 'map') return mapChecks(s);
|
|
345
350
|
if (s.type === 'groups') return groupsChecks(s);
|
|
346
351
|
if (s.type === 'lines') return linesChecks(s);
|
|
347
352
|
if (s.type === 'panels') {
|